{"openapi":"3.1.0","info":{"title":"VD CRM API","version":"1.0.0","description":"API REST do VD CRM. Cada chave age somente na sua operação, com as mesmas regras do CRM. Escopos: inbox:read (Ler conversas e mensagens), inbox:write (Enviar mensagens e gerenciar conversas), contacts:read (Ler contatos e listas), contacts:write (Criar e alterar contatos), lists:write (Criar listas e importar contatos), templates:read (Ler modelos), templates:write (Criar e excluir modelos), campaigns:read (Ler campanhas e resultados), campaigns:write (Criar e controlar campanhas), webhooks:manage (Gerenciar webhooks), flows:read (Ler fluxos e execuções), flows:write (Criar, publicar e iniciar fluxos), pipelines:read (Ler funis e negócios), pipelines:write (Criar e mover negócios), accounts:read (Ler BMs, WABAs e números), accounts:write (Sincronizar, editar perfil e conectar números), metrics:read (Ler métricas e gerar relatórios), team:manage (Gerenciar operações e equipe), settings:manage (Respostas rápidas, tags e departamentos), embed:create (Criar sessões de telas embutidas (SSO)). Eventos de webhook: message.received, message.status, conversation.assigned, conversation.closed, contact.opted_out, template.status, campaign.started, campaign.completed, campaign.paused, phone_number.quality_changed, phone_number.status_changed, phone_number.connected, connect_session.failed, flow.completed, deal.stage_changed, report.ready."},"servers":[{"url":"https://crm.vdgestaobranding.com/api/v1"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Chave de operação (vdk_live_… / vdk_test_…) ou de conta parceira (vdk_acct_live_… / vdk_acct_test_…)."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","enum":["unauthorized","invalid_key","key_expired","ip_not_allowed","plan_not_allowed","key_owner_inactive","insufficient_scope","operation_read_only","plan_limit","not_found","validation_error","rule_violation","contact_opted_out","meta_error","idempotency_mismatch","idempotency_in_progress","rate_limited","flow_invalid","shared_flow","invalid_state","disconnected","conflict","internal_error"]},"message":{"type":"string"},"details":{"type":"object"},"request_id":{"type":"string"}}}}}}},"paths":{"/phone-numbers":{"get":{"operationId":"phones","tags":["Números"],"summary":"Listar números","description":"Números WhatsApp conectados à operação, com WABA, qualidade, limite e status.\n\nQualquer chave válida.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"phone_number_id":{"type":"string"},"display_phone_number":{"type":"string"},"verified_name":{"type":"string"},"waba_id":{"type":"string"},"quality_rating":{"type":"string"},"messaging_limit_tier":{"type":"string"},"status":{"type":"string"}}}}}},"example":{"data":[{"id":"a0b1…","phone_number_id":"1340490742483622","display_phone_number":"+55 55 92482-1431","verified_name":"Suporte Comercial","waba_id":"1095419929937194","quality_rating":"GREEN","messaging_limit_tier":"TIER_1K","status":"CONNECTED"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts":{"get":{"operationId":"contacts-list","tags":["Contatos"],"summary":"Listar e buscar contatos","description":"Escopo: `contacts:read`.","parameters":[{"name":"q","in":"query","description":"Busca por nome, telefone ou e-mail.","schema":{"type":"string"}},{"name":"tag","in":"query","description":"Somente contatos com esta tag.","schema":{"type":"string"}},{"name":"wa_id","in":"query","description":"Telefone exato.","schema":{"type":"string"}},{"name":"opted_out","in":"query","description":"true/false.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}}},"next_cursor":{"type":"string"}}},"example":{"data":[{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}],"next_cursor":"WyIyMDI2…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"contacts-create","tags":["Contatos"],"summary":"Criar contato","description":"Para marcar opt_in é obrigatório informar opt_in_source (origem do consentimento).\n\nEscopo: `contacts:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"}}},"example":{"phone":"5511999998888","name":"Maria Silva","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site"}}}}}},"/contacts/batch":{"post":{"operationId":"contacts-batch","tags":["Contatos"],"summary":"Criar/atualizar em lote","description":"Até 1.000 contatos por chamada. Retorna um relatório por linha.\n\nEscopo: `contacts:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"updated":{"type":"integer"},"errors":{"type":"integer"},"results":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"status":{"type":"string"},"id":{"type":"string"}}}}}},"example":{"created":1,"updated":0,"errors":1,"results":[{"index":0,"status":"created","id":"c1d2…"},{"index":1,"status":"error","error":"Telefone inválido…"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"upsert":{"type":"boolean"},"contacts":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string"},"name":{"type":"string"}}}}}},"example":{"upsert":true,"contacts":[{"phone":"5511999998888","name":"Maria"},{"phone":"123"}]}}}}}},"/contacts/{id}":{"get":{"operationId":"contacts-get","tags":["Contatos"],"summary":"Obter contato","description":"Escopo: `contacts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"contacts-update","tags":["Contatos"],"summary":"Atualizar contato","description":"custom_fields é mesclado com os campos existentes.\n\nEscopo: `contacts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"custom_fields":{"type":"object","properties":{"plano":{"type":"string"}}}}},"example":{"name":"Maria S.","custom_fields":{"plano":"ouro"}}}}}},"delete":{"operationId":"contacts-delete","tags":["Contatos"],"summary":"Excluir contato","description":"Escopo: `contacts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/tags":{"post":{"operationId":"contacts-tags","tags":["Contatos"],"summary":"Adicionar/remover tags","description":"Escopo: `contacts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"add":{"type":"array","items":{"type":"string"}},"remove":{"type":"array","items":{"type":"string"}}}},"example":{"add":["cliente"],"remove":["lead"]}}}}}},"/contacts/{id}/opt-out":{"post":{"operationId":"contacts-optout","tags":["Contatos"],"summary":"Registrar opt-out","description":"O contato deixa de receber campanhas e modelos.\n\nEscopo: `contacts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":false,"opt_in_source":"Formulário do site","opted_out_at":"2026-11-03T15:10:00Z","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string"}}},"example":{"source":"Pediu pelo SAC"}}}}}},"/contacts/{id}/opt-in":{"post":{"operationId":"contacts-optin","tags":["Contatos"],"summary":"Registrar opt-in","description":"Escopo: `contacts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wa_id":{"type":"string"},"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","properties":{"cidade":{"type":"string"}}},"opt_in":{"type":"boolean"},"opt_in_source":{"type":"string"},"opted_out_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"example":{"id":"c1d2…","wa_id":"5511999998888","name":"Maria Silva","phone":"+5511999998888","email":"maria@exemplo.com","tags":["vip"],"custom_fields":{"cidade":"São Paulo"},"opt_in":true,"opt_in_source":"Formulário do site","opted_out_at":null,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source":{"type":"string"}}},"example":{"source":"Checkbox no checkout"}}}}}},"/lists":{"get":{"operationId":"lists-list","tags":["Listas"],"summary":"Listar listas","description":"Escopo: `contacts:read`.","parameters":[{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"created_at":{"type":"string"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"l1…","name":"Clientes VIP","description":null,"created_at":"2026-11-03T15:00:00Z"}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"lists-create","tags":["Listas"],"summary":"Criar lista","description":"Escopo: `lists:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"example":{"id":"l1…","name":"Clientes VIP"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"Clientes VIP"}}}}}},"/lists/{id}":{"get":{"operationId":"lists-get","tags":["Listas"],"summary":"Obter lista","description":"Escopo: `contacts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"lists-update","tags":["Listas"],"summary":"Renomear lista","description":"Escopo: `lists:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"VIP 2026"}}}}},"delete":{"operationId":"lists-delete","tags":["Listas"],"summary":"Excluir lista","description":"Os contatos são preservados.\n\nEscopo: `lists:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/lists/{id}/contacts":{"post":{"operationId":"lists-add","tags":["Listas"],"summary":"Adicionar contatos","description":"Escopo: `lists:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"affected":{"type":"integer"}}},"example":{"affected":1}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contact_ids":{"type":"array","items":{"type":"string"}}}},"example":{"contact_ids":["c1d2…"]}}}}},"delete":{"operationId":"lists-remove","tags":["Listas"],"summary":"Remover contatos","description":"Escopo: `lists:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"affected":{"type":"integer"}}},"example":{"affected":1}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contact_ids":{"type":"array","items":{"type":"string"}}}},"example":{"contact_ids":["c1d2…"]}}}}}},"/lists/{id}/imports":{"post":{"operationId":"lists-import","tags":["Listas"],"summary":"Importar CSV/XLSX","description":"Envie JSON com file_url (https) ou multipart com o campo file. Colunas reconhecidas: telefone/phone, nome/name, email, tags; as demais viram campos personalizados. source (origem do consentimento) é obrigatório.\n\nEscopo: `lists:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"total":{"type":"integer"},"imported":{"type":"integer"},"updated":{"type":"integer"},"invalid":{"type":"integer"}}},"example":{"id":"i1…","status":"completed","total":500,"imported":480,"updated":15,"invalid":5}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"file_url":{"type":"string"},"source":{"type":"string"}}},"example":{"file_url":"https://exemplo.com/contatos.csv","source":"Cadastro na loja física"}}}}}},"/lists/{id}/imports/{importId}":{"get":{"operationId":"lists-import-get","tags":["Listas"],"summary":"Status da importação","description":"Escopo: `contacts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"importId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"imported":{"type":"integer"}}},"example":{"id":"i1…","status":"processing","imported":120}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations":{"get":{"operationId":"conv-list","tags":["Inbox"],"summary":"Listar conversas","description":"Escopo: `inbox:read`.","parameters":[{"name":"phone_number_ref","in":"query","description":"ID do número no CRM.","schema":{"type":"string"}},{"name":"status","in":"query","description":"open | closed.","schema":{"type":"string"}},{"name":"assignee_id","in":"query","description":"Atendente.","schema":{"type":"string"}},{"name":"tag","in":"query","description":"Tag do contato.","schema":{"type":"string"}},{"name":"unread","in":"query","description":"true para não lidas.","schema":{"type":"string"}},{"name":"since","in":"query","description":"ISO 8601 (última mensagem a partir de).","schema":{"type":"string"}},{"name":"until","in":"query","description":"ISO 8601.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}":{"get":{"operationId":"conv-get","tags":["Inbox"],"summary":"Obter conversa","description":"Escopo: `inbox:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/messages":{"get":{"operationId":"conv-messages","tags":["Inbox"],"summary":"Listar mensagens","description":"Escopo: `inbox:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"direction":{"type":"string"},"type":{"type":"string"},"content":{"type":"object","properties":{"text":{"type":"string"}}},"status":{"type":"string"},"created_at":{"type":"string"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"m1…","direction":"inbound","type":"text","content":{"text":"Olá!"},"status":"received","created_at":"2026-11-03T15:02:00Z"}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"conv-send","tags":["Inbox"],"summary":"Enviar mensagem na conversa","description":"type: text | media | template. Texto e mídia só com a janela de 24h aberta; fora dela use um modelo aprovado.\n\nEscopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wamid":{"type":"string"},"status":{"type":"string"}}},"example":{"id":"m2…","wamid":"wamid.HBg…","status":"sent"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"text":{"type":"string"}}},"example":{"type":"text","text":"Olá, Maria! Seu pedido foi enviado."}}}}}},"/messages":{"post":{"operationId":"msg-send","tags":["Inbox"],"summary":"Enviar mensagem para um telefone","description":"Cria o contato e a conversa se necessário. Para iniciar conversa use um modelo aprovado.\n\nEscopo: `inbox:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"wamid":{"type":"string"},"status":{"type":"string"}}},"example":{"id":"m3…","wamid":"wamid.HBg…","status":"sent"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone_number_ref":{"type":"string"},"to":{"type":"string"},"type":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"variables":{"type":"array","items":{"type":"string"}}}},"example":{"phone_number_ref":"a0b1…","to":"5511999998888","type":"template","name":"pedido_enviado","language":"pt_BR","variables":["Maria","#1234"]}}}}}},"/conversations/{id}/read":{"post":{"operationId":"conv-read","tags":["Inbox"],"summary":"Marcar como lida","description":"Escopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/close":{"post":{"operationId":"conv-close","tags":["Inbox"],"summary":"Finalizar","description":"Escopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/reopen":{"post":{"operationId":"conv-reopen","tags":["Inbox"],"summary":"Reabrir","description":"Escopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/archive":{"post":{"operationId":"conv-archive","tags":["Inbox"],"summary":"Arquivar","description":"Escopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/assign":{"post":{"operationId":"conv-assign","tags":["Inbox"],"summary":"Atribuir atendente","description":"Escopo: `inbox:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"contact_id":{"type":"string"},"phone_number_ref":{"type":"string"},"status":{"type":"string"},"assignee_id":{"type":["string","null"]},"unread_count":{"type":"integer"},"last_message_at":{"type":"string"},"window_open":{"type":"boolean"}}},"example":{"id":"9f1e…","contact_id":"c1d2…","phone_number_ref":"a0b1…","status":"aberta","assignee_id":null,"unread_count":2,"last_message_at":"2026-11-03T15:02:00Z","window_open":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"assignee_id":{"type":"string"}}},"example":{"assignee_id":"u1…"}}}}}},"/templates":{"get":{"operationId":"tpl-list","tags":["Modelos"],"summary":"Listar modelos","description":"Escopo: `templates:read`.","parameters":[{"name":"waba_id","in":"query","description":"WABA.","schema":{"type":"string"}},{"name":"status","in":"query","description":"APPROVED, PENDING, REJECTED…","schema":{"type":"string"}},{"name":"category","in":"query","description":"MARKETING, UTILITY, AUTHENTICATION.","schema":{"type":"string"}},{"name":"language","in":"query","description":"pt_BR…","schema":{"type":"string"}},{"name":"name","in":"query","description":"Nome exato.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"1–200.","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Cursor.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"category":{"type":"string"},"status":{"type":"string"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"t1…","name":"pedido_enviado","language":"pt_BR","category":"UTILITY","status":"APPROVED"}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"tpl-create","tags":["Modelos"],"summary":"Criar modelo","description":"template segue o mesmo formato do editor do CRM: kind (standard | carousel | lto | auth), category, languages, headerType, body, examples, footer, buttons, cards, lto, auth. Mídia de exemplo por header_media_url / header_media_id e card_media.\n\nEscopo: `templates:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"language":{"type":"string"},"ok":{"type":"boolean"},"status":{"type":"string"},"meta_template_id":{"type":"string"}}}}}},"example":{"results":[{"language":"pt_BR","ok":true,"status":"PENDING","meta_template_id":"1234567890"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"waba_id":{"type":"string"},"header_media_url":{"type":"string"},"template":{"type":"object","properties":{"name":{"type":"string"},"category":{"type":"string"},"languages":{"type":"array","items":{"type":"string"}},"kind":{"type":"string"},"headerType":{"type":"string"},"body":{"type":"string"},"examples":{"type":"object","properties":{"1":{"type":"string"},"2":{"type":"string"}}},"footer":{"type":"string"},"buttons":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"text":{"type":"string"},"url":{"type":"string"},"urlExample":{"type":"string"}}}}}}}},"example":{"waba_id":"1095419929937194","header_media_url":"https://exemplo.com/banner.jpg","template":{"name":"promo_novembro","category":"MARKETING","languages":["pt_BR"],"kind":"standard","headerType":"IMAGE","body":"Olá {{1}}, aproveite {{2}}% de desconto!","examples":{"1":"Maria","2":"20"},"footer":"VD CRM","buttons":[{"id":"b1","type":"URL","text":"Ver ofertas","url":"https://loja.com/{{1}}","urlExample":"https://loja.com/promo"}]}}}}}}},"/templates/{id}":{"get":{"operationId":"tpl-get","tags":["Modelos"],"summary":"Obter modelo e status","description":"Escopo: `templates:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"tpl-delete","tags":["Modelos"],"summary":"Excluir modelo","description":"Escopo: `templates:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean"}}},"example":{"deleted":true}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/media":{"post":{"operationId":"media-upload","tags":["Mídia"],"summary":"Enviar mídia","description":"multipart com o campo file (até 100 MB) ou JSON com url https.\n\nEscopo: `inbox:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string"},"mime":{"type":"string"},"size_bytes":{"type":"integer"}}},"example":{"id":"md1…","kind":"document","mime":"application/pdf","size_bytes":120334}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"}}},"example":{"url":"https://exemplo.com/catalogo.pdf"}}}}}},"/media/{id}":{"get":{"operationId":"media-get","tags":["Mídia"],"summary":"Obter mídia","description":"Inclui um link temporário (1 h).\n\nEscopo: `inbox:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"url_expires_in":{"type":"integer"}}},"example":{"id":"md1…","url":"https://…","url_expires_in":3600}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns":{"get":{"operationId":"camp-list","tags":["Campanhas"],"summary":"Listar campanhas","description":"Escopo: `campaigns:read`.","parameters":[{"name":"status","in":"query","description":"rascunho, agendada, enviando, pausada, concluida, cancelada.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"camp-create","tags":["Campanhas"],"summary":"Criar campanha","description":"Uma campanha usa uma única WABA da operação e números dessa mesma WABA. start=false cria como rascunho; use /dispatch para disparar. Suporta A/B (variants, soma 100%), agendamento (scheduled_at) e janela de envio (send_window).\n\nEscopo: `campaigns:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}},"eligible_recipients":{"type":"integer"}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0},"eligible_recipients":1200}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"waba_id":{"type":"string"},"phone_number_refs":{"type":"array","items":{"type":"string"}},"template":{"type":"object","properties":{"name":{"type":"string"},"language":{"type":"string"},"variables":{"type":"array","items":{"type":"object","properties":{"source":{"type":"string"},"field":{"type":"string"},"fallback":{"type":"string"}}}}}},"audience":{"type":"object","properties":{"include_lists":{"type":"array","items":{"type":"string"}},"include_tags":{"type":"array","items":{}},"exclude_lists":{"type":"array","items":{}},"exclude_tags":{"type":"array","items":{"type":"string"}}}},"scheduled_at":{"type":["string","null"]},"rate_per_second":{"type":"integer"},"send_window":{"type":"object","properties":{"start":{"type":"integer"},"end":{"type":"integer"},"days":{"type":"array","items":{"type":"integer"}}}},"start":{"type":"boolean"}}},"example":{"name":"Black Friday","waba_id":"1095419929937194","phone_number_refs":["a0b1…"],"template":{"name":"promo_novembro","language":"pt_BR","variables":[{"source":"field","field":"nome","fallback":"cliente"},{"source":"text","value":"20"}]},"audience":{"include_lists":["l1…"],"include_tags":[],"exclude_lists":[],"exclude_tags":["nao_enviar"]},"scheduled_at":null,"rate_per_second":10,"send_window":{"start":9,"end":20,"days":[1,2,3,4,5]},"start":false}}}}}},"/campaigns/{id}":{"get":{"operationId":"camp-get","tags":["Campanhas"],"summary":"Obter campanha","description":"Escopo: `campaigns:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/dispatch":{"post":{"operationId":"camp-dispatch","tags":["Campanhas"],"summary":"Disparar agora","description":"Escopo: `campaigns:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/pause":{"post":{"operationId":"camp-pause","tags":["Campanhas"],"summary":"Pausar","description":"Escopo: `campaigns:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/resume":{"post":{"operationId":"camp-resume","tags":["Campanhas"],"summary":"Retomar","description":"Escopo: `campaigns:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/cancel":{"post":{"operationId":"camp-cancel","tags":["Campanhas"],"summary":"Cancelar","description":"Escopo: `campaigns:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"waba_id":{"type":"string"},"totals":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}}}},"example":{"id":"7c3a…","name":"Black Friday","status":"rascunho","waba_id":"1095419929937194","totals":{"total":1200,"sent":0,"delivered":0,"read":0,"replied":0,"failed":0,"skipped":0}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/results":{"get":{"operationId":"camp-results","tags":["Campanhas"],"summary":"Resultados","description":"Funil, erros por motivo (com explicação) e contagem por variante.\n\nEscopo: `campaigns:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"funnel":{"type":"object","properties":{"total":{"type":"integer"},"sent":{"type":"integer"},"delivered":{"type":"integer"},"read":{"type":"integer"},"replied":{"type":"integer"},"failed":{"type":"integer"},"skipped":{"type":"integer"}}},"errors":{"type":"array","items":{"type":"object","properties":{"meta_code":{"type":"string"},"count":{"type":"integer"},"title":{"type":"string"},"explanation":{"type":"string"},"action":{"type":"string"}}}},"variants":{"type":"array","items":{"type":"object","properties":{"variant":{"type":"integer"},"template_name":{"type":"string"},"counts":{"type":"object","properties":{"lido":{"type":"integer"}}}}}}}},"example":{"funnel":{"total":1200,"sent":1180,"delivered":1150,"read":900,"replied":120,"failed":20,"skipped":0},"errors":[{"meta_code":"131049","count":12,"title":"Meta limitou mensagens de marketing","explanation":"…","action":"…"}],"variants":[{"variant":0,"template_name":"promo_novembro","counts":{"lido":900}}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/recipients":{"get":{"operationId":"camp-recipients","tags":["Campanhas"],"summary":"Destinatários","description":"Escopo: `campaigns:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"status","in":"query","description":"pendente, enviado, entregue, lido, falhou…","schema":{"type":"string"}},{"name":"limit","in":"query","description":"1–500.","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Cursor.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks":{"get":{"operationId":"hooks-list","tags":["Webhooks"],"summary":"Listar webhooks","description":"Escopo: `webhooks:manage`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"hooks-create","tags":["Webhooks"],"summary":"Cadastrar webhook","description":"O segredo de assinatura (secret) é exibido só nesta resposta.\n\nEscopo: `webhooks:manage`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"secret":{"type":"string"}}},"example":{"id":"w1…","url":"https://minha-api.com/vdcrm","events":["message.received","message.status"],"secret":"whsec_…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}}}},"example":{"url":"https://minha-api.com/vdcrm","events":["message.received","message.status"]}}}}}},"/webhooks/{id}":{"patch":{"operationId":"hooks-update","tags":["Webhooks"],"summary":"Alterar webhook","description":"Escopo: `webhooks:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"active":{"type":"boolean"}}},"example":{"active":false}}}}},"delete":{"operationId":"hooks-delete","tags":["Webhooks"],"summary":"Excluir webhook","description":"Escopo: `webhooks:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}/test":{"post":{"operationId":"hooks-test","tags":["Webhooks"],"summary":"Enviar evento de teste","description":"Escopo: `webhooks:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"delivery_id":{"type":"string"},"delivered":{"type":"boolean"},"status_code":{"type":"integer"}}},"example":{"delivery_id":"d1…","delivered":true,"status_code":200}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}/deliveries":{"get":{"operationId":"hooks-deliveries","tags":["Webhooks"],"summary":"Registro de entregas","description":"Escopo: `webhooks:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhook-deliveries/{id}/redeliver":{"post":{"operationId":"hooks-redeliver","tags":["Webhooks"],"summary":"Reenviar entrega","description":"Escopo: `webhooks:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/embed/sessions":{"post":{"operationId":"embed-session","tags":["Embed"],"summary":"Criar sessão de embed (SSO)","description":"Chame do seu servidor. Devolve um token de troca de uso único (5 min) e a URL do embed. A sessão dura 30 min, é renovável até 12 h e só enxerga os números e módulos informados. Exige ao menos um domínio permitido em Configurações → Marca e embed.\n\nEscopo: `embed:create`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string"},"embed_user_id":{"type":"string"},"token":{"type":"string"},"token_expires_at":{"type":"string"},"url":{"type":"string"},"modules":{"type":"array","items":{"type":"string"}},"test":{"type":"boolean"}}},"example":{"session_id":"es1…","embed_user_id":"eu1…","token":"vdex_…","token_expires_at":"2026-11-03T15:05:00Z","url":"https://crm.vdgestaobranding.com/embed?t=vdex_…","modules":["inbox","metrics"],"test":false}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"external_id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"}}},"phone_number_refs":{"type":"array","items":{"type":"string"}},"modules":{"type":"array","items":{"type":"string"}},"permissions":{"type":"array","items":{"type":"string"}}}},"example":{"user":{"external_id":"u-123","name":"Ana","email":"ana@cliente.com"},"phone_number_refs":["a0b1…"],"modules":["inbox","metrics"],"permissions":["inbox:read","inbox:reply","metrics:read"]}}}}}},"/flows":{"get":{"operationId":"flows-list","tags":["Fluxos"],"summary":"Listar fluxos","description":"Escopo: `flows:read`.","parameters":[{"name":"status","in":"query","description":"rascunho | ativo | inativo.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"trigger_kind":{"type":"string"},"priority":{"type":"integer"},"runs_count":{"type":"integer"},"published_version_id":{"type":"string"},"shared":{"type":"boolean"},"created_at":{"type":"string"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"f1…","name":"Boas-vindas","status":"ativo","trigger_kind":"keyword","priority":0,"runs_count":42,"published_version_id":"v1…","shared":false,"created_at":"2026-11-03T15:00:00Z"}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"flows-create","tags":["Fluxos"],"summary":"Criar fluxo","description":"draft é o JSON do fluxo (nodes/edges), o mesmo do editor do CRM.\n\nEscopo: `flows:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"trigger_kind":{"type":"string"},"priority":{"type":"integer"},"runs_count":{"type":"integer"},"published_version_id":{"type":"string"},"shared":{"type":"boolean"},"created_at":{"type":"string"}}},"example":{"id":"f1…","name":"Boas-vindas","status":"ativo","trigger_kind":"keyword","priority":0,"runs_count":42,"published_version_id":"v1…","shared":false,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"draft":{"type":"object","properties":{"nodes":{"type":"array","items":{}},"edges":{"type":"array","items":{}}}}}},"example":{"name":"Boas-vindas","draft":{"nodes":[],"edges":[]}}}}}}},"/flows/{id}":{"get":{"operationId":"flows-get","tags":["Fluxos"],"summary":"Obter fluxo (JSON)","description":"Inclui o rascunho (draft) e a versão publicada (published.graph).\n\nEscopo: `flows:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"trigger_kind":{"type":"string"},"priority":{"type":"integer"},"runs_count":{"type":"integer"},"published_version_id":{"type":"string"},"shared":{"type":"boolean"},"created_at":{"type":"string"},"draft":{"type":"object","properties":{"nodes":{"type":"array","items":{}},"edges":{"type":"array","items":{}}}},"published":{"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"graph":{"type":"object","properties":{"nodes":{"type":"array","items":{}},"edges":{"type":"array","items":{}}}}}}}},"example":{"id":"f1…","name":"Boas-vindas","status":"ativo","trigger_kind":"keyword","priority":0,"runs_count":42,"published_version_id":"v1…","shared":false,"created_at":"2026-11-03T15:00:00Z","draft":{"nodes":[],"edges":[]},"published":{"id":"v1…","version":3,"graph":{"nodes":[],"edges":[]}}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"flows-update","tags":["Fluxos"],"summary":"Atualizar fluxo","description":"Altera o rascunho; publique para que passe a rodar.\n\nEscopo: `flows:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"Boas-vindas v2"}}}}},"delete":{"operationId":"flows-delete","tags":["Fluxos"],"summary":"Excluir fluxo","description":"Escopo: `flows:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/flows/{id}/publish":{"post":{"operationId":"flows-publish","tags":["Fluxos"],"summary":"Publicar e ativar","description":"Valida o fluxo (422 flow_invalid com details.issues) e respeita os limites do plano.\n\nEscopo: `flows:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"trigger_kind":{"type":"string"},"priority":{"type":"integer"},"runs_count":{"type":"integer"},"published_version_id":{"type":"string"},"shared":{"type":"boolean"},"created_at":{"type":"string"},"version":{"type":"integer"}}},"example":{"id":"f1…","name":"Boas-vindas","status":"ativo","trigger_kind":"keyword","priority":0,"runs_count":42,"published_version_id":"v1…","shared":false,"created_at":"2026-11-03T15:00:00Z","version":4}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/flows/{id}/unpublish":{"post":{"operationId":"flows-unpublish","tags":["Fluxos"],"summary":"Despublicar","description":"Desativa o fluxo e encerra as execuções em andamento.\n\nEscopo: `flows:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/flows/{id}/start":{"post":{"operationId":"flows-start","tags":["Fluxos"],"summary":"Iniciar fluxo para um contato","description":"Com a janela de 24h fechada, o primeiro envio do fluxo precisa ser um modelo aprovado. Contatos com opt-out são recusados. Chaves de teste não enviam nada.\n\nEscopo: `flows:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"started":{"type":"boolean"},"run":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"}}}}},"example":{"started":true,"run":{"id":"r1…","state":"aguardando"}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string"},"variables":{"type":"object","properties":{"pedido":{"type":"string"}}}}},"example":{"contact_id":"c1d2…","variables":{"pedido":"1234"}}}}}}},"/flows/{id}/runs":{"get":{"operationId":"flows-runs","tags":["Fluxos"],"summary":"Listar execuções","description":"Escopo: `flows:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"1–100.","schema":{"type":"integer"}},{"name":"before","in":"query","description":"ISO 8601; use next_before para paginar.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"flow_id":{"type":"string"},"contact_id":{"type":"string"},"state":{"type":"string"},"outcome":{"type":"string"},"current_node":{"type":"string"},"started_at":{"type":"string"},"finished_at":{"type":"string"}}}},"next_before":{"type":["string","null"]}}},"example":{"data":[{"id":"r1…","flow_id":"f1…","contact_id":"c1d2…","state":"concluido","outcome":"concluido","current_node":"end","started_at":"2026-11-03T15:00:00Z","finished_at":"2026-11-03T15:03:00Z"}],"next_before":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/flow-runs/{id}":{"get":{"operationId":"flow-run-get","tags":["Fluxos"],"summary":"Execução e caminho percorrido","description":"Escopo: `flows:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"flow_id":{"type":"string"},"contact_id":{"type":"string"},"state":{"type":"string"},"outcome":{"type":"string"},"current_node":{"type":"string"},"started_at":{"type":"string"},"finished_at":{"type":"string"},"variables":{"type":"object","properties":{"pedido":{"type":"string"}}},"path":{"type":"array","items":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"action":{"type":"string"},"created_at":{"type":"string"}}}}}},"example":{"id":"r1…","flow_id":"f1…","contact_id":"c1d2…","state":"concluido","outcome":"concluido","current_node":"end","started_at":"2026-11-03T15:00:00Z","finished_at":"2026-11-03T15:03:00Z","variables":{"pedido":"1234"},"path":[{"node_id":"n1","node_type":"message","action":"sent","created_at":"2026-11-03T15:00:01Z"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pipelines":{"get":{"operationId":"pipelines-list","tags":["Pipelines"],"summary":"Listar funis e etapas","description":"Escopo: `pipelines:read`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"order":{"type":"integer"},"stages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"}}}}}}}}},"example":{"data":[{"id":"p1…","name":"Vendas","order":0,"stages":[{"id":"s1…","name":"Novo","type":"open"},{"id":"s9…","name":"Ganho","type":"won"}]}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals":{"get":{"operationId":"deals-list","tags":["Pipelines"],"summary":"Listar negócios","description":"Escopo: `pipelines:read`.","parameters":[{"name":"pipeline_id","in":"query","description":"Funil.","schema":{"type":"string"}},{"name":"stage_id","in":"query","description":"Etapa.","schema":{"type":"string"}},{"name":"contact_id","in":"query","description":"Contato.","schema":{"type":"string"}},{"name":"status","in":"query","description":"aberto | ganho | perdido.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Itens por página (1–100, padrão 25).","schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"Valor de next_cursor da página anterior.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}}},"next_cursor":{"type":["string","null"]}}},"example":{"data":[{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"aberto","created_at":"2026-11-03T15:00:00Z"}],"next_cursor":null}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"deals-create","tags":["Pipelines"],"summary":"Criar negócio","description":"Sem stage_id, entra na primeira etapa do funil. contact_id vincula ao contato.\n\nEscopo: `pipelines:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"aberto","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pipeline_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"contact_id":{"type":"string"}}},"example":{"pipeline_id":"p1…","title":"Plano anual","value":4800,"contact_id":"c1d2…"}}}}}},"/deals/{id}":{"get":{"operationId":"deals-get","tags":["Pipelines"],"summary":"Obter negócio","description":"Escopo: `pipelines:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"aberto","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"deals-update","tags":["Pipelines"],"summary":"Atualizar / vincular contato","description":"Escopo: `pipelines:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"aberto","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"value":{"type":"integer"},"contact_id":{"type":"string"}}},"example":{"value":5200,"contact_id":"c1d2…"}}}}},"delete":{"operationId":"deals-delete","tags":["Pipelines"],"summary":"Excluir negócio","description":"Escopo: `pipelines:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals/{id}/move":{"post":{"operationId":"deals-move","tags":["Pipelines"],"summary":"Mover de etapa","description":"Dispara o webhook deal.stage_changed.\n\nEscopo: `pipelines:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"aberto","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"stage_id":{"type":"string"}}},"example":{"stage_id":"s2…"}}}}}},"/deals/{id}/win":{"post":{"operationId":"deals-win","tags":["Pipelines"],"summary":"Marcar como ganho","description":"Escopo: `pipelines:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"ganho","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals/{id}/lose":{"post":{"operationId":"deals-lose","tags":["Pipelines"],"summary":"Marcar como perdido","description":"Escopo: `pipelines:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"pipeline_id":{"type":"string"},"stage_id":{"type":"string"},"contact_id":{"type":"string"},"title":{"type":"string"},"value":{"type":"integer"},"owner_id":{"type":["string","null"]},"expected_close":{"type":"string"},"tags":{"type":"array","items":{}},"notes":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}}},"example":{"id":"d1…","pipeline_id":"p1…","stage_id":"s1…","contact_id":"c1d2…","title":"Plano anual","value":4800,"owner_id":null,"expected_close":"2026-12-01","tags":[],"notes":null,"status":"perdido","created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/accounts":{"get":{"operationId":"accounts-list","tags":["Contas e números"],"summary":"BMs, WABAs e números","description":"Árvore BM → WABA → número com qualidade, limite, uso nas últimas 24h, registro e verificação.\n\nEscopo: `accounts:read`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"business_id":{"type":"string"},"name":{"type":"string"},"verification_status":{"type":"string"},"wabas":{"type":"array","items":{"type":"object","properties":{"waba_id":{"type":"string"},"name":{"type":"string"},"phone_numbers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"phone_number_id":{"type":"string"},"display_phone_number":{"type":"string"},"verified_name":{"type":"string"},"quality_rating":{"type":"string"},"messaging_limit_tier":{"type":"string"},"status":{"type":"string"},"registration":{"type":"object","properties":{"registered":{"type":"boolean"},"requires_registration":{"type":"boolean"},"coexistence":{"type":"boolean"}}},"verification":{"type":"object","properties":{"code_verification_status":{"type":"string"}}},"usage_24h":{"type":"object","properties":{"unique_contacts_24h":{"type":"integer"},"max_daily_7d":{"type":"integer"}}}}}}}}}}}}}},"example":{"data":[{"id":"b1…","business_id":"4511…","name":"Minha empresa","verification_status":"verified","wabas":[{"waba_id":"1095419929937194","name":"Atendimento","phone_numbers":[{"id":"a0b1…","phone_number_id":"1340490742483622","display_phone_number":"+55 55 92482-1431","verified_name":"Suporte Comercial","quality_rating":"GREEN","messaging_limit_tier":"TIER_1K","status":"CONNECTED","registration":{"registered":true,"requires_registration":false,"coexistence":false},"verification":{"code_verification_status":"VERIFIED"},"usage_24h":{"unique_contacts_24h":120,"max_daily_7d":380}}]}]}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/{id}":{"get":{"operationId":"phone-get","tags":["Contas e números"],"summary":"Detalhes do número","description":"Escopo: `accounts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"phone_number_id":{"type":"string"},"display_phone_number":{"type":"string"},"verified_name":{"type":"string"},"quality_rating":{"type":"string"},"messaging_limit_tier":{"type":"string"},"status":{"type":"string"},"registration":{"type":"object","properties":{"registered":{"type":"boolean"},"requires_registration":{"type":"boolean"},"coexistence":{"type":"boolean"}}},"verification":{"type":"object","properties":{"code_verification_status":{"type":"string"}}},"usage_24h":{"type":"object","properties":{"unique_contacts_24h":{"type":"integer"},"max_daily_7d":{"type":"integer"}}}}},"example":{"id":"a0b1…","phone_number_id":"1340490742483622","display_phone_number":"+55 55 92482-1431","verified_name":"Suporte Comercial","quality_rating":"GREEN","messaging_limit_tier":"TIER_1K","status":"CONNECTED","registration":{"registered":true,"requires_registration":false,"coexistence":false},"verification":{"code_verification_status":"VERIFIED"},"usage_24h":{"unique_contacts_24h":120,"max_daily_7d":380}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/{id}/sync":{"post":{"operationId":"phone-sync","tags":["Contas e números"],"summary":"Sincronizar com a Meta","description":"Escopo: `accounts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"synced":{"type":"boolean"},"phone":{"type":"object","properties":{"id":{"type":"string"},"phone_number_id":{"type":"string"},"display_phone_number":{"type":"string"},"verified_name":{"type":"string"},"quality_rating":{"type":"string"},"messaging_limit_tier":{"type":"string"},"status":{"type":"string"},"registration":{"type":"object","properties":{"registered":{"type":"boolean"},"requires_registration":{"type":"boolean"},"coexistence":{"type":"boolean"}}},"verification":{"type":"object","properties":{"code_verification_status":{"type":"string"}}},"usage_24h":{"type":"object","properties":{"unique_contacts_24h":{"type":"integer"},"max_daily_7d":{"type":"integer"}}}}}}},"example":{"synced":true,"phone":{"id":"a0b1…","phone_number_id":"1340490742483622","display_phone_number":"+55 55 92482-1431","verified_name":"Suporte Comercial","quality_rating":"GREEN","messaging_limit_tier":"TIER_1K","status":"CONNECTED","registration":{"registered":true,"requires_registration":false,"coexistence":false},"verification":{"code_verification_status":"VERIFIED"},"usage_24h":{"unique_contacts_24h":120,"max_daily_7d":380}}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/{id}/profile":{"get":{"operationId":"phone-profile","tags":["Contas e números"],"summary":"Obter foto e nome do perfil","description":"Escopo: `accounts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"profile_picture_url":{"type":"string"},"verified_name":{"type":"string"},"name_status":{"type":"string"}}},"example":{"profile_picture_url":"https://…","verified_name":"Suporte Comercial","name_status":"APPROVED"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone-numbers/{id}/profile/photo":{"post":{"operationId":"phone-photo","tags":["Contas e números"],"summary":"Atualizar foto do perfil","description":"JPG ou PNG (até 5 MB, mínimo 192×192). Envie file_url (https) ou media_id de POST /media.\n\nEscopo: `accounts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"updated":{"type":"boolean"},"profile_picture_url":{"type":"string"}}},"example":{"updated":true,"profile_picture_url":"https://…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"file_url":{"type":"string"}}},"example":{"file_url":"https://exemplo.com/logo.jpg"}}}}}},"/phone-numbers/{id}/display-name":{"get":{"operationId":"phone-name","tags":["Contas e números"],"summary":"Ler o nome","description":"Escopo: `accounts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"verified_name":{"type":"string"},"name_status":{"type":"string"},"request":{"type":["string","null"]},"notice":{"type":"string"}}},"example":{"verified_name":"Suporte Comercial","name_status":"APPROVED","request":null,"notice":"A troca de nome é analisada pela Meta…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"phone-name-req","tags":["Contas e números"],"summary":"Solicitar troca de nome","description":"A Meta analisa o novo nome (normalmente de 1 a 3 dias). O nome atual continua até a aprovação.\n\nEscopo: `accounts:write`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"requested":{"type":"boolean"},"status":{"type":"string"},"notice":{"type":"string"}}},"example":{"requested":true,"status":"PENDING_REVIEW","notice":"A troca de nome é analisada pela Meta…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"Loja Exemplo"}}}}}},"/connect-sessions":{"post":{"operationId":"connect-create","tags":["Contas e números"],"summary":"Criar link de conexão","description":"Gera um link de uso único (30 min) para o cliente abrir o Embedded Signup da Meta numa página do VD CRM. Ao concluir, é enviado phone_number.connected; em caso de erro, connect_session.failed com a etapa. Com chave de teste, a página simula a conexão. mode: \"new\" (número novo, padrão) ou \"coexistence\" (conectar um número que já está no app WhatsApp Business; sem PIN/registro, até 6 meses de histórico, o app continua funcionando). Passo a passo para o cliente no modo coexistence: (1) na janela da Meta, digite no campo de telefone o número que está no app WhatsApp Business; (2) no app chegará uma mensagem da conta oficial do Facebook Business: toque em \"Conectar\" → \"Conectar-se à Plataforma do WhatsApp Business\" → confirme o compartilhamento do histórico; (3) copie o código de verificação e cole na janela da Meta; (4) conclua a janela; (5) mantenha o app aberto durante a sincronização. Se a janela avisar que o número será removido do app, pare e fale com o suporte.\n\nEscopo: `accounts:write`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string"},"status":{"type":"string"},"url":{"type":"string"},"expires_at":{"type":"string"}}},"example":{"session_id":"cs1…","status":"pending","url":"https://crm.vdgestaobranding.com/conectar/…","expires_at":"2026-11-03T15:30:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"redirect_url":{"type":"string"},"mode":{"type":"string"}}},"example":{"redirect_url":"https://meu-sistema.com/conectado","mode":"coexistence"}}}}}},"/connect-sessions/{id}":{"get":{"operationId":"connect-get","tags":["Contas e números"],"summary":"Status da conexão","description":"status: pending | processing | completed | failed | expired.\n\nEscopo: `accounts:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string"},"status":{"type":"string"},"step":{"type":"string"},"waba_id":{"type":"string"},"phone_number_id":{"type":"string"}}},"example":{"session_id":"cs1…","status":"completed","step":"done","waba_id":"1095…","phone_number_id":"1340…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/metrics":{"get":{"operationId":"metrics-get","tags":["Métricas"],"summary":"Indicadores do período","description":"Disparos (campanhas) e atendimento separados, os mesmos números do painel. Padrão: últimos 30 dias.\n\nEscopo: `metrics:read`.","parameters":[{"name":"from","in":"query","description":"ISO 8601.","schema":{"type":"string"}},{"name":"to","in":"query","description":"ISO 8601.","schema":{"type":"string"}},{"name":"phone_number_ref","in":"query","description":"Filtrar por número.","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}}},"metrics":{"type":"object","properties":{"campaigns":{"type":"object","properties":{"sent":{"type":"integer"},"delivered":{"type":"integer"}}},"attendance":{"type":"object","properties":{"conversations":{"type":"integer"}}}}}}},"example":{"period":{"from":"2026-10-01T00:00:00Z","to":"2026-11-01T00:00:00Z"},"metrics":{"campaigns":{"sent":1200,"delivered":1150},"attendance":{"conversations":300}}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports":{"post":{"operationId":"reports-create","tags":["Métricas"],"summary":"Gerar relatório","description":"Assíncrono. Ao ficar pronto, envia report.ready; consulte GET /reports/{id} para a URL de download (válida por 1 h).\n\nEscopo: `metrics:read`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"202":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"}}},"example":{"id":"rp1…","status":"queued"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"format":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"}}},"example":{"format":"xlsx","from":"2026-10-01T00:00:00Z","to":"2026-11-01T00:00:00Z"}}}}}},"/reports/{id}":{"get":{"operationId":"reports-get","tags":["Métricas"],"summary":"Status / download do relatório","description":"Escopo: `metrics:read`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"format":{"type":"string"},"download_url":{"type":"string"}}},"example":{"id":"rp1…","status":"ready","format":"xlsx","download_url":"https://…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/operations":{"get":{"operationId":"ops-list","tags":["Equipe e operações"],"summary":"Listar operações da conta","description":"Escopo: `team:manage`.\n\n**Com chave de conta (operations:manage):** Listar operações (clientes finais). Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. Filtre por external_id para achar a operação de um cliente do seu sistema.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"archived":{"type":"boolean"},"current":{"type":"boolean"}}}},"quota":{"type":"object","properties":{"plan":{"type":"string"},"cap":{"type":"integer"},"used":{"type":"integer"},"allowed":{"type":"boolean"}}}}},"example":{"data":[{"id":"o1…","name":"Loja Centro","slug":"loja-centro","archived":false,"current":true}],"quota":{"plan":"Profissional","cap":3,"used":1,"allowed":true}}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"ops-create","tags":["Equipe e operações"],"summary":"Criar operação","description":"Respeita o limite de operações do plano (403 plan_limit).\n\nEscopo: `team:manage`.\n\n**Com chave de conta (operations:manage):** Criar operação para um cliente final. Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. external_id é único na conta (409 external_id_taken se repetido, com operation_id existente).","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"slug":{"type":"string"},"name":{"type":"string"}}},"example":{"id":"o2…","slug":"loja-norte","name":"Loja Norte"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"color":{"type":"string"},"icon":{"type":"string"}}},"example":{"name":"Loja Norte","color":"cyan","icon":"store"}}}}}},"/members":{"get":{"operationId":"members-list","tags":["Equipe e operações"],"summary":"Listar membros e convites","description":"Escopo: `team:manage`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"profile":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"}},"phone_ids":{"type":["string","null"]},"operation_ids":{"type":"array","items":{"type":"string"}}}}},"pending_invitations":{"type":"array","items":{}}}},"example":{"data":[{"user_id":"u1…","name":"Ana","email":"ana@exemplo.com","role":"atendente","profile":"personalizado","permissions":["inbox.assigned","inbox.reply","templates.view"],"phone_ids":null,"operation_ids":["o1…"]}],"pending_invitations":[]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"members-invite","tags":["Equipe e operações"],"summary":"Convidar membro","description":"profile: admin | gerente | atendente | disparador | personalizado (role admin/atendente continua aceito). permissions: lista de permissões (ex.: inbox.all, inbox.assigned, inbox.reply, leads.view, templates.view, campaigns.dispatch…); sem permissions, o perfil pronto é aplicado. operation_ids: operações liberadas (padrão: a da chave). phone_ids: números liberados (null = todos). Respeita o limite de usuários do plano.\n\nEscopo: `team:manage`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"profile":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"}},"operation_ids":{"type":"array","items":{"type":"string"}},"phone_ids":{"type":["string","null"]}}},"example":{"email":"ana@exemplo.com","profile":"personalizado","permissions":["inbox.assigned","inbox.reply","templates.view"],"operation_ids":["o1…"],"phone_ids":null}}}}}},"/members/{id}":{"patch":{"operationId":"members-update","tags":["Equipe e operações"],"summary":"Alterar perfil e permissões","description":"Altera perfil, permissões, operações e números liberados; vale na hora e fica no histórico. Mudar permissões de um perfil pronto o torna Personalizado. O owner e o criador da chave não podem ser alterados.\n\nEscopo: `team:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"profile":{"type":"string"},"operation_ids":{"type":"array","items":{"type":"string"}},"phone_ids":{"type":["string","null"]}}},"example":{"profile":"gerente","operation_ids":["o1…","o2…"],"phone_ids":null}}}}},"delete":{"operationId":"members-remove","tags":["Equipe e operações"],"summary":"Remover membro","description":"Escopo: `team:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/quick-replies":{"get":{"operationId":"quick-replies-list","tags":["Respostas rápidas"],"summary":"Listar respostas rápidas","description":"Escopo: `settings:manage`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"shortcut":{"type":"string"},"text":{"type":"string"}}}}}},"example":{"data":[{"id":"x1…","shortcut":"/ola","text":"Olá! Como posso ajudar?"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"quick-replies-create","tags":["Respostas rápidas"],"summary":"Criar","description":"Escopo: `settings:manage`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"shortcut":{"type":"string"},"text":{"type":"string"}}},"example":{"id":"x1…","shortcut":"/ola","text":"Olá! Como posso ajudar?"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"shortcut":{"type":"string"},"text":{"type":"string"}}},"example":{"shortcut":"/ola","text":"Olá! Como posso ajudar?"}}}}}},"/quick-replies/{id}":{"patch":{"operationId":"quick-replies-update","tags":["Respostas rápidas"],"summary":"Atualizar","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"shortcut":{"type":"string"},"text":{"type":"string"}}},"example":{"shortcut":"/ola","text":"Olá! Como posso ajudar?"}}}}},"delete":{"operationId":"quick-replies-delete","tags":["Respostas rápidas"],"summary":"Excluir","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tags":{"get":{"operationId":"tags-list","tags":["Tags"],"summary":"Listar tags","description":"Escopo: `settings:manage`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"color":{"type":"string"}}}}}},"example":{"data":[{"id":"x1…","name":"vip","color":"amber"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"tags-create","tags":["Tags"],"summary":"Criar","description":"Escopo: `settings:manage`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"color":{"type":"string"}}},"example":{"id":"x1…","name":"vip","color":"amber"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"color":{"type":"string"}}},"example":{"name":"vip","color":"amber"}}}}}},"/tags/{id}":{"patch":{"operationId":"tags-update","tags":["Tags"],"summary":"Atualizar","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"color":{"type":"string"}}},"example":{"name":"vip","color":"amber"}}}}},"delete":{"operationId":"tags-delete","tags":["Tags"],"summary":"Excluir","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/departments":{"get":{"operationId":"departments-list","tags":["Departamentos"],"summary":"Listar departamentos","description":"Escopo: `settings:manage`.","parameters":[],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}}}}},"example":{"data":[{"id":"x1…","name":"Suporte"}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"departments-create","tags":["Departamentos"],"summary":"Criar","description":"Escopo: `settings:manage`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"example":{"id":"x1…","name":"Suporte"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"Suporte"}}}}}},"/departments/{id}":{"patch":{"operationId":"departments-update","tags":["Departamentos"],"summary":"Atualizar","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}},"example":{"name":"Suporte"}}}}},"delete":{"operationId":"departments-delete","tags":["Departamentos"],"summary":"Excluir","description":"Escopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/departments/{id}/members":{"post":{"operationId":"departments-members","tags":["Departamentos"],"summary":"Definir membros do departamento","description":"Substitui a lista. Somente usuários com acesso a esta operação.\n\nEscopo: `settings:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"user_ids":{"type":"array","items":{"type":"string"}}}},"example":{"user_ids":["u1…"]}}}}}},"/operations/{id}":{"get":{"operationId":"acct-ops-get","tags":["Conta parceira"],"summary":"Obter operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `operations:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"external_id":{"type":"string"},"slug":{"type":"string"},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"cnpj":{"type":"string"},"archived":{"type":"boolean"},"created_at":{"type":"string"}}},"example":{"id":"op1…","name":"Cliente Exemplo Ltda","external_id":"cli-42","slug":"cliente-exemplo","color":null,"icon":null,"cnpj":"12345678000190","archived":false,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"acct-ops-update","tags":["Conta parceira"],"summary":"Atualizar operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `operations:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"external_id":{"type":"string"},"slug":{"type":"string"},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"cnpj":{"type":"string"},"archived":{"type":"boolean"},"created_at":{"type":"string"}}},"example":{"id":"op1…","name":"Cliente Exemplo Ltda","external_id":"cli-42","slug":"cliente-exemplo","color":null,"icon":null,"cnpj":"12345678000190","archived":false,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"external_id":{"type":"string"}}},"example":{"name":"Cliente Exemplo","external_id":"cli-42"}}}}}},"/operations/{id}/archive":{"post":{"operationId":"acct-ops-archive","tags":["Conta parceira"],"summary":"Arquivar operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. Chamadas a uma operação arquivada retornam 409 operation_archived.\n\nEscopo: `operations:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"external_id":{"type":"string"},"slug":{"type":"string"},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"cnpj":{"type":"string"},"archived":{"type":"boolean"},"created_at":{"type":"string"}}},"example":{"id":"op1…","name":"Cliente Exemplo Ltda","external_id":"cli-42","slug":"cliente-exemplo","color":null,"icon":null,"cnpj":"12345678000190","archived":true,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/operations/{id}/restore":{"post":{"operationId":"acct-ops-restore","tags":["Conta parceira"],"summary":"Restaurar operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `operations:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"external_id":{"type":"string"},"slug":{"type":"string"},"color":{"type":["string","null"]},"icon":{"type":["string","null"]},"cnpj":{"type":"string"},"archived":{"type":"boolean"},"created_at":{"type":"string"}}},"example":{"id":"op1…","name":"Cliente Exemplo Ltda","external_id":"cli-42","slug":"cliente-exemplo","color":null,"icon":null,"cnpj":"12345678000190","archived":false,"created_at":"2026-11-03T15:00:00Z"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/operations/{id}/keys":{"get":{"operationId":"acct-keys-list","tags":["Conta parceira"],"summary":"Listar chaves da operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `keys:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"expires_at":{"type":["string","null"]},"created_at":{"type":"string"},"last_used_at":{"type":["string","null"]},"revoked_at":{"type":["string","null"]}}}}}},"example":{"data":[{"id":"k1…","name":"Back-end JMR","mode":"live","prefix":"vdk_live_ab12","scopes":["inbox:write"],"expires_at":null,"created_at":"2026-11-03T15:00:00Z","last_used_at":null,"revoked_at":null}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"acct-keys-create","tags":["Conta parceira"],"summary":"Criar chave de operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. A chave completa aparece só nesta resposta; guarde-a em um cofre de segredos. Chave de conta de teste só emite chaves de teste. Máximo de 25 chaves ativas por operação.\n\nEscopo: `keys:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mode":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"key":{"type":"string"}}},"example":{"id":"k1…","name":"Back-end JMR","mode":"live","prefix":"vdk_live_ab12","scopes":["inbox:read","inbox:write"],"key":"vdk_live_…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"mode":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"expires_at":{"type":["string","null"]},"allowed_ips":{"type":"array","items":{}}}},"example":{"name":"Back-end JMR","mode":"live","scopes":["inbox:read","inbox:write","contacts:write","webhooks:manage"],"expires_at":null,"allowed_ips":[]}}}}}},"/operations/{id}/keys/{keyId}":{"delete":{"operationId":"acct-keys-revoke","tags":["Conta parceira"],"summary":"Revogar chave de operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. Efeito imediato.\n\nEscopo: `keys:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"keyId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/operations/{id}/embed/sessions":{"post":{"operationId":"acct-embed-session","tags":["Conta parceira"],"summary":"Criar sessão de embed para um usuário final","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. Mesmo corpo de POST /embed/sessions; external_user_id é um atalho para user.external_id.\n\nEscopo: `embed:create`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string"},"token":{"type":"string"},"url":{"type":"string"},"modules":{"type":"array","items":{"type":"string"}},"test":{"type":"boolean"}}},"example":{"session_id":"es1…","token":"vdex_…","url":"https://crm.vdgestaobranding.com/embed?t=vdex_…","modules":["inbox"],"test":false}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"external_id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"}}},"modules":{"type":"array","items":{"type":"string"}},"permissions":{"type":"array","items":{"type":"string"}},"phone_number_refs":{"type":"array","items":{"type":"string"}}}},"example":{"user":{"external_id":"u-123","name":"Ana","email":"ana@cliente.com"},"modules":["inbox"],"permissions":["inbox:read","inbox:reply"],"phone_number_refs":["a0b1…"]}}}}}},"/operations/{id}/connect-sessions":{"post":{"operationId":"acct-connect-create","tags":["Conta parceira"],"summary":"Criar link de conexão do WhatsApp","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave. Link de uso único (30 min) para o cliente final abrir a janela da Meta. Ao concluir: webhook phone_number.connected; em erro: connect_session.failed.\n\nEscopo: `connect:create`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string"},"status":{"type":"string"},"expires_at":{"type":"string"},"operation_id":{"type":"string"},"url":{"type":"string"}}},"example":{"session_id":"cs1…","status":"pending","expires_at":"2026-11-03T15:30:00Z","operation_id":"op1…","url":"https://crm.vdgestaobranding.com/conectar/…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"redirect_url":{"type":"string"}}},"example":{"redirect_url":"https://painel.parceiro.com/whatsapp/conectado"}}}}}},"/operations/{id}/members":{"get":{"operationId":"acct-members-list","tags":["Conta parceira"],"summary":"Listar membros com acesso à operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `members:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"user_id":{"type":"string"},"email":{"type":"string"},"role":{"type":"string"},"operation_ids":{"type":"array","items":{"type":"string"}}}}}}},"example":{"data":[{"user_id":"u1…","email":"ana@cliente.com","role":"atendente","operation_ids":["op1…"]}]}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"acct-members-invite","tags":["Conta parceira"],"summary":"Convidar membro para a operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `members:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Repete a mesma resposta por 24 h.","schema":{"type":"string","maxLength":255}}],"responses":{"201":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{}},"example":{}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"role":{"type":"string"}}},"example":{"email":"ana@cliente.com","role":"atendente"}}}}}},"/operations/{id}/members/{userId}":{"patch":{"operationId":"acct-members-update","tags":["Conta parceira"],"summary":"Alterar perfil do membro","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `members:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso","content":{"application/json":{"schema":{"type":"object","properties":{"user_id":{"type":"string"},"role":{"type":"string"},"operation_id":{"type":"string"}}},"example":{"user_id":"u1…","role":"admin","operation_id":"op1…"}}}},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string"}}},"example":{"role":"admin"}}}}},"delete":{"operationId":"acct-members-remove","tags":["Conta parceira"],"summary":"Remover acesso de atendente à operação","description":"Requer chave de conta (vdk_acct_live_… / vdk_acct_test_…), plano Agência ou Enterprise. A operação precisa pertencer à conta da chave.\n\nEscopo: `members:manage`.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Sem conteúdo"},"default":{"description":"Erro","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}