> ## 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/knowledge/nodes/:id

> Delete a node (folder or document). If it's a folder, all of its descendants are deleted too.

Deletes a node from the knowledge base. If the node is a folder, all of its descendants (subfolders and documents) are deactivated along with it. The delete is logical (`is_active: false`); data stays in the database in case the support team needs to restore it, but it stops appearing in [`GET /v1/knowledge/tree`](/dev/endpoints/knowledge-tree) and is no longer eligible for [`POST /v1/knowledge/search`](/dev/endpoints/knowledge-search).

After deletion, the API enqueues a reindex to clean up the chunks tied to the node.

## Endpoint

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

## Required scope

`knowledge:delete`

## Headers

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

## Path params

| Param | Type     | Description                                            |
| ----- | -------- | ------------------------------------------------------ |
| `id`  | `string` | `ObjectId` of the node (folder or document) to delete. |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl -X DELETE https://api.keebai.com/v1/knowledge/nodes/65f3a1b2c3d4e5f6a7b8c9d3 \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={null}
  await fetch(
    `https://api.keebai.com/v1/knowledge/nodes/65f3a1b2c3d4e5f6a7b8c9d3`,
    {
      method: "DELETE",
      headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
    },
  );
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.delete(
      "https://api.keebai.com/v1/knowledge/nodes/65f3a1b2c3d4e5f6a7b8c9d3",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  resp.raise_for_status()
  ```
</CodeGroup>

## Response

### 204 No Content

No body. The delete is idempotent only within the same request: if the node was already deleted, it returns `404 NOT_FOUND`.

### 401 / 403 / 404 / 429

* `403 FORBIDDEN` with `code: INSUFFICIENT_SCOPE`: the PAT doesn't have `knowledge:delete`.
* `404 NOT_FOUND`: the node doesn't exist, was already deleted, or belongs to another company.

<Warning>
  Worker assignments (see [`POST /v1/knowledge/assignments`](/dev/endpoints/knowledge-assign)) keep pointing to the deleted node. Since the chunk is removed from the index on the next rebuild, the assistant loses access to the content even if the `knowledge_node_id` is still referenced.
</Warning>


## OpenAPI

````yaml DELETE /v1/knowledge/nodes/{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/knowledge/nodes/{id}:
    delete:
      tags:
        - knowledge
      summary: >-
        Eliminar un nodo (carpeta o documento). Si es carpeta, elimina sus
        descendientes.
      operationId: PublicKnowledgeController_deleteNode
      parameters:
        - name: id
          required: true
          in: path
          description: ObjectId del nodo a eliminar.
          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`.

````