Skip to main content
POST
Creates an agent in the token’s project and returns it with its _id. The goal is the decision that matters. It is what switches the toolkits on, so an agent created to inform cannot later be made to book without changing it. Everything else — sections, channels, tools — can be adjusted afterwards. You can send the prompt sections here, or create the agent bare and write them one at a time. Valid values for section, goal.type and channels come from the catalogue.

Endpoint

Required scope

agents:write

Body

Example request

An agent on the scenarios engine

With engine: "scenarios" the agent reads the sections identity and objective (kind=escenarios) and works from its scenarios. Create the agent first, then its scenarios and their routes: the steps of a route carry the actions it uses.
curl

Response

201 Created

400 Bad Request

A field over its length limit, a malformed ObjectId, an unknown property, INVALID_MODEL, or a case action that is not in the actions list (UNKNOWN_ACTION_TARGET). A new agent has no stages yet, so a case cannot point to one until it exists.

401 Unauthorized

Missing, invalid, revoked, or expired token.

403 Forbidden

The token does not have the agents:write scope.

502 Bad Gateway

The agent service is unreachable.

Operational notes

  • An agent created here is not yet answering. The channel has to be connected on the company as well as enabled on the agent, and a goal that uses tools needs the data behind them — services, staff, catalogue — to exist.
  • Every section you send is versioned from the start. The creation is version 1 of each.
  • language carries the country and it is not cosmetic. It is what decides how the agent conjugates; getting it wrong is the first thing a customer notices.
  • engine: "scenarios" moves the behaviour out of the sections. The agent then reads the index of its scenarios and opens the one that fits; create them after the agent, or start from a template.
  • Leaving a section out is better than inventing one. An empty section is filled later; an invented one is discovered by a customer.

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
Maximum string length: 150
Example:

"Agente de ventas"

description
string
Maximum string length: 500
Example:

"Atiende WhatsApp y la web, agenda horas y resuelve dudas."

model
string

Identificador del modelo. Se valida contra los modelos soportados; uno desconocido devuelve 400 INVALID_MODEL.

Example:

"openai/gpt-5"

language
string

Locale del agente. El pais importa: es-CL y es-MX no conjugan igual.

Example:

"es-CL"

timezone
string
Example:

"America/Santiago"

engine
enum<string>

Como corre el turno: turn, un agente con todo el prompt (el default al crear); scenarios, el motor de escenarios, que lee el indice de escenarios y abre el que corresponde. Los escenarios y sus rutas se crean despues, con POST /v1/agents/{id}/scenarios y POST /v1/agents/{id}/scenarios/{scenarioId}/routes.

Available options:
turn,
scenarios
Example:

"turn"

goal
object
prompts
object[]

Las secciones del prompt. Se pueden mandar aca al crear, o una por una con PUT /v1/agents/{id}/prompts/{section}. Al crear, las acciones de los casos no pueden nombrar etapas: el embudo nace con el agente y sus ids salen despues en GET /v1/agents/{id}/actions.

Maximum array length: 20
channels
string[]

Canales por los que atiende, del catalogo (GET /v1/prompt-types?kind=channel).

Maximum array length: 10
Example:
reengagement
object

Reenganche: cuantas veces vuelve sobre una conversacion enfriada y cada cuanto. max_attempts: 0 lo apaga.

tools
string[]

ObjectIds de herramientas (GET /v1/tools) que puede usar.

Maximum array length: 100
Example:
knowledge_node_ids
string[]

ObjectIds de nodos de la base de conocimiento a asignar.

Maximum array length: 200
Example:
stages
string[]

Etapas del embudo, por NOMBRE y en orden. Se crea un pipeline en el CRM con el nombre del agente y esas etapas, y el agente queda habilitado para mover tickets solo entre ellas. Sin esto no se crea ningun pipeline y el agente no mueve tickets.

Maximum array length: 20
Example:

Response

201 - application/json
agent
object
required