Track Event
curl --request POST \
--url https://api.example.com/track \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "<string>",
"namespace": "<string>",
"timestamp": {},
"properties": {},
"anonymousId": "<string>",
"sessionId": "<string>",
"websiteId": "<string>",
"source": "<string>"
}
'{
"status": "<string>",
"type": "<string>",
"count": 123,
"message": "<string>"
}Events API
Track Event
Send custom events to track user actions and behaviors
POST
/
track
Track Event
curl --request POST \
--url https://api.example.com/track \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "<string>",
"namespace": "<string>",
"timestamp": {},
"properties": {},
"anonymousId": "<string>",
"sessionId": "<string>",
"websiteId": "<string>",
"source": "<string>"
}
'{
"status": "<string>",
"type": "<string>",
"count": 123,
"message": "<string>"
}The track endpoint allows you to send custom events with optional properties to track specific user actions and behaviors in your application.
Authentication
This endpoint supports two authentication methods:- API Key: Include your API key in the
Authorizationheader. The API key must have thetrack:eventsscope. - Website ID: Pass
website_idas a query parameter for client-side tracking.
Request
Headers
Bearer token with your API key (required if not using website_id)
Must be
application/jsonQuery Parameters
UUID of the website. Required if not using API key authentication.
Body Parameters
You can send either a single event object or an array of event objects.Name of the event (1-256 characters)
Namespace to organize events (max 64 characters)
Event timestamp. Accepts Unix timestamp (ms), ISO date string, or Date object. Defaults to current time.
Custom properties as key-value pairs. Can contain any JSON-serializable data.
Anonymous user identifier (max 256 characters)
Session identifier (max 256 characters)
UUID of the website. Can be specified per event in batch requests.
Source of the event (max 64 characters)
Response
Status of the request:
success or errorType of event processed:
custom_eventNumber of events successfully processed
Error message (only present when status is
error)Examples
Single Event
curl -X POST https://api.databuddy.io/track \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "button_clicked",
"namespace": "ui",
"properties": {
"button_id": "signup",
"page": "/pricing"
},
"anonymousId": "user-123",
"sessionId": "session-456"
}'
Response
{
"status": "success",
"type": "custom_event",
"count": 1
}
Multiple Events
curl -X POST https://api.databuddy.io/track \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{
"name": "page_viewed",
"properties": {
"path": "/dashboard"
}
},
{
"name": "feature_used",
"namespace": "product",
"properties": {
"feature": "export",
"format": "csv"
}
}
]'
Response
{
"status": "success",
"type": "custom_event",
"count": 2
}
With Website ID (Client-Side)
curl -X POST https://api.databuddy.io/track?website_id=550e8400-e29b-41d4-a716-446655440000 \
-H "Content-Type: application/json" \
-d '{
"name": "video_played",
"properties": {
"video_id": "intro-2024",
"duration": 120
}
}'
Error Responses
Invalid Request Body
{
"status": "error",
"message": "Invalid request body"
}
Missing API Key or Website ID
{
"status": "error",
"message": "API key or website_id required"
}
Missing Scope
{
"status": "error",
"message": "API key missing track:events scope"
}
Website Not Found
{
"status": "error",
"message": "Website not found"
}
⌘I