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

# Delete Agent

> Delete an agent by ID from your workspace.

Destructive
Deletes an agent and all of its versions from your workspace. The agent disappears from [List Agents](https://dialnexa.com/docs/api-reference/v1/agents/list.md) and can no longer be assigned to phone numbers or used for new calls. Historical call logs that reference it remain available.

## When to use this

* **Cleanup**: remove test or superseded agents so pickers and audits only show agents that are in use.
* **Decommissioning**: retire an agent after migrating its phone numbers and workflows to a replacement.

## Before you call it

* Deactivate any active workflows that use this agent first. While one exists, the delete returns `409 Conflict` with code `AGENT_USED_IN_ACTIVE_WORKFLOWS` and the list of `affected_workflows`.
* The agent's phone numbers are unlinked automatically, with `unlink_reason` set to `agent_deleted`. The agent's phone number history is not readable after the delete, because the agent no longer exists. Inbound calls to those numbers have no agent until you attach them to another one.
* The delete is refused while one of the agent's numbers cannot be released: `409 Conflict` with code `PHONE_NUMBER_HAS_LIVE_CALLS`, `NUMBER_USED_BY_BATCH`, or `PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS`. See [Detach Agent Phone Number](https://dialnexa.com/docs/api-reference/v1/agents/detach-phone-number.md#errors-and-recovery) for each case.
* Confirm the `id` with [Get Agent Details](https://dialnexa.com/docs/api-reference/v1/agents/get.md); the delete is scoped to the workspace associated with your API key.

## Result

The agent no longer appears in API results, but existing call history stays readable. A `404 Not Found` means the agent does not exist in this workspace; a `409 Conflict` means an active workflow still uses it or one of its numbers is still in use. See [API errors](https://dialnexa.com/docs/api-reference/api-fundamentals.md#handle-dialnexa-api-errors) for the standard error format.


## OpenAPI

````yaml DELETE /v1/agents/{id}
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/agents/{id}:
    delete:
      tags:
        - Agents
      summary: Delete Agent
      description: >-
        Deletes an agent and all its versions. Historical call records remain
        available.
      operationId: deleteAgent
      parameters:
        - name: id
          required: true
          in: path
          description: Agent ID
          schema:
            example: agent_2g7Xy3tY53gRlp
            type: string
      responses:
        '200':
          description: Agent deleted successfully.
          content:
            application/json:
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    error: false
                    statusCode: 200
                    message: Success
                    timestamp: '2026-09-07T06:00:00.000Z'
              schema:
                type: object
                required:
                  - success
                  - error
                  - statusCode
                  - message
                  - timestamp
                description: The standard envelope without a data member.
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    type: boolean
                    enum:
                      - false
                  statusCode:
                    type: integer
                    example: 200
                  message:
                    type: string
                    example: Success
                  timestamp:
                    type: string
                    format: date-time
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 Unauthorized
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '404':
          description: Agent not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 404 Not Found
                  value:
                    statusCode: 404
                    error: true
                    success: false
                    data: []
                    message: Agent with ID 2g7Xy3tY53gRlp not found
                    errors: []
        '409':
          description: >-
            Conflict: the agent is used by active workflows
            (AGENT_USED_IN_ACTIVE_WORKFLOWS, with affected_workflows in data),
            or one of its numbers cannot be released yet
            (PHONE_NUMBER_HAS_LIVE_CALLS, NUMBER_USED_BY_BATCH, or
            PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS). Resolve what data lists,
            then retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                agentInActiveWorkflows:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data:
                      code: AGENT_USED_IN_ACTIVE_WORKFLOWS
                      affected_workflows:
                        - id: Xy7Kp2mQ9rT4vB
                          title: Lead follow-up
                          status: active
                    message: >-
                      This agent is used in 1 active workflow(s). Deactivate
                      those workflows first, then retry.
                    errors: []
                usedByBatch:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data:
                      code: NUMBER_USED_BY_BATCH
                      batches:
                        - id: batch_abc123
                          title: September renewals
                          status: paused
                      live_calls: 0
                    message: >-
                      1 unfinished batch(es) ("September renewals") and 0 live
                      call(s) use this number. Change the batches' number or
                      cancel them first.
                    errors: []
                liveCalls:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data:
                      code: PHONE_NUMBER_HAS_LIVE_CALLS
                      live_calls: 2
                      batches: []
                    message: >-
                      2 call(s) are in progress on this number. Wait for them to
                      finish, then retry.
                    errors: []
                activeWorkflows:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data:
                      code: PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS
                      affected_workflows:
                        - id: Xy7Kp2mQ9rT4vB
                          title: Lead follow-up
                          status: active
                    message: >-
                      This phone number is used in 1 active workflow(s). Pause
                      those workflows first, then retry.
                    errors: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 500 Internal Server Error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: 'Failed to delete agent: Internal server error'
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

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