Skip to main content
POST
Crear una funcion de webhook
Creates a webhook function. You describe what it does and which arguments it takes; the model decides when to call it and with what. Placeholders written {{name}} in the path, the query string or the body are filled at call time from the arguments the model chose, so https://erp.example.com/stock/{{sku}} with a sku parameter is the normal shape. Not in the host — read why.

Endpoint

Required scope

assistants:write

Headers

Body

Example request

Response

201 Created

The function, same shape as GET /v1/functions/{id}, with the header values already masked.

400 Bad Request

A missing required field, a field over its limit, or an unknown property. Two specific codes:
  • FUNCTION_URL_NOT_ALLOWED — the URL failed validation. details.reason names the rule; see the table.
  • FUNCTION_TIMEOUT_NOT_ALLOWEDtimeout outside 1–30 seconds.

401 Unauthorized

Missing, invalid, revoked, or expired token.

403 Forbidden

The token does not have the assistants:write scope.

409 Conflict

A function with that name already exists in the company.

502 Bad Gateway

The assistant service is unreachable.

Operational notes

  • description is a prompt, not documentation. It is the only thing the model reads when deciding whether to call the function, so say when to use it and when not to. “Devuelve el stock. Usar antes de prometer disponibilidad” beats “Endpoint de stock”.
  • A tool_params entry with no matching placeholder is still passed to the model, which will supply it and see it go nowhere. Keep the two in sync.
  • name is unique per company, not per project. A 409 can come from a function created under a different project.
  • Creating a function does not attach it to anything. The model can only call functions bound to a block in the assistant’s prompt; that binding is done in the portal.
  • type is forced to webhook. Sending anything else is rejected, and there is no way to create a calendar, ecommerce or block-managed function through this API.

Authorizations

Authorization
string
header
required

Personal Access Token con prefijo kbai_pk_. Generar desde el portal con permiso developer.manage_tokens.

Body

application/json
name
string
required

Nombre tecnico, unico por company. Es el nombre con el que el modelo invoca la funcion.

Maximum string length: 100
Example:

"consultar_stock"

display_name
string
required
Maximum string length: 200
Example:

"Consultar stock"

description
string
required

Para que sirve la funcion. Es lo que lee el modelo para decidir cuando llamarla.

Maximum string length: 1000
Example:

"Devuelve el stock disponible de un SKU en el ERP."

context
object
required
tool_params
object[]
Maximum array length: 30
tags
string[]
Maximum array length: 20
is_active
boolean
default:true

Response

201 - application/json
function
object
required