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

# Test an agent

> Run the agent's prompt, model and knowledge base against a message and return the reply instead of delivering it. Writes nothing and charges nothing, so it is safe to call repeatedly while iterating on a prompt.

Note that this exercises the **text** path, which does not offer tools to the model. When the agent has enabled tools, that is reported in `warnings` rather than silently producing an answer that looks like a tool call happened.



## OpenAPI

````yaml /openapi.json post /v1/agents/{agentId}/test
openapi: 3.0.3
info:
  title: Zavu Unified Messaging Layer API
  version: 0.2.0
  description: >
    Unified multi-channel messaging API for Zavu.


    Supported channels:

    - **SMS**: Simple text messages

    - **WhatsApp**: Rich messaging with media, buttons, lists, CTA URL buttons,
    and templates

    - **Telegram**: Bot messaging with text, media, and interactive elements

    - **Email**: Transactional emails via Amazon SES


    Design goals:

    - Simple `send()` entrypoint for developers

    - Project-level authentication via Bearer token

    - Support for all WhatsApp message types (text, image, video, audio,
    document, sticker, location, contact, buttons, list, cta_url, reaction,
    template)

    - If a non-text message type is sent, WhatsApp channel is used automatically

    - 24-hour WhatsApp conversation window enforcement

    - Universal `to` field accepts phone numbers (E.164), email addresses, or
    numeric chat IDs (Telegram/Instagram/Messenger)
servers:
  - url: https://api.zavu.dev
security:
  - bearerAuth: []
paths:
  /v1/agents/{agentId}/test:
    post:
      tags:
        - Agents
      summary: Test an agent
      description: >-
        Run the agent's prompt, model and knowledge base against a message and
        return the reply instead of delivering it. Writes nothing and charges
        nothing, so it is safe to call repeatedly while iterating on a prompt.


        Note that this exercises the **text** path, which does not offer tools
        to the model. When the agent has enabled tools, that is reported in
        `warnings` rather than silently producing an answer that looks like a
        tool call happened.
      operationId: testAgent
      parameters:
        - $ref: '#/components/parameters/AgentIdParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentTestRequest'
      responses:
        '200':
          description: The agent's reply.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentTestResponse'
        '400':
          description: message is required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Sender or agent not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    AgentIdParam:
      name: agentId
      in: path
      required: true
      description: Agent ID.
      schema:
        type: string
  schemas:
    AgentTestRequest:
      type: object
      description: >-
        Run the agent and return what it would say. Nothing is delivered to
        anyone, no execution is recorded, and nothing is charged.
      required:
        - message
      properties:
        message:
          type: string
          description: What to say to the agent.
          example: Where is order ORD-12345?
        history:
          type: array
          description: >-
            Prior turns, oldest first, to exercise multi-turn behaviour without
            persisting a thread. Trimmed to the agent's context window.
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
              content:
                type: string
        useKnowledgeBase:
          type: boolean
          default: true
          description: >-
            Set false to skip retrieval and isolate prompt behaviour from the
            knowledge base.
    AgentTestResponse:
      type: object
      required:
        - success
        - text
        - error
        - inputTokens
        - outputTokens
        - latencyMs
        - knowledgeChunksUsed
        - warnings
      properties:
        success:
          type: boolean
        text:
          type: string
          nullable: true
          description: What the agent would reply.
        error:
          type: string
          nullable: true
        inputTokens:
          type: integer
        outputTokens:
          type: integer
        latencyMs:
          type: integer
        knowledgeChunksUsed:
          type: integer
          description: >-
            Knowledge-base chunks retrieved for this message. Zero means the
            answer was not grounded in your documents.
        warnings:
          type: array
          items:
            type: string
          description: >-
            Things that are true of this agent but that a dry run cannot prove:
            the agent being disabled, enabled tools that its channels will never
            call (the text path does not offer tools to the model), and contact
            metadata that exists on a real conversation but not here. Surfaced
            so a passing dry run is never mistaken for proof that the agent
            works live.
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: invalid_request
        message:
          type: string
          example: Phone number is invalid
        details:
          type: object
          additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````