Criar agente
/v1/instances/{id}/attendant/agentsdesde M5btoken da instância ou adminQuando usar
Campos de roteiro ausentes vêm do preset do modo; tudo é editável depois. Até 20 agentes por instância.
Autenticação
Aceita o token da instância (só a própria instância) ou o token admin. Um token de outra instância recebe 403 forbidden (ou 404 not_found em webhooks de outra instância).
Parâmetros
Caminho
| Nome | Tipo | Descrição |
|---|---|---|
idobrigatório | string | Id da instância (inst_...). |
Corpo (JSON)
| Nome | Tipo | Descrição |
|---|---|---|
nameobrigatório | string | (até 80) |
mode | "vendedor" | "pedido" | "sdr" | "suporte" | "custom" | |
objective | string | |
steps | string[] | |
tone | string | |
handoff_criteria | string[] | |
actions | "handoff" | "lead" | "appointment" | "order_draft"[] | |
business | string | Contexto do negócio (texto livre |
knowledge | object[] | (até 300 itens) |
language | string | (padrão "pt-BR") |
currency | string | (padrão "BRL") |
voice_reply | "off" | "when_audio" | "always" | (padrão "off") |
call_followup | boolean | |
call_hint | string | |
max_reply_chars | integer | (padrão 1000, 50–4000) |
hide_contact_name | boolean |
Exemplo
curl -s -X POST "$LITEZAP_URL/v1/instances/$ID/attendant/agents" \ -H "Authorization: Bearer $LITEZAP_TOKEN" \ -d '{"name":"Bia da Pizzaria","mode":"pedido","business":"Pizzaria do Zé, Rua A 10, Centro. Entrega em até 40 min. Pix ou cartão na entrega.","knowledge":[{"kind":"product","title":"Pizza Margherita","price":45,"content":"8 fatias"},{"kind":"hours","title":"Seg a Dom","content":"18h às 23h"},{"kind":"faq","title":"Tem opção sem glúten?","content":"Sim, massa sem glúten por +R$ 8."}]}'const res = await fetch("http://localhost:8787/v1/instances/inst_7f3a9c2e5b1d4086/attendant/agents", { method: "POST", headers: { Authorization: `Bearer ${process.env.LITEZAP_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ "name": "Bia da Pizzaria", "mode": "pedido", "business": "Pizzaria do Zé, Rua A 10, Centro. Entrega em até 40 min. Pix ou cartão na entrega.", "knowledge": [ { "kind": "product", "title": "Pizza Margherita", "price": 45, "content": "8 fatias" }, { "kind": "hours", "title": "Seg a Dom", "content": "18h às 23h" }, { "kind": "faq", "title": "Tem opção sem glúten?", "content": "Sim, massa sem glúten por +R$ 8." } ] }),});console.log(res.status, res.status === 204 ? "" : await res.json());import osimport requests
r = requests.post( "http://localhost:8787/v1/instances/inst_7f3a9c2e5b1d4086/attendant/agents", headers={"Authorization": f"Bearer {os.environ['LITEZAP_TOKEN']}"}, json={ "name": "Bia da Pizzaria", "mode": "pedido", "business": "Pizzaria do Zé, Rua A 10, Centro. Entrega em até 40 min. Pix ou cartão na entrega.", "knowledge": [ { "kind": "product", "title": "Pizza Margherita", "price": 45, "content": "8 fatias", }, { "kind": "hours", "title": "Seg a Dom", "content": "18h às 23h", }, { "kind": "faq", "title": "Tem opção sem glúten?", "content": "Sim, massa sem glúten por +R$ 8.", }, ], }, timeout=150,)print(r.status_code, r.json() if r.content else "")package main
import ( "fmt" "io" "net/http" "os" "strings")
func main() { req, _ := http.NewRequest("POST", "http://localhost:8787/v1/instances/inst_7f3a9c2e5b1d4086/attendant/agents", strings.NewReader(`{"name":"Bia da Pizzaria","mode":"pedido","business":"Pizzaria do Zé, Rua A 10, Centro. Entrega em até 40 min. Pix ou cartão na entrega.","knowledge":[{"kind":"product","title":"Pizza Margherita","price":45,"content":"8 fatias"},{"kind":"hours","title":"Seg a Dom","content":"18h às 23h"},{"kind":"faq","title":"Tem opção sem glúten?","content":"Sim, massa sem glúten por +R$ 8."}]}`)) req.Header.Set("Authorization", "Bearer "+os.Getenv("LITEZAP_TOKEN")) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, _ := io.ReadAll(resp.Body) fmt.Println(resp.Status, string(out))}<?phprequire 'vendor/autoload.php'; // composer require guzzlehttp/guzzle
$client = new GuzzleHttp\Client(['base_uri' => 'http://localhost:8787']);$res = $client->request('POST', '/v1/instances/inst_7f3a9c2e5b1d4086/attendant/agents', [ 'headers' => ['Authorization' => 'Bearer ' . getenv('LITEZAP_TOKEN')], 'json' => [ 'name' => 'Bia da Pizzaria', 'mode' => 'pedido', 'business' => 'Pizzaria do Zé, Rua A 10, Centro. Entrega em até 40 min. Pix ou cartão na entrega.', 'knowledge' => [ [ 'kind' => 'product', 'title' => 'Pizza Margherita', 'price' => 45, 'content' => '8 fatias', ], [ 'kind' => 'hours', 'title' => 'Seg a Dom', 'content' => '18h às 23h', ], [ 'kind' => 'faq', 'title' => 'Tem opção sem glúten?', 'content' => 'Sim, massa sem glúten por +R$ 8.', ], ], ], 'http_errors' => false,]);echo $res->getStatusCode(), ' ', $res->getBody(), PHP_EOL;Nos exemplos, LITEZAP_URL é a URL base (ex.: http://localhost:8787) e o token vem deLITEZAP_TOKEN (instância) ou LITEZAP_ADMIN_TOKEN.
Resposta
201 Agente criado.
Erros
| Código | HTTP | Retentável | O que fazer |
|---|---|---|---|
validation_failed | 400 | não | Corrija o corpo ou os parâmetros; a message diz o campo. |
unauthorized | 401 | não | Envie Authorization: Bearer <token> válido. |
forbidden | 403 | não | Use o token certo (admin, ou o da própria instância). |
instance_not_found | 404 | não | Confira o id da instância. |
Todo erro usa o envelope {"error":{"code","message","retryable"}}. Tabela completa em Erros.
Outras operações de Atendente IA: Ler hook de agente · Configurar hook de agente · Remover hook de agente · Ligar ou desligar o atendente numa conversa · Últimas chamadas do atendente · Ler o Atendente LiteZap · Configurar provedor do atendente · Modos prontos do atendente · Listar agentes · Ler agente · Alterar agente · Excluir agente · Ativar agente · Simular conversa · Uso e custo do atendente

