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

# Run agent (single-shot)

> Execute the agent with one or more messages. By default a session is created and persisted. Pass `persist=false` for an ephemeral run that leaves no persisted session.



## OpenAPI

````yaml /agent/api/openapi.json post /v1/agents/{agent_id}/run
openapi: 3.1.0
info:
  title: Quintus Agent API
  description: >-
    Quintus Agent API - server-to-server integration for running AI agents from

    your backend (CRMs, automation platforms, internal tools).


    **Authentication.** Single scheme: **API Key** (`X-API-Key` header), with
    the

    `agent:run` scope. Keys may be restricted to specific agents via

    `api_key.resources["agents"]`.


    **Concepts.**

    - A **session** is a stateful conversation bound to one agent (and
    optionally one user).

    - A **user** is a tenant-scoped end-user (e.g. your customer) referenced by
    sessions.

    - A **file** is a tenant-pool resource, reusable across sessions and
    messages.

    - A **run** is a one-shot interaction (creates a session, sends messages,
    returns reply).


    **Streaming.** Use `POST /sessions/{id}/messages/stream` for SSE responses;

    the sync `POST /sessions/{id}/messages` returns a JSON message exchange.


    **Rate limiting.** Per-API-key. Exceeded -> `429` with `Retry-After`.


    **Errors.** All non-2xx responses use the standard `ErrorEnvelope` shape
    with a

    stable `error.code` for programmatic handling.
  contact:
    name: Quintus Support
    email: support@quintus.tec.br
  license:
    name: Proprietary - Quintus
    url: https://quintus.tec.br/
  version: 1.0.0
servers:
  - url: https://api.quintus.tec.br
security: []
tags:
  - name: Users
    description: End-user CRUD.
  - name: Sessions
    description: Stateful agent sessions.
  - name: Messages
    description: Messages within a session (sync + streaming).
  - name: Files
    description: Tenant-pool file management.
  - name: Runs
    description: One-shot agent runs.
paths:
  /v1/agents/{agent_id}/run:
    post:
      tags:
        - Runs
      summary: Run agent (single-shot)
      description: >-
        Execute the agent with one or more messages. By default a session is
        created and persisted. Pass `persist=false` for an ephemeral run that
        leaves no persisted session.
      operationId: runAgent
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunResponse'
        '401':
          description: Authentication missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded - see Retry-After header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - ApiKey: []
components:
  schemas:
    RunRequest:
      properties:
        messages:
          items:
            $ref: '#/components/schemas/MessageCreateRequest'
          type: array
          maxItems: 10
          minItems: 1
          title: Messages
        user:
          anyOf:
            - $ref: '#/components/schemas/SessionUser'
            - type: 'null'
        context:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Context
          description: >-
            Free-form key/value pairs injected into the agent's system context
            for this run.
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Integrator-defined storage. Not seen by the agent.
        persist:
          type: boolean
          title: Persist
          description: >-
            If true, a session is created and persisted. If false, the run is
            intended to be ephemeral (current implementation still persists;
            this will change in a future release).
          default: true
      type: object
      required:
        - messages
      title: RunRequest
    RunResponse:
      properties:
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
        agent_message:
          $ref: '#/components/schemas/Message'
      type: object
      required:
        - agent_message
      title: RunResponse
    ErrorEnvelope:
      example:
        error:
          code: session_token_expired
          context: {}
          message: Session token has expired. Refresh to continue.
          name: SessionTokenExpiredError
        request_id: 5f0c-...
        timestamp: '2026-04-27T12:00:00Z'
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Request ID for support correlation.
          title: Request Id
        timestamp:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: ISO-8601 server timestamp when the error occurred.
          title: Timestamp
      required:
        - error
      title: ErrorEnvelope
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MessageCreateRequest:
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
          default: user
        content:
          anyOf:
            - type: string
            - items:
                oneOf:
                  - $ref: '#/components/schemas/TextBlock'
                  - $ref: '#/components/schemas/ImageBlock'
                  - $ref: '#/components/schemas/FileBlock'
                discriminator:
                  propertyName: type
                  mapping:
                    file:
                      $ref: '#/components/schemas/FileBlock'
                    image:
                      $ref: '#/components/schemas/ImageBlock'
                    text:
                      $ref: '#/components/schemas/TextBlock'
              type: array
          title: Content
          description: >-
            Either a plain string (treated as a single text block) or a list of
            typed content blocks (text/image/file).
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: >-
            Free-form integrator storage attached to this message. Not seen by
            the agent.
      type: object
      required:
        - content
      title: MessageCreateRequest
    SessionUser:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        reference:
          anyOf:
            - type: string
            - type: 'null'
          title: Reference
      type: object
      title: SessionUser
      description: |-
        Reference to a user when creating a session. Lookup-only.
        Use POST /users to create users.
    Message:
      properties:
        id:
          type: string
          title: Id
        role:
          type: string
          enum:
            - user
            - assistant
          title: Role
        content:
          items:
            oneOf:
              - $ref: '#/components/schemas/TextBlock'
              - $ref: '#/components/schemas/ImageBlock'
              - $ref: '#/components/schemas/FileBlock'
            discriminator:
              propertyName: type
              mapping:
                file:
                  $ref: '#/components/schemas/FileBlock'
                image:
                  $ref: '#/components/schemas/ImageBlock'
                text:
                  $ref: '#/components/schemas/TextBlock'
          type: array
          title: Content
        created_at:
          type: string
          format: date-time
          title: Created At
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
      type: object
      required:
        - id
        - role
        - content
        - created_at
      title: Message
    ErrorBody:
      properties:
        code:
          type: string
          title: Code
          description: Stable machine-readable error code (snake_case).
        name:
          type: string
          title: Name
          description: Error class name (PascalCase).
        message:
          type: string
          title: Message
          description: Human-readable explanation.
        context:
          additionalProperties: true
          type: object
          title: Context
          description: Error-specific structured context (ids, limits, hints).
      type: object
      required:
        - code
        - name
        - message
      title: ErrorBody
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TextBlock:
      properties:
        type:
          type: string
          const: text
          title: Type
          default: text
        text:
          type: string
          minLength: 1
          title: Text
          description: UTF-8 text content.
      type: object
      required:
        - text
      title: TextBlock
      example:
        text: Hello agent
        type: text
    ImageBlock:
      properties:
        type:
          type: string
          const: image
          title: Type
          default: image
        file_id:
          type: string
          title: File Id
          description: ID returned by POST /files.
      type: object
      required:
        - file_id
      title: ImageBlock
      example:
        file_id: f_abc123
        type: image
    FileBlock:
      properties:
        type:
          type: string
          const: file
          title: Type
          default: file
        file_id:
          type: string
          title: File Id
          description: ID returned by POST /files.
      type: object
      required:
        - file_id
      title: FileBlock
      example:
        file_id: f_abc123
        type: file
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key

````