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
Authorization header. The API key must have the track:events scope.
- Website ID: Pass
website_id as a query parameter for client-side tracking.
Request
Bearer token with your API key (required if not using website_id)
Query 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 error
Type of event processed: custom_event
Number 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"
}'
{
"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"
}
}
]'
{
"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"
}