{"openapi":"3.0.3","info":{"title":"Flexa Go CRM — API de Integrações","version":"1.0.0","description":"Tokens por ambiente; contatos e negociações com controle de duplicidade. Requisições de servidor para servidor."},"servers":[{"url":"https://crm.flexago.com.br/api/v1"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"fg_api_…"}}},"paths":{"/account":{"get":{"summary":"Validar token e consultar ambiente","description":"Retorna id, nome, fuso, permissões e ID do token. Nenhum workspace_id precisa ser informado.","operationId":"get_account","tags":["account"],"security":[{"bearerAuth":[]}],"parameters":[],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/pipelines":{"get":{"summary":"Listar funis e etapas","description":"Cada funil retorna suas etapas com id, nome, posição e tipo: open, won ou lost. Escopo: pipelines:read.","operationId":"get_pipelines","tags":["pipelines"],"security":[{"bearerAuth":[]}],"parameters":[],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/custom-fields":{"get":{"summary":"Listar campos personalizados","description":"Filtre por ?entity=contact ou ?entity=lead. Use o id retornado para preencher fields. Escopo: fields:read.","operationId":"get_custom_fields","tags":["custom-fields"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"entity","schema":{"type":"string","enum":["contact","lead"]}}],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}},"post":{"summary":"Criar definição de campo","description":"Cria um campo e retorna seu UUID estável. Mesmo nome/entidade já existente retorna 409. Escopo: fields:write.","operationId":"post_custom_fields","tags":["custom-fields"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["name","entity","type"],"properties":{"name":{"type":"string","maxLength":100},"entity":{"type":"string","enum":["contact","lead"]},"type":{"type":"string","enum":["text","number","boolean","date","select"]},"options":{"type":"array","maxItems":100,"items":{"type":"string"},"description":"Obrigatório e não vazio para select; deve ficar vazio nos outros tipos."}}}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"201":{"description":"Registro criado.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/contacts":{"get":{"summary":"Consultar contatos","description":"Lista paginada. Filtros: phone, source, created_since, limit e cursor. Escopo: contacts:read.","operationId":"get_contacts","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"in":"query","name":"source","schema":{"type":"string"}},{"in":"query","name":"created_since","schema":{"type":"string"}},{"in":"query","name":"phone","schema":{"type":"string"}}],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}},"post":{"summary":"Criar ou reutilizar contato","description":"name e phone obrigatórios. Reutiliza telefone equivalente. Preserva nome/e-mail existentes; fields e atribuição recebidos são mesclados. Escopo: contacts:write.","operationId":"post_contacts","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":150},"phone":{"type":"string","description":"Telefone brasileiro completo com DDD ou internacional com +país. Ex.: +5541999990000."},"email":{"type":"string","format":"email","nullable":true},"fields":{"type":"object","description":"Objeto UUID do campo → valor. null limpa apenas o valor indicado. Outros campos são preservados.","additionalProperties":{"oneOf":[{"type":"string","nullable":true},{"type":"number"},{"type":"boolean"}]}},"attribution":{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","maxLength":1000},"medium":{"type":"string","maxLength":1000},"campaign":{"type":"string","maxLength":1000},"utm_source":{"type":"string","maxLength":1000},"utm_medium":{"type":"string","maxLength":1000},"utm_campaign":{"type":"string","maxLength":1000},"utm_content":{"type":"string","maxLength":1000},"utm_term":{"type":"string","maxLength":1000},"landing_page":{"type":"string","maxLength":1000},"referrer":{"type":"string","maxLength":1000},"external_id":{"type":"string","maxLength":1000},"form_id":{"type":"string","maxLength":1000},"ad_id":{"type":"string","maxLength":1000},"adset_id":{"type":"string","maxLength":1000},"campaign_id":{"type":"string","maxLength":1000},"fbclid":{"type":"string","maxLength":1000},"gclid":{"type":"string","maxLength":1000}}},"stop_sends":{"type":"boolean"}},"required":["name","phone"]}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"201":{"description":"Registro criado.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/contacts/{id}":{"get":{"summary":"Consultar um contato","description":"Retorna cadastro, fields, preferências e atribuição. ID de outro ambiente retorna 404. Escopo: contacts:read.","operationId":"get_contacts__id_","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}},"patch":{"summary":"Atualizar contato","description":"Altera apenas propriedades informadas. Para trocar telefone, exige que o novo telefone não pertença a outro contato. Escopo: contacts:write.","operationId":"patch_contacts__id_","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":150},"phone":{"type":"string","description":"Telefone brasileiro completo com DDD ou internacional com +país. Ex.: +5541999990000."},"email":{"type":"string","format":"email","nullable":true},"fields":{"type":"object","description":"Objeto UUID do campo → valor. null limpa apenas o valor indicado. Outros campos são preservados.","additionalProperties":{"oneOf":[{"type":"string","nullable":true},{"type":"number"},{"type":"boolean"}]}},"attribution":{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","maxLength":1000},"medium":{"type":"string","maxLength":1000},"campaign":{"type":"string","maxLength":1000},"utm_source":{"type":"string","maxLength":1000},"utm_medium":{"type":"string","maxLength":1000},"utm_campaign":{"type":"string","maxLength":1000},"utm_content":{"type":"string","maxLength":1000},"utm_term":{"type":"string","maxLength":1000},"landing_page":{"type":"string","maxLength":1000},"referrer":{"type":"string","maxLength":1000},"external_id":{"type":"string","maxLength":1000},"form_id":{"type":"string","maxLength":1000},"ad_id":{"type":"string","maxLength":1000},"adset_id":{"type":"string","maxLength":1000},"campaign_id":{"type":"string","maxLength":1000},"fbclid":{"type":"string","maxLength":1000},"gclid":{"type":"string","maxLength":1000}}},"stop_sends":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/contacts/deduplicate":{"post":{"summary":"Verificar telefone duplicado","description":"Consulta sem modificar dados. Retorna matches, count e action: create, reuse ou review. Não exige Idempotency-Key. Escopo: contacts:read.","operationId":"post_contacts_deduplicate","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["phone"],"properties":{"phone":{"type":"string","description":"Telefone brasileiro completo com DDD ou internacional com +país. Ex.: +5541999990000."}}}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/contacts/merge":{"post":{"summary":"Unir duplicados existentes","description":"União explícita, somente para telefones válidos equivalentes. Preserva auditoria e recusa vínculos ou agendamentos conflitantes. Exige também contacts:write. Escopo: contacts:merge.","operationId":"post_contacts_merge","tags":["contacts"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["keep_id","source_id"],"properties":{"keep_id":{"type":"string","format":"uuid"},"source_id":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/leads":{"get":{"summary":"Consultar negociações","description":"Filtros: contact_id, pipeline_id, stage_id, source, created_since, limit e cursor. Escopo: leads:read.","operationId":"get_leads","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"in":"query","name":"cursor","schema":{"type":"string"}},{"in":"query","name":"source","schema":{"type":"string"}},{"in":"query","name":"created_since","schema":{"type":"string"}},{"in":"query","name":"contact_id","schema":{"type":"string","format":"uuid"}},{"in":"query","name":"pipeline_id","schema":{"type":"string","format":"uuid"}},{"in":"query","name":"stage_id","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}},"post":{"summary":"Capturar lead com contato","description":"Envie contact_id existente OU name/phone e e-mail opcional. Cria contato se necessário; reutiliza a negociação aberta mais recente do mesmo contato e funil. Escopo: leads:write.","operationId":"post_leads","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"contact_id":{"type":"string","format":"uuid"},"name":{"type":"string","maxLength":150},"phone":{"type":"string","description":"Telefone brasileiro completo com DDD ou internacional com +país. Ex.: +5541999990000."},"email":{"type":"string","format":"email","nullable":true},"contact_fields":{"type":"object","description":"Objeto UUID do campo → valor. null limpa apenas o valor indicado. Outros campos são preservados.","additionalProperties":{"oneOf":[{"type":"string","nullable":true},{"type":"number"},{"type":"boolean"}]}},"title":{"type":"string","maxLength":150},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid"},"value_cents":{"type":"integer","minimum":0,"maximum":9007199254740991},"fields":{"type":"object","description":"Objeto UUID do campo → valor. null limpa apenas o valor indicado. Outros campos são preservados.","additionalProperties":{"oneOf":[{"type":"string","nullable":true},{"type":"number"},{"type":"boolean"}]}},"attribution":{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","maxLength":1000},"medium":{"type":"string","maxLength":1000},"campaign":{"type":"string","maxLength":1000},"utm_source":{"type":"string","maxLength":1000},"utm_medium":{"type":"string","maxLength":1000},"utm_campaign":{"type":"string","maxLength":1000},"utm_content":{"type":"string","maxLength":1000},"utm_term":{"type":"string","maxLength":1000},"landing_page":{"type":"string","maxLength":1000},"referrer":{"type":"string","maxLength":1000},"external_id":{"type":"string","maxLength":1000},"form_id":{"type":"string","maxLength":1000},"ad_id":{"type":"string","maxLength":1000},"adset_id":{"type":"string","maxLength":1000},"campaign_id":{"type":"string","maxLength":1000},"fbclid":{"type":"string","maxLength":1000},"gclid":{"type":"string","maxLength":1000}}}},"oneOf":[{"required":["contact_id"],"not":{"anyOf":[{"required":["name"]},{"required":["phone"]},{"required":["email"]}]}},{"required":["name","phone"],"not":{"required":["contact_id"]}}]}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"201":{"description":"Registro criado.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}},"/leads/{id}":{"get":{"summary":"Consultar uma negociação","description":"Retorna id, contact_id, pipeline_id, stage_id, título, valor, fields e atribuição. Escopo: leads:read.","operationId":"get_leads__id_","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}},"patch":{"summary":"Atualizar negociação","description":"Permite title, pipeline_id, stage_id, value_cents, fields e attribution. Para mover de funil, envie uma etapa pertencente ao destino ou será usada sua primeira etapa aberta. Escopo: leads:write.","operationId":"patch_leads__id_","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}},{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":8,"maxLength":128},"description":"Chave única por evento. Repetir chave e dados retorna o resultado por até 24 h. Chave com dados diferentes retorna 409."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"title":{"type":"string","maxLength":150},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid"},"value_cents":{"type":"integer","minimum":0,"maximum":9007199254740991},"fields":{"type":"object","description":"Objeto UUID do campo → valor. null limpa apenas o valor indicado. Outros campos são preservados.","additionalProperties":{"oneOf":[{"type":"string","nullable":true},{"type":"number"},{"type":"boolean"}]}},"attribution":{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","maxLength":1000},"medium":{"type":"string","maxLength":1000},"campaign":{"type":"string","maxLength":1000},"utm_source":{"type":"string","maxLength":1000},"utm_medium":{"type":"string","maxLength":1000},"utm_campaign":{"type":"string","maxLength":1000},"utm_content":{"type":"string","maxLength":1000},"utm_term":{"type":"string","maxLength":1000},"landing_page":{"type":"string","maxLength":1000},"referrer":{"type":"string","maxLength":1000},"external_id":{"type":"string","maxLength":1000},"form_id":{"type":"string","maxLength":1000},"ad_id":{"type":"string","maxLength":1000},"adset_id":{"type":"string","maxLength":1000},"campaign_id":{"type":"string","maxLength":1000},"fbclid":{"type":"string","maxLength":1000},"gclid":{"type":"string","maxLength":1000}}}}}}}},"responses":{"200":{"description":"Sucesso. Envelope {data,request_id}; listas incluem pagination; upserts incluem created/deduplicated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"request_id":{"type":"string","format":"uuid"},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"has_more":{"type":"boolean"},"next_cursor":{"type":"string","nullable":true}}},"replayed":{"type":"boolean"}}}}}},"400":{"description":"Formato inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"401":{"description":"Token inválido, expirado ou revogado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"403":{"description":"Escopo insuficiente ou origem de navegador","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"404":{"description":"Registro não encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"405":{"description":"Método não permitido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"409":{"description":"Conflito ou chave repetida com outros dados","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"413":{"description":"Corpo maior que 32 KB","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"415":{"description":"Content-Type inválido","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"422":{"description":"Dados ou campo incompatível","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"429":{"description":"Limite de requisições; observe Retry-After","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}},"503":{"description":"Indisponibilidade temporária","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}},"request_id":{"type":"string","format":"uuid"}}}}}}}}}}}