> ## 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.

# API quickstart

> Read and match your first invoice through the equate agent API.

This guide is for developers calling equate from their own systems. You'll create an
agent, publish it, generate an API key, and make your first call.

> [!TIP]
>
> New to equate? Start with the [quickstart](https://equatetravel.ai/docs/quickstart.md) instead. It gets invoices
> matching from the dashboard without writing any code.

> [!NOTE]
>
> The agent API is available on plans that include the **Agent Builder**. If your
> workspace doesn't have it yet, see [plans & billing](https://equatetravel.ai/docs/guides/billing.md).

## 1. Build and publish an agent

An **agent** is a pipeline's reading and matching, published as a version and called by
its slug. See [building agents](https://equatetravel.ai/docs/guides/agents.md) for every setting.

**1. Create the agent**

In the dashboard, go to **Agents** and choose **New agent**. Give it a name (the slug
is made from it, so `Cruise Invoices` becomes `cruise-invoices`). Connect booking data
sources if it should match, or leave them empty to only read. The matching settings
start as a pipeline's do: your sector rules and each supplier's own rules apply.

**2. Test it in the playground**

Paste an invoice or upload a file and run it. Adjust the output settings: which
extracted fields come back, whether the match comes back, and any fixed fields. The
playground never runs actions.

**3. Publish**

Hit **Publish**. Only a published version answers API calls; each publish bumps the
version number that comes back in responses.

## 2. Create an API key

In **Organisation → Keys & secrets**, create a key (workspace admins only). The full
secret (`ip_live_…`) is shown **once**. Copy it somewhere safe. equate only stores its
hash.

> [!WARNING]
>
> Treat the key like a password. Anyone with it can run your agents and consume quota.
> Revoke and rotate keys from the same screen if one leaks.

## 3. Run the agent

Send a document one of three ways: inline `content`, a `fileUrl` or a base64 `fileBase64`.

```bash cURL theme={null}
curl -X POST https://equatetravel.ai/api/v1/agents/cruise-invoices/run \
  -H "Authorization: Bearer ip_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "INVOICE\nSupplier: Oceania Cruises\nRef: OC-44821\nTotal: GBP 4,250.00",
    "reference": "order-9921"
  }'
```

```ts TypeScript theme={null}
const res = await fetch(
  "https://equatetravel.ai/api/v1/agents/cruise-invoices/run",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.EQUATE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      fileUrl: "https://example.com/invoices/OC-44821.pdf",
      reference: "order-9921",
    }),
  },
)

const { data } = await res.json()
console.log(data.result)
```

```python Python theme={null}
import os, requests

res = requests.post(
    "https://equatetravel.ai/api/v1/agents/cruise-invoices/run",
    headers={"Authorization": f"Bearer {os.environ['EQUATE_API_KEY']}"},
    json={
        "fileUrl": "https://example.com/invoices/OC-44821.pdf",
        "reference": "order-9921",
    },
)
print(res.json()["data"]["result"])
```

## 4. Read the response

A successful run returns the recorded `runId`, the agent `slug` and `version`, and the
`result`. `document`, `outcome` and `actions` are always there. `data` and `match` follow
your output settings:

```json theme={null}
{
  "data": {
    "runId": "b1d9…",
    "agent": "cruise-invoices",
    "version": 3,
    "result": {
      "reference": "order-9921",
      "document": { "type": "invoice", "isInvoice": true },
      "outcome": "AUTO_MATCHED",
      "actions": [],
      "data": {
        "supplier": "Oceania Cruises",
        "reference": "OC-44821",
        "invoiceCurrency": "GBP",
        "totalCost": "4250.00"
      },
      "match": {
        "matched": true,
        "decision": "auto",
        "confidence": 0.97,
        "bookingReference": "BK-55012"
      }
    }
  }
}
```

Branch on `outcome`. `AUTO_MATCHED` needs nobody. `NEEDS_REVIEW` found a likely booking
that someone should check. `NO_MATCH` found none. A run that didn't try to match answers
`EXTRACTED`, `OUT_OF_SCOPE` or `NOT_HANDLED`. All of them are a `200`. See
[outcomes](https://equatetravel.ai/docs/guides/agents.md#outcomes).

If the agent has [actions](https://equatetravel.ai/docs/guides/agents.md#actions), `actions` lists the ones this outcome
set off. They are queued and run after the response, so they never slow the call.

## 5. Process many at once

For more than one document, use the [batch endpoint](https://equatetravel.ai/docs/api-reference/agents/batch.md). It
takes up to 100 items per call, each with its own `reference`, and each is a run of its
own with its own `outcome`:

```bash theme={null}
curl -X POST https://equatetravel.ai/api/v1/agents/cruise-invoices/batch \
  -H "Authorization: Bearer ip_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "items": [ { "content": "…", "reference": "row-1" }, { "fileUrl": "https://…", "reference": "row-2" } ] }'
```

> [card] [Next: the full API reference](https://equatetravel.ai/docs/api-reference/introduction.md)
>
> Authentication, errors, rate limits and the complete request and response schemas.


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