Skip to main content

Two kinds of failure

A batch can fail as a whole, or one event inside it can fail on its own. These need different handling.

Request failures

The SDK throws typed errors, so one catch can branch on the failure kind:
ReconifyApiError exposes:
number
The HTTP status code.
string
The stable machine-readable error code, such as not_found or forbidden. When the response carries no code, the SDK derives one from the status: not_found, validation_error, rate_limited, service_unavailable, or api_error.
string | undefined
The failing request field, when the API identified one.
ReconifyErrorDetail[]
Every validation entry the API returned, each with message and an optional field.
unknown
The parsed response body.
Response
The raw Response. Read response.headers.get("x-request-id") and include it in support requests.
ReconifyTimeoutError carries code: "timeout" and timeoutMs. Cancelling through your own AbortSignal rejects with the signal’s reason instead.

Which status to act on

Each status implies one action:

Rejected events inside a batch

The batch endpoint returns 202 when at least one event is accepted or duplicated, and 422 when every event is rejected. Always read results.
item.index matches the position in the array you sent. Use it to locate the producer-side record without writing the event or customer reference to logs.

Automatic retries

The client retries on its own, with exponential backoff. Retries apply to 429 and 503 responses, request timeouts, and transport failures. A Retry-After header overrides the computed backoff, capped at maxDelayMs. By default only GET, HEAD, and OPTIONS are retried, so event ingestion is not retried automatically.
Turn on retryNonIdempotent only when every event in the batch has a stable id. Reconify then returns duplicate for events it already stored instead of recording them twice.
An event without id receives a generated ID on every attempt. Retrying a batch that contains such events records them more than once.

Next

Put this together in Send events with TypeScript.