Skip to main content

WhatsApp tools workflow

WhatsApp tools are company templates the bot uses to prepare operation drafts. They are the same WhatsAppOperationTool rows as Configuración → WhatsApp → Tools. Authenticate with x-api-key. The dashboard employee session API stays at /api/kapso/tools. This public integrator surface is /api/whatsapp/tools so it matches other company-scoped catalogs (/api/tags, /api/operation-types). Delete is a soft-delete (deleted_at + enabled=false), same as the dashboard. List never returns soft-deleted tools; it does include disabled ones. operationTypeId lives inside fixed_config (dashboard field). There is no top-level operation_type_id. Cross-company IDs are rejected.

List tools (including disabled)

The response is an array of tools (id, name, slug, enabled, company_operation_type_id, fixed_config, parameter_schema, …).

Create a tool

Body shape matches the dashboard form: name, optional slug / description / enabled, required fixed_config, optional parameter_schema (defaults to no dynamic fields). fixed_config.toolKind must match the company operation type: up/down → up_down, other → other, exchange → exchange, budget → budget.
A duplicate slug for the same company returns 409. Invalid fixed_config or an operationTypeId that is not this company’s (or the wrong base type) returns 400.

OTHER example

EXCHANGE example

BUDGET example

Budget tools do not send up/down mode, source, or destination. Direction defaults to expense (same as the dashboard budget form). paymentSourceMode defaults to internal (caja). Expense + external drafts the same Gastos op as the dashboard: credit payerClientId (type=1, not the center client), no caja debit. Source, centro, amount, and description can each be fixed or a param. If internalAccountId is omitted on internal, confirm uses the cost center default caja.
Personal expense (cuenta corriente, no caja):
A budget operation type with toolKind=up_down returns 400.

Enable, rename, or update config

Soft-delete

Returns 204. Soft-deleted tools disappear from GET and return 404 on later PATCH/DELETE.

Company agent prompt (prompt base del bot)

House rules appended after the global WhatsApp agent prompt. They never replace accounting or safety rules. This is the same value as the dashboard card in Configuración → WhatsApp → Tools (employee route /api/kapso/system-prompt-extra), just with x-api-key.

Read

Response: { "system_prompt_extra": "..." }, or null when unset.

Set or clear

Send the text to replace it, or null / "" to clear it (the bot falls back to the global prompt). The value is trimmed and capped at 12.000 characters; longer bodies return 400.
Use it for company vocabulary, habitual multi-step requests, or the multi-draft / discard conventions described in WhatsApp.
  • GET /api/whatsapp/tools
  • POST /api/whatsapp/tools
  • GET /api/whatsapp/tools/{id}
  • PATCH /api/whatsapp/tools/{id}
  • DELETE /api/whatsapp/tools/{id}
  • GET /api/whatsapp/system-prompt-extra
  • PATCH /api/whatsapp/system-prompt-extra
  • GET /api/operation-types — resolve fixed_config.operationTypeId
  • Dashboard catalog/apply (employee session, whatsapp.manage): GET /api/kapso/tool-templates, POST /api/kapso/tool-templates/apply