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

# Delete agent

> Permanently deletes an agent you have edit permission on. Fails with 409 if any campaign still references the agent (in its voice or WhatsApp slot); remove it from those campaigns first. Scope `sessions:write`.



## OpenAPI

````yaml /api-reference/openapi.json delete /agent/{agent_id}
openapi: 3.1.0
info:
  title: Lehar API
  version: v0
  description: >-
    Customer-facing REST API for the Lehar voice-AI platform. Platform-admin
    endpoints are intentionally excluded from this reference. Regenerate with
    `npm run sync:openapi`.
servers:
  - url: https://api.lehar.ai/ca/api/v0
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /agent/{agent_id}:
    delete:
      tags:
        - Agents
      summary: Delete agent
      description: >-
        Permanently deletes an agent you have edit permission on. Fails with 409
        if any campaign still references the agent (in its voice or WhatsApp
        slot); remove it from those campaigns first. Scope `sessions:write`.
      operationId: delete_agent_ca_api_v0_agent__agent_id__delete
      parameters:
        - name: agent_id
          in: path
          required: true
          description: Identifier of the agent to delete.
          schema:
            type: string
      responses:
        '200':
          description: Agent deleted.
          content:
            application/json:
              example:
                deleted: true
                id: agent_7f3a1c9e
        '401':
          description: Authentication is missing or invalid.
          content:
            application/json:
              example:
                error:
                  code: unauthorized
                  message: Authentication required
        '403':
          description: >-
            The caller lacks the required scope or is not allowed to delete this
            agent.
          content:
            application/json:
              example:
                error:
                  code: forbidden
                  message: You cannot delete this agent
        '404':
          description: No agent with this id is visible to the caller.
          content:
            application/json:
              example:
                error:
                  code: not_found
                  message: Agent 'agent_7f3a1c9e' not found
        '409':
          description: The agent is still referenced by one or more campaigns.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: >-
                    Agent is used by 2 campaign(s) and cannot be deleted. Remove
                    it from those campaigns first.
        '500':
          description: Unexpected server error.
          content:
            application/json:
              example:
                error:
                  code: internal_error
                  message: An unexpected error occurred
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    BearerAuth:
      type: http
      scheme: bearer

````