S
API Reference/Track Events

📤 Track Events API

Send events directly to Sypnia from your server or client.

POST/api/track

Track 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

PropertyTypeDescription
project_key*stringYour API key (starts with sk_)
event_type*stringEvent type: pageview, click, error, custom, etc.
session_idstringSession identifier (auto-generated if omitted)
visitor_idstringVisitor identifier (auto-generated if omitted)
timestampstringISO 8601 timestamp (defaults to now)
urlstringFull URL of the page
pathstringURL path without domain
referrerstringReferrer URL
titlestringPage title
propertiesobjectCustom 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.