pex

Events API

The events endpoint ingests pageviews, clicks, form submissions, and custom events. This is a public endpoint — no authentication required.

Ingest Events

POST/api/events

Ingest one or more tracking events

Accepts two payload formats: snippet (single event from the browser) and batch (multiple events from the SDK).

Snippet Format

Used by the Apex JavaScript snippet for individual browser events.

ParameterTypeDescription
typerequiredstringEvent type: pageview, click, form_submit, or a custom event name
visitorIdrequiredstringAnonymous visitor identifier generated by the snippet
projectKeyrequiredstringYour Apex project key
urlrequiredstringFull URL where the event occurred
dataobjectArbitrary event properties (e.g. element ID, form fields, custom data)
referrerstringDocument referrer URL
timestampstringISO 8601 timestamp. Defaults to server receipt time.
curl -X POST https://your-instance.com/api/events \ -H "Content-Type: application/json" \ -d '{ "type": "pageview", "visitorId": "v_abc123", "projectKey": "pk_live_xyz", "url": "https://example.com/pricing", "referrer": "https://google.com" }'

Batch Format

Used by the server-side SDK to send multiple events in a single request.

ParameterTypeDescription
projectKeyrequiredstringYour Apex project key
userIdstringKnown user/lead ID to associate with all events in the batch
eventsrequiredarrayArray of event objects, each with type, url, and optional data/timestamp
curl -X POST https://your-instance.com/api/events \ -H "Content-Type: application/json" \ -d '{ "projectKey": "pk_live_xyz", "userId": "lead_456", "events": [ { "type": "pageview", "url": "/pricing", "timestamp": "2025-01-15T10:30:00Z" }, { "type": "click", "url": "/pricing", "data": { "elementId": "plan-pro" } }, { "type": "form_submit", "url": "/signup", "data": { "plan": "pro" } } ] }'

Response

Returns 200 OK with the count of events processed:

{ "received": 3 }

Tip

Batch events whenever possible. A single batch request counts as one request against rate limits regardless of array size.