Skip to Content

Record contact events in a batch

Validates the full request shape, contact references, and event names before processing.

POST
/v1/events/batch

Validates the full request shape, contact references, and event names before processing. A schema failure rejects the entire batch without writes. Between 1 and 100 valid entries are then processed in input order, with independent indexed results for properties limits, contact resolution, and domain validation. An optional Idempotency-Key header scopes the batch; retries reuse each entry's original receipt by its position in the batch.

Authorization

apiKey
headerx-api-key<token>

Header Parameters

idempotency-key?string
Length1 <= length <= 255

Request Body

application/json
  1. body
events*array<>
Items1 <= items <= 100

Response Body

BatchEventsResult

application/json
  1. response
total*integer
Range-9007199254740991 <= value <= 9007199254740991
accepted*integer
Range-9007199254740991 <= value <= 9007199254740991
errors*integer
Range-9007199254740991 <= value <= 9007199254740991
results*array<>
Example Request
import { createClient } from "samva";

const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });

const result = await samva.events.batch({
  "events": [
    {
      "contact": {
        "id": "example"
      },
      "name": "example"
    }
  ]
});
Example Response
{
  "total": -9007199254740991,
  "accepted": -9007199254740991,
  "errors": -9007199254740991,
  "results": [
    {
      "index": -9007199254740991,
      "status": "accepted",
      "event": {
        "id": "string",
        "contactId": "string",
        "name": "string",
        "source": "api",
        "properties": {
          "property1": "string",
          "property2": "string"
        },
        "occurredAt": "string",
        "recordedAt": "string"
      },
      "error": "string"
    }
  ]
}

Related documentation