v1.2.0

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 header
curl -H "x-api-key: jns_your_api_key" ...
# Option 2: Bearer token
curl -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#

FieldTypeRequiredDescription
typestringYesEvent name
payloadobjectNoEvent properties (JSON object, 10KB combined limit with context)
tagsstring[]NoArray of string tags (max 10, each max 100 chars)
distinctIdstringNoUser identifier
sessionIdstringNoSession identifier
contextobjectNoAdditional context (JSON object, 10KB combined limit with payload; country auto-added server-side)
timestampISO 8601NoEvent time (defaults to server time)

Error Handling#

HTTP status codes returned by the events endpoint:
StatusMeaningAction
201Event(s) created
401Invalid or missing API keyCheck your x-api-key header and key value
403Origin not allowedAdd your domain to the key's allowed origins in Settings
429Rate limited or monthly cap exceededBack 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