Pular para o conteúdo principal

Eventos de negócio

Um evento de negócio é qualquer coisa que aparece na timeline de um deal: uma nota, uma atividade agendada, ou uma mensagem disparada via Chatwoot ou Evolution API (WhatsApp).

Existe um único endpoint, mas ele aceita vários tipos (kinds) de evento. O campo kind decide quais campos são obrigatórios e quais efeitos colaterais o sistema executa.

Endpoint

POST /api/v1/accounts/{account_id}/deals/{deal_id}/events

Path paramTipoObrigatórioDescrição
account_idintegerSimEscopo da conta.
deal_idintegerSimNegócio que receberá o evento.

Headers

HeaderValor
Content-Typeapplication/json
AuthorizationBearer SEU_TOKEN_AQUI

Atributos comuns

AtributoTipoObrigatórioExemploNotas
kindstringSimnoteUm de note, activity, chatwoot_message, evolution_api_message.
titlestringNãoLigação de follow-upDefault vazio.
contentstringGeralmente simTudo certo?Corpo da nota / atividade / mensagem.
donebooleanNãotrueMarca o evento como concluído.
auto_donebooleanNãofalseSe true, o sistema marca o evento como done automaticamente (ex.: após enviar uma mensagem).
done_atdatetime (UTC)Não2025-01-18T15:30:00ZQuando foi concluído.
scheduled_atdatetime (UTC)Às vezes2025-01-20T14:00:00ZObrigatório para mensagens agendadas.
send_nowbooleanÀs vezestrueObrigatório para mensagens "enviar agora".
app_typestringÀs vezesApps::ChatwootUm de Apps::Chatwoot, Apps::EvolutionApi.
app_idintegerÀs vezes5ID da integração do app.
additional_attributesobjectÀs vezes{ "chatwoot_inbox_id": "62483" }Extras específicos do app.
custom_attributesobjectNão{ "channel": "whatsapp" }Campos customizados livres.

As próximas seções mostram o body exato para cada kind.


1. Criar nota (kind = note)

Uma nota é um registro em texto livre na timeline do negócio. Sem efeitos colaterais.

Body

{
"kind": "note",
"content": "Conteúdo do texto..."
}

Exemplo de requisição

curl -X POST "https://app.woofedcrm.com/api/v1/accounts/1/deals/1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SEU_TOKEN_AQUI" \
-d '{
"kind": "note",
"content": "Liguei para o cliente para discutir os próximos passos."
}'

Exemplo de resposta — 201 Created

{
"id": 88,
"deal_id": 1,
"contact_id": 1,
"app_type": null,
"app_id": null,
"kind": "note",
"scheduled_at": null,
"done_at": null,
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": {},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "",
"auto_done": false,
"account_id": 1,
"done": false,
"send_now": null,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Liguei para o cliente para discutir os próximos passos."
}

2. Criar atividade (kind = activity)

Uma atividade é uma tarefa agendada na timeline (uma ligação, uma reunião, um follow-up).

Body

{
"title": "Activity example title",
"kind": "activity",
"content": "Conteúdo do texto...",
"scheduled_at": "2025-01-20T14:00:00Z",
"done": false
}

Exemplo de requisição

curl -X POST "https://app.woofedcrm.com/api/v1/accounts/1/deals/1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SEU_TOKEN_AQUI" \
-d '{
"title": "Ligação de follow-up",
"kind": "activity",
"content": "Confirmar que a proposta foi recebida",
"scheduled_at": "2025-01-20T14:00:00Z",
"done": false
}'

Exemplo de resposta — 201 Created

{
"id": 89,
"deal_id": 1,
"contact_id": 1,
"app_type": null,
"app_id": null,
"kind": "activity",
"scheduled_at": "2025-01-20T14:00:00Z",
"done_at": null,
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": {},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "Ligação de follow-up",
"auto_done": false,
"account_id": 1,
"done": false,
"send_now": null,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Confirmar que a proposta foi recebida"
}

3. Agendar mensagem do Chatwoot (kind = chatwoot_message)

Agenda uma mensagem que será enviada por uma inbox do Chatwoot em scheduled_at.

Body

{
"title": "Chatwoot Message",
"content": "Tudo certo?",
"kind": "chatwoot_message",
"auto_done": false,
"scheduled_at": "2025-01-20T14:00:00Z",
"app_type": "Apps::Chatwoot",
"app_id": 6,
"additional_attributes": {
"chatwoot_inbox_id": "62483"
}
}

Campos obrigatórios deste kind

AtributoObrigatórioNotas
kindSimDeve ser chatwoot_message.
contentSimCorpo da mensagem.
scheduled_atSimUTC.
app_typeSimApps::Chatwoot.
app_idSimID da integração Chatwoot.
additional_attributes.chatwoot_inbox_idSimInbox de destino.

Exemplo de requisição

curl -X POST "https://app.woofedcrm.com/api/v1/accounts/1/deals/1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SEU_TOKEN_AQUI" \
-d '{
"title": "Chatwoot Message",
"content": "Tudo certo?",
"kind": "chatwoot_message",
"auto_done": false,
"scheduled_at": "2025-01-20T14:00:00Z",
"app_type": "Apps::Chatwoot",
"app_id": 6,
"additional_attributes": { "chatwoot_inbox_id": "62483" }
}'

Exemplo de resposta — 201 Created

{
"id": 90,
"deal_id": 1,
"contact_id": 1,
"app_type": "Apps::Chatwoot",
"app_id": 6,
"kind": "chatwoot_message",
"scheduled_at": "2025-01-20T14:00:00Z",
"done_at": null,
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": { "chatwoot_inbox_id": "62483" },
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "Chatwoot Message",
"auto_done": false,
"account_id": 1,
"done": false,
"send_now": null,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Tudo certo?"
}

4. Enviar mensagem do Chatwoot imediatamente

Mesmo kind do anterior, mas enviada imediatamente com send_now: true.

Body

{
"title": "Chatwoot Message",
"content": "Tudo certo?",
"kind": "chatwoot_message",
"send_now": true,
"app_type": "Apps::Chatwoot",
"app_id": 5,
"additional_attributes": {
"chatwoot_inbox_id": "62483"
}
}

Campos obrigatórios deste kind

AtributoObrigatórioNotas
kindSimchatwoot_message.
contentSimCorpo da mensagem.
send_nowSimtrue.
app_typeSimApps::Chatwoot.
app_idSimID da integração Chatwoot.
additional_attributes.chatwoot_inbox_idSimInbox de destino.

Exemplo de resposta — 201 Created

{
"id": 91,
"deal_id": 1,
"contact_id": 1,
"app_type": "Apps::Chatwoot",
"app_id": 5,
"kind": "chatwoot_message",
"scheduled_at": null,
"done_at": "2025-01-15T10:30:00Z",
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": { "chatwoot_inbox_id": "62483" },
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "Chatwoot Message",
"auto_done": true,
"account_id": 1,
"done": true,
"send_now": true,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Tudo certo?"
}

5. Agendar mensagem do WhatsApp (kind = evolution_api_message)

Agenda uma mensagem da Evolution API (WhatsApp) para ser enviada em scheduled_at.

Body

{
"title": "Whatsapp Message",
"content": "Tudo certo?",
"kind": "evolution_api_message",
"auto_done": false,
"scheduled_at": "2025-01-20T14:00:00Z",
"app_type": "Apps::EvolutionApi",
"app_id": 5
}

Campos obrigatórios deste kind

AtributoObrigatórioNotas
kindSimevolution_api_message.
contentSimCorpo da mensagem.
scheduled_atSimUTC.
app_typeSimApps::EvolutionApi.
app_idSimID da integração Evolution API.

Exemplo de requisição

curl -X POST "https://app.woofedcrm.com/api/v1/accounts/1/deals/1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SEU_TOKEN_AQUI" \
-d '{
"title": "Whatsapp Message",
"content": "Tudo certo?",
"kind": "evolution_api_message",
"scheduled_at": "2025-01-20T14:00:00Z",
"app_type": "Apps::EvolutionApi",
"app_id": 5
}'

Exemplo de resposta — 201 Created

{
"id": 92,
"deal_id": 1,
"contact_id": 1,
"app_type": "Apps::EvolutionApi",
"app_id": 5,
"kind": "evolution_api_message",
"scheduled_at": "2025-01-20T14:00:00Z",
"done_at": null,
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": {},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "Whatsapp Message",
"auto_done": false,
"account_id": 1,
"done": false,
"send_now": null,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Tudo certo?"
}

6. Enviar mensagem do WhatsApp imediatamente

Mesmo kind do anterior, mas com send_now: true.

Body

{
"title": "Whatsapp Message",
"content": "Tudo certo?",
"kind": "evolution_api_message",
"send_now": true,
"app_type": "Apps::EvolutionApi",
"app_id": 5
}

Exemplo de requisição

curl -X POST "https://app.woofedcrm.com/api/v1/accounts/1/deals/1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer SEU_TOKEN_AQUI" \
-d '{
"title": "Whatsapp Message",
"content": "Tudo certo?",
"kind": "evolution_api_message",
"send_now": true,
"app_type": "Apps::EvolutionApi",
"app_id": 5
}'

Exemplo de resposta — 201 Created

{
"id": 93,
"deal_id": 1,
"contact_id": 1,
"app_type": "Apps::EvolutionApi",
"app_id": 5,
"kind": "evolution_api_message",
"scheduled_at": null,
"done_at": "2025-01-15T10:30:00Z",
"from_me": true,
"status": null,
"custom_attributes": {},
"additional_attributes": {},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z",
"title": "Whatsapp Message",
"auto_done": true,
"account_id": 1,
"done": true,
"send_now": true,
"files": [],
"files_events": [],
"invalid_files": null,
"content": "Tudo certo?"
}

Possíveis erros

StatusQuando
401Token ausente ou inválido.
404O negócio não existe nessa conta.
422kind inválido, campo obrigatório do kind ausente, scheduled_at mal formatado, ou app_id / app_type desconhecidos.