Batch an analytics event
Records a batch of events.
Records a batch of events. Each event is judged alone: a bad event is reported in results and the rest are stored. A duplicate event_id (in this or an earlier batch) is counted once. The response is sent only after the store holds the accepted events.
- Path
POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/analytics_events:batch - Scope
analytics:ingest - Effect
write— a successful call changes state. - Collection analytics_events
- Publishable key callable
Request
| Field | Type | What it is |
|---|---|---|
parent | string | The parent the method acts in. Required. |
events | EventInput[] | The events, 1 to 500. Required. |
sent_time | timestamp | When the sender built the batch, on its clock. When it differs from the receive time by more than 10 minutes, every event time is shifted by the difference. |
consent | AnalyticsConsent | The app's current analytics consent; events are stored only when GRANTED. A publishable-key batch that is not GRANTED has every event rejected consent_not_granted (still 200, nothing stored). A secret-key batch with UNSPECIFIED counts as granted (the tenant's server attests); DENIED is always refused. One of granted, denied. |
EventInput
| Field | Type | What it is |
|---|---|---|
event_id | string | A UUID made by the sender when the event happens (UUIDv7 recommended). It is the deduplication key: a resend, in any batch, is counted once. Required. |
name | string | The event name: 1 to 128 characters of A-Za-z0-9_.:/-; a leading $ is reserved for the platform. Required. |
timestamp | timestamp | When it happened, on the sender's clock. Older than 31 days is refused too_old; more than 10 minutes ahead is stored as the receive time. Required. |
anon_id | string | The device- or install-scoped id; required. Required. |
user_id | string | The signed-in end user, when known. When present it, not anon_id, is the subject that stats and retention count. |
session_id | string | The SDK session, when there is one. |
properties | struct | Free properties, at most 8 KiB encoded, nesting depth 4. |
context | EventContext | The sender's context. |
is_internal_qa | bool | True for internal QA, false for verified customer traffic; omit if unknown. Honored only with a verified secret key. |
EventContext
| Field | Type | What it is |
|---|---|---|
sdk_name | string | The SDK, for example @sylphx/sdk. |
sdk_version | string | The SDK version. |
platform | string | web, ios, android, unity, server,... |
app_version | string | The app's own version. |
locale | string | A BCP 47 locale, for example zh-HK. |
experiments | map<string, string> | The experiments the subject is in when the event happens: experiment key to variant key, at most 20 entries. |
Response
| Field | Type | What it is |
|---|---|---|
results | EventResult[] | One result per event, in the order sent. |
accepted_count | int32 | Events stored by this call. |
duplicate_count | int32 | Events already held. |
rejected_count | int32 | Events refused. |
EventResult
| Field | Type | What it is |
|---|---|---|
event_id | string | The event id as sent (empty when it was missing). |
status | EventStatus | What became of it. One of accepted, duplicate, rejected. |
reason | string | For a rejection: invalid:<field> (the JSON name of the field that is wrong, for example invalid:anon_id), too_old, too_large, name_reserved, or consent_not_granted. |
Errors
UNAUTHENTICATED— No valid key or token was presented.PERMISSION_DENIED— The key lacks the method's permission.INVALID_FIELD— A field failed validation.RATE_LIMITED— The rate limit is reached; see Retry-After.
Every error arrives in the body Errors describes.
Examples
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/analytics_events:batch" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"events":[{"anon_id":"…","event_id":"…","name":"…","timestamp":{}}]}'