Janus Client SDK
A lightweight JavaScript library for tracking events from web applications. Automatically handles batching, retries, rate limiting, and persistence.
Lightweight (~3KB)Auto RetryBatchingPersistence
HTTP API
Authentication#
Authenticate requests with your API key using either header format:
bash
# Option 1: x-api-key headercurl -H "x-api-key: jns_your_api_key" ...# Option 2: Bearer tokencurl -H "Authorization: Bearer jns_your_api_key" ...
Send Events#
POST a single event object or an array of events to the events endpoint.
Single Event#
bash
curl -X POST https://api.addjanus.ca/api/v1/events \-H "Content-Type: application/json" \-H "x-api-key: jns_your_api_key" \-d '{"type": "purchase_completed","payload": { "orderId": "ORD-123", "amount": 99.99 },"distinctId": "user_456","timestamp": "2026-03-05T12:00:00.000Z"}'
Response (201)
{"id": "clx...","userId": "...","type": "purchase_completed","payload": { "orderId": "ORD-123", "amount": 99.99 },"distinctId": "user_456","context": { "country": "CA" },"timestamp": "2026-03-05T12:00:00.000Z","createdAt": "2026-03-05T12:00:01.000Z"}
Batch Events#
Send an array instead of a single object:
bash
curl -X POST https://api.addjanus.ca/api/v1/events \-H "Content-Type: application/json" \-H "x-api-key: jns_your_api_key" \-d '[{ "type": "page_view", "payload": { "path": "/pricing" }, "distinctId": "user_456" },{ "type": "button_click", "payload": { "id": "cta" }, "distinctId": "user_456" }]'
Response (201)
{ "count": 2 }
Event Schema#
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Event name |
| payload | object | No | Event properties (JSON object, 10KB combined limit with context) |
| tags | string[] | No | Array of string tags (max 10, each max 100 chars) |
| distinctId | string | No | User identifier |
| sessionId | string | No | Session identifier |
| context | object | No | Additional context (JSON object, 10KB combined limit with payload; country auto-added server-side) |
| timestamp | ISO 8601 | No | Event time (defaults to server time) |
Error Handling#
HTTP status codes returned by the events endpoint:
| Status | Meaning | Action |
|---|---|---|
| 201 | Event(s) created | — |
| 401 | Invalid or missing API key | Check your x-api-key header and key value |
| 403 | Origin not allowed | Add your domain to the key's allowed origins in Settings |
| 429 | Rate limited or monthly cap exceeded | Back off and retry; check Retry-After header |
Need Help?
If you have questions or run into issues, check out our troubleshooting guide or reach out to our support team.
Troubleshooting Guide