> ## 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.

# GET /v1/functions/{id}

> Get one webhook function with its request shape and the blocks that reference it.

Returns one webhook function. Same shape as an entry in [the list](/dev/endpoints/functions-list), with header and query-string values masked.

The field worth coming here for is `used_by_blocks`: it tells you which blocks reference the function, which is what you need before [deleting it](/dev/endpoints/functions-delete).

## Endpoint

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

## Required scope

`assistants:read`

## 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 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",
    { headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` } },
  );
  const { function: fn } = await resp.json();

  if (fn.used_by_blocks.length > 0) {
    // Unbind these blocks before deleting.
  }
  ```

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

  resp = requests.get(
      "https://api.keebai.com/v1/functions/6650cccc3333dddd4444eeee",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      timeout=10,
  )
  resp.raise_for_status()
  fn = resp.json()["function"]
  ```
</CodeGroup>

## Response

### 200 OK

```json theme={null}
{
  "function": {
    "_id": "6650cccc3333dddd4444eeee",
    "name": "consultar_stock",
    "display_name": "Consultar stock",
    "description": "Devuelve el stock disponible de un SKU en el ERP.",
    "type": "webhook",
    "tool_params": [
      {
        "name": "sku",
        "description": "Código del producto",
        "type": "string",
        "required": true
      }
    ],
    "context": {
      "url": "https://erp.example.com/stock/{{sku}}",
      "method": "GET",
      "headers": { "Authorization": "***" },
      "params": {},
      "timeout": 30
    },
    "tags": ["erp"],
    "is_active": true,
    "used_by_blocks": [
      { "block_id": "6650bbbb2222cccc3333dddd", "name": "Reserva", "type": "steps" }
    ],
    "created_at": "2026-07-22T08:12:04.221Z",
    "updated_at": "2026-07-25T16:30:19.008Z"
  }
}
```

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `assistants:read` scope.

### 404 Not Found

No function with that id in the token's company, **or** the id belongs to a function that is not a webhook.

### 502 Bad Gateway

The assistant service is unreachable.

## Operational notes

* **A non-webhook function reads as `404`, not `403`.** An id you cannot manage is deliberately indistinguishable from one that does not exist.
* **The masked values are not a permissions thing.** Every caller sees `***`, including one with `assistants:write`. The stored value is never returned by any endpoint.
* **`is_active: false` means the model will not be offered the function**, but the configuration is intact. It is the reversible way to switch one off.
* **`type` is always `webhook`** on this surface, and is included so the field is not silently absent from a contract that upstream considers polymorphic.


## OpenAPI

````yaml GET /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}:
    get:
      tags:
        - functions
      summary: Obtener una funcion de webhook
      description: >-
        Incluye que bloques la referencian, que es lo que hay que desvincular
        antes de poder borrarla.
      operationId: PublicFunctionsController_get
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicFunctionEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicFunctionEnvelopeDto:
      type: object
      properties:
        function:
          $ref: '#/components/schemas/PublicFunctionDto'
      required:
        - function
    PublicFunctionDto:
      type: object
      properties:
        _id:
          type: string
        name:
          type: string
        display_name:
          type: string
        description:
          type: string
        type:
          type: string
          example: webhook
        tool_params:
          type: array
          items:
            $ref: '#/components/schemas/PublicFunctionParamResponseDto'
        context:
          $ref: '#/components/schemas/PublicWebhookContextResponseDto'
        tags:
          type: array
          items:
            type: string
        is_active:
          type: boolean
        used_by_blocks:
          description: >-
            Bloques que referencian esta funcion. Mientras la lista no este
            vacia, borrarla devuelve 409.
          type: array
          items:
            $ref: '#/components/schemas/PublicFunctionUsageDto'
        created_at:
          type: string
        updated_at:
          type: string
      required:
        - _id
        - name
        - display_name
        - description
        - type
        - tool_params
        - context
        - tags
        - is_active
        - used_by_blocks
        - created_at
        - updated_at
    PublicFunctionParamResponseDto:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        type:
          type: string
          enum:
            - string
            - number
            - boolean
            - array
            - object
        required:
          type: boolean
      required:
        - name
        - type
        - required
    PublicWebhookContextResponseDto:
      type: object
      properties:
        url:
          type: string
        method:
          type: string
          enum:
            - GET
            - POST
            - PUT
            - PATCH
            - DELETE
        headers:
          type: object
          additionalProperties:
            type: string
          description: >-
            Headers configurados. Las claves se muestran y los valores vuelven
            siempre como '***'.
          example:
            Authorization: '***'
        params:
          type: object
          additionalProperties:
            type: string
          description: >-
            Query string configurada, con los valores enmascarados igual que
            headers.
        body:
          type: object
          additionalProperties: true
          description: >-
            Body de la request. No se enmascara: es la plantilla que rellena el
            modelo.
        timeout:
          type: number
        response_path:
          type: string
      required:
        - url
        - method
        - headers
        - params
        - timeout
    PublicFunctionUsageDto:
      type: object
      properties:
        block_id:
          type: string
        name:
          type: string
        type:
          type: string
          enum:
            - personification
            - objective
            - response_format
            - steps
            - cases_possible
            - do_not
            - product_info
            - store_info
            - reservation_info
            - tables_info
            - tags
            - response_policy
      required:
        - block_id
        - name
        - type
  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`.

````