# Receive signed server events

Verify signed JSON batches, process them idempotently, and recover failed deliveries.

Tringify sends JSON batches to the HTTPS endpoint configured for the installed release. A batch contains one store, installation, schema version, and consent purpose. It contains at most 200 events and has a 10-second request timeout.

## Request headers

| Header | Purpose |
| --- | --- |
| `Content-Type` | Always `application/json`. |
| `X-Tringify-Timestamp` | Unix timestamp included in the signature. |
| `X-Tringify-Signature` | `t=<timestamp>,v1=<lowercase HMAC-SHA256 hex>`. |
| `X-Tringify-Store-ID` | Store that owns every event in the batch. |
| `X-Tringify-App-Install-ID` | Installation receiving the batch. |

## Verify the signature

Read the raw request body before JSON parsing. Compute HMAC-SHA256 with the app signing secret over the timestamp, one literal period, and the exact raw body bytes. Compare the lowercase hexadecimal digest in constant time, and reject a request whose `X-Tringify-Timestamp` is more than five minutes from your clock, in either direction, before performing work. A retried batch is signed again with a fresh timestamp, so a healthy retry always passes this check. During a signing-key rotation the header carries one `v1` per key, current first; accept the request when any of them matches.

```text
<X-Tringify-Timestamp>.<exact raw request body>
```

## Batch envelope

```json
{
  "consent_purpose": "analytics",
  "events": [
    {
      "context": {
        "url": "https://shop.example/checkout/confirmation"
      },
      "event_id": "019f0000-0000-7000-8000-000000000001",
      "occurred_at": "2026-08-11T00:00:00Z",
      "payload": {
        "currency": "EUR",
        "order_id": "66b0a1d2-4f13-4d32-a51d-93e595034e95",
        "value": "2798.00"
      },
      "schema_version": 1,
      "surface": "theme",
      "type": "purchase"
    }
  ],
  "schema_version": 1,
  "store_id": "f192d1f9-b01f-48c2-9300-3f3bf14716b0"
}
```

## Where an event happened

Every event carries `surface`: `theme` for events from the storefront, including orders placed at its checkout. Orders made elsewhere carry `sales_channel` (a sales channel app, such as a marketplace), `app` (another app, through the Store API or MCP) or `admin` (Store Admin), from the order's `origin`. `headless`, `mobile_app` and `agent` are reserved for storefront surfaces to come; treat an unknown value as a non-website source. Ad platforms usually need it to choose the event's action source, such as `website` for `theme`. An event from before `surface` existed has none and came from the storefront.

## Order events

- `purchase`, `refund`, `cancellation` and `order_edited` can carry `origin`, `channel_id` and `channel_name` when your release selects them; see the [event reference](/apps/event-delivery/events).
- An order made outside checkout carries no shopper consent: no shopper saw the store's consent banner. Its events allow no consent purpose, so they reach no app today.
- An app never receives events about an order it created: not when its sales channel created the order, and not when it created the order through the Store API or MCP.
- `refund`, `cancellation` and `order_edited` reach an installation only if it received the order's `purchase`. Orders whose purchase was recorded before 23 November 2026 keep sending them to every subscribed installation.

## Acknowledge and retry

Return any HTTP status from 200 through 299 only after the complete batch has been accepted durably. Any other response or transport failure retries with exponential delays of 1, 2, 4, 8, 16, 32, 64, 128, 256, then 512 seconds. Later retries remain at 512 seconds. After 20 unsuccessful attempts, each event enters the installation's dead-letter list.

## Idempotency and ordering

Use `event_id` as the idempotency key. A retry may repeat an event or batch after an ambiguous response. Do not assume batches arrive in strict event-time order, and do not make correctness depend on two event types sharing one batch.

## Find and replay failed events

A dead letter keeps the event's identity, type, attempt count and last error, but not its payload. Your app reads them for each store with its Store API token: `GET /api/2025-01/event-deliveries/health` returns the installation's pending, delivered and dead-letter counts with the last error, and `GET /api/2025-01/event-deliveries/dead-letters` lists the dead letters (`page`, and `limit` up to 100). Fix your endpoint first, then send one again with `POST /api/2025-01/event-deliveries/dead-letters/{id}/replay`: it goes through the normal signed retries with its original `event_id` and payload. Replay is refused while delivery to your endpoint is switched off or paused.

## Your click IDs and cookies

When your release declares `server_events.attribution`, each event in a batch with an advertising consent purpose (`advertising`, `advertising_data` or `personalized_advertising`) carries `context.app_attribution` when the visitor has any of your declared values. Batches under `analytics` or `personalization` never carry it. A `click_ids` entry gives the value and `captured_at`, when its landing was captured (RFC 3339, UTC), which ad platforms need to build a click cookie. `purchase` and the order's later events, such as `refund`, carry what the shopper had when checkout created the order.

```json
{
  "context": {
    "app_attribution": {
      "click_ids": {
        "exclid": {
          "captured_at": "2026-08-10T21:14:03Z",
          "value": "Cj0KCQjw-example"
        }
      },
      "cookies": {
        "_exa": "ex.1.1786302843000.4821930457",
        "_exc": "ex.1.1786302843000.Cj0KCQjw-example"
      }
    }
  }
}
```

## See what you will receive

**Payload preview** under the app's **Event Delivery** in the Developer Portal shows the batch your endpoint receives for the events, fields and envelope you selected, before you submit the release. Use it to build your parser; the [event reference](/apps/event-delivery/events) lists every field.

