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

# Create agent

> Create an AI agent for a sender. Each sender can have at most one agent.



## OpenAPI

````yaml /openapi.json post /v1/senders/{senderId}/agent
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)
servers:
  - url: https://api.zavu.dev
security:
  - bearerAuth: []
paths:
  /v1/senders/{senderId}/agent:
    post:
      tags:
        - Agents
      summary: Create agent
      description: Create an AI agent for a sender. Each sender can have at most one agent.
      operationId: createAgent
      parameters:
        - $ref: '#/components/parameters/SenderIdParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentCreateRequest'
            example:
              name: Customer Support
              provider: openai
              model: gpt-4o-mini
              systemPrompt: >-
                You are a helpful customer support agent. Be friendly and
                concise.
              apiKey: sk-...
      responses:
        '201':
          description: Agent created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentResponse'
        '400':
          description: Invalid request or agent already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Sender not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  parameters:
    SenderIdParam:
      name: senderId
      in: path
      required: true
      schema:
        type: string
  schemas:
    AgentCreateRequest:
      type: object
      required:
        - name
        - provider
        - model
        - systemPrompt
      properties:
        name:
          type: string
          maxLength: 100
        provider:
          $ref: '#/components/schemas/AgentProvider'
        model:
          type: string
        systemPrompt:
          type: string
          maxLength: 10000
        apiKey:
          type: string
          description: API key for the LLM provider. Required unless provider is 'zavu'.
        contextWindowMessages:
          type: integer
          minimum: 1
          maximum: 50
          default: 10
        includeContactMetadata:
          type: boolean
          default: true
        maxTokens:
          type: integer
          minimum: 1
          maximum: 4096
        temperature:
          type: number
          minimum: 0
          maximum: 2
        triggerOnChannels:
          type: array
          items:
            type: string
          default:
            - '*'
        triggerOnMessageTypes:
          type: array
          items:
            type: string
          default:
            - text
    AgentResponse:
      type: object
      required:
        - agent
      properties:
        agent:
          $ref: '#/components/schemas/Agent'
    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
    AgentProvider:
      type: string
      description: LLM provider for the AI agent.
      enum:
        - openai
        - anthropic
        - google
        - mistral
        - zavu
    Agent:
      type: object
      description: AI Agent configuration for a sender.
      required:
        - id
        - senderId
        - name
        - enabled
        - provider
        - model
        - systemPrompt
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          example: agent_abc123
        senderId:
          type: string
          example: sender_12345
        name:
          type: string
          example: Customer Support Agent
        enabled:
          type: boolean
          description: Whether the agent is active.
        provider:
          $ref: '#/components/schemas/AgentProvider'
        model:
          type: string
          description: Model ID (e.g., gpt-4o-mini, claude-3-5-sonnet).
          example: gpt-4o-mini
        systemPrompt:
          type: string
          description: System prompt for the agent.
        contextWindowMessages:
          type: integer
          description: Number of previous messages to include as context.
          default: 10
        includeContactMetadata:
          type: boolean
          description: Whether to include contact metadata in context.
          default: true
        maxTokens:
          type: integer
          description: Maximum tokens for LLM response.
          nullable: true
        temperature:
          type: number
          description: LLM temperature (0-2).
          nullable: true
        triggerOnChannels:
          type: array
          items:
            type: string
          description: Channels that trigger the agent.
          example:
            - sms
            - whatsapp
        triggerOnMessageTypes:
          type: array
          items:
            type: string
          description: Message types that trigger the agent.
          example:
            - text
        stats:
          type: object
          properties:
            totalInvocations:
              type: integer
            totalTokensUsed:
              type: integer
            totalCost:
              type: number
              description: Total cost in USD.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````