HTTP API
The browser SDK uses this endpoint, and you can call it directly from your server. See Sending from your server for a complete example.
Request
Section titled “Request”- URL:
https://<ingest-host>/v1/batch - Body: JSON, sent as
Content-Type: text/plainfrom browsers (avoids a CORS preflight; the server parses JSON either way). Max 64 KB. - Auth:
- Browser: public site key in the body (
key). The request'sOriginmust be on the key's allowlist.sendBeaconcan't set headers, which is why the key is in the body. - Server-to-server:
Authorization: Bearer <secret key>;keyomitted; no origin check.
- Browser: public site key in the body (
{ "key": "pk_live_abc123", "sdk": { "name": "cosembra-js", "version": "0.1.0" }, "sent_at": "2026-12-04T15:30:05.120Z", "context": { "anonymous_id": "a_7f3k9x2m4q1z8w0e", "user_id": null, "session_id": "s_q81mz0r5t2y7u4i9", "page": { "url": "https://client.com/watch/88", "path": "/watch/88", "title": "Episode 3", "referrer": "https://google.com/" }, "utm": { "source": "newsletter" }, "screen": { "w": 1440, "h": 900 }, "locale": "en-US", "timezone": "America/Chicago", "consent": "granted" }, "super": { "exp.checkout_v2": "B" }, "events": [ { "event_id": "01JEX4MP7EQ2V3K4M5N6P7R8ST", "name": "item_viewed", "ts": "2026-12-04T15:30:01.004Z", "properties": { "item_id": "vid_88", "item_type": "video" } } ]}| Field | Notes |
|---|---|
context |
Sent once per batch; copied onto every stored event. The SDK only batches events whose context and super properties are identical. |
event_id |
Client-generated ULID (Crockford base32, 26 chars). Retries reuse it; storage deduplicates on it. |
ts / sent_at |
Server corrects clock skew: stored_ts = ts + (received_at − sent_at). |
| User agent, IP | Taken from the request, never the body. The IP is not stored. |
Limits
Section titled “Limits”| Item | Limit |
|---|---|
| Body | 64 KB |
| Events per batch | 1–100 |
| Event name | ^[a-z][a-z0-9_]{0,63}$ |
| Properties | 8 KB serialized, 100 keys, nesting depth 3 |
| Event age | Corrected ts older than 7 days is rejected; more than 60 s in the future is clamped to receive time |
| Super properties | 50 keys, scalar values |
Responses
Section titled “Responses”| Status | Body | Client should |
|---|---|---|
| 202 | {"accepted": n, "rejected": [{"index": i, "reason": "..."}]} |
Remove the batch (rejected events won't succeed on retry) |
| 400 | {"error": "invalid_json" | "invalid_batch" | "empty_body", "issues"?: [...]} |
Drop |
| 401 | {"error": "invalid_site_key" | "invalid_secret_key"} |
Drop, stop sending |
| 403 | {"error": "origin_not_allowed"} |
Drop, stop sending |
| 413 | {"error": "body_too_large"} |
Split the batch and resend |
| 429 | {"error": "rate_limited"} + Retry-After |
Retry after the delay |
| 503 | {"error": "buffer_full" | "buffer_unavailable"} + Retry-After |
Retry with backoff |
Rejection reasons: invalid_event, invalid_name, invalid_event_id, invalid_ts,
too_old, properties_too_large, properties_too_many_keys, properties_too_deep,
duplicate_in_batch.