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

# Building agents

> An agent is a pipeline's reading and matching, called over the API one document at a time. Create one, give it the settings a pipeline has, test it, publish it and call it.

An **agent** does to a document what a [pipeline](https://equatetravel.ai/docs/guides/pipelines.md) does: it reads it, says
what it is, matches it to a booking under your [business rules](https://equatetravel.ai/docs/guides/business-rules.md) and
sets off your [actions](https://equatetravel.ai/docs/guides/actions.md). The difference is how it is driven. A pipeline
works through documents as they arrive and puts what it is unsure of in a queue for a
person. An agent is called by your own code over the
[API](https://equatetravel.ai/docs/api-reference/introduction.md), one document at a time, and answers in the same
request.

Agents and pipelines are separate. A pipeline does not run on an agent, and you do not
need an agent to use pipelines. Use an agent when a program, not a person, should see the
result first. See [agent mode vs workflow mode](https://equatetravel.ai/docs/platform/agent-vs-workflow.md).

> [!NOTE]
>
> An agent never puts work in a queue: your system gets the answer and acts on it. Each
> call is recorded as a **run** under the agent, with a summary of what was sent, the
> answer it gave, which version answered and any actions it set off. An agent set to keep
> [records](#records) also keeps the document in equate, beside everything your pipelines
> process.

## Settings

An agent has every pipeline setting that means something for a single call.

| Setting | What it does |
| - | - |
| **Name and slug** | The slug is a URL-safe id made from the name (`Cruise Invoices` becomes `cruise-invoices`). It addresses the agent over the API and does not change. |
| **Booking data** | The booking data sources the agent matches against. It looks only in these, never in the rest of your booking data. Connect none and the agent only reads. |
| **Suppliers** | Every supplier, or a chosen list. A document from a supplier outside the list is read and answered as [out of scope](#outcomes). |
| **Matching** | Whether its matches take your sector rules, whether they take each supplier's own rules and depth, and the one depth to use when they don't. See [How matching is decided](#how-matching-is-decided). |
| **Documents** | Whether it tells invoices from other documents and runs your [document handlers](https://equatetravel.ai/docs/guides/document-handling.md) on the ones they cover. See [Documents that aren't invoices](#documents-that-arent-invoices). |
| **Actions** | The actions it sets off after it answers, per outcome. See [Actions](#actions). |
| **Records** | Whether each document it answers is kept in equate as a record, and whether its file is kept too. See [Records](#records). |
| **Test mode** | Reads and matches as usual and runs no actions. |
| **Output** | Which extracted fields come back, whether the match comes back, and any fixed fields to add. See [Shaping the response](#shaping-the-response). |
| **Limits** | Optional calls per minute and per day. See [rate limits](https://equatetravel.ai/docs/api-reference/rate-limits.md). |

Some pipeline settings are left out on purpose. They describe how documents arrive or who
works on them, and an agent has neither:

* **Invoice source, triggers and timing.** Your code sends the document, when it wants.
* **Teams.** Nothing lands in a review queue, so there is nobody to route it to.
* **Documents at once.** An agent has per-minute and per-day limits instead.
* **Unknown senders and adding suppliers automatically.** These are about email routing.

The rules that compare a document with ones equate processed earlier do not apply either:
duplicates, re-issues, "already in your system", superseded invoices, guest copy waits and
quality sampling. They hold a document for a person, and an agent has nobody to hold it
for. An agent that keeps [records](#records) tells you instead: the answer says when the
invoice is on record already, and your system decides what a repeat means. A file holding
several documents is read as one document, and agent and client copies are not paired. If
you need any of these, [push the document into a pipeline](https://equatetravel.ai/docs/connectors/rest-api.md) instead.

## How matching is decided

An agent's match runs through the same rules as a pipeline's.

**Where it looks.** Only in the booking data sources connected to the agent. A source that
is switched off is skipped. If none of its sources can be used, nothing matches.

**How deep it compares.** The [depth](https://equatetravel.ai/docs/guides/business-rules.md) is decided in this order:

1. On a plan without matching customisation, every match is held to Tier 1.
2. The agent's own depth, when one is set. Set one when supplier rules are off.
3. The supplier's depth, when the agent takes supplier rules and the document's supplier
   is one of yours.
4. Your workspace's default depth.

**Which rules apply.**

* With **sector rules** on, the tier moves and tolerances you set per sector apply.
* With **supplier rules** on, the supplier's own depth, tier moves and tolerances apply,
  and win over a sector rule on the same field.
* Your [custom fields](https://equatetravel.ai/docs/guides/business-rules.md) are read from the document and take part in
  the match, as on a pipeline. A required custom field that disagrees holds the match for
  review.

The document's supplier is the one of your suppliers whose name the document carries. A
match that agrees on every field in force is `AUTO_MATCHED`. A likely booking with a
disagreement is `NEEDS_REVIEW`. An agent never offers a booking that shares no reference,
name or amount with the document. That is `NO_MATCH`.

## Documents that aren't invoices

With **Documents** on (and [document handling](https://equatetravel.ai/docs/guides/document-handling.md) in your plan),
the agent says what each document is:

* An **invoice** is matched as described above.
* Anything else is named with the same document types a pipeline uses. If you have an
  enabled document handler for that type, the agent takes it. The document's own columns
  are read, the data is narrowed to the fields the type carries, and it is matched **field
  for field**, with no tiers. A field the handler says must match, and that disagrees,
  holds the match for review. A handler set to pass documents on without a booking is
  answered as matched, with no booking.
* A document no handler covers is answered as [not handled](#outcomes). It is read and
  named, not matched.

Two differences from a pipeline:

* A handler limited to specific pipelines does not cover agents. Only a handler set to
  cover every pipeline does.
* A handler's own actions run for documents that arrive through a pipeline. For a document
  an agent takes, the **agent's** actions run. A handler in test mode still puts its
  documents in test mode.

With **Documents** off, every document is read as an invoice.

## Actions

An agent can run the same [actions](https://equatetravel.ai/docs/guides/actions.md) as a pipeline: a webhook, an email, an
export, an FTP upload or a row in a Google Sheet. Pick them from your action library and
say which outcome each runs on.

| The run ends as | Actions that run |
| - | - |
| `AUTO_MATCHED` | Those added under **Auto-matched** |
| `NEEDS_REVIEW` | Those added under **Needs review** |
| `NO_MATCH` | Those added under **No match** |
| `EXTRACTED`, `OUT_OF_SCOPE`, `NOT_HANDLED` | None |

* An action can be limited to [principal or agent bookings](https://equatetravel.ai/docs/guides/actions.md#principal-and-agent).
  It then only runs when the matched booking says so.
* Actions run **after** the agent has answered. A slow or failing destination never delays
  or fails your call. The response lists what was set off under `actions`, and each
  delivery and how it went is listed on the run's page.
* A delivery is tried up to three times, and never sent twice for the same run.
* In **test mode** nothing is run. The response still lists the actions, with the status
  `SKIPPED_TEST_MODE`, so you can see what a live run would do. Runs from the playground
  never run actions, and report them the same way.
* An action set to attach or link the **agent copy** sends the document the call sent,
  when the agent [keeps files](#records). Without a kept file, or for an action that only
  asks for a client copy or an email's other attachments (a run has neither), it is sent
  without a file and the delivery says so.
* In a delivery's payload, `jobId` is the id of the run (the `runId` the API answered
  with).
* An action that runs once per batch (the batch summary email) cannot be added to an
  agent. An action set to run only by hand never runs from an agent.

## Records

With **Keep a record in equate** on, each document the agent answers is kept as a record.
New agents start with it on.

* **Where it shows.** In the Invoice log (status **Agent**), in
  [Reports](https://equatetravel.ai/docs/guides/reports.md) (pick the **Agent** queue, or use the **Agent** and **Agent
  outcome** fields), in Analytics under **Agents**, and in the history of the booking it
  matched. Opening one shows what was read and the match, as for any invoice.
* **It is never work.** A record joins no queue. Nobody is asked to review it, it is not
  routed to a team, and it cannot be flagged, corrected, rematched or closed. Your system
  received the answer and acted on it.
* **It stays out of your pipeline figures.** Auto-match, issue and error rates, the
  dashboard and the daily digest count what your pipelines processed. Agents are reported
  on their own.
* **Bookings count towards your plan.** A booking an agent matches automatically
  (`AUTO_MATCHED`) is counted once, exactly as a pipeline's match is. A booking a pipeline
  or another agent has already matched in the period is not counted again. Runs that end
  any other way, including `NEEDS_REVIEW`, count nothing.
* **The file is kept only if you ask.** **Keep the file too** stores the document with its
  record, where it follows your retention period. With it off, the record holds what was
  read and no file.
* **Not everything is recorded.** Playground tests, test mode and calls that could not
  read the document keep nothing.

With it off, nothing is kept beyond the run and no booking is counted.

> [!NOTE]
>
> Agents published before records existed keep none until you publish them again. Open the
> agent, choose what to keep under **Records**, then publish.

### Seen before

An agent that keeps records adds `seenBefore` to every answer. It is `null` when the
invoice is not on record. When equate already has an invoice with the same supplier and
reference, from an earlier call to an agent that keeps records or from a pipeline that
delivered it, it says so:

```json theme={null}
"seenBefore": {
  "kind": "changed",
  "moneyChanged": true,
  "changedFields": ["commission"],
  "receivedAt": "2026-11-01T09:00:00.000Z",
  "handledBy": "pipeline"
}
```

* `kind` is `duplicate` when every field reads the same, and `changed` when something
  differs.
* `moneyChanged` is true when the total, commission or VAT differs.
* `changedFields` names what differs.
* `handledBy` is `agent` or `pipeline`.

It is a flag, never a hold. The document is still read, matched and answered, and its
actions still run. A document that is not an invoice is never looked up.

## Outcomes

Every run that could read the document answers `200` with an `outcome`:

| Outcome | What happened |
| - | - |
| `AUTO_MATCHED` | Matched to a booking, with every field in force agreeing. |
| `NEEDS_REVIEW` | A likely booking was found, but someone should check it. Your system decides what happens next. |
| `NO_MATCH` | No booking was found. |
| `EXTRACTED` | The agent has no booking data, so the document was only read. |
| `OUT_OF_SCOPE` | The document's supplier is not one the agent takes, or not one of your suppliers. It was read, not matched, and no actions ran. |
| `NOT_HANDLED` | The document is not an invoice and no enabled handler covers its type. It was read and named, not matched. |

## Shaping the response

Every result carries three fields whatever the output settings say:

* **`document`** is what the document is: `type` (`invoice`, a document type's name, or
  `other`) and `isInvoice`. A handled document also carries its type's own columns under
  `fields`.
* **`outcome`** is one of the [outcomes](#outcomes) above.
* **`actions`** lists the actions the outcome set off, each with its `status`.

An agent that keeps [records](#records) also answers with **`seenBefore`**.

The output settings shape the rest:

* **`data`** is the extracted fields, optionally limited to a chosen subset.
* **`match`** is the match: `matched`, `decision`, `confidence`, `bookingReference`,
  `bookingId`, `reason` and a field-by-field comparison. It is included whenever the agent
  has booking data and match output is on. For a document that was not matched, `reason`
  says why.
* **`files`** is the document itself. It is off unless you switch **Document** on, since
  your system usually still holds the file it sent. Return it **in the answer**
  (`contentBase64`) or **as a link** (`url`, which works until `expiresAt`: 15 minutes to
  7 days). A link is to the file the agent keeps, so it needs the agent to
  [keep files](#records); test mode and the playground keep none and return no link. Each
  entry also has `role` (`original`), `fileName`, `contentType` and `sizeBytes`.
* **Fixed values** are constants you add at the top level, such as a `tenant` tag. They
  can never replace one of the fields above.

Document fields and the match result each return every field, or a set you choose: pick
**Choose fields** and tick them in the searchable list.

> [!NOTE]
>
> The full request and response schemas are in the
> [API reference](https://equatetravel.ai/docs/api-reference/agents/run.md).

## How a document is read

An agent reads a document the way a pipeline does, on the same models.

* A **PDF** with a text layer is read from its text, and the supplier is also identified
  from the logos on it, so a supplier that appears only as a logo is still found.
* A **scanned PDF** with no text layer is sent to the model as the file. Logos are not
  read from it, and it cannot be named if it is not an invoice.
* A **password-protected PDF** cannot be read and is refused with a `400`.
* **Text**, sent inline or as a text or CSV file, is read as it is.

## Lifecycle

**1. Create a draft**

Go to **Agents** and choose **New agent**. Name it, connect booking data if it should
match, and set the rest.

**2. Test in the playground**

Paste text or upload a file and run it against the draft. The result shows the
document, the outcome and the actions a live run would set off. Nothing is sent.

**3. Publish**

Publishing saves the settings as a **version** that never changes. Only a published
version answers API calls, and its number comes back in every response.

**4. Change it safely**

Keep editing the draft and publish again for a new version. Every run records the
version that answered it, and you can put an earlier version back into production
from the agent's version history.

A version fixes every setting above, including which actions are linked and which
suppliers it takes. The actions themselves live in your action library, so changing where
a webhook posts takes effect straight away for every agent and pipeline that uses it.

> [!NOTE]
>
> Agents created before they had these settings keep working as they did: sector rules
> on, supplier rules off, the one depth they were given, every supplier, every document
> read as an invoice, and no actions. Change the settings and publish to move one on.

## Calling an agent

| How | Use for |
| - | - |
| **Playground** | Testing while you build. Runs the draft, never runs actions. |
| **`/run`** | One document from your code. See [Run an agent](https://equatetravel.ai/docs/api-reference/agents/run.md). |
| **`/batch`** | Up to 100 documents in one call, each its own run. See [Run a batch](https://equatetravel.ai/docs/api-reference/agents/batch.md). |

Every API call needs a [workspace API key](https://equatetravel.ai/docs/api-reference/authentication.md). Past runs, with
what was sent, what was answered and any deliveries, are listed under the agent.

> [card] [Try it with the API quickstart](https://equatetravel.ai/docs/api-reference/quickstart.md)
>
> Build an agent and make your first API call end to end.


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