Ingest events from SDKs and server-side integrations with sdk.events.v1.EventsService/BatchCreate.
Auth: an x-api-key header holding a public key (pub_...) or a private key (prv_...). The key identifies the project, so no Authorization or x-project-id header is needed. See Authentication.
BatchCreate
POST /sdk.events.v1.EventsService/BatchCreateValidates and queues up to 1000 events per request; there is no single-event endpoint. Timestamps (occurTime, and timestampValue in a PropertyValue) are RFC 3339 strings with Z or an offset, such as "2026-06-05T10:00:00Z".
Event fields
| Proto field | JSON name | Type | Required | Notes |
|---|---|---|---|---|
event_id |
eventId |
string | Yes | A UUID, any version (v7 recommended) |
auto_properties |
autoProperties |
map<string, PropertyValue> |
No | Context set by the SDK or server. Keys must start with $, and some are server-only |
custom_properties |
customProperties |
map<string, PropertyValue> |
No | Your event properties. Keys must not start with $ |
distinct_id |
distinctId |
string | Unless cookieless |
Anonymous or identified user ID. Must not start with cookieless- |
kind |
kind |
string | Yes | Event name, matching ^[a-zA-Z0-9_.-]+$ |
occur_time |
occurTime |
google.protobuf.Timestamp -> RFC 3339 |
Yes | When the event occurred |
session_id |
sessionId |
string | Unless cookieless |
A UUID grouping events in a visit |
cookieless |
cookieless |
bool | No | Ask the server to derive identity. See Cookieless events |
The JSON names are canonical, and the proto field names (snake_case) work too, here and in PropertyValue. Unknown fields are ignored, not rejected: a misspelled name such as customProps loses its data silently.
Cookieless events
Set "cookieless": true when the client stores no identifier: the Web SDK’s default consent state, and what to send for a visitor who hasn’t consented. Omit distinctId and sessionId: the request fails if either is set, even a sessionId of "" (an empty distinctId passes). A batch may mix cookieless and identified events.
{
"eventId": "01966b9e-1234-7abc-abcd-0123456789ab",
"kind": "page_view",
"cookieless": true,
"occurTime": "2026-06-05T10:00:00Z",
"customProperties": {},
"autoProperties": {}
}The server derives a daily-rotating distinctId, prefixed cookieless-, from the request’s IP address and User-Agent, and stitches a sessionId that closes after 30 minutes of inactivity. Send these events from the visitor’s own device: from your backend, every visitor gets the same identity. Insights leave cookieless visitors out of user counts by default; see Insights.
PropertyValue: typed property wrapper
Every value in customProperties and autoProperties is an object holding exactly one typed field, the Connect JSON form of a protobuf oneof. Profile traits are plain JSON instead.
| Variant | JSON shape | Notes |
|---|---|---|
| String | { "stringValue": "hello" } |
At most 1024 characters (Unicode code points); a longer value is rejected, not truncated |
| Integer | { "intValue": "42" } |
int64, as a JSON string or a whole number |
| Double | { "doubleValue": 3.14 } |
Must be finite |
| Boolean | { "boolValue": true } |
|
| Timestamp | { "timestampValue": "2026-06-05T10:00:00Z" } |
RFC 3339; stored at millisecond precision |
Validation summary
A request that breaks any rule fails whole with invalid_argument, and nothing in it is stored:
- Batch: at most 1000 events, no two with the same
eventId. - Identity:
distinctIdandsessionIdare required unlesscookielessistrue, then omitted. NodistinctIdmay start withcookieless-, nor may anexternalIdon Identify. - Fields and values: every rule in the
Eventfields andPropertyValuetables.
Ingest then rewrites some auto-properties:
$ipis stripped from every event and never stored.- Server-only keys (
$bot,$bot_reason,$bot_score,$verified_bot,$channel,$referrerDomain): any value you send is dropped, and the server sets its own where it can. - Geo (
$country,$city, …): on a public-key request, each key the CDN headers supply replaces the event’s. A private-key request derives none and keeps what the event sends, verbatim, so send$countryas ISO 3166-1 alpha-2; an event that sends none stores none. Node’s and Ruby’slocationoption (Node, Ruby) and Go’spug.WithLocationset them, and Auto-properties lists the keys. - User agent (
$browser,$os,$device,$mobile, …): on a public-key request, parsed from theUser-Agentheader where the event has none. A private-key request derives none, so send your own.
Request / response shape
BatchCreateRequest
{
"events": [
{
"eventId": "<uuid>",
"distinctId": "anon-abc123",
"kind": "page_view",
"sessionId": "<uuid>",
"occurTime": "2026-06-05T10:00:00Z",
"customProperties": {
"plan": { "stringValue": "pro" },
"seats": { "intValue": "5" },
"mrr": { "doubleValue": 299.0 },
"trial": { "boolValue": false }
},
"autoProperties": {}
}
]
}BatchCreateResponse
{ "accepted": 1, "dropped": 0 }accepted (uint32) counts the events queued for storage, and dropped those refused while deriving cookieless identity; together they equal the number sent. droppedByReason appears when dropped isn’t zero. A drop is not an error, so a 200 doesn’t mean every event landed:
{ "accepted": 8, "dropped": 2, "droppedByReason": { "salt_unavailable": 2 } }| Reason | Cause | Retry the same payload? |
|---|---|---|
day_out_of_range |
occurTime is neither today nor yesterday (UTC), usually from client clock skew |
No - it drops again |
salt_unavailable |
The day’s salt couldn’t be read or created, a server-side fault | Yes |
salt_corrupt |
The day’s stored salt can’t be decoded | No - it drops until an operator replaces the salt or it expires |
A cookieless request with no User-Agent header or no resolvable client address (usually a proxy stripping headers) fails whole with invalid_argument instead.
Errors
The codes BatchCreate returns, a subset of the error model:
| Connect code | HTTP status | Cause |
|---|---|---|
unauthenticated |
401 | Missing or invalid x-api-key |
invalid_argument |
400 | The request was malformed or broke a rule, and nothing in it was stored; the message names the rule |
aborted |
409 | An identical batch is still being stored: retry it |
resource_exhausted |
429 | Request body over 8 MiB, measured after decompression |
internal |
500 | Server error: retry with exponential backoff |
unavailable |
503 | The key couldn’t be checked: retry with exponential backoff |
Resend the same events on a retry, with the same eventId and occurTime, so any stored before the error are deduplicated rather than counted twice.
Error responses follow the Connect envelope:
{
"code": "invalid_argument",
"message": "validation error: events[0].kind: does not match regex pattern `^[a-zA-Z0-9_.-]+$`"
}Further reading
- HTTP transport: full curl, Python, and Go examples for
BatchCreate - Auto-properties: the
$-prefixed property catalog set by the server - Authentication: public vs. private keys, key rotation