> ## 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/functions/{id}

> Delete a webhook function permanently. Fails while any block still references it.

Deletes the function. This is a hard delete and it cannot be undone.

It is refused while any block still references the function, and the error names them — so the normal sequence is: read [`used_by_blocks`](/dev/endpoints/functions-get), unbind those blocks in the portal, then delete.

<Warning>
  If you only want the assistant to stop calling it, [`PUT` it with `is_active: false`](/dev/endpoints/functions-update) instead. That is reversible and keeps the URL, headers and parameters intact.
</Warning>

## Endpoint

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

## Required scope

`assistants:write`

## Headers

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

## Path parameters

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

## Example request

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

  ```js JavaScript theme={null}
  const resp = await fetch(
    "https://api.keebai.com/v1/functions/6650cccc3333dddd4444eeee",
    {
      method: "DELETE",
      headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` },
    },
  );

  if (resp.status === 409) {
    const { error } = await resp.json();
    console.error("Still used by:", error.details.blocks);
  }
  ```

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

  resp = requests.delete(
      "https://api.keebai.com/v1/functions/6650cccc3333dddd4444eeee",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  if resp.status_code == 409:
      print("still used by:", resp.json()["error"]["details"]["blocks"])
  elif 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 `assistants:write` scope.

### 404 Not Found

No webhook function with that id in the token's company. A repeated delete lands here, so treat `404` as "already gone".

### 409 Conflict

`error.code` is `AGENT_TOOL_IN_USE`. At least one block still references the function; `error.details.blocks` lists them.

### 502 Bad Gateway

The assistant service is unreachable.

## Operational notes

* **The `409` is the useful part of this endpoint.** It is what stops you silently breaking an assistant mid-conversation, and it tells you exactly which blocks to fix.
* **Unbinding a function from a block is done in the portal.** This API can save a block's text but not its function bindings, so the last step of a clean removal is a portal action.
* **Deleting is company-wide.** A function used by an assistant in another project of the same company counts as in use and blocks the delete.
* **A retry is safe**: the second call is a `404`, never a partial delete.
* **`is_active: false` is the reversible alternative** and is usually what you want when retiring an integration gradually.


## OpenAPI

````yaml DELETE /v1/functions/{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/functions/{id}:
    delete:
      tags:
        - functions
      summary: Eliminar una funcion de webhook
      description: >-
        Falla con 409 AGENT_TOOL_IN_USE mientras algun bloque la referencie, y
        el error dice cuales.
      operationId: PublicFunctionsController_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`.

````