> ## Documentation Index
> Fetch the complete documentation index at: https://equatetravel.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook

> Deliver processed results to your endpoint as an authenticated, signed HTTP POST, with replay protection, idempotency keys, secret rotation and document links built in.

A **webhook connector** is a delivery target: when a [pipeline](https://equatetravel.ai/docs/guides/pipelines.md)
action fires, equate POSTs the result to your endpoint. Gate the action by outcome to,
say, push auto-matched invoices straight into your back office while the rest go to a
human.

This page is the integration contract. If you are the engineer receiving the hook, the
[checklist](#onboarding-checklist) at the end is everything you need to decide and build.

## What you'll need

| From you | Why |
| - | - |
| An **https endpoint** that accepts `POST` | Where results land. It must respond `2xx` quickly (store, then process). |
| How the endpoint **authenticates callers** | None, an API key header, a bearer token, basic credentials, or OAuth 2.0 client credentials (Cognito, Auth0, Entra ID). See [Authentication](#authentication). |
| A **signing secret** (we can generate it) | So your endpoint can verify each body came from equate and isn't a replay. See [Verifying the signature](#verifying-the-signature). |
| Which **fields** you want | The payload is opt-in per field; it can be as small as a reference and a total. See [The delivery](#the-delivery). |
| How long **document links** should live | One hour by default, adjustable from 1 minute to 7 days. See [Document links](#document-links). |

## Creating the connector

**1. Endpoint URL**

The https URL equate should POST to. It must be publicly reachable; private
and link-local addresses are refused, and redirects are not followed.

**2. Signing secret**

Press **Generate** and copy the value into your system, or paste one you minted.
Stored encrypted, never shown again, rotatable at any time with an overlap window.

**3. Authentication (Additional security)**

Open **Additional security** to say how your endpoint checks it's us (see
[Authentication](#authentication)). Leave it on **None** if the signature alone is
enough for you.

**4. Test connection**

Sends a test POST through exactly the path deliveries take: the same
authentication (including the OAuth token exchange) and the same signatures. The
body is `{"test": true, "source": "equate", "at": "<ISO time>"}` and the request
carries `X-Equate-Test: true`, so you can recognise and discard it.

**5. Attach it to a pipeline**

Add a **Webhook** action in the pipeline builder, pick this connector, choose
which **outcomes** trigger it (auto-matched, needs review, failed or flagged), and
shape the payload.

Connectors are managed by workspace admins and members with the **Technical** role.
Admins also see every signing secret and stored credential in one place under
**Organisation → Keys & secrets**.

## Authentication

Two independent layers protect a delivery. **Authentication** is how your endpoint
recognises the caller: a credential you issue us, sent on every request.
**Signing** is how it verifies the message: an HMAC over the body with a shared secret.
Use both; the signature is sent whichever authentication you choose.

| Option | What we send | Typical use |
| - | - | - |
| **None** | Only the signature headers. | Endpoints that verify the HMAC and nothing else. |
| **API key (header)** | A header you name, e.g. `X-API-Key: <key>`. | API gateways with key auth. |
| **Bearer token** | `Authorization: Bearer <token>`, a static token you issue. | Simple services. |
| **Basic** | `Authorization: Basic base64(user:password)`. | Legacy endpoints. |
| **OAuth 2.0 client credentials** | `Authorization: Bearer <access token>`. Before delivering, equate POSTs your **token endpoint** with `grant_type=client_credentials` (client id and secret as HTTP Basic, also `client_id` in the body, optional `scope`), caches the token until shortly before it expires, and sends it. | Amazon Cognito, Auth0, Microsoft Entra ID, any RFC 6749 §4.4 server. |

> [accordion] Setting up Cognito for equate
>
> 1. In your user pool, add a **resource server** (for example identifier `equate`) with a
>    custom scope such as `invoices/write`.
> 2. Create an **app client** for equate with a client secret, the **client credentials**
>    flow enabled, and that scope allowed.
> 3. On the connector, choose *OAuth 2.0 client credentials* and enter the token endpoint
>    (`https://<your-domain>.auth.<region>.amazoncognito.com/oauth2/token`), the client
>    id, the client secret and the scope (`equate/invoices/write`).
> 4. Protect your endpoint with a Cognito authorizer (API Gateway) or validate the JWT
>    yourself. **Test connection** performs the token exchange and the POST, so a green
>    test means the whole chain works.
>
> Cognito access tokens last an hour by default; equate fetches a new one about a minute
> before expiry, so you'll see roughly one token request an hour per connector, not one
> per invoice.

Credentials are encrypted with AES-256-GCM before they reach our database, under a key
that lives only in the application environment. They are never displayed again; to
change one, edit the connector and enter the new value.

## The delivery

Each delivery is a JSON POST. The `data` object always carries `jobId` and
`reference`; everything else is opt-in per pipeline action, so the payload can be as
small as you like:

```json theme={null}
{
  "data": {
    "jobId": "0d2c8e6e-5f0b-4a3d-9a3b-4c1e8f0a2b7d",
    "reference": "OC-44821",
    "matchResult": {
      "matched": true,
      "decision": "auto",
      "confidence": 0.96,
      "bookingReference": "OC-44821",
      "bookingId": "BK-100482",
      "reason": "Reference, supplier and amounts agree"
    },
    "extractedData": {
      "supplier": "Oceania Cruises",
      "invoiceCurrency": "GBP",
      "totalCost": "4250.00"
    },
    "bookingData": {
      "bookingId": "BK-100482",
      "isPrincipal": "1",
      "exchangeRate": "1.0000"
    }
  },
  "artifacts": [
    {
      "id": "3f9a1c2e-8b7d-4e6f-9a0b-1c2d3e4f5a6b",
      "role": "agent",
      "filename": "OC-44821.pdf",
      "url": "https://app.equatetravel.ai/api/files/<signed token>"
    }
  ]
}
```

* **`data`** is shaped in the pipeline action: toggle the match result, the per-field
  match breakdown, the invoice fields (`extractedData`) and the matched booking's fields
  (`bookingData`, `null` when no booking was found) on or off, pick exactly **which
  invoice and booking fields** to include, and add fixed key/values of your own (a flag such as
  `"source": "equate"` or a system identifier, the same on every delivery from that
  pipeline). A pipeline per document family (flights, hotels) with its own fixed values
  is the usual way to tell them apart.
* **`matchResult`** always has the same six fields when the action includes it:

  | Field | Meaning |
  | - | - |
  | `matched` | `true` when a booking was matched. |
  | `decision` | `auto` (matched automatically), `review` (went to a person to check) or `none` (no booking found). |
  | `confidence` | 0 to 1. |
  | `bookingReference` | The matched booking's reference, or `null`. |
  | `bookingId` | The matched booking's own ID (the `bookingId` in your booking data), or `null` when there's no match or your booking data doesn't carry one. |
  | `reason` | A short, readable explanation, or `null`. |

  The booking's other fields go in `bookingData`, when the action includes them.
* **`artifacts`** are [document links](#document-links), present only when the action
  asks for documents. Webhooks carry **links, never file bytes**. Each one has:

  | Field | Meaning |
  | - | - |
  | `id` | The document's id. It stays the same for the life of the file, so store it with `jobId` and you can [ask for the file again](#if-a-download-fails). |
  | `role` | `agent` (the invoice itself), `client` (a paired guest copy) or `associated` (another file from the same email). |
  | `filename` | The file's name as it arrived. |
  | `url` | A signed link that expires. |
* The body can instead be **XML, CSV or TXT** (`payloadFormat` on the action); then the
  data is serialised directly with a matching `Content-Type`, with no envelope.

### Headers

| Header | Purpose |
| - | - |
| `Content-Type` | `application/json` (or the chosen format's type). |
| `Idempotency-Key` | Stable per job + action: `<jobId>:<actionId>`. Dedupe retried deliveries on your side. |
| `X-Equate-Signature` | `t=<unix seconds>,v1=<hex>` — the timestamped HMAC (see below). Two `v1` values during a [rotation](#rotating-the-signing-secret). |
| `X-Signature-256` | `sha256=<hex HMAC-SHA256 of the raw body>` with the current secret. The original scheme, kept for receivers built against it. New integrations should verify `X-Equate-Signature`. |
| `Authorization` or your API-key header | Per the connector's [authentication](#authentication). |
| `X-Equate-Test` | `true` on the connector's test ping only. The ping also carries the header's old name, `X-Invoice-Processing-Test`, for receivers built against it. New integrations should read `X-Equate-Test`. |

Both signature headers are present whenever the connector has a signing secret.

### Verifying the signature

`X-Equate-Signature` is `t=<timestamp>,v1=<signature>` where the signature is
**HMAC-SHA256** (hex) with your signing secret over the string `` `${t}.${rawBody}` ``:
the timestamp, a full stop, then the **raw request body** exactly as received (don't
parse and re-serialise it first). Reject anything whose timestamp is more than
**5 minutes** from your clock, which is what stops a captured request being replayed.

```ts theme={null}
import { createHmac, timingSafeEqual } from "node:crypto"

export function verifyEquateSignature(
  rawBody: string,
  header: string | undefined,
  secret: string,
  toleranceSeconds = 300
): boolean {
  if (!header) return false
  const parts = Object.fromEntries(
    header.split(",").map((p) => p.trim().split("=") as [string, string])
  )
  const t = Number(parts.t)
  if (!Number.isInteger(t)) return false
  if (Math.abs(Math.floor(Date.now() / 1000) - t) > toleranceSeconds) return false

  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex")
  // During a rotation the header carries two v1 values; accept either.
  return header
    .split(",")
    .filter((p) => p.trim().startsWith("v1="))
    .map((p) => p.trim().slice(3))
    .some((sig) => sig.length === expected.length && timingSafeEqual(Buffer.from(sig), Buffer.from(expected)))
}
```

In an AWS Lambda authorizer or API Gateway, read the raw body before any JSON parsing
and the header case-insensitively (`x-equate-signature`). A receiver that still checks
`X-Signature-256` computes `sha256=` + HMAC-SHA256(secret, rawBody); that header has no
timestamp, so pair it with the `Idempotency-Key` to refuse repeats.

### Rotating the signing secret

Rotate from the connector page or **Organisation → Keys & secrets**. You choose, or
let us generate, the new secret, and an **overlap window** (1 hour to 7 days, 24 hours
by default):

1. From the moment you rotate, every request carries **two** `v1` signatures: the new
   secret's first, then the previous secret's. `X-Signature-256` switches to the new
   secret immediately.
2. Deploy the new secret on your side whenever suits you inside the window. A verifier
   that accepts *any* matching `v1` (as the sample above does) passes throughout.
3. When the window closes, or when you press **Finish rotation now**, the previous
   secret stops signing.

Rotation is logged in the audit log (who, when, the window). The secret is shown once,
at rotation, and never again.

## Retries and failure

A non-2xx response (or a timeout) marks the delivery failed and it is retried with
backoff. A `429`, or a `503` with `Retry-After`, is treated as "slow down": the job is
held and retried after the delay rather than counted as a failure. Repeated failures
park the job as `ACTION_FAILED`: it keeps its match and shows in **Processed** with a
**Delivery Failed** badge. **Logs → Outbound** shows the request we sent, how it
authenticated, and the response we received; fix the endpoint, then re-send it from
there.

> [!TIP]
>
> Respond `2xx` as soon as you've **stored** the payload; do your downstream processing
> asynchronously. Slow endpoints look like failures and trigger retries, which is what
> the `Idempotency-Key` is for.

## Document links

When the action includes documents (the processed invoice, a paired client copy, other
files from the same email), each `artifacts[].url` is a **signed, expiring link** served
from equate's own domain. No storage backend URL is ever exposed. The lifetime is set per
action: **1 hour by default**, anywhere from 1 minute to 7 days. An expired link returns
`404`.

### If a download fails

Store two ids from the delivery, not the link: `data.jobId` and the document's
`artifacts[].id`. With those you can get a fresh link at any time, without waiting for
the delivery to be sent again:

```bash theme={null}
curl https://equatetravel.ai/api/v1/invoices/<jobId>/documents/<documentId> \
  -H "Authorization: Bearer $EQUATE_API_KEY"
```

```json theme={null}
{
  "data": {
    "jobId": "0d2c8e6e-5f0b-4a3d-9a3b-4c1e8f0a2b7d",
    "reference": "OC-44821",
    "expiresAt": "2026-12-03T11:30:00.000Z",
    "document": {
      "id": "3f9a1c2e-8b7d-4e6f-9a0b-1c2d3e4f5a6b",
      "role": "agent",
      "filename": "OC-44821.pdf",
      "contentType": "application/pdf",
      "url": "https://app.equatetravel.ai/api/files/<signed token>"
    }
  }
}
```

Leave the document id off (`/api/v1/invoices/<jobId>/documents`) to list **every**
document held for the invoice, each with its `id` and a fresh link. That list can be
longer than the delivery's `artifacts`: an action sends only the documents it was set to
send, and the list has all of them.

* **`jobId` is on every delivery**, whatever fields the action sends. The document `id`
  is on every entry in `artifacts`.
* **Call it as often as you need.** Each call returns a new link and leaves earlier ones
  working until they expire. `?ttl=<seconds>` sets the lifetime (60 to 604800, one hour by
  default).
* **Authenticate with an API key** from **Organisation → Keys & secrets** (see
  [API keys](https://equatetravel.ai/docs/guides/api-keys.md)). The links themselves need no key.
* **`404`** means the invoice isn't in your workspace, the document isn't one of that
  invoice's, or your [retention period](https://equatetravel.ai/docs/guides/data-retention.md) has removed the file. A
  removed file can't be recovered, so there is nothing to retry.

A sensible receiver: download each `artifacts[].url` when the delivery arrives. On a
failure (a timeout, a `404` from the link, a `5xx`), wait, ask for a fresh link by id and
try that. After a few attempts with backoff, raise it on your side with the `jobId` and
the document `id`. See the API reference for [one document](https://equatetravel.ai/docs/api-reference/invoices/document.md)
and [all of an invoice's documents](https://equatetravel.ai/docs/api-reference/invoices/documents.md).

## Network

Deliveries come from equate's hosting in the EU (Dublin) over https. Outbound
addresses are not fixed by default, so prefer authenticating the request (signature
plus one of the [authentication](#authentication) options) over IP allow-listing. If
your security policy requires a **fixed source address**, ask us: deliveries to your
workspace's webhooks and APIs can be routed through a static address.

See [connector security](https://equatetravel.ai/docs/connectors/security.md) for what is encrypted, what is verified
and how every credential is rotated, across all connectors.

## Onboarding checklist

Agree these with equate and the integration is specified:

* [ ] **Endpoint URL** (https, accepts `POST`, replies `2xx` fast).
* [ ] **Authentication**: none / API key header / bearer / basic / OAuth 2.0 client
  credentials. For OAuth: token endpoint, client id, client secret, scope.
* [ ] **Signing secret**: generated by equate or minted by you; where it lives on your
  side; who rotates it and how often (the overlap window makes this painless).
* [ ] **Payload**: which fields, any fixed key/values, JSON or another format.
* [ ] **Documents**: include them or not, and the link lifetime. Store `jobId` and each
  document's `id` so a failed download can be retried with a fresh link.
* [ ] **Outcomes** that trigger the hook (auto-matched, needs review, failed or flagged).
* [ ] **On your side**: verify `X-Equate-Signature` (5-minute tolerance), dedupe on
  `Idempotency-Key`, ignore `X-Equate-Test`, return `429` or
  `503 + Retry-After` when you need us to back off.

> [card] [Next: shape what gets sent](https://equatetravel.ai/docs/guides/pipelines.md)
>
> Actions are gated by outcome and configured per pipeline.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.