{"info":{"_postman_id":"d319eb3a-e829-4d3f-955e-b27e42e8d2f3","name":"Morada.ai - Documentação","description":"<html><head></head><body><p>Boas-vindas a documentação da Morada.ai!</p>\n<p>O escopo dessa documentação é o cadastro e ingestão de leads dentro da M.I.A, com cada método tendo sua especificidade detalhada.</p>\n<p>Caso haja dúvidas sobre a API, entre em contato direto com nosso time de engenharia em <a href=\"https://mailto:team.engineering@morada.ai\">team.engineering@morada.ai</a>, ou caso seja uma dúvida geral, entre em contato com nosso time de atendimento através de seu Account Manager, ou através do e-mail <a href=\"https://mailto:help@morada.ai\">help@morada.ai</a>.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"27478249","collectionId":"d319eb3a-e829-4d3f-955e-b27e42e8d2f3","publishedId":"2s9YXmZ1qL","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EE1201"},"publishDate":"2024-12-12T15:10:33.000Z"},"item":[{"name":"Integrations","item":[{"name":"Create Deal","id":"369d4259-ac18-4d6d-a76d-58ae5a6f4120","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"{{leadName}}\",\n  \"phoneNumber\": \"{{leadPhone}}\",\n  \"email\": \"{{leadEmail}}\",\n  \"productId\": \"{{productId}}\",\n  \"productExternalId\": \"{{productExternalId}}\",\n  \"partnerId\": \"\",\n  \"conversionIdentifier\": \"{{conversionIdentifier}}\",\n  \"bypassProductCheck\": {{bypassProductCheck}},\n  \"source\": \"{{source}}\",\n  \"messageTemplate\": \"{{messageTemplate}}\",\n  \"replacements\": [\"{{replacement1}}\", \"{{replacement2}}\"],\n  \"instanceId\": {{instanceId}},\n  \"externalId\": \"{{externalId}}\",\n  \"variantId\": \"{{variantId}}\",\n  \"extras\": {\n    \"campaign\": \"{{campaign}}\",\n    \"medium\": \"{{medium}}\",\n    \"returnUrl\": \"{{returnUrl}}\"\n  },\n  \"specialInstructions\": \"{{specialInstructions}}\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal","description":"<p>Cria um novo deal na plataforma.</p>\n<p>Campos obrigatórios:</p>\n<ul>\n<li><p>name: string (nome do lead)</p>\n</li>\n<li><p>phoneNumber: string|number (telefone válido)</p>\n</li>\n<li><p>source: string (origem do lead)</p>\n</li>\n</ul>\n<p>Campos opcionais:</p>\n<ul>\n<li><p>email: string (email válido)</p>\n</li>\n<li><p>productId: string (ID do produto/propriedade)</p>\n</li>\n<li><p>productExternalId: string (ID externo do produto)</p>\n</li>\n<li><p>partnerId: string (ID do parceiro, se não vier do path)</p>\n</li>\n<li><p>conversionIdentifier: string (identificador de conversão)</p>\n</li>\n<li><p>bypassProductCheck: boolean (pular validação de produto)</p>\n</li>\n<li><p>messageTemplate: string (template de mensagem para iniciar uma conversa com a MIA)</p>\n</li>\n<li><p>replacements: array de strings (substituições para o template)</p>\n</li>\n<li><p>instanceId: string|number (ID da instância do bot)</p>\n</li>\n<li><p>externalId: string|number (ID externo do deal)</p>\n</li>\n<li><p>variantId: string (ID da variante)</p>\n</li>\n<li><p>extras: object|string (dados extras - pode ser JSON string)</p>\n</li>\n<li><p>specialInstructions: string (instruções especiais)</p>\n</li>\n</ul>\n","urlObject":{"path":["","deal"],"host":[""],"query":[],"variable":[]}},"response":[{"id":"16c42dd4-c4d9-40c2-bce5-7d0df7f47e5e","name":"200 OK - Deal criado com sucesso","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\",\n  \"productId\": \"prod-123\",\n  \"source\": \"Website\",\n  \"messageTemplate\": \"message_template_name\",\n  \"replacements\": [\"João Silva\"]\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"dealId\": \"\",\n  \"message\": \"Deal created successfully\"\n}"},{"id":"1fa49dad-63fb-4579-bd3a-95e66c32fad8","name":"200 OK - Deal criado sem template de mensagem","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"Maria Santos\",\n  \"phoneNumber\": \"+5511888888888\",\n  \"email\": \"maria@email.com\",\n  \"productId\": \"prod-456\",\n  \"source\": \"Facebook\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"dealId\": \"\",\n  \"message\": \"Deal created successfully without conversation (no message template)\"\n}"},{"id":"a9c1399a-ae24-4fd1-b9e1-d7e8e58c1ff7","name":"200 OK - Deal atualizado (conversa já existe)","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"Carlos Lima\",\n  \"phoneNumber\": \"+5511777777777\",\n  \"email\": \"carlos@email.com\",\n  \"productId\": \"prod-789\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Deal updated successfully. Conversation already open\",\n  \"dealId\": \"\",\n  \"conversationId\": \"\"\n}"},{"id":"3f34c6a8-34e8-4fc3-92f9-b013af9e4efd","name":"200 OK - Criação pulada (horário de atendimento)","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"Ana Costa\",\n  \"phoneNumber\": \"+5511666666666\",\n  \"email\": \"ana@email.com\",\n  \"productId\": \"prod-101\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Lead creation skipped during service hours\",\n  \"skipped\": true\n}"},{"id":"4fa76ec2-6488-4b0f-91a4-0835ba8ba266","name":"400 Bad Request - Body ausente","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"Missing body"},{"id":"8104f95a-8c9c-4944-b657-365c0176a65d","name":"400 Bad Request - JSON inválido","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{ invalid json","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"Invalid JSON in body"},{"id":"c88d54b6-bd96-4aac-a051-f4bad13a8251","name":"400 Bad Request - Validação de payload (nome obrigatório)","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"test@email.com\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"[\n  {\n    \"code\": \"invalid_type\",\n    \"expected\": \"string\",\n    \"received\": \"undefined\",\n    \"path\": [\n      \"name\"\n    ],\n    \"message\": \"Required\"\n  }\n]"},{"id":"9357c569-f161-4cb0-bc81-13e72147c187","name":"400 Bad Request - Telefone inválido","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"123\",\n  \"email\": \"joao@email.com\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"[\n  {\n    \"code\": \"custom\",\n    \"message\": \"Invalid phone number\",\n    \"path\": [\n      \"phoneNumber\"\n    ]\n  }\n]"},{"id":"36810431-9d5d-4de7-9117-7354d121c2e5","name":"400 Bad Request - Email inválido","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"email-invalido\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"[\n  {\n    \"code\": \"invalid_string\",\n    \"validation\": \"email\",\n    \"message\": \"Invalid email\",\n    \"path\": [\n      \"email\"\n    ]\n  }\n]"},{"id":"34d2804c-59a8-4a00-9f27-7962f77913c5","name":"400 Bad Request - partnerId ausente","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\"\n}","options":{"raw":{"language":"json"}}},"url":"/deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"Missing partnerId"},{"id":"cbaee7da-37c0-49ae-a54f-f598eccd350a","name":"400 Bad Request - productExternalId inválido","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\",\n  \"productExternalId\": \"produto-inexistente\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Invalid productExternalId\"\n}"},{"id":"2614df59-c9b2-4783-9d05-275fa061ee2e","name":"400 Bad Request - Instância não encontrada","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\",\n  \"instanceId\": 99999\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"No instance found. Skipping deal creation\"\n}"},{"id":"0ac4f2e1-e97b-4055-8ab9-b217e61e2fd6","name":"400 Bad Request - Deal não criado","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Deal not created\"\n}"},{"id":"75c04e2e-6fd5-4dde-8ea7-e83c909d9fc3","name":"500 Internal Server Error","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"João Silva\",\n  \"phoneNumber\": \"+5511999999999\",\n  \"email\": \"joao@email.com\"\n}","options":{"raw":{"language":"json"}}},"url":"//deal"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"Text","header":[],"cookie":[],"responseTime":null,"body":"Internal Server Error"}],"_postman_id":"369d4259-ac18-4d6d-a76d-58ae5a6f4120"},{"name":"Ingest Lead","id":"7f9b189a-ffa1-42fc-b4d0-47fcb0a94cdd","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n   \"object\": \"page\",\n   \"entry\": [\n       {\n           \"id\": 153125381133,\n           \"time\": 1438292065,\n           \"changes\": [\n               {\n                   \"field\": \"leadgen\",\n                   \"value\": {\n                       \"leadgen_id\": 123123123123,\n                       \"page_id\": 123123123,\n                       \"form_id\": 12312312312,\n                       \"adgroup_id\": 12312312312,\n                       \"ad_id\": 12312312312,\n                       \"created_time\": 1440120384\n                   }\n               },\n               {\n                   \"field\": \"leadgen\",\n                   \"value\": {\n                       \"leadgen_id\": 123123123124,\n                       \"page_id\": 123123123,\n                       \"form_id\": 12312312312,\n                       \"adgroup_id\": 12312312312,\n                       \"ad_id\": 12312312312,\n                       \"created_time\": 1440120384\n                   }\n               }\n           ]\n       }\n   ]\n}","options":{"raw":{"language":"json"}}},"url":"/ingest-lead/{partnerConnectionId}","description":"<p>Este método serve para receber leads que geralmente vem de webhooks das mais diversas fontes, como webhooks da Meta Lead Ads e CRMs em geral.</p>\n<p>Você geralmente não precisa se preocupar com os detalhes técnicos desse endpoint, porque ele recebe as requisições esperando o formato específico que esses conectores enviam para a URL.</p>\n<p>Para gerar a URL, utilize nossa plataforma. Você precisa especificar qual serviço enviará requisições para a API, e nossa plataforma gerará um link único para essa fonte.</p>\n<p>Dessa forma, conseguimos rastrear qual a fonte que adicionou o lead, e qual o formato que esse conector usa.</p>\n","urlObject":{"path":["ingest-lead","{partnerConnectionId}"],"host":[""],"query":[],"variable":[]}},"response":[{"id":"70221c4a-6bdd-4d34-8bc6-02231e6eb012","name":"Meta Lead Ads","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n   \"object\": \"page\",\n   \"entry\": [\n       {\n           \"id\": 153125381133,\n           \"time\": 1438292065,\n           \"changes\": [\n               {\n                   \"field\": \"leadgen\",\n                   \"value\": {\n                       \"leadgen_id\": 123123123123,\n                       \"page_id\": 123123123,\n                       \"form_id\": 12312312312,\n                       \"adgroup_id\": 12312312312,\n                       \"ad_id\": 12312312312,\n                       \"created_time\": 1440120384\n                   }\n               },\n               {\n                   \"field\": \"leadgen\",\n                   \"value\": {\n                       \"leadgen_id\": 123123123124,\n                       \"page_id\": 123123123,\n                       \"form_id\": 12312312312,\n                       \"adgroup_id\": 12312312312,\n                       \"ad_id\": 12312312312,\n                       \"created_time\": 1440120384\n                   }\n               }\n           ]\n       }\n   ]\n}","options":{"raw":{"language":"json"}}},"url":"/ingest-lead/{partnerConnectionId}"},"status":"OK","code":200,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null},{"id":"6e1762e9-aacf-4f1e-b26b-eef99c6efdf9","name":"CV CRM","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n      \"idlead\": \"1\",\n      \"gestor\": {\n        \"id\": \"217\",\n        \"nome\": \"José da Silva\",\n        \"email\": \"josedasilva@souexemplo.com\"\n      },\n      \"imobiliaria\": {\n        \"id\": \"123\",\n        \"nome\": \"Imobiliária de Imóveis\"\n      },\n      \"corretor\": {\n        \"id\": \"48\",\n        \"nome\": \"João dos Santos\",\n        \"email\": \"joaodossantos@souexemplo.com\"\n      },\n      \"situacao\": {\n        \"id\": \"1\",\n        \"nome\": \"Novo Lead\"\n      },\n      \"nome\": \"Maria das Neves\",\n      \"email\": \"mariadasneves@email.com\",\n      \"telefone\": \"+55(79) 99999-9999\",\n      \"score\": \"5\",\n      \"data_cad\": \"2020-03-19 18:12:05\",\n      \"midia_principal\": \"Facebook Ads\",\n      \"documento_tipo\": \"cpf\",\n      \"documento\": \"76789571574\",\n      \"sexo\": \"F\",\n      \"renda_familiar\": \"3500.00\",\n      \"cep\": \"49030420\",\n      \"numero\": \"16516\",\n      \"bairro\": \"Farolândia\",\n      \"complemento\": \"Condominio Vale do Ribeiro\",\n      \"estado\": \"Sergipe\",\n      \"cidade\": \"Aracaju\",\n      \"profissao\": \"Enfermeiro(a)\",\n      \"origem\": \"Facebook\",\n      \"data_reativacao\": \"2021-08-07 10:20:25\",\n      \"data_vencimento\": \"2021-08-07 11:20:25\",\n      \"ultima_data_conversao\": \"2021-08-07 11:20:25\",\n      \"empreendimentos\": [\n        {\n          \"id\": \"3\",\n          \"nome\": \"Empreendimento Vila Verde\"\n        }\n      ],\n      \"midias\": [\n        \"Facebook Ads\"\n      ],\n      \"tags\": [\n        \"tag-do-lead\"\n      ],\n      \"data_cancelamento\": \"2021-08-12 16:20:25\",\n      \"descricao_motivo_cancelamento\": \"Lead perdeu interesse\",\n      \"motivo_cancelamento\": {\n        \"id\": \"1\",\n        \"nome\": \"Cancelamento em lote\",\n        \"descricao\": \"Lead foi ancelado em lote\"\n      },\n      \"data_venda\": \"2021-08-15 18:50:25\",\n      \"campos_adicionais\": [\n        {\n          \"slug\": \"cf_renda_customizada\",\n          \"valor\": \"Entre R$5.000,00 e R$10.000,00\"\n        }\n      ],\n      \"interacao\": [\n        {\n          \"id\": \"3254\",\n          \"descricao\": \"Tentei entrar em contato e o cliente não atendeu.\",\n          \"data_cad\": \"2021-08-12 16:15:00\"\n        }\n      ]\n    }","options":{"raw":{"language":"json"}}},"url":"/ingest-lead/{partnerConnectionId}"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null}],"_postman_id":"7f9b189a-ffa1-42fc-b4d0-47fcb0a94cdd"},{"name":"Create Deal (deprecated)","id":"3a4aae58-adc2-4ba4-a405-686418356b73","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"name\": \"João da Silva\",\n    \"email\": \"joao@silva.com\",\n    \"phoneNumber\": \"31992342344\",\n    \"productId\": \"4c8a4bc9-48f8-4255-bf70-83b4120861f8\",\n    \"conversionIdentifier\": \"SITE-1234\",\n    \"source\": \"Site-Partner\",\n    \"messageTemplate\": \"whatsapp_message_template\",\n    \"extras\": {\n        \"any\": \"thing\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"/create-deal/{integrationId}","description":"<p><strong>Este endpoint está depreciado e será removido em versões futuras da API</strong></p>\n<p>Este método cria o lead na base da M.I.A, e baseado nos dados enviados, envia uma mensagem ativa para o lead iniciar a interação através do canal configurado.</p>\n<p>O parâmetro <code>integrationId</code> será fornecido pelo time da Morada para configuração no seu ambiente.</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Propriedade</th>\n<th>Tipo</th>\n<th>Descrição</th>\n<th>Exemplo</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>name</td>\n<td>string - requerido</td>\n<td>Nome Completo do Lead</td>\n<td>José da Silva</td>\n</tr>\n<tr>\n<td>email</td>\n<td>string - opcional</td>\n<td>Email</td>\n<td><a href=\"https://mailto:jose@silva.com\">jose@silva.com</a></td>\n</tr>\n<tr>\n<td>phoneNumber</td>\n<td>string - requerido</td>\n<td>Telefone com DDD. DDI é opcional, caso não seja enviado é assumido valor 55.  <br />Não é necessário formatar, nossa API normaliza o número antes de cadastrar e fazer o envio.</td>\n<td>31 99333-1202  <br />5531998371234  <br />(31) 99923-2132</td>\n</tr>\n<tr>\n<td>productId</td>\n<td>string (uuid) - opcional</td>\n<td>ID do produto na plataforma M.I.A.  <br />Caso seja enviado, o deal é cadastrado com o produto vinculado, e caso uma conversa seja iniciada, esse produto já é enviado para o contexto.</td>\n<td>4d375b3b-0bfe-4326-8404-47b3e5a4c5d2</td>\n</tr>\n<tr>\n<td>productExternalId</td>\n<td>string - opcional</td>\n<td>ID do Produto no CRM ou plataforma do cliente</td>\n<td></td>\n</tr>\n<tr>\n<td>conversionIdentifier</td>\n<td>string - opcional</td>\n<td>Identificador da conversão. Caso haja um ID da conversão, pode ser enviado para encaminhamento posterior a redes de anúncios, etc.  <br />Também pode ser usado para vínculo com produtos.</td>\n<td>F-123</td>\n</tr>\n<tr>\n<td>source</td>\n<td>string - requerido</td>\n<td>Origem da conversão</td>\n<td>Site, Simulador, etc.</td>\n</tr>\n<tr>\n<td>messageTemplate</td>\n<td>string - opcional</td>\n<td>Identificador do template de mensagem a ser enviado.  <br />Caso seja enviado, é iniciado fluxo de envio de mensagem ativa e a notificação é enviada para o número do lead, de acordo com parametrizações de instância.</td>\n<td>whatsapp_message_template</td>\n</tr>\n<tr>\n<td>extras</td>\n<td>objeto - opcional</td>\n<td>Dados extras que podem ser usados em integrações.</td>\n<td><code>{</code>  <br /><code>\"externalId\": \"XPTO\"</code>  <br /><code>}</code></td>\n</tr>\n</tbody>\n</table>\n</div>","urlObject":{"path":["create-deal","{integrationId}"],"host":[""],"query":[],"variable":[]}},"response":[{"id":"e9a5a5d0-4edc-44c5-996c-4b6807778318","name":"Create simple lead","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"name\": \"João da Silva\",\n    \"email\": \"joao@silva.com\",\n    \"phoneNumber\": \"31992342344\",\n    \"source\": \"Site\"\n}","options":{"raw":{"language":"json"}}},"url":"/create-deal/{integrationId}"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"dealId\": \"4d375b3b-0bfe-4326-8404-47b3e5a4c5d2\"\n}"},{"id":"11905a14-49ec-4e61-9440-49aa45f08cbe","name":"Create deal with product","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"name\": \"João da Silva\",\n    \"email\": \"joao@silva.com\",\n    \"phoneNumber\": \"31992342344\",\n    \"productId\": \"4c8a4bc9-48f8-4255-bf70-83b4120861f8\",\n    \"conversionIdentifier\": \"SITE-1234\",\n    \"source\": \"Site-Partner\"\n}","options":{"raw":{"language":"json"}}},"url":"/create-deal/{integrationId}"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"dealId\": \"4d375b3b-0bfe-4326-8404-47b3e5a4c5d2\"\n}"},{"id":"093be5bf-6699-477a-9b43-1d796d664257","name":"Create detailed deal","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"name\": \"João da Silva\",\n    \"email\": \"joao@silva.com\",\n    \"phoneNumber\": \"31992342344\",\n    \"productId\": \"4c8a4bc9-48f8-4255-bf70-83b4120861f8\",\n    \"conversionIdentifier\": \"SITE-1234\",\n    \"source\": \"Site-Partner\",\n    \"messageTemplate\": \"whatsapp_message_template\",\n    \"extras\": {\n        \"any\": \"thing\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"/create-deal/{integrationId}"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"dealId\": \"4d375b3b-0bfe-4326-8404-47b3e5a4c5d2\"\n}"}],"_postman_id":"3a4aae58-adc2-4ba4-a405-686418356b73"},{"name":"Send deal log","id":"6c2f32f0-775a-4cbe-bc5a-c5e2a1c205f2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{},"isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n  \"type\": \"success\",\r\n  \"subject\": \"Venda Concluída\",\r\n  \"description\": \"Descrição detalhada do sucesso da venda\",\r\n  \"metadata\": {\r\n    \"salesPrice\": \"Valor da venda\",\r\n    \"soldAt\": \"Data da venda\"\r\n  }\r\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-integration.morada.ai/api/v1/deals/{dealId}/log","description":"<p>#### Descrição<br />Este endpoint é utilizado para registrar um sucesso de venda (success fee) no sistema da MIA.</p>\n<p>#### Parâmetros de URL<br />- `dealId`: (Obrigatório) O identificador único do deal na Morada.</p>\n","urlObject":{"protocol":"https","path":["api","v1","deals","{dealId}","log"],"host":["mia-integration","morada","ai"],"query":[],"variable":[]}},"response":[{"id":"f3cec725-c94f-436c-b985-a6bf43f2cfec","name":"Send deal log","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n  \"type\": \"success\",\r\n  \"subject\": \"Venda Concluída\",\r\n  \"description\": \"Descrição detalhada do sucesso da venda\",\r\n  \"metadata\": {\r\n    \"salesPrice\": \"500000\",\r\n    \"soldAt\": \"2023-06-01T12:00:00Z\"\r\n  }\r\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-integration.morada.ai/api/v1/deals/{dealId}/log"},"status":"Created","code":201,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null}],"_postman_id":"6c2f32f0-775a-4cbe-bc5a-c5e2a1c205f2"},{"name":"Send notification","id":"5a441d05-d663-4ac9-a746-4dccd60d7ea4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"+55 (11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234,\n  \"source\": \"Nome da Origem\",\n  \"ignoreTransferToTalkIfUnanswered\": true,\n  \"specialInstructions\": \"Direcione o lead apresentando o empreendiment XYZ\",\n  \"template\": {\n    \"name\": \"template_header_url_button\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"header\", \n        \"parameters\": [\n          { \n            \"type\": \"document\", \n            \"document\": { \n              \"link\": \"https://exemplo.com/documento.pdf\", \n              \"filename\": \"documento.pdf\" \n            } \n          }\n        ]\n      },\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      },\n      {\n        \"type\": \"button\",\n        \"sub_type\": \"url\", \n        \"index\": 0,\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"codigo123\" },\n          { \"type\": \"text\", \"text\": \"usuario456\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification","description":"<p>Envia mensagens template do WhatsApp Business via Meta Cloud API para contatos específicos. O endpoint suporta dois formatos de payload: o formato moderno (baseado na estrutura de componentes da Meta API) e o formato legado (com substituições simples de texto).</p>\n<p>Este endpoint permite que parceiros integrados enviem notificações template personalizadas, incluindo mensagens com texto dinâmico, botões interativos (URL e quick reply), headers com mídia (imagem, vídeo, documento) e parâmetros formatados (moeda, data/hora).</p>\n<p>A diferença desse endponint para o Create Deal, é que nesse endpoint não é realizado a criação de um deal na abertura de conversa. Ele tem como foco o envio de mensagens/notificações de forma avulsa, sem intenção de captação para o funil.</p>\n<p>Se o lead não responder, não gerará nenhum deal. Caso ele responda, a depender das mensagens trocadas, um deal poderá ser criado.</p>\n<p>O sistema automaticamente:</p>\n<ul>\n<li><p>Valida a autenticação do parceiro via API key</p>\n</li>\n<li><p>Consulta e valida o template aprovado no Meta Business Manager</p>\n</li>\n<li><p>Cria ou localiza o contato e conversa no sistema Morada</p>\n</li>\n<li><p>Envia a mensagem via WhatsApp Cloud API</p>\n</li>\n<li><p>Persiste o histórico da mensagem enviada</p>\n</li>\n</ul>\n<p>Casos de uso típicos:</p>\n<ul>\n<li><p>Notificações de status de processo (aprovação, rejeição, pendências)</p>\n</li>\n<li><p>Envio de links personalizados para formulários ou documentos</p>\n</li>\n<li><p>Mensagens de boas-vindas com informações do especialista</p>\n</li>\n<li><p>Lembretes com botões de ação rápida</p>\n</li>\n<li><p>Comunicação proativa com anexos (PDFs, imagens)</p>\n</li>\n<li><p>Mensagem de lembrete para contato que NÃO deve integrar no CRM</p>\n</li>\n</ul>\n<p>Limitações importantes:</p>\n<ul>\n<li><p>Templates devem estar previamente aprovados no Meta Business Manager</p>\n</li>\n<li><p>Formato legado não suporta botões URL com parâmetros dinâmicos</p>\n</li>\n<li><p>Cada template possui regras específicas de componentes e placeholders</p>\n</li>\n<li><p>Rate limits aplicados conforme política do WhatsApp Business</p>\n</li>\n</ul>\n","urlObject":{"protocol":"https","path":["send-notification"],"host":["mia-gateway","morada","ai"],"query":[{"disabled":true,"key":" ","value":null}],"variable":[]}},"response":[{"id":"7a0bdbd1-6ee0-4d21-8520-94aa8060dcbf","name":"200 - Success","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234, \n  \"source\": \"Origem\",\n  \"template\": {\n    \"name\": \"template_body_simples\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"c52c7b42-1380-4e1e-8892-b1e28ddc6c43","name":"200 - Success with ignore transfer to talk","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234, \n  \"source\": \"Origem\",\n  \"ignoreTransferToTalkIfUnanswered\": true,\n  \"template\": {\n    \"name\": \"template_body_simples\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"79aee97f-77c1-4128-80f3-c01f0efdaca2","name":"200 - Success with special instruction","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234, \n  \"source\": \"Origem\",\n  \"template\": {\n    \"name\": \"template_body_simples\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      }\n    ]\n  },\n  \"specialInstructions\": \"Direcione o lead pelo fluxo de ...\"\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"04792769-9f7d-4743-bb4f-8f9a6c2741d6","name":"200 - Button URL + Body + Header","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"name\": \"Nome do Cliente\",\n    \"phoneNumber\": \"(11) 999999999\",\n    \"email\": \"cliente@exemplo.com\",\n    \"instanceId\": 1234,\n    \"source\": \"Origem\",\n    \"template\": {\n        \"name\": \"template_header_url_button\",\n        \"language\": {\n            \"code\": \"pt_BR\"\n        },\n        \"components\": [\n            {\n                \"type\": \"header\",\n                \"parameters\": [\n                    {\n                        \"type\": \"document\",\n                        \"document\": {\n                            \"link\": \"https://exemplo.com/documento.pdf\",\n                            \"filename\": \"documento.pdf\"\n                        }\n                    }\n                ]\n            },\n            {\n                \"type\": \"body\",\n                \"parameters\": [\n                    {\n                        \"type\": \"text\",\n                        \"text\": \"João Silva\"\n                    }\n                ]\n            },\n            {\n                \"type\": \"button\",\n                \"sub_type\": \"url\",\n                \"index\": 0,\n                \"parameters\": [\n                    {\n                        \"type\": \"text\",\n                        \"text\": \"codigo123\"\n                    },\n                    {\n                        \"type\": \"text\",\n                        \"text\": \"usuario456\"\n                    }\n                ]\n            }\n        ]\n    }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"99993f1b-b499-46bf-9eae-a90d4641b0ab","name":"200 - Quick Reply","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234,\n  \"source\": \"Origem\",\n  \"template\": {\n    \"name\": \"template_com_quick_reply\", \n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" },\n          { \"type\": \"text\", \"text\": \"Status Aprovado\" }\n        ]\n      },\n      {\n        \"type\": \"button\",\n        \"sub_type\": \"quick_reply\", \n        \"index\": 0\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"code":200,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"0e1958c9-80da-4359-9b8a-30dbf6314c02","name":"200 - Legado","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\", \n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234,\n  \"source\": \"Origem\",\n  \"messageTemplate\": \"template_com_tres_params\", \n  \"replacements\": [\"João\", \"Maria\", \"Carlos\"]\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"OK","code":200,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"conversationId\": \"7a7806cd-597d-49f8-b6a1-c27a47e724f7\"\n}"},{"id":"0d669982-edf7-4025-96d5-3f863beb601a","name":"400 - Invalid Payload","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234,\n  \"source\": \"Nome da Origem\", \n  \"template\": {\n    \"name\": \"template_header_url_button\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"header\", \n        \"parameters\": [\n          { \n            \"type\": \"document\", \n            \"document\": { \n              \"link\": \"https://exemplo.com/documento.pdf\", \n              \"filename\": \"documento.pdf\" \n            } \n          }\n        ]\n      },\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      },\n      {\n        \"type\": \"button\",\n        \"sub_type\": \"url\", \n        \"index\": 0,\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"codigo123\" },\n          { \"type\": \"text\", \"text\": \"usuario456\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"Bad Request","code":400,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"[{\\\"code\\\":\\\"invalid_type\\\",\\\"expected\\\":\\\"string\\\",\\\"received\\\":\\\"undefined\\\",\\\"path\\\":[\\\"phoneNumber\\\"],\\\"message\\\":\\\"Required\\\"}]\"\n}"},{"id":"b089e7ae-94da-4024-b101-208e0224448e","name":"404 - Not Found","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 0,\n  \"source\": \"Nome da Origem\", \n  \"template\": {\n    \"name\": \"template_header_url_button\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"header\", \n        \"parameters\": [\n          { \n            \"type\": \"document\", \n            \"document\": { \n              \"link\": \"https://exemplo.com/documento.pdf\", \n              \"filename\": \"documento.pdf\" \n            } \n          }\n        ]\n      },\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      },\n      {\n        \"type\": \"button\",\n        \"sub_type\": \"url\", \n        \"index\": 0,\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"codigo123\" },\n          { \"type\": \"text\", \"text\": \"usuario456\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"Bad Request","code":400,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"Instance not found\"\n}"},{"id":"ca17d4e8-c61d-471d-8be0-e86b46974eb8","name":"500 - Template not found","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n  \"name\": \"Nome do Cliente\",\n  \"phoneNumber\": \"(11) 999999999\",\n  \"email\": \"cliente@exemplo.com\",\n  \"instanceId\": 1234,\n  \"source\": \"Nome da Origem\", \n  \"template\": {\n    \"name\": \"template_inexistente\",\n    \"language\": { \"code\": \"pt_BR\" },\n    \"components\": [\n      {\n        \"type\": \"header\", \n        \"parameters\": [\n          { \n            \"type\": \"document\", \n            \"document\": { \n              \"link\": \"https://exemplo.com/documento.pdf\", \n              \"filename\": \"documento.pdf\" \n            } \n          }\n        ]\n      },\n      {\n        \"type\": \"body\",\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"João Silva\" }\n        ]\n      },\n      {\n        \"type\": \"button\",\n        \"sub_type\": \"url\", \n        \"index\": 0,\n        \"parameters\": [\n          { \"type\": \"text\", \"text\": \"codigo123\" },\n          { \"type\": \"text\", \"text\": \"usuario456\" }\n        ]\n      }\n    ]\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://mia-gateway.morada.ai/send-notification"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"Template 'template_inexistente' not found\"\n}"}],"_postman_id":"5a441d05-d663-4ac9-a746-4dccd60d7ea4"},{"name":"Search products","id":"534ec939-6c46-4a9a-bc7d-3f4c34368f25","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://mia-gateway.morada.ai/products","description":"<p>Buscar produtos de maneira paginada, os query parameters <em><strong>page</strong></em> e <em><strong>size</strong></em> são opcionais</p>\n","urlObject":{"protocol":"https","path":["products"],"host":["mia-gateway","morada","ai"],"query":[{"disabled":true,"key":" ","value":null}],"variable":[]}},"response":[{"id":"c535040d-bffc-4f8a-982a-5649b81f6fda","name":"Search products","originalRequest":{"method":"GET","header":[{"key":"","value":"","type":"text","disabled":true}],"url":{"raw":"https://mia-gateway.morada.ai/products?page=1&size=10","protocol":"https","host":["mia-gateway","morada","ai"],"path":["products"],"query":[{"key":"page","value":"1"},{"key":"size","value":"10"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Date","value":"Fri, 30 Jan 2026 01:14:26 GMT"},{"key":"Content-Type","value":"application/json","description":"","type":"text"},{"key":"Content-Length","value":"1874"},{"key":"Connection","value":"keep-alive"},{"key":"Apigw-Requestid","value":"X-XdNhCQoAMEbmA="}],"cookie":[{"expires":"Invalid Date","domain":"","path":""}],"responseTime":null,"body":"{\n    \"products\": [\n        {\n            \"productId\": \"49de5ba2-d5a5-436f-843f-5e6ab5ce530a\",\n            \"productName\": \"Apartamento teste\",\n            \"status\": \"Em Obras\",\n            \"agents\": [\n                {\n                    \"id\": 83,\n                    \"name\": \"Iago - Morada.ai (Staging)\",\n                    \"number\": \"+55 11 1234-5678\"\n                }\n            ]\n        },\n        {\n            \"productId\": \"0351db1b-3664-4a43-961e-0dc8afed1259\",\n            \"productName\": \"Função teste\",\n            \"status\": \"Lançamento\",\n            \"agents\": []\n        }\n    ],\n    \"pagination\": {\n        \"page\": 1,\n        \"size\": 10,\n        \"totalItems\": 2,\n        \"totalPages\": 1,\n        \"hasNextPage\": false,\n        \"hasPreviousPage\": false\n    }\n}"}],"_postman_id":"534ec939-6c46-4a9a-bc7d-3f4c34368f25"},{"name":"Search products by name","id":"e21fdfa2-28e9-435c-8377-d2fb2027720f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://mia-gateway.morada.ai/products-by-name?term=\"imóvel teste\"","description":"<p>Este endpoint permite a pesquisa de produtos pelo nome utilizando <strong>fuzzy search</strong>, possibilitando encontrar resultados mesmo quando o termo informado possui variações, erros de digitação ou correspondências parciais. A consulta é realizada de forma <strong>paginada</strong>, garantindo performance e controle no volume de dados retornados.</p>\n<p>O <strong>parâmetro principal é o</strong> <strong><code>term</code></strong>, utilizado para indicar o nome (ou parte do nome) do produto que se deseja pesquisar.</p>\n<p>Este é o <strong>único parâmetro obrigatório</strong> para a execução da busca.</p>\n<p>O endpoint foi projetado para atender cenários de listagem, autocomplete e busca avançada de produtos, retornando resultados ordenados por <strong>relevância</strong>, com base no grau de similaridade entre o valor informado em <code>term</code> e o nome dos produtos cadastrados.</p>\n<p>O sistema automaticamente:</p>\n<ul>\n<li><p>Valida a autenticação do parceiro via <strong>API key</strong></p>\n</li>\n<li><p>Processa o valor informado em <code>term</code> aplicando algoritmo de <strong>fuzzy matching</strong></p>\n</li>\n<li><p>Identifica produtos com nomes semelhantes ao termo pesquisado</p>\n</li>\n<li><p>Ordena os resultados por score de relevância</p>\n</li>\n<li><p>Aplica paginação nos resultados</p>\n</li>\n<li><p>Retorna os produtos encontrados junto com metadados de paginação</p>\n</li>\n</ul>\n<h3 id=\"casos-de-uso-típicos\">Casos de uso típicos:</h3>\n<ul>\n<li><p>Pesquisa de produtos por nome aproximado</p>\n</li>\n<li><p>Busca em catálogos extensos com tolerância a erros de digitação</p>\n</li>\n<li><p>Integração com sistemas externos que não possuem o ID do produto</p>\n</li>\n</ul>\n<h3 id=\"limitações-importantes\">Limitações importantes:</h3>\n<ul>\n<li><p>Apenas o parâmetro <code>term</code> é obrigatório; os demais são opcionais</p>\n</li>\n<li><p>A qualidade dos resultados depende do conteúdo do nome dos produtos</p>\n</li>\n<li><p>O fuzzy search pode retornar múltiplos produtos semelhantes</p>\n</li>\n<li><p>A paginação limita a quantidade de resultados por requisição</p>\n</li>\n</ul>\n","urlObject":{"protocol":"https","path":["products-by-name"],"host":["mia-gateway","morada","ai"],"query":[{"disabled":true,"key":" ","value":null},{"key":"term","value":"\"imóvel teste\""}],"variable":[]}},"response":[{"id":"578526ca-14a8-41fd-95bd-32984c2686b2","name":"Search products by name","originalRequest":{"method":"GET","header":[{"key":"","value":"","type":"text","disabled":true}],"url":{"raw":"https://mia-gateway.morada.ai/products-by-name?term=\"imóvel teste\"","protocol":"https","host":["mia-gateway","morada","ai"],"path":["products-by-name"],"query":[{"key":" ","value":null,"disabled":true},{"key":"term","value":"\"imóvel teste\""}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Date","value":"Fri, 30 Jan 2026 01:37:58 GMT"},{"key":"Content-Type","value":"application/json","description":"","type":"text"},{"key":"Content-Length","value":"1166"},{"key":"Connection","value":"keep-alive"},{"key":"Apigw-Requestid","value":"X-a6ghNnoAMEYjA="}],"cookie":[{"expires":"Invalid Date","domain":"","path":""}],"responseTime":null,"body":"{\n    \"term\": \"\\\"imóvel teste\\\"\",\n    \"products\": [\n        {\n            \"id\": \"84320188-1452-4fe8-900e-3bca9d46fb6c\",\n            \"name\": \"[21] imóvel teste\",\n            \"description\": \"teste\",\n            \"similarityScore\": 1\n        }\n    ],\n    \"pagination\": {\n        \"page\": 1,\n        \"size\": 10,\n        \"totalItems\": 1,\n        \"totalPages\": 1,\n        \"hasNextPage\": false,\n        \"hasPreviousPage\": false\n    }\n}"}],"_postman_id":"e21fdfa2-28e9-435c-8377-d2fb2027720f"},{"name":"Search product by Id","id":"db8bb7de-7c64-45c8-8c1a-bdc5ebd3e8c9","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://mia-gateway.morada.ai/products/{productId}","description":"<p>Buscar produto pelo id</p>\n","urlObject":{"protocol":"https","path":["products","{productId}"],"host":["mia-gateway","morada","ai"],"query":[{"disabled":true,"key":" ","value":null}],"variable":[]}},"response":[{"id":"8f2c7b9b-3513-4b76-a34f-6315c84cecc5","name":"Search product by Id","originalRequest":{"method":"GET","header":[{"key":"","value":"","type":"text","disabled":true}],"url":{"raw":"https://mia-gateway.morada.ai/products/49de5ba2-d5a5-436f-843f-5e6ab5ce530a","protocol":"https","host":["mia-gateway","morada","ai"],"path":["products","49de5ba2-d5a5-436f-843f-5e6ab5ce530a"],"query":[{"key":" ","value":null,"disabled":true}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Date","value":"Fri, 30 Jan 2026 01:23:09 GMT"},{"key":"Content-Type","value":"application/json","description":"","type":"text"},{"key":"Content-Length","value":"273"},{"key":"Connection","value":"keep-alive"},{"key":"Apigw-Requestid","value":"X-Yu1gGGoAMEMDw="}],"cookie":[{"expires":"Invalid Date","domain":"","path":""}],"responseTime":null,"body":"{\n    \"product\": {\n        \"productId\": \"49de5ba2-d5a5-436f-843f-5e6ab5ce530a\",\n        \"productName\": \"Apartamento teste\",\n        \"status\": \"Em Obras\",\n        \"agents\": [\n            {\n                \"id\": 83,\n                \"name\": \"Iago - Morada.ai (Staging)\",\n                \"number\": \"+55 11 1234-5678\"\n            }\n        ]\n    }\n}"}],"_postman_id":"db8bb7de-7c64-45c8-8c1a-bdc5ebd3e8c9"},{"name":"Get Deals from lead info","id":"307c9548-9784-4fb0-ace6-40dc978720b0","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"x-morada-api-key","value":"api-key","description":"<p>Chave de API do parceiro (obrigatória)</p>\n","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":"/deal?leadPhoneNumber=&leadEmail=&dealId=&dealExternalId=","description":"<p>Busca negócios do parceiro autenticado.</p>\n<p>Todos os parâmetros são opcionais e podem ser combinados, mas pelo menos um deve ser fornecido.</p>\n","urlObject":{"path":["deal"],"host":[""],"query":[{"description":{"content":"<p>Número de telefone do lead (opcional)</p>\n","type":"text/plain"},"key":"leadPhoneNumber","value":""},{"description":{"content":"<p>Email do lead (opcional; precisa ser válido)</p>\n","type":"text/plain"},"key":"leadEmail","value":""},{"description":{"content":"<p>ID interno do negócio na Morada (opcional)</p>\n","type":"text/plain"},"key":"dealId","value":""},{"description":{"content":"<p>ID externo do negócio (opcional)</p>\n","type":"text/plain"},"key":"dealExternalId","value":""}],"variable":[]}},"response":[{"id":"4d64c7b4-be23-41d2-9e5e-26b032eecdbc","name":"200 OK - Sucesso (com resultados)","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":{"raw":"/deal?leadEmail=john@example.com","host":[""],"path":["deal"],"query":[{"key":"leadEmail","value":"john@example.com"}]}},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"[\n  {\n    \"deal\": {\n      \"id\": \"deal-123\",\n      \"status\": \"open\",\n      \"createdAt\": \"2023-01-01T00:00:00.000Z\",\n      \"updatedAt\": \"2023-01-01T00:00:00.000Z\",\n      \"ownerId\": \"owner-123\",\n      \"ownerName\": \"Jane Agent\",\n      \"ownerEmail\": \"jane@company.com\",\n      \"props\": { \"externalIntegrationId\": \"ext-123\" }\n    },\n    \"person\": {\n      \"id\": \"person-123\",\n      \"name\": \"John Doe\",\n      \"email\": \"john@example.com\",\n      \"phoneNumber\": \"+1234567890\"\n    },\n    \"property\": {\n      \"id\": \"property-123\",\n      \"name\": \"Downtown Apartment\",\n      \"externalId\": \"prop-ext-123\"\n    },\n    \"agent\": {\n        \"id\": 1234,\n        \"name\": \"Test agent\",\n        \"number\": \"+55 11 1234-5678\"\n    }\n  }\n]"},{"id":"1a54a823-a390-4cf1-af4b-e80e53543d2c","name":"200 OK - Sucesso (sem resultados)","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":{"raw":"/deal?leadPhoneNumber=+5511999999999","host":[""],"path":["deal"],"query":[{"key":"leadPhoneNumber","value":"+5511999999999"}]}},"status":"OK","code":200,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"[]"},{"id":"bf8ec7ba-abc2-448b-be71-6407891f8651","name":"400 Bad Request - Email inválido","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":{"raw":"/deal?leadEmail=invalid-email","host":[""],"path":["deal"],"query":[{"key":"leadEmail","value":"invalid-email"}]}},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\"error\":\"[{\\\"code\\\":\\\"invalid_string\\\",\\\"message\\\":\\\"Invalid email\\\"}]\"}"},{"id":"42e21f58-6a32-413a-9214-d83122b58312","name":"400 Bad Request - Parâmetro não reconhecido","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":{"raw":"/deal?unknownParam=value","host":[""],"path":["deal"],"query":[{"key":"unknownParam","value":"value"}]}},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\"error\":\"[{\\\"code\\\":\\\"unrecognized_keys\\\",\\\"message\\\":\\\"Unrecognized key(s) in object\\\"}]\"}"},{"id":"704f5f2a-1227-4284-9e86-158229c8bb37","name":"401 Unauthorized - Missing API key","originalRequest":{"method":"GET","header":[{"key":"Accept","value":"application/json","type":"text"}],"url":"/deal"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\"error\":\"Unauthorized - Missing API key\"}"},{"id":"7edecd9a-9fa7-4148-ab88-18cd088b87ad","name":"401 Unauthorized - Invalid API key","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"invalid-key","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":"/deal"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\"error\":\"Unauthorized - Invalid API key\"}"},{"id":"c0380527-7206-4ef8-b504-8302a90b6df1","name":"500 Internal Server Error","originalRequest":{"method":"GET","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"url":"/deal"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\"error\":\"Internal Server Error\"}"}],"_postman_id":"307c9548-9784-4fb0-ace6-40dc978720b0"},{"name":"Update Deal","id":"2d9434b2-123a-44c8-8278-3e880ca8f1dd","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","description":"<p>Chave de API do parceiro (obrigatória)</p>\n","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"{{dealStatus}}\",\n  \"stageCode\": \"{{stageCode}}\",\n  \"propertyExternalId\": \"{{propertyExternalId}}\",\n  \"ownerEmail\": \"{{ownerEmail}}\"\n}","options":{"raw":{"language":"json"}}},"url":"/deal/","description":"<p>Atualiza um negócio existente. Pelo menos um campo deve ser fornecido.</p>\n<p>Campos disponíveis (todos opcionais, mas pelo menos 1 obrigatório):</p>\n<p><strong>status</strong> (enum):</p>\n<ul>\n<li>\"won\" - Negócio ganho</li>\n<li>\"lost\" - Negócio perdido</li>\n<li>\"closed\" - Negócio fechado</li>\n<li>\"open\" - Negócio aberto</li>\n</ul>\n<p><strong>stageCode</strong> (enum):</p>\n<ul>\n<li>\"transferred\" - Transferido</li>\n<li>\"in_qualification\" - Em qualificação</li>\n<li>\"waiting_service\" - Aguardando atendimento</li>\n<li>\"in_service\" - Em atendimento</li>\n<li>\"visit_scheduled\" - Visita agendada</li>\n<li>\"visit_completed\" - Visita realizada</li>\n<li>\"closed_won\" - Fechado ganho</li>\n<li>\"closed_lost\" - Fechado perdido</li>\n<li>\"negotiating\" - Negociando</li>\n</ul>\n<p><strong>propertyExternalId</strong>: string - ID externo da propriedade</p>\n<p><strong>ownerEmail</strong>: string - Email do novo responsável (deve ser email válido)</p>\n<p>Validações:</p>\n<ul>\n<li>Deal deve existir e pertencer ao parceiro autenticado</li>\n<li>Pelo menos um campo deve ser fornecido</li>\n<li>Campos extras são rejeitados (schema estrito)</li>\n</ul>\n","urlObject":{"path":["deal",""],"host":[""],"query":[],"variable":[]}},"response":[{"id":"2210c2fa-f5e2-4bb5-a3b4-b6a53fa4c7ef","name":"202 Accepted - Atualização aceita","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\",\n  \"stageCode\": \"closed_won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Accepted","code":202,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Deal update accepted\"\n}"},{"id":"b44438e8-2404-4536-878e-aa359554393f","name":"202 Accepted - Atualização de propriedade","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"propertyExternalId\": \"PROP-EXT-789\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Accepted","code":202,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Deal update accepted\"\n}"},{"id":"066d7866-8cde-409a-aaca-a5b7826437de","name":"202 Accepted - Atualização de responsável","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"ownerEmail\": \"novo.responsavel@empresa.com\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Accepted","code":202,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"message\": \"Deal update accepted\"\n}"},{"id":"0c689fff-b422-4e09-88df-0913b0c3923f","name":"400 Bad Request - Missing API key","originalRequest":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Unauthorized - Missing API key\"\n}"},{"id":"723f5bf9-8321-4a56-b0d8-3b3e115eb74a","name":"400 Bad Request - Missing dealId","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Deal ID is required\"\n}"},{"id":"02163931-b313-4030-bf1f-3aeec8a78b8e","name":"400 Bad Request - Missing body","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Missing body\"\n}"},{"id":"0010aff2-9619-4b88-b5ae-07e3bca0c748","name":"400 Bad Request - Invalid JSON body","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{ invalid json","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Invalid JSON body\"\n}"},{"id":"20b77e5b-a49d-47c2-b19e-650c3d80edf4","name":"400 Bad Request - Nenhum campo fornecido","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"[{\\\"code\\\":\\\"custom\\\",\\\"message\\\":\\\"At least one property must be provided for update.\\\",\\\"path\\\":[]}]\"\n}"},{"id":"8f67f611-28cd-4cea-8bd2-56ee1c401328","name":"400 Bad Request - Status inválido","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"invalid_status\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"[{\\\"received\\\":\\\"invalid_status\\\",\\\"code\\\":\\\"invalid_enum_value\\\",\\\"options\\\":[\\\"won\\\",\\\"lost\\\",\\\"closed\\\",\\\"open\\\"],\\\"path\\\":[\\\"status\\\"],\\\"message\\\":\\\"Invalid enum value. Expected 'won' | 'lost' | 'closed' | 'open', received 'invalid_status'\\\"}]\"\n}"},{"id":"ed095cf6-ef1b-4475-b084-6c690f51c2b5","name":"400 Bad Request - Email inválido","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"ownerEmail\": \"email-invalido\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"[{\\\"validation\\\":\\\"email\\\",\\\"code\\\":\\\"invalid_string\\\",\\\"message\\\":\\\"Invalid email\\\",\\\"path\\\":[\\\"ownerEmail\\\"]}]\"\n}"},{"id":"b1c05760-884e-4bb6-acf9-396ebfde34e8","name":"400 Bad Request - Campo não reconhecido","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\",\n  \"unknownField\": \"value\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Bad Request","code":400,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"[{\\\"code\\\":\\\"unrecognized_keys\\\",\\\"keys\\\":[\\\"unknownField\\\"],\\\"path\\\":[],\\\"message\\\":\\\"Unrecognized key(s) in object: 'unknownField'\\\"}]\"\n}"},{"id":"5b645f09-f253-42f0-96e6-59046e25c166","name":"401 Unauthorized - Invalid API key","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"invalid-key","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Unauthorized - Invalid API key\"\n}"},{"id":"6c10671d-b12e-49b3-9ce7-8085c0c26ab7","name":"404 Not Found - Deal not found","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-inexistente"},"status":"Not Found","code":404,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Not Found - Deal not found\"\n}"},{"id":"a6f97bdb-6395-4ff3-8fd4-475a4fe5b620","name":"404 Not Found - Deal não pertence ao parceiro","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-de-outro-parceiro"},"status":"Not Found","code":404,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Not Found - Deal not found\"\n}"},{"id":"06da82b2-bbb6-43b1-886f-342686ac94c7","name":"500 Internal Server Error","originalRequest":{"method":"PATCH","header":[{"key":"x-morada-api-key","value":"{{apiKey}}","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"Accept","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"won\"\n}","options":{"raw":{"language":"json"}}},"url":"/api/v1/deal/deal-123456"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"Text","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n  \"error\": \"Internal Server Error\"\n}"}],"_postman_id":"2d9434b2-123a-44c8-8278-3e880ca8f1dd"}],"id":"4063b582-24f7-48ec-b46f-552a8f9671a5","_postman_id":"4063b582-24f7-48ec-b46f-552a8f9671a5","description":""},{"name":"Webhooks","item":[{"name":"New Message","id":"f4b68796-67fb-4686-930c-03d302b57748","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"id\": \"8b61b40f-4171-4b82-892b-e55f4aafc3cb\",\n    \"from\": \"user\",\n    \"type\": \"plain/text\",\n    \"content\": \"Oi! Tudo bem?\"\n}","options":{"raw":{"language":"json"}}},"url":"https://www.example.com/endpoint","urlObject":{"protocol":"https","path":["endpoint"],"host":["www","example","com"],"query":[],"variable":[]}},"response":[{"id":"b39d3408-f427-441c-9c0e-064f6d65d9ac","name":"New Message from user (text)","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"id\": \"fe13c664-9e0c-4add-b7f4-0edb14897b72\",\n    \"from\": \"user\",\n    \"type\": \"plain/text\",\n    \"content\": \"Oi! Tudo bem?\"\n}","options":{"raw":{"language":"json"}}},"url":"https://www.example.com/endpoint"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null},{"id":"ceaec1dc-4f31-4ed0-a468-df2c54df11b1","name":"New Message from assistant (text)","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"id\": \"ba4cf6f1-6971-499a-8eed-791c3c0a62ee\",\n    \"from\": \"assistant\",\n    \"type\": \"plain/text\",\n    \"content\": \"Olá, aqui é a sua assistente virtual! Vamos lá?\"\n}","options":{"raw":{"language":"json"}}},"url":"https://www.example.com/endpoint"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null},{"id":"dd5cc215-56dd-4455-a08b-e2a951c3a9c9","name":"New Message (media)","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"id\": \"15096f33-c7cf-41bc-8572-3c8feeffeee4\",\n    \"from\": \"user\",\n    \"type\": \"application/json\",\n    \"content\": {\n        \"type\": \"image/jpeg\",\n        \"uri\": \"https://example.com/media.jpg\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"https://www.example.com/endpoint"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null}],"_postman_id":"f4b68796-67fb-4686-930c-03d302b57748"},{"name":"Deal Stage","id":"0d5b4fe6-94a9-47a3-9c64-3bb7b4fae011","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"url":"https://www.example.com/endpoint","description":"<p>Toda vez que um deal avança de etapa, esse webhook é acionado.</p>\n<p>Um deal pode ter 3 etapas:</p>\n<ul>\n<li><p>Deal criado</p>\n</li>\n<li><p>Deal em qualificação</p>\n</li>\n<li><p>Deal transferido</p>\n<ul>\n<li><p>Ganho</p>\n</li>\n<li><p>Perdido</p>\n</li>\n</ul>\n</li>\n</ul>\n<p>Ou seja, toda vez que ele passar por uma dessas 3 etapas acima, o webhook será acionado para o seu endpoint passando as informações relacionadas ao deal.</p>\n<p>Observe quais são as informações no payload de exemplo.</p>\n","urlObject":{"protocol":"https","path":["endpoint"],"host":["www","example","com"],"query":[],"variable":[]}},"response":[{"id":"39efb732-b463-42f2-ab01-40aa808ed67e","name":"Deal Created","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n  \"deal\": {\n    \"id\": \"deal_abc123\",\n    \"title\": \"[MORADA] [Residencial Prime] João Silva\",\n    \"personId\": \"person_xyz789\",\n    \"ownerId\": \"owner_456\",\n    \"ownerName\": \"Maria Santos\",\n    \"ownerEmail\": \"maria.santos@empresa.com\",\n    \"ownerPhoneNumber\": \"+5511998765432\",\n    \"status\": \"open\",\n    \"stageCode\": \"engaged\",\n    \"productId\": \"prod_789\",\n    \"externalIntegrationId\": \"ext_123\",\n    \"partnerId\": \"partner_001\",\n    \"conversationId\": \"conv_abc\",\n    \"createdAt\": \"2025-10-10T10:00:00.000Z\",\n    \"updatedAt\": \"2025-10-10T12:35:10.000Z\",\n    \"deletedAt\": null,\n    \"finishedAt\": null,\n    \"props\": {\n      \"externalIntegrationId\": \"ext_123\",\n      \"externalContactId\": \"contact_456\"\n    }\n  },\n  \"person\": {\n    \"id\": \"person_xyz789\",\n    \"name\": \"João Silva\",\n    \"email\": \"joao.silva@email.com\",\n    \"phone\": \"+5511987654321\"\n  },\n  \"product\": {\n    \"id\": \"prod_789\",\n    \"name\": \"Residencial Prime - Apto 101\"\n  },\n  \"source\": {\n    \"media\": \"Instagram Ads\",\n    \"campaign\": \"Campanha Q4 2025\",\n    \"source\": \"Meta\",\n    \"utm\": {\n      \"utm_source\": \"facebook\",\n      \"utm_medium\": \"cpc\",\n      \"utm_campaign\": \"residencial_prime_q4\",\n      \"utm_content\": \"carousel_v2\",\n      \"utm_term\": \"apartamento_novo\"\n    },\n    \"conversion\": \"form_submission\"\n  },\n  \"metadata\": {\n    \"timestamp\": \"2025-10-10T12:35:10.123Z\",\n    \"eventType\": \"deal_stage_change\",\n    \"stageId\": \"1\" <-- deal.created\n  }\n}","options":{"raw":{"language":"json"}}},"url":"https://www.example.com/endpoint"},"_postman_previewlanguage":null,"header":null,"cookie":[],"responseTime":null,"body":null}],"_postman_id":"0d5b4fe6-94a9-47a3-9c64-3bb7b4fae011"}],"id":"f1fc06b3-7e06-47ba-af4d-c8f9e795a30b","description":"<p>Nessa seção, descrevemos os webhooks que podem ser enviados pela M.I.A em determinadas etapas do processo de qualificação.</p>\n<p>Para receber o webhook, deve ser adicionado uma integração do tipo webhook, e se inscrever nos eventos que devem ser enviados para o endpoint desejado.</p>\n<p>Cada evento possui um payload específico que é enviado para o endpoint parametrizado.</p>\n<h3 id=\"autenticação\">Autenticação</h3>\n<p>A M.I.A envia um cabeçalho <code>X-Mia-Key</code>, que pode ser usado para validar que aquela requisição foi realmente enviada pela M.I.A.</p>\n<p>Isso pode ser usado para validar e evitar que qualquer outro agente envie requisições maliciosas.</p>\n","_postman_id":"f1fc06b3-7e06-47ba-af4d-c8f9e795a30b"},{"name":"Simulator","item":[{"name":"Simulador Web - Integração","id":"0ab27712-a77b-4060-ac98-860be693f4dc","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"GET","header":[],"url":"https://simulador.{{parceiro}}.miacred.com.br/simulador?imovel=https://landingpageemprendimento.com.br&utm_source=lp&utm_medium=landing_page&utm_campaign=nome-campanha&utm_content=cta-xpto","description":"<p>Observe os parâmetros abaixo para enviar leads ao simulador, enviando a origem e o imóvel que será usado como referência.</p>\n<p>Todos os parâmetros são opcionais, porém é altamente recomendado sua utilização para gerar relatórios analíticos corretos, e aumentar a taxa de conversão do lead.</p>\n","urlObject":{"protocol":"https","path":["simulador"],"host":["simulador","{{parceiro}}","miacred","com","br"],"query":[{"description":{"content":"<p>Neste parâmetro opcional, você deve incluir o link do imóvel que será usado como referência na simulação.\nCaso não seja informado, será adicionado uma etapa no final da simulação para o usuário selecionar o empreendimento.</p>\n","type":"text/plain"},"key":"imovel","value":"https://landingpageemprendimento.com.br"},{"description":{"content":"<p>Parâmetro de origem, fonte da navegação ao simulador.\nCaso seja informado, será usado ao repassar para outras integrações, informando a origem inicial.\nCaso não seja informado, a origem se torna \"Simulador Morada\".</p>\n","type":"text/plain"},"key":"utm_source","value":"lp"},{"description":{"content":"<p>Parâmetro de mídia</p>\n","type":"text/plain"},"key":"utm_medium","value":"landing_page"},{"description":{"content":"<p>Parâmetro de campanha</p>\n","type":"text/plain"},"key":"utm_campaign","value":"nome-campanha"},{"description":{"content":"<p>Parâmetro de conteúdo</p>\n","type":"text/plain"},"key":"utm_content","value":"cta-xpto"}],"variable":[]}},"response":[],"_postman_id":"0ab27712-a77b-4060-ac98-860be693f4dc"}],"id":"bca31b35-2bae-49b4-96a0-38ae9f55756c","_postman_id":"bca31b35-2bae-49b4-96a0-38ae9f55756c","description":""},{"name":"Enri.ai","item":[{"name":"Webhook Enri.ai","id":"d693dc17-24d9-4bfc-81fc-f2e1fe09f347","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"source\": {\n        \"id\": \"c5aff917-5cdd-4648-a22d-32abc3abe5b0\",\n        \"name\": \"Cobertura à venda, 2 quartos, 1 suíte, 2 vagas, Boa Vista - Belo Horizonte/MG\",\n        \"external_id\": \"123456\"\n    },\n    \"enrichment\": {\n        \"place_name\": \"Condomínio nascer do sol\",\n        \"meta\": {\n            \"description\": \"Descubra o luxo e conforto nesta exclusiva cobertura no Boa Vista, Belo Horizonte! Com 2 quartos, incluindo uma suíte sofisticada, 2 vagas de garagem, e uma deslumbrante sala de estar integrada à uma cozinha moderna e elegante. Localização privilegiada, perto de importantes pontos de interesse. Venha viver seu sonho com estilo e modernidade!\"\n        },\n        \"points_of_interest\": [\n            {\n                \"name\": \"SENAI Horto (Escola, ponto de interesse, estabelecimento)\"\n            },\n            {\n                \"name\": \"Museu de História Natural e Jardim Botânico da UFMG (Museu)\"\n            }\n        ],\n        \"media\": [\n            {\n                \"url\": \"https://cdn.example.com/1663343681.jpeg\",\n                \"group\": \"quarto\",\n                \"description\": \"Quarto elegante com cama de casal, roupa de cama cinza e almofadas verdes. Armário espelhado, luminária circular na parede e cortinas brancas. Decoração minimalista com quadro artístico e mesinha lateral com vaso de flores\"\n            },\n            {\n                \"url\": \"https://cdn.example.com/1663343681.jpeg\",\n                \"group\": \"fachada\",\n                \"description\": \"Edifício residencial moderno com revestimento em tons de bege e detalhes em madeira. Possui garagem coberta e paisagismo com palmeiras\"\n            }\n        ]\n    }\n}","options":{"raw":{"language":"json"}}},"url":"https://example.com/webhook","urlObject":{"protocol":"https","path":["webhook"],"host":["example","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"d693dc17-24d9-4bfc-81fc-f2e1fe09f347"}],"id":"d5456cc0-5b18-4ac1-ba63-3fef595f75c8","description":"<p>O Enri.ai é o serviço de enriquecimento de anúncio de imóveis da Morada.ai.</p>\n<p>A integração atual com o Enri é feita através de webhook, que é enviada pelo Enri, a um endpoint do cliente, na medida que os enriquecimentos acontecem.</p>\n<p>Confira no endpoint abaixo a estrutura da requisição que o Enri.ai envia para o webhook.</p>\n","auth":{"type":"noauth","isInherited":false},"event":[{"listen":"prerequest","script":{"id":"d52904fd-82d6-4175-85da-408d51f5d582","type":"text/javascript","packages":{},"exec":[""]}},{"listen":"test","script":{"id":"7bebfce2-8960-47f6-bc0b-461aff9f1f47","type":"text/javascript","packages":{},"exec":[""]}}],"_postman_id":"d5456cc0-5b18-4ac1-ba63-3fef595f75c8"},{"name":"Conversation","item":[],"id":"36a59507-15eb-4fe0-a195-db96080d7e33","description":"<h1 id=\"mia-websocket-api\">M.I.A Websocket API</h1>\n<h2 id=\"environments\">Environments</h2>\n<ul>\n<li><p>Production env: <a href=\"https://mia-chat-api.morada.ai\">https://mia-chat-api.morada.ai</a></p>\n</li>\n<li><p>Staging env: <a href=\"https://mia-chat-api.staging.morada.ai\">https://mia-chat-api.staging.morada.ai</a></p>\n</li>\n</ul>\n<h2 id=\"requirements\">Requirements</h2>\n<p>Use Socket IO Client: <a href=\"https://socket.io/docs/v4/client-api/\">https://socket.io/docs/v4/client-api/</a><br />Include script</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;script src=\"/socket.io/socket.io.js\"&gt;&lt;/script&gt;\n&lt;comment class=&amp;#x27;preserveHtml&amp;#x27; class=&amp;#x27;preserveHtml&amp;#x27; class=&amp;#x27;preserveHtml&amp;#x27; class=&amp;#x27;preserveHtml&amp;#x27; class=&amp;#x27;preserveHtml&amp;#x27;&gt; or by cdn:    --&gt;\n&lt;script src=\"https://cdn.socket.io/4.7.5/socket.io.esm.min.js\"&gt;&lt;/script&gt;\n\n</code></pre><h2 id=\"how-tos\">How-Tos</h2>\n<h3 id=\"initialize-chat-instance-to-connect-to-api-server\">Initialize Chat instance to connect to API server:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>const socket = io({\n    auth: {\n        instance: {\n            chatId: \"UniqueChatId\",     // required, instance chat channel id (`bots.props-&gt;'chat'-&gt;&gt;'id'`)\n            token: \"TokenFromInstance\", // required, instance token (`bots.props-&gt;'chat'-&gt;&gt;'clientToken'`)\n        },\n        roomId: \"uniqueRoomId\",         // optional, person identifier\n    }\n});\n\n</code></pre><p>Chat should be <strong>enabled</strong> in Instance chat config</p>\n<img src=\"https://content.pstmn.io/44d5bb93-ebc3-40ec-9024-1961bfb068f8/Q3JvcHBlZF9JbWFnZS5wbmc=\" alt=\"https://app.morada.ai/instances\" />\n\n<h3 id=\"send-message-to-mia\">Send message to Mia:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>socket.emit(EVENT_CLIENT_SEND_MESSAGE, { content: \"Hello Mia!\" });\n\n</code></pre><h3 id=\"listen-messages-from-mia\">Listen messages from Mia:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>socket.on(EVENT_SERVER_SEND_MESSAGE, ({ id, content, from, createdAt, status }: ServerMessageDto) =&gt; {\n    item = document.createElement('li');\n    item.setAttribute(\"id\", `message_${id}`);\n    item.innerHTML = `${content}, by ${from}`;\n    document.getElementById('messages').appendChild(item);\n});\n\n</code></pre><h2 id=\"chat-events\">Chat Events:</h2>\n<ul>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE\"</code> - message added to chat, including ones that client sent</p>\n</li>\n<li><p><code>\"EVENT_SERVER_INIT_MESSAGE_LIST\"</code> - send all messages from previous conversation, one time after chat connected</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_USER_DATA\"</code> - send user details when person identified or details changed</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE_STATUS\"</code> - message status changed</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_CHAT_STATE\"</code> - send chat status - e.g.,composing for Mia message typing</p>\n</li>\n<li><p><code>\"EVENT_INIT_ROOM\"</code> - chat <code>roomId</code> identifier defined or restored due person identified</p>\n</li>\n<li><p><code>\"EVENT_ERROR\"</code> - chat found an error</p>\n</li>\n</ul>\n<h2 id=\"payload-types\">Payload types:</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>type ClientMessageDto = {\n    content: string;\n};\ntype ServerMessageDto = {\n    id: string;\n    content: string;\n    from: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n    createdAt: string;\n    direction: \"outgoing\" | \"incoming\";\n}\ntype StatusDTO = {\n    messageId: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n}\ntype PersonDTO = {\n    name: string | null;\n    email: string | null;\n    phoneNumber: string | null;\n}\n\n</code></pre>","_postman_id":"36a59507-15eb-4fe0-a195-db96080d7e33"},{"name":"Talk","item":[{"name":"Auth","id":"554dec91-6ad8-46ec-9944-55ce69a02456","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer {{partnerToken}}","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"email_response_ticket@email.com\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://app.morada.ai/api/integrations/auth","auth":{"type":"bearer","bearer":{"token":"<token>"},"isInherited":true,"source":{"_postman_id":"af19302b-80b9-4334-997f-b429aea265fe","id":"af19302b-80b9-4334-997f-b429aea265fe","name":"Talk","type":"folder"}},"urlObject":{"protocol":"https","path":["api","integrations","auth"],"host":["app","morada","ai"],"query":[],"variable":[]}},"response":[],"_postman_id":"554dec91-6ad8-46ec-9944-55ce69a02456"},{"name":"Get Tickets","id":"d6a5b33c-9133-4f3e-952b-c77bcfe58c7d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Cookie","value":"__Secure-next-auth.session-token={{sessionToken}}","type":"text"},{"key":"Authorization","value":"Bearer {{partnerToken}}","type":"text"}],"url":"https://app.morada.ai/api/desk/tickets","auth":{"type":"bearer","bearer":{"token":"<token>"},"isInherited":true,"source":{"_postman_id":"af19302b-80b9-4334-997f-b429aea265fe","id":"af19302b-80b9-4334-997f-b429aea265fe","name":"Talk","type":"folder"}},"urlObject":{"protocol":"https","path":["api","desk","tickets"],"host":["app","morada","ai"],"query":[],"variable":[]}},"response":[],"_postman_id":"d6a5b33c-9133-4f3e-952b-c77bcfe58c7d"},{"name":"Websocket Talk","id":"cdc1c0ff-5759-4d7e-996c-b2ded7a02396","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"WSS","header":[],"url":"https://mia-gateway.morada.ai/talk","description":"<h1 id=\"talk-agent-interface\">Talk Agent Interface</h1>\n<p>Communication with the Talk service for human agents handling tickets.</p>\n<h3 id=\"testing\">Testing</h3>\n<p>Initialize Talk connection to connect to API server:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>const socket = io('/talk', {\n    auth: {\n        sessionToken: \"SessionToken\",   // required, agent's session token\n        ticketId: \"TicketId\",           // required, ID of the ticket the agent is handling\n    }\n});\n\n</code></pre><p>The agent must have permission to access the specified ticket. The system will validate the session token and ticket permissions before allowing the connection.</p>\n<h3 id=\"features\">Features</h3>\n<p>When an agent connects to the Talk service:</p>\n<ol>\n<li><p>The system validates the agent's session token and permissions for the ticket</p>\n</li>\n<li><p>Uses the ticket ID as the room ID (not the conversation ID)</p>\n</li>\n<li><p>Maintains a mapping between conversation IDs and ticket IDs for message routing</p>\n</li>\n<li><p>Retrieves the complete message history for the conversation, including messages from finished conversations</p>\n</li>\n<li><p>Allows the agent to send messages as an assistant</p>\n</li>\n<li><p>Provides real-time feedback during message sending process</p>\n</li>\n</ol>\n<h3 id=\"send-message-to-a-user\">Send message to a user:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>socket.emit(EVENT_CLIENT_SEND_MESSAGE, { content: \"Hello! I'm here to help you.\" });\n\n</code></pre><h3 id=\"listen-for-events\">Listen for events:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>// When room is initialized\nsocket.on(EVENT_INIT_ROOM, (data) =&gt; {\n    console.log(\"Connected as agent:\", data.agent);\n    console.log(\"Handling ticket:\", data.ticket);\n});\n// When message history is loaded\nsocket.on(EVENT_SERVER_INIT_MESSAGE_LIST, (messages) =&gt; {\n    messages.forEach(message =&gt; {\n        console.log(`${message.from}: ${message.content}`);\n    });\n});\n// When a new message is received\nsocket.on(EVENT_SERVER_SEND_MESSAGE, (message) =&gt; {\n    console.log(`${message.from}: ${message.content}`);\n});\n// When a message is being sent (in-progress)\nsocket.on(EVENT_SENDING_MESSAGE, ({ messageId }) =&gt; {\n    console.log(\"Message sending in progress:\", messageId);\n    // Show temporary \"Sending...\" indicator\n});\n// When a message fails to send\nsocket.on(EVENT_MESSAGE_SEND_FAILED, ({ messageId, error }) =&gt; {\n    console.error(\"Failed to send message:\", messageId, error);\n    // Show error notification\n});\n\n</code></pre><h3 id=\"talk-events\">Talk Events:</h3>\n<ul>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE\"</code> - message added to chat, including ones that client sent</p>\n</li>\n<li><p><code>\"EVENT_SERVER_INIT_MESSAGE_LIST\"</code> - send all messages from previous conversation, one time after chat connected</p>\n</li>\n<li><p><code>\"EVENT_CLIENT_SEND_MESSAGE\"</code> - send message as agent to the conversation</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE_STATUS\"</code> - message status changed</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_CHAT_STATE\"</code> - send chat status - e.g., composing for message typing</p>\n</li>\n<li><p><code>\"EVENT_INIT_ROOM\"</code> - chat information with agent and ticket details</p>\n</li>\n<li><p><code>\"EVENT_ERROR\"</code> - service found an error</p>\n</li>\n<li><p><code>\"SENDING_MESSAGE\"</code> - indicates a message is currently being sent (provides feedback to user)</p>\n</li>\n<li><p><code>\"MESSAGE_SEND_FAILED\"</code> - indicates a message failed to send (with error details)</p>\n</li>\n</ul>\n<h3 id=\"message-flow\">Message Flow</h3>\n<ol>\n<li><p>Agent sends message using <code>EVENT_CLIENT_SEND_MESSAGE</code></p>\n</li>\n<li><p>Client receives <code>SENDING_MESSAGE</code> event with <code>messageId</code> to show sending indicator</p>\n</li>\n<li><p>Message is sent to MIA Gateway</p>\n</li>\n<li><p>When message is stored in database, a database notification is triggered</p>\n</li>\n<li><p>Talk Service detects the notification and sends the message to all connected agents</p>\n</li>\n<li><p>Client receives final message via <code>EVENT_SERVER_SEND_MESSAGE</code> and removes sending indicator</p>\n</li>\n<li><p>If there's an error, client receives <code>MESSAGE_SEND_FAILED</code> with error details</p>\n</li>\n</ol>\n<h3 id=\"payload-types\">Payload types:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>type ClientMessageDto = {\n    content: string;\n};\ntype ServerMessageDto = {\n    id: string;\n    content: string;\n    from: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n    createdAt: string;\n    direction: \"outgoing\" | \"incoming\";\n    type: \"text/plain\" | \"application/vnd.lime.media-link+json\";\n    actor?: \"user\" | \"assistant\";\n}\ntype StatusDTO = {\n    messageId: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n}\ntype ChatStateDTO = {\n    from: string;\n    state: \"composing\" | string;\n};\ntype SendingMessageDto = {\n    messageId: string;\n};\ntype MessageSendFailedDto = {\n    messageId: string;\n    error: string;\n};\n\n</code></pre><h3 id=\"technical-details\">Technical Details</h3>\n<p>The Talk service is built on top of Socket.IO and runs as a separate namespace (<code>/talk</code>) to handle human agent connections in a more focused way than the general chat service. This separation allows for:</p>\n<ol>\n<li><p>More specific authentication for agents</p>\n</li>\n<li><p>Dedicated UI for agent workflows</p>\n</li>\n<li><p>Access to complete conversation history (including finished conversations)</p>\n</li>\n<li><p>Clear identification of messages sent by human agents</p>\n</li>\n<li><p>Routing messages by ticketId, making it agent-centric rather than conversation-centric</p>\n</li>\n</ol>\n<h3 id=\"connection-debugging\">Connection Debugging</h3>\n<p>If you're encountering issues with connections or message delivery:</p>\n<ol>\n<li><p>Check that the agent has permissions to access the specified ticket</p>\n</li>\n<li><p>Verify the session token is valid and not expired</p>\n</li>\n<li><p>Ensure the ticketId exists and is associated with a valid conversation</p>\n</li>\n<li><p>Monitor server logs for warnings or errors related to the Talk service</p>\n</li>\n<li><p>Check client console for connection errors or event issues</p>\n</li>\n<li><p>Verify that database notifications are being generated when messages are inserted</p>\n</li>\n</ol>\n","urlObject":{"protocol":"https","path":["talk"],"host":["mia-gateway","morada","ai"],"query":[],"variable":[]}},"response":[],"_postman_id":"cdc1c0ff-5759-4d7e-996c-b2ded7a02396"}],"id":"af19302b-80b9-4334-997f-b429aea265fe","description":"<h1 id=\"talk-agent-interface\">Talk Agent Interface</h1>\n<p>Communication with the Talk service for human agents handling tickets.</p>\n<h3 id=\"testing\">Testing</h3>\n<p>Initialize Talk connection to connect to API server:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">const socket = io('/talk', {\n    auth: {\n        sessionToken: \"SessionToken\",   // required, agent's session token\n        ticketId: \"TicketId\",           // required, ID of the ticket the agent is handling\n    }\n});\n\n</code></pre>\n<p>The agent must have permission to access the specified ticket. The system will validate the session token and ticket permissions before allowing the connection.</p>\n<h3 id=\"features\">Features</h3>\n<p>When an agent connects to the Talk service:</p>\n<ol>\n<li><p>The system validates the agent's session token and permissions for the ticket</p>\n</li>\n<li><p>Uses the ticket ID as the room ID (not the conversation ID)</p>\n</li>\n<li><p>Maintains a mapping between conversation IDs and ticket IDs for message routing</p>\n</li>\n<li><p>Retrieves the complete message history for the conversation, including messages from finished conversations</p>\n</li>\n<li><p>Allows the agent to send messages as an assistant</p>\n</li>\n<li><p>Provides real-time feedback during message sending process</p>\n</li>\n</ol>\n<h3 id=\"send-message-to-a-user\">Send message to a user:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">socket.emit(EVENT_CLIENT_SEND_MESSAGE, { content: \"Hello! I'm here to help you.\" });\n\n</code></pre>\n<h3 id=\"listen-for-events\">Listen for events:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">// When room is initialized\nsocket.on(EVENT_INIT_ROOM, (data) =&gt; {\n    console.log(\"Connected as agent:\", data.agent);\n    console.log(\"Handling ticket:\", data.ticket);\n});\n// When message history is loaded\nsocket.on(EVENT_SERVER_INIT_MESSAGE_LIST, (messages) =&gt; {\n    messages.forEach(message =&gt; {\n        console.log(`${message.from}: ${message.content}`);\n    });\n});\n// When a new message is received\nsocket.on(EVENT_SERVER_SEND_MESSAGE, (message) =&gt; {\n    console.log(`${message.from}: ${message.content}`);\n});\n// When a message is being sent (in-progress)\nsocket.on(EVENT_SENDING_MESSAGE, ({ messageId }) =&gt; {\n    console.log(\"Message sending in progress:\", messageId);\n    // Show temporary \"Sending...\" indicator\n});\n// When a message fails to send\nsocket.on(EVENT_MESSAGE_SEND_FAILED, ({ messageId, error }) =&gt; {\n    console.error(\"Failed to send message:\", messageId, error);\n    // Show error notification\n});\n\n</code></pre>\n<h3 id=\"talk-events\">Talk Events:</h3>\n<ul>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE\"</code> - message added to chat, including ones that client sent</p>\n</li>\n<li><p><code>\"EVENT_SERVER_INIT_MESSAGE_LIST\"</code> - send all messages from previous conversation, one time after chat connected</p>\n</li>\n<li><p><code>\"EVENT_CLIENT_SEND_MESSAGE\"</code> - send message as agent to the conversation</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_MESSAGE_STATUS\"</code> - message status changed</p>\n</li>\n<li><p><code>\"EVENT_SERVER_SEND_CHAT_STATE\"</code> - send chat status - e.g., composing for message typing</p>\n</li>\n<li><p><code>\"EVENT_INIT_ROOM\"</code> - chat information with agent and ticket details</p>\n</li>\n<li><p><code>\"EVENT_ERROR\"</code> - service found an error</p>\n</li>\n<li><p><code>\"SENDING_MESSAGE\"</code> - indicates a message is currently being sent (provides feedback to user)</p>\n</li>\n<li><p><code>\"MESSAGE_SEND_FAILED\"</code> - indicates a message failed to send (with error details)</p>\n</li>\n</ul>\n<h3 id=\"message-flow\">Message Flow</h3>\n<ol>\n<li><p>Agent sends message using <code>EVENT_CLIENT_SEND_MESSAGE</code></p>\n</li>\n<li><p>Client receives <code>SENDING_MESSAGE</code> event with <code>messageId</code> to show sending indicator</p>\n</li>\n<li><p>Message is sent to MIA Gateway</p>\n</li>\n<li><p>When message is stored in database, a database notification is triggered</p>\n</li>\n<li><p>Talk Service detects the notification and sends the message to all connected agents</p>\n</li>\n<li><p>Client receives final message via <code>EVENT_SERVER_SEND_MESSAGE</code> and removes sending indicator</p>\n</li>\n<li><p>If there's an error, client receives <code>MESSAGE_SEND_FAILED</code> with error details</p>\n</li>\n</ol>\n<h3 id=\"payload-types\">Payload types:</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-typescript\">type ClientMessageDto = {\n    content: string;\n};\ntype ServerMessageDto = {\n    id: string;\n    content: string;\n    from: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n    createdAt: string;\n    direction: \"outgoing\" | \"incoming\";\n    type: \"text/plain\" | \"application/vnd.lime.media-link+json\";\n    actor?: \"user\" | \"assistant\";\n}\ntype StatusDTO = {\n    messageId: string;\n    status: \"sent\" | \"delivered\" | \"read\" | \"failed\";\n}\ntype ChatStateDTO = {\n    from: string;\n    state: \"composing\" | string;\n};\ntype SendingMessageDto = {\n    messageId: string;\n};\ntype MessageSendFailedDto = {\n    messageId: string;\n    error: string;\n};\n\n</code></pre>\n<h3 id=\"technical-details\">Technical Details</h3>\n<p>The Talk service is built on top of Socket.IO and runs as a separate namespace (<code>/talk</code>) to handle human agent connections in a more focused way than the general chat service. This separation allows for:</p>\n<ol>\n<li><p>More specific authentication for agents</p>\n</li>\n<li><p>Dedicated UI for agent workflows</p>\n</li>\n<li><p>Access to complete conversation history (including finished conversations)</p>\n</li>\n<li><p>Clear identification of messages sent by human agents</p>\n</li>\n<li><p>Routing messages by ticketId, making it agent-centric rather than conversation-centric</p>\n</li>\n</ol>\n<h3 id=\"connection-debugging\">Connection Debugging</h3>\n<p>If you're encountering issues with connections or message delivery:</p>\n<ol>\n<li><p>Check that the agent has permissions to access the specified ticket</p>\n</li>\n<li><p>Verify the session token is valid and not expired</p>\n</li>\n<li><p>Ensure the ticketId exists and is associated with a valid conversation</p>\n</li>\n<li><p>Monitor server logs for warnings or errors related to the Talk service</p>\n</li>\n<li><p>Check client console for connection errors or event issues</p>\n</li>\n<li><p>Verify that database notifications are being generated when messages are inserted</p>\n</li>\n</ol>\n","auth":{"type":"bearer","bearer":{"token":"<token>"},"isInherited":false},"event":[{"listen":"prerequest","script":{"id":"ecdc511c-e631-4354-a0e9-d57008ca5b31","type":"text/javascript","packages":{},"exec":[""]}},{"listen":"test","script":{"id":"1415cc7a-c92a-4bc4-9ec6-3704fa7d4a01","type":"text/javascript","packages":{},"exec":[""]}}],"_postman_id":"af19302b-80b9-4334-997f-b429aea265fe"}],"event":[{"listen":"prerequest","script":{"id":"1e20421c-595a-4243-85e5-3a2a379ce575","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"e3c8b105-e6b9-4ec8-a91e-9ab8b0b8f456","type":"text/javascript","exec":[""]}}],"variable":[{"key":"baseUrl","value":""},{"key":"partnerId","value":""},{"key":"dealId","value":""}]}