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

# Run an agent

> Invoke a published agent against a single document.



## OpenAPI

````yaml openapi.json POST /api/v1/agents/{slug}/run
openapi: 3.1.0
info:
  title: equate API
  version: 1.0.0
  description: >-
    The public equate Agent API. Send a supplier invoice (as text, a
    base64-encoded file, or a URL) to a published agent and receive structured,
    travel-aware extraction — optionally matched against your booking data.
    Authenticated with a workspace API key.
  contact:
    name: equate support
    email: support@equatetravel.ai
servers:
  - url: https://equatetravel.ai
    description: >-
      Production. Replace with your equate workspace domain if you use a custom
      one.
  - url: http://localhost:3000
    description: Local development
security:
  - apiKey: []
tags:
  - name: Agents
    description: >-
      Invoke a published agent to read a document, say what it is, match it to a
      booking and set off its actions.
  - name: Invoices
    description: >-
      Push invoice documents into the workspace's pipelines, and fetch the
      documents held for an invoice.
paths:
  /api/v1/agents/{slug}/run:
    post:
      tags:
        - Agents
      summary: Run an agent
      description: >-
        Invoke a published agent against a single document. Provide the document
        exactly one of three ways: inline `content`, a base64-encoded
        `fileBase64`, or a `fileUrl` the server fetches. The agent reads the
        document, says what it is, matches it against its booking data under the
        workspace's business rules and answers in this response. The result
        always carries `document`, `outcome` and `actions`; `data` and `match`
        are shaped by the agent's published output config. Any actions the
        outcome sets off are queued and run after the response is sent, so a
        slow or failing destination never delays or fails the call.
      operationId: runAgent
      parameters:
        - name: slug
          in: path
          required: true
          description: The agent's URL-safe slug, e.g. `cruise-invoices`.
          schema:
            type: string
            pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
            example: cruise-invoices
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunRequest'
            examples:
              text:
                summary: Inline text
                value:
                  content: |-
                    INVOICE
                    Supplier: Oceania Cruises
                    Ref: OC-44821
                    Total: GBP 4,250.00
                  reference: order-9921
              url:
                summary: File URL
                value:
                  fileUrl: https://example.com/invoices/OC-44821.pdf
                  reference: order-9921
              base64:
                summary: Base64 file
                value:
                  fileBase64: JVBERi0xLjQKJ...
                  fileType: application/pdf
                  fileName: OC-44821.pdf
      responses:
        '200':
          description: >-
            The agent ran successfully. Read `result.outcome` for how the run
            ended: a run that found no booking, or did not try to match, is
            still a 200.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunResponse'
              examples:
                matched:
                  summary: An invoice matched to a booking
                  value:
                    data:
                      runId: 6f0f6c0e-7d5e-4a35-9a55-2f1f6c1f0a11
                      agent: cruise-invoices
                      version: 4
                      result:
                        reference: order-9921
                        document:
                          type: invoice
                          isInvoice: true
                        outcome: AUTO_MATCHED
                        actions:
                          - actionId: 0b6a4f6e-2f0b-4c1e-9a0c-6b9d2a7f3c21
                            name: Post to finance
                            type: WEBHOOK
                            status: QUEUED
                        data:
                          supplier: Oceania Cruises
                          reference: OC-44821
                          totalCost: '4250.00'
                        match:
                          matched: true
                          decision: auto
                          confidence: 0.97
                          bookingReference: OC-44821
                          bookingId: BK-10293
                          reason: Reference, supplier and total agree
                          fields: []
                outOfScope:
                  summary: A supplier the agent does not take
                  value:
                    data:
                      runId: c1a5d0b2-3e4f-4b6a-8c7d-9e0f1a2b3c4d
                      agent: cruise-invoices
                      version: 4
                      result:
                        document:
                          type: invoice
                          isInvoice: true
                        outcome: OUT_OF_SCOPE
                        actions: []
                        data:
                          supplier: Alpine Trails
                          reference: AT-2207
                          totalCost: '980.00'
                        match:
                          matched: false
                          decision: none
                          confidence: 0
                          bookingReference: null
                          bookingId: null
                          reason: >-
                            This document's supplier is not one this agent
                            takes, so it was not matched.
                          fields: []
                notHandled:
                  summary: >-
                    A document that is not an invoice, with no handler for its
                    type
                  value:
                    data:
                      runId: 9d8c7b6a-5f4e-4d3c-8b2a-1f0e9d8c7b6a
                      agent: cruise-invoices
                      version: 4
                      result:
                        document:
                          type: ATOL Certificate
                          isInvoice: false
                        outcome: NOT_HANDLED
                        actions: []
                        data:
                          supplier: Oceania Cruises
                          reference: OC-44821
                        match:
                          matched: false
                          decision: none
                          confidence: 0
                          bookingReference: null
                          bookingId: null
                          reason: >-
                            This document is not an invoice and no document
                            handler covers its type, so it was not matched.
                          fields: []
        '400':
          description: >-
            The request body failed validation (e.g. none of `content`,
            `fileBase64` or `fileUrl` was supplied).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: Missing, malformed, unknown or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '402':
          description: The workspace has no active subscription (`SUBSCRIPTION_REQUIRED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: >-
            The plan does not include the Agent Builder, or the agent is
            disabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: No agent with that slug exists in the workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          description: The agent exists but has not been published yet (`NOT_PUBLISHED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '413':
          description: The base64 file exceeds the per-call size limit (~10.5 MB decoded).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: >-
            The agent's per-minute or per-day throttle was exceeded. A
            `Retry-After` header gives the cool-off in seconds.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '500':
          description: >-
            The run failed unexpectedly. The response still carries the `runId`
            for support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    RunRequest:
      type: object
      description: >-
        A single agent invocation. Supply the document via exactly one of
        `content`, `fileBase64` or `fileUrl`.
      anyOf:
        - required:
            - content
        - required:
            - fileBase64
        - required:
            - fileUrl
      properties:
        content:
          type: string
          maxLength: 200000
          description: Inline document text to extract from.
        fileBase64:
          type: string
          description: >-
            A base64-encoded file (PDF, CSV or plain text). Decoded size must
            stay under ~10.5 MB.
        fileUrl:
          type: string
          format: uri
          maxLength: 2048
          description: >-
            A publicly reachable http(s) URL the server fetches the document
            from.
        fileName:
          type: string
          maxLength: 500
          description: Optional original filename, used as a hint.
        fileType:
          type: string
          maxLength: 120
          description: Optional MIME type for `fileBase64`, e.g. `application/pdf`.
        reference:
          type: string
          maxLength: 200
          description: Your own correlation id, echoed back unchanged in the result.
        modelTier:
          type: string
          enum:
            - smart
            - fast
          description: >-
            Which built-in model preset reads the document: `smart` favours
            accuracy, `fast` favours latency. An agent stores no tier of its
            own, so omitting this means `smart`. It only applies while no
            extraction models have been set up for the platform; once they have,
            they always run and this is ignored.
    RunResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            runId:
              type:
                - string
                - 'null'
              description: Id of the recorded run, for auditing and support.
            agent:
              type: string
              description: The agent slug that handled the request.
            version:
              type: integer
              description: The published agent version that ran.
            result:
              $ref: '#/components/schemas/RunResult'
    ApiError:
      type: object
      description: Every error response uses this envelope.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - UNAUTHORIZED
                - VALIDATION_ERROR
                - SUBSCRIPTION_REQUIRED
                - FEATURE_NOT_AVAILABLE
                - NOT_FOUND
                - AGENT_DISABLED
                - NOT_PUBLISHED
                - PAYLOAD_TOO_LARGE
                - UNSUPPORTED_MEDIA_TYPE
                - FETCH_FAILED
                - INGEST_FAILED
                - RATE_LIMITED
                - RUN_FAILED
                - INTERNAL_ERROR
              description: A stable, machine-readable error code.
            message:
              type: string
              description: A human-readable explanation.
            details:
              type: object
              additionalProperties: true
              description: >-
                Present for `VALIDATION_ERROR`: a flattened list of field
                issues.
          required:
            - code
            - message
        runId:
          type:
            - string
            - 'null'
          description: 'Present on `RUN_FAILED`: the id of the recorded (failed) run.'
    RunResult:
      type: object
      description: >-
        What the agent answers. `document`, `outcome` and `actions` are always
        present. `seenBefore` is present on every answer from an agent that
        keeps records. `data` and `match` are shaped by the agent's published
        output config and are each included only when the agent is configured to
        return them. Operator-defined static fields are merged at the top level
        and can never replace one of the named keys.
      additionalProperties: true
      required:
        - document
        - outcome
        - actions
      properties:
        reference:
          type: string
          description: Echoed back from the request when supplied.
        document:
          $ref: '#/components/schemas/RunDocument'
        outcome:
          type: string
          enum:
            - AUTO_MATCHED
            - NEEDS_REVIEW
            - NO_MATCH
            - EXTRACTED
            - OUT_OF_SCOPE
            - NOT_HANDLED
          description: >-
            How the run ended. `AUTO_MATCHED`: matched to a booking with every
            field in force agreeing. `NEEDS_REVIEW`: a likely booking was found
            but someone should check it. `NO_MATCH`: no booking was found.
            `EXTRACTED`: the agent has no booking data connected, so the
            document was only read. `OUT_OF_SCOPE`: the document's supplier is
            not one the agent takes, so it was read and not matched.
            `NOT_HANDLED`: the document is not an invoice and no enabled
            document handler covers its type, so it was read and not matched.
        actions:
          type: array
          description: >-
            The agent's actions this outcome set off, in running order. Empty
            when the outcome has none. `AUTO_MATCHED` and `NEEDS_REVIEW` set off
            the actions added under their own name, `NO_MATCH` sets off the
            actions added under No match, and the other outcomes set off none.
          items:
            $ref: '#/components/schemas/RunAction'
        seenBefore:
          description: >-
            Only from an agent set to keep records. `null` when the invoice is
            not on record. Otherwise 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. A flag, never a hold:
            the document is still read, matched and answered.
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/RunSeenBefore'
        data:
          $ref: '#/components/schemas/ExtractedInvoiceData'
          description: >-
            The extracted invoice fields. Filtered to the agent's selected
            fields when configured.
        match:
          $ref: '#/components/schemas/MatchResult'
          description: >-
            The booking match outcome. Present whenever the agent has booking
            data connected and match output is enabled, including when the
            document was not matched (`OUT_OF_SCOPE`, `NOT_HANDLED`): `reason`
            then says why.
        files:
          type: array
          description: >-
            The document itself. Present only when the agent's response is set
            to return the document, which is off by default. Returned inline, or
            as a link when the agent keeps files and the call is recorded (not
            in test mode).
          items:
            $ref: '#/components/schemas/RunFile'
    RunDocument:
      type: object
      description: >-
        What the document is. With document handling switched off on the agent,
        or not included in the plan, every document is read as an invoice.
      required:
        - type
        - isInvoice
      properties:
        type:
          type: string
          description: >-
            `invoice`, the name of a document type (for example `Flight
            Update`), or `other` for a document that is not an invoice and could
            not be named.
          example: invoice
        isInvoice:
          type: boolean
        fields:
          type: object
          additionalProperties: true
          description: >-
            The document type's own columns, keyed by column, for example an
            ATOL certificate's number. Present only on a document a handler took
            whose type has columns.
    RunAction:
      type: object
      description: One action the run's outcome set off.
      required:
        - actionId
        - name
        - type
        - status
      properties:
        actionId:
          type: string
          format: uuid
        name:
          type: string
          description: The action's name, or its type when it has none.
        type:
          type: string
          enum:
            - EXPORT_JSON
            - EXPORT_XML
            - WEBHOOK
            - EMAIL
            - FTP_UPLOAD
            - GOOGLE_SHEETS_APPEND
        status:
          type: string
          enum:
            - QUEUED
            - SKIPPED_TEST_MODE
          description: >-
            `QUEUED`: handed over for delivery, which happens after this
            response. `SKIPPED_TEST_MODE`: the agent, or the document handler
            that took the document, is in test mode, so it was not run.
    RunSeenBefore:
      type: object
      description: >-
        The invoice on record for the same supplier and reference, compared with
        this one.
      required:
        - kind
        - moneyChanged
        - changedFields
        - receivedAt
        - handledBy
      properties:
        kind:
          type: string
          enum:
            - duplicate
            - changed
          description: >-
            `duplicate`: every field reads the same. `changed`: something
            differs.
        moneyChanged:
          type: boolean
          description: The total, commission or VAT differs from the earlier invoice.
        changedFields:
          type: array
          items:
            type: string
          description: The fields that differ. Empty for a duplicate.
          example:
            - commission
        receivedAt:
          type: string
          format: date-time
          description: When the earlier invoice arrived.
        handledBy:
          type: string
          enum:
            - agent
            - pipeline
          description: >-
            Whether an agent answered the earlier invoice or a pipeline
            processed it.
    ExtractedInvoiceData:
      type: object
      description: >-
        Travel-aware extraction. Every scalar field is a string or null;
        passenger and flight lists are arrays. Which fields are populated
        depends on the trip type (cruise, ski, flights, trains, hotel, package,
        …).
      additionalProperties: true
      properties:
        supplier:
          type:
            - string
            - 'null'
        reference:
          type:
            - string
            - 'null'
        invoiceDate:
          type:
            - string
            - 'null'
        invoiceCurrency:
          type:
            - string
            - 'null'
        totalCost:
          type:
            - string
            - 'null'
        vat:
          type:
            - string
            - 'null'
        resortTax:
          type:
            - string
            - 'null'
        commission:
          type:
            - string
            - 'null'
        onboardSpendingPerPerson:
          type:
            - string
            - 'null'
        drinksPackageCostPerPerson:
          type:
            - string
            - 'null'
        shipName:
          type:
            - string
            - 'null'
        tourName:
          type:
            - string
            - 'null'
        cruiseEmbarkation:
          type:
            - string
            - 'null'
        cruiseDisembarkation:
          type:
            - string
            - 'null'
        cruiseDuration:
          type:
            - string
            - 'null'
        cabinName:
          type:
            - string
            - 'null'
        cabinNumber:
          type:
            - string
            - 'null'
        cabinCategory:
          type:
            - string
            - 'null'
        bedType:
          type:
            - string
            - 'null'
        boardBasis:
          type:
            - string
            - 'null'
        diningRequest:
          type:
            - string
            - 'null'
        passengers:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Passenger'
        numberOfPassengers:
          type:
            - string
            - 'null'
        leadName:
          type:
            - string
            - 'null'
        flights:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Flight'
        trains:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Train'
        transfers:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Transfer'
        holidayStartDate:
          type:
            - string
            - 'null'
        holidayEndDate:
          type:
            - string
            - 'null'
        holidayDuration:
          type:
            - string
            - 'null'
        includesCarHire:
          type:
            - boolean
            - 'null'
        includesCarParking:
          type:
            - boolean
            - 'null'
        resort:
          type:
            - string
            - 'null'
        accommodation:
          type:
            - string
            - 'null'
        includesTransfer:
          type:
            - boolean
            - 'null'
        eventPackages:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/EventPackage'
        skiArea:
          type:
            - string
            - 'null'
        skiExtras:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/SkiExtra'
        skiCarriages:
          type:
            - integer
            - 'null'
    MatchResult:
      type: object
      description: >-
        The outcome of matching the document against the agent's own booking
        data sources. The agent looks only in the sources connected to it.
      properties:
        matched:
          type: boolean
        decision:
          type: string
          enum:
            - auto
            - review
            - none
          description: >-
            `auto` = confident auto-match, `review` = suggested match needs a
            human, `none` = no match.
        confidence:
          type:
            - number
            - 'null'
          description: Match confidence between 0 and 1.
        bookingReference:
          type:
            - string
            - 'null'
        bookingId:
          type:
            - string
            - 'null'
          description: >-
            The matched booking's own ID (its `bookingId` in your booking data),
            or null when there is no match or the booking data doesn't carry
            one.
        reason:
          type:
            - string
            - 'null'
        fields:
          type: array
          description: >-
            Field-by-field comparison between the invoice and the matched
            booking. Each entry has `field` (the public field name, e.g.
            `totalCost`), `tier`, `status` (`match`, `mismatch` or `missing`),
            `invoice`, `booking`, `normalisedInvoice`, `normalisedBooking` and
            `note`.
          items:
            type: object
            additionalProperties: true
    RunFile:
      type: object
      description: >-
        A file returned with the result, either as a time-limited link (`url`
        and `expiresAt`) or inline (`contentBase64`), by the agent's setting.
      required:
        - role
        - fileName
        - contentType
        - sizeBytes
      properties:
        role:
          type: string
          enum:
            - original
          description: '`original`: the document the call sent.'
        fileName:
          type: string
          example: invoice.pdf
        contentType:
          type: string
          example: application/pdf
        sizeBytes:
          type: integer
          example: 48213
        url:
          type: string
          format: uri
          description: >-
            A link the file can be downloaded from, with no further
            authentication, until `expiresAt`.
        expiresAt:
          type: string
          format: date-time
          description: When `url` stops working.
        contentBase64:
          type: string
          description: The file's bytes, base64 encoded.
    Passenger:
      type: object
      properties:
        title:
          type:
            - string
            - 'null'
        firstName:
          type:
            - string
            - 'null'
        middleName:
          type:
            - string
            - 'null'
        lastName:
          type:
            - string
            - 'null'
        fullName:
          type:
            - string
            - 'null'
    Flight:
      type: object
      properties:
        flightNumber:
          type:
            - string
            - 'null'
        outboundAirport:
          type:
            - string
            - 'null'
        outboundDepartureDateTime:
          type:
            - string
            - 'null'
        inboundAirport:
          type:
            - string
            - 'null'
        inboundArrivalDateTime:
          type:
            - string
            - 'null'
    Train:
      type: object
      properties:
        departureStation:
          type:
            - string
            - 'null'
        departureTime:
          type:
            - string
            - 'null'
        arrivalStation:
          type:
            - string
            - 'null'
        arrivalTime:
          type:
            - string
            - 'null'
        ticketType:
          type:
            - string
            - 'null'
    Transfer:
      type: object
      properties:
        transferFrom:
          type:
            - string
            - 'null'
        transferTo:
          type:
            - string
            - 'null'
        transferType:
          type:
            - string
            - 'null'
        vehicleType:
          type:
            - string
            - 'null'
        numberOfPassengers:
          type:
            - number
            - 'null'
    EventPackage:
      type: object
      properties:
        hotelName:
          type:
            - string
            - 'null'
        roomType:
          type:
            - string
            - 'null'
        mealDetail:
          type:
            - string
            - 'null'
        arrivalDate:
          type:
            - string
            - 'null'
        departureDate:
          type:
            - string
            - 'null'
        nights:
          type:
            - number
            - 'null'
        noOfGuestsAdults:
          type:
            - number
            - 'null'
        noOfGuestsChildren:
          type:
            - number
            - 'null'
        ticketDescription:
          type:
            - string
            - 'null'
        durationDays:
          type:
            - number
            - 'null'
        validFor:
          type:
            - string
            - 'null'
        carParkingIncluded:
          type:
            - boolean
            - 'null'
        pricing:
          type:
            - number
            - 'null'
        currency:
          type:
            - string
            - 'null'
    SkiExtra:
      type: object
      properties:
        item:
          type:
            - string
            - 'null'
        quantity:
          type:
            - number
            - 'null'
        price:
          type:
            - number
            - 'null'
        name:
          type:
            - string
            - 'null'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        A workspace API key, sent as `Authorization: Bearer ip_live_…`. Create
        and revoke keys in the equate dashboard under Settings → API keys
        (workspace admins only). The full key is shown once at creation — store
        it securely.

````

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