Skip to main content
POST
/
v1
/
risk
/
velocity
/
record
Record velocity event
curl --request POST \
  --url https://api.truthlocks.com/v1/risk/velocity/record \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "subject_id": "<string>",
  "action": "<string>",
  "metadata": {}
}
'
import requests

url = "https://api.truthlocks.com/v1/risk/velocity/record"

payload = {
"subject_id": "<string>",
"action": "<string>",
"metadata": {}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({subject_id: '<string>', action: '<string>', metadata: {}})
};

fetch('https://api.truthlocks.com/v1/risk/velocity/record', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.truthlocks.com/v1/risk/velocity/record",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'subject_id' => '<string>',
'action' => '<string>',
'metadata' => [

]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.truthlocks.com/v1/risk/velocity/record"

payload := strings.NewReader("{\n \"subject_id\": \"<string>\",\n \"action\": \"<string>\",\n \"metadata\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.truthlocks.com/v1/risk/velocity/record")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subject_id\": \"<string>\",\n \"action\": \"<string>\",\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.truthlocks.com/v1/risk/velocity/record")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subject_id\": \"<string>\",\n \"action\": \"<string>\",\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "event_id": "<string>",
  "current_count": 123,
  "window": "<string>"
}
{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}
Records an action for a subject and updates rolling window counters across four time windows (1 m, 5 m, 1 h, 24 h). A weighted velocity score is computed from the updated counts. When the score reaches 60 or above, a risk signal with signal_type: "velocity" is automatically ingested into the risk signal pipeline. See the velocity and anomaly scoring guide for the full workflow, scoring model, and integration patterns.

Scoring weights

WindowWeightPurpose
1 minute30Burst detection
5 minutes20Sustained short-term abuse
1 hour10Medium-term patterns
24 hours5Persistent anomalies

Request

subject_id
string
required
Identifier of the subject performing the action (user ID, device ID, IP address, or any entity reference).
action_type
string
required
The type of action being recorded (e.g. login.failed, api.request, transaction.create).
ip_address
string
Source IP address associated with this action.

Response

subject_id
string
The subject that was recorded.
action_type
string
The action type that was recorded.
windows
object
Current action counts per rolling window: 1m, 5m, 1h, 24h.
velocity_score
integer
Weighted velocity score (0–100). Scores at or above 60 trigger automatic signal ingestion.
signal_ingested
boolean
true if a risk signal was auto-ingested because the velocity score reached 60 or above.
signal_id
string
UUID of the auto-ingested risk signal (only present when signal_ingested is true).

Authorizations

X-API-Key
string
header
required

API key for machine-to-machine authentication

Body

application/json
subject_id
string
required
action
string
required

Action type being tracked

metadata
object

Response

Velocity event recorded

event_id
string
current_count
integer
window
string