---
# @generated by sylphx-gen. Do not edit.
title: "Batch an analytics event"
description: "`analytics.analytics_events.batch` (POST /v1/{parent}/analytics_events:batch): Records a batch of events."
type: reference
product: analytics
summary: "Records a batch of events."
updated: 2026-09-28
nav: false
---

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.

**Not available yet.** Sylphx Analytics is declared in the registry but no backend serves it: every call answers `501` with the problem code `UNIMPLEMENTED`.

- **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](/docs/api/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. |

### 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`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`RATE_LIMITED`](/docs/api/errors/RATE_LIMITED) — The rate limit is reached; see Retry-After.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
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":{}}]}'
```

**TypeScript**

```ts
const response = await sylphx.analytics.analyticsEvents.batch({ events: [{ anonId: '…', eventId: '…', name: '…', timestamp: {} }], parent: 'orgs/acme/projects/shop/envs/production' })
```

**Rust**

```rust
let mut req = sylphx::analytics::BatchEventsRequest::default();
req.events = vec![Default::default()];
req.parent = "orgs/acme/projects/shop/envs/production".to_string();
let response = sx.analytics().analytics_events().batch(req).await?;
```

**CLI**

```bash
sylphx analytics analytics-events batch orgs/acme/projects/shop/envs/production
```

**MCP**

```json
{ "method_id": "analytics.analytics_events.batch", "args": {"events":[{"anon_id":"…","event_id":"…","name":"…","timestamp":{}}],"parent":"orgs/acme/projects/shop/envs/production"} }
```
