📤 Track Events API
Send events directly to Sypnia from your server or client.
POST
/api/trackTrack one or more events
📝 Request Body
{
"events": [
{
"project_key": "sk_your_api_key",
"event_type": "custom",
"session_id": "sess_abc123",
"visitor_id": "vis_xyz789",
"timestamp": "2025-12-15T10:30:00Z",
"url": "https://example.com/pricing",
"path": "/pricing",
"referrer": "https://google.com",
"properties": {
"event_name": "pricing_viewed",
"plan": "pro"
}
}
]
}📋 Event Schema
| Property | Type | Description |
|---|---|---|
project_key* | string | Your API key (starts with sk_) |
event_type* | string | Event type: pageview, click, error, custom, etc. |
session_id | string | Session identifier (auto-generated if omitted) |
visitor_id | string | Visitor identifier (auto-generated if omitted) |
timestamp | string | ISO 8601 timestamp (defaults to now) |
url | string | Full URL of the page |
path | string | URL path without domain |
referrer | string | Referrer URL |
title | string | Page title |
properties | object | Custom properties for the event |
🔧 Examples
cURL
curl -X POST https://sypnia.com/api/track \
-H "Content-Type: application/json" \
-d '{
"events": [{
"project_key": "sk_your_api_key",
"event_type": "custom",
"properties": {
"event_name": "server_purchase",
"user_id": "user_123",
"amount": 99.99
}
}]
}'Node.js
const response = await fetch('https://sypnia.com/api/track', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
events: [{
project_key: 'sk_your_api_key',
event_type: 'custom',
properties: {
event_name: 'user_signup',
user_id: 'user_123',
plan: 'pro'
}
}]
})
});
const data = await response.json();
console.log(data); // { success: true, processed: 1 }Python
import requests
response = requests.post(
'https://sypnia.com/api/track',
json={
'events': [{
'project_key': 'sk_your_api_key',
'event_type': 'custom',
'properties': {
'event_name': 'order_completed',
'order_id': 'order_456',
'total': 149.99
}
}]
}
)
print(response.json()) # {'success': True, 'processed': 1}📤 Response
Success (200)
{
"success": true,
"processed": 1
}Error (400/401)
{
"error": "Invalid API key"
}ℹ️Batching
You can send up to 100 events in a single request. The SDK automatically batches events to reduce network requests.