API reference

Send events

Record a signup, purchase or any other action from your server with one request.

curl -X POST https://basket.databuddy.cc/track \
  -H "Authorization: Bearer $DATABUDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "websiteId": "'"$DATABUDDY_CLIENT_ID"'",
    "name": "purchase",
    "profileId": "user_123",
    "properties": { "value": 99.99, "currency": "USD" }
  }'
{ "status": "success", "type": "custom_event", "count": 1 }

The key needs the track:events scope. Without a key, pass your Client ID as ?website_id= or websiteId, as the browser tracker does. In Node, the Node SDK wraps this for you.

Fill in an event

FieldTypeLimit
namestringRequired, 1 to 256 characters
propertiesobjectUp to 50 keys and 32 KB
websiteIdstringYour Client ID, or ?website_id= in the URL
profileIdstringYour own user ID
anonymousIdstringVisitor ID, up to 256 characters
sessionIdstringUp to 256 characters
eventIdstringYour ID for removing duplicates, up to 512 characters
timestampnumber, string or dateMilliseconds or ISO date; now by default
pathstringPage path or URL, up to 2,048 characters
namespacestringA group for related events, up to 64 characters
sourcestringWhere the event came from, up to 64 characters
anonymizeVisitorIdsboolean or "auto"Whether to hash visitor IDs

Keep property values to strings, numbers and booleans, and leave out personal data.

Send a batch

Send an array of up to 100 events, at most 1 MB of JSON in total. Valid events are kept even when others fail, and the failures come back in rejected:

{
  "status": "success",
  "type": "custom_event",
  "count": 1,
  "rejected": [{ "index": 1, "eventId": "evt_2", "error": "1.name: Too small: expected string to have >=1 characters" }]
}

Fix and resend only the rejected events. The request fails with 400 only when no event in it is valid.

Identify users and accounts

EndpointBodySets
POST /identifyprofileId (required), anonymousId, traits, websiteIdLinks a visitor to your user ID and sets their traits. null removes a trait.
POST /groupgroupType (required), groupKey (required, up to 256 characters), traits, websiteIdSets traits on an account, such as a workspace. See accounts.
{ "groupType": "workspace", "groupKey": "ws_123", "traits": { "name": "Databuddy", "billing_mrr": 49, "billing_currency": "USD" } }

Both accept a track:events key or a Client ID; websiteId is required with a key. billing_ traits and account usage traits need a key, so a browser can't change what a customer pays.

Fix errors

StatusMessageWhat to do
400Invalid request bodyFix the fields in errors
401API key or website_id requiredSend a key or a Client ID
402Event quota exceededUpgrade your plan
403API key missing track:events scopeAdd the scope to the key
403Origin not authorized, IP address not authorizedCheck the website's allowed origins and IPs
404Website not foundCheck the Client ID
413Payload too largeSplit the batch or trim properties
429Rate limit exceededWait. Events allow 600 requests a minute per key, or per website and IP; /identify and /group allow 6,000 a minute per key, or 60 per website and IP
503Billing check unavailableRetry later

Errors carry code, message, requestId and retryable, which is true for 429 and 5xx.

How is this guide?