palbaseDocs

Palbase Analytics · API

POST/analytics/capture

Send an event

One event: a name, who did it (distinct_id), its properties (100 at most, 8 KiB each, 32 KiB in all), when on the device's clock (corrected by sent_at). The request is answered once what it sends is kept — on the platform's stream, written to the store within seconds, even while the store is restarting. A signed-in user's token (with the publishable key) makes it theirs: their user id is the distinct id, whatever the body says.

Called by your app, with the publishable key; or a signed-in user of your app, with their token and the publishable key; or your server, with the project's secret key.

Headers

Idempotency-Keystring · optionalThe request's key: the same key sent again within two minutes is not kept twice.
X-Palbase-Client-Versionstring · optionalThe app's version: kept with what it sends.
X-Platformstring · optionalThe app's platform (ios, android, web).
X-OS-Versionstring · optionalThe operating system's version.

Request body

app_versionstring · optionalThe app's version.
distinct_idstring · optionalWho did it (256 characters at most). With a user's token, the user's id instead; with user_id, the user's id. Required unless user_id names the user. An app (the publishable key) names its signed-in user's id and its own anonymous ids (anon_…, as the SDKs make them) only: any other id is someone else's and is refused (400 distinct_id_not_yours); the project's server names whom it means.
eventstring · requiredThe event's name: a letter or $, then letters, digits and _.:-$; 64 at most.
propertiesobject · optionalFree-form properties: 100 at most, 8 KiB each as JSON.
sent_atnumber · optionalWhen the device sent it, unix milliseconds on its clock: the difference to the server's is the clock's error, taken off timestamp.
session_idstring · optionalThe session it happened in.
timestampnumber · optionalUnix milliseconds on the device's clock.
user_idstring · optionalThe user whose event it is: the project's server alone names one (its secret key) — their own event, as their app sends it signed in, on their timeline and acted on by their journeys. An app's event is its signed-in user's; one that names user_id is refused (invalid_user_id).
curl
curl -X POST "https://<your-ref>.palbase.studio/analytics/capture" \
  -H "apikey: $PALBASE_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"event":"string"}'

Responses

202Kept

400The request is malformed, or what it sends breaks a limit (the error names which: the SDKs' codes)

401No key, or not a key of this project, or a token that is not valid (the edge's answer)

413The body is over this operation's limit (payload_too_large), or an upload's record or batch is (record_too_large, batch_too_large)

429The project is sending analytics faster than its per-second limit (rate_limited), or its quota for the period is used up (quota_exceeded); Retry-After says when to try again

503The platform could not take or answer this now; nothing was kept, and retrying is safe (Retry-After)

defaultAn error: the envelope names it (`error`) and explains it (`error_description`).

Operation Capture of analytics's contract.