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

# DELETE /v1/agents/{id}

> Delete an agent permanently. Its tools and knowledge nodes survive and stay in the project catalogue.

Deletes the agent. This is a hard delete of the agent document and it cannot be undone.

It is **not** a cascade. Every block the agent referenced stays in the project catalogue, un-archived, with its full version history. Deleting an agent unwires it; it does not clean up after it.

<Warning>
  If your goal is to stop an agent answering, [`PATCH` it with `is_active: false`](/dev/endpoints/agents-update) instead. That is reversible and keeps the configuration intact.
</Warning>

## Endpoint

```
DELETE https://api.keebai.com/v1/agents/{id}
```

## Required scope

`agents:write`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |

## Path parameters

| Parameter | Type     | Description              |
| --------- | -------- | ------------------------ |
| `id`      | `string` | `ObjectId` of the agent. |

## Example request

<CodeGroup>
  ```bash curl theme={"system"}
  curl -X DELETE https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0 \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={"system"}
  const resp = await fetch(
    "https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0",
    {
      method: "DELETE",
      headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
    },
  );
  // 204 on success, 404 if it was already gone.
  ```

  ```python Python theme={"system"}
  import os, requests

  resp = requests.delete(
      "https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  if resp.status_code != 404:
      resp.raise_for_status()
  ```
</CodeGroup>

## Response

### 204 No Content

Deleted. No body.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `agents:write` scope.

### 404 Not Found

No agent with that id in the token's company and project. A repeated delete lands here, so treat `404` as "already gone" when retrying.

### 502 Bad Gateway

The agent service is unreachable.

## Operational notes

* **The sections go with the agent**, and so does their history: they belonged to it. The [tools](/dev/endpoints/tools-list) and knowledge nodes it referenced belong to the company and are left alone.
* **Knowledge documents are untouched.** Deleting an agent removes its assignments, not the documents themselves.
* **Anything still routing to this agent will stop working.** The delete does not check for inbound routes, channels or funnel stages pointing at it. Repoint them first.
* **A retry is safe.** The operation is idempotent from the caller's point of view: the second call is a `404`, never a partial delete.


## OpenAPI

````yaml DELETE /v1/agents/{id}
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/agents/{id}:
    delete:
      tags:
        - agents
      summary: Eliminar un agente
      description: >-
        Borra el agente de forma permanente. Sus bloques sobreviven y quedan en
        el catalogo: esto desarma el cableado, no limpia lo que habia detras.
      operationId: PublicAgentsController_remove
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '204':
          description: ''
      security:
        - PAT: []
components:
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````