Skip to content

Server events ​

Send events from your own backend when something happens that the browser does not see: a payment succeeded, a webhook fired, a job finished. Server events count toward analytics, segments and funnels like browser events.

You authenticate with your Secret key (see Keys), never the Public key.

Track an event ​

POST /ingest/events/track

FieldTypeNotes
userIdstringYour own user id, the one you pass to identify(). Recommended.
visitorIdstringOne browser's visitor id. Use it only if you have it.
accountIdstring, optionalLinks the person to an account, like group().
eventNamestringFor example subscription_upgraded.
propertiesobject, optionalStrings, numbers, booleans or null.

Send userId or visitorId. Both are fine.

With userId, the event goes to that person's profile across all their browsers. If the person has never opened your app, a profile is created and joins the later identify() for the same id. The call returns 204 and no body.

bash
curl -X POST https://api.justonecx.com/ingest/events/track \
  -H "Authorization: Bearer $JUSTONECX_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"userId": "user-123", "eventName": "subscription_upgraded", "accountId": "acme", "properties": {"plan": "pro"}}'
js
// Node.js, server only
await fetch(`${process.env.JUSTONECX_API_URL}/ingest/events/track`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.JUSTONECX_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    userId: user.id,
    eventName: "invoice_paid",
    properties: { amount: 4900 },
  }),
});

Errors ​

StatusMeaning
400The body has neither userId nor visitorId, or a field is too long or the wrong type.
401The Secret key is missing, wrong or was rotated.
429Too many calls for this key (3000 per minute). Slow down and retry.

Use identify and group from the browser as usual. The server also accepts POST /ingest/events/identify and POST /ingest/events/group with the same bodies as the browser calls, with a visitorId.

JustOneCX