This page details the JSON schemas for events sent by our API, typically via webhooks
event: "user.created"
event: "user.created"Fired when a new user is created.
Full JSON Payload Example:
{
"event": "user.created",
"timestamp": "2024-05-21T10:30:00.123Z",
"data": {
"id": "usr_12345abcde",
"name": "John Doe",
"externalIdentifier": "CUST-9876",
"email": "[email protected]",
"birthDate": "1990-05-15",
"cpf": "123.456.789-00",
"phone": "+14155552671",
"gender": "male",
"metadata": {
"signup_source": "website",
"plan": "premium"
},
"preferences": {
"timezone": "America/Los_Angeles",
"language": "en-US",
"communicationOptIn": {
"whatsapp": true,
"sms": false
}
}
}
}JSON Schema fordata field:
{
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"externalIdentifier": { "type": "string" },
"email": { "type": "string", "format": "email" },
"birthDate": { "type": "string", "format": "date" },
"cpf": { "type": "string" },
"phone": { "type": "string" },
"gender": { "type": "string" },
"metadata": { "type": "object", "additionalProperties": true },
"preferences": {
"type": "object",
"properties": {
"timezone": { "type": "string" },
"language": { "type": "string" },
"communicationOptIn": {
"type": "object",
"properties": {
"whatsapp": { "type": "boolean" },
"sms": { "type": "boolean" }
}
}
}
}
},
"required": ["id", "name", "email", "birthDate", "cpf", "phone", "gender", "metadata"]
}event: "user.updated"
event: "user.updated"Fired when an existing user's data is updated. Includes the previous state (oldState).
Full JSON Payload Example:
{
"event": "user.updated",
"timestamp": "2024-05-21T11:00:05.456Z",
"data": {
"id": "usr_12345abcde",
"name": "John A. Doe",
"externalIdentifier": "CUST-9876",
"email": "[email protected]",
"birthDate": "1990-05-15",
"cpf": "123.456.789-00",
"phone": "+14155551234",
"gender": "male",
"metadata": {
"signup_source": "website",
"plan": "premium",
"last_update_source": "support_agent"
},
"preferences": {
"timezone": "America/Los_Angeles",
"language": "en-US",
"communicationOptIn": {
"whatsapp": true,
"sms": true
}
},
"oldState": {
"id": "usr_12345abcde",
"name": "John Doe",
"externalIdentifier": "CUST-9876",
"email": "[email protected]",
"birthDate": "1990-05-15",
"cpf": "123.456.789-00",
"phone": "+14155552671",
"gender": "male",
"metadata": {
"signup_source": "website",
"plan": "premium"
},
"preferences": {
"timezone": "America/Los_Angeles",
"language": "en-US",
"communicationOptIn": {
"whatsapp": true,
"sms": false
}
}
}
}
}JSON Schema fordata field:
{
"definitions": {
"UserBase": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"externalIdentifier": { "type": "string" },
"email": { "type": "string", "format": "email" },
"birthDate": { "type": "string", "format": "date" },
"cpf": { "type": "string" },
"phone": { "type": "string" },
"gender": { "type": "string" },
"metadata": { "type": "object", "additionalProperties": true },
"preferences": {
"type": "object",
"properties": {
"timezone": { "type": "string" },
"language": { "type": "string" },
"communicationOptIn": {
"type": "object",
"properties": {
"whatsapp": { "type": "boolean" },
"sms": { "type": "boolean" }
}
}
}
}
},
"required": ["id", "name", "email", "birthDate", "cpf", "phone", "gender", "metadata"]
}
},
"type": "object",
"allOf": [
{ "$ref": "#/definitions/UserBase" }
],
"properties": {
"oldState": {
"$ref": "#/definitions/UserBase"
}
},
"required": ["oldState"]
}event: "user.deleted"
event: "user.deleted"Fired when a user is deleted.
Full JSON Payload Example:
{
"event": "user.deleted",
"timestamp": "2024-05-21T12:00:00.000Z",
"data": {
"id": "usr_12345abcde",
"externalIdentifier": "CUST-9876"
}
}JSON Schema fordata field:
{
"type": "object",
"properties": {
"id": { "type": "string" },
"externalIdentifier": { "type": "string" }
},
"required": ["id"]
}event: "chat.created"
event: "chat.created"Fired when a new chat is created.
Full JSON Payload Example:
{
"event": "chat.created",
"timestamp": "2024-05-21T14:15:30.987Z",
"data": {
"id": "chat_fedcba9876",
"agent": {
"id": "agent_support_01",
"name": "Support Agent Mary"
},
"userId": "usr_12345abcde"
}
}JSON Schema fordata field:
{
"type": "object",
"properties": {
"id": { "type": "string" },
"agent": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" }
},
"required": ["id", "name"]
},
"userId": { "type": "string" }
},
"required": ["id", "agent", "userId"]
}event: "chat.deleted"
event: "chat.deleted"Fired when a chat is deleted.
Full JSON Payload Example:
{
"event": "chat.deleted",
"timestamp": "2024-05-21T15:00:00.005Z",
"data": {
"id": "chat_fedcba9876",
"agent": {
"id": "agent_support_01",
"name": "Support Agent Mary"
},
"userId": "usr_12345abcde"
}
}JSON Schema fordata field:
{
"type": "object",
"properties": {
"id": { "type": "string" },
"agent": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" }
},
"required": ["id", "name"]
},
"userId": { "type": "string" }
},
"required": ["id", "agent", "userId"]
}event: "chat.message.created"
event: "chat.message.created"Fired when a new message is sent within a chat.
Full JSON Payload Example (User Message):
{
"event": "chat.message.created",
"timestamp": "2024-05-21T14:16:02.111Z",
"data": {
"chat": {
"id": "chat_fedcba9876",
"userId": "usr_12345abcde",
"agentId": "agent_support_01"
},
"id": "msg_zyxwvu6543",
"content": {
"text": "Hello, I need help with my order.",
"image": [
{ "fileId": "file_img_order_issue.jpg" }
]
},
"from": {
"type": "user"
},
"timestamp": "2024-05-21T14:16:01.999Z",
"platform": {
"type": "whatsapp"
}
}
}Full JSON Payload Example (Agent Message):
{
"event": "chat.message.created",
"timestamp": "2024-05-21T14:17:10.555Z",
"data": {
"chat": {
"id": "chat_fedcba9876",
"userId": "usr_12345abcde",
"agentId": "agent_support_01"
},
"id": "msg_abcdef1234",
"content": {
"text": "Hello John! Sure, what is the order number, please?"
},
"from": {
"type": "agent",
"agentId": "agent_support_01",
"reason": "response_to_user"
},
"timestamp": "2024-05-21T14:17:10.444Z",
"platform": {
"type": "psycoai"
}
}
}JSON Schema fordata field:
{
"type": "object",
"properties": {
"chat": {
"type": "object",
"properties": {
"id": { "type": "string" },
"userId": { "type": "string" },
"agentId": { "type": "string" }
},
"required": ["id", "userId", "agentId"]
},
"id": { "type": "string" },
"content": {
"type": "object",
"properties": {
"text": { "type": "string" },
"image": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fileId": { "type": "string" }
},
"required": ["fileId"]
}
},
"medias": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["text"]
},
"from": {
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["user", "agent", "mediator"] },
"agentId": { "type": "string" },
"reason": { "type": "string" },
"userId": { "type": "string" }
},
"required": ["type"]
},
"timestamp": { "type": "string", "format": "date-time" },
"platform": {
"type": "object",
"properties": {
"type": { "type": "string", "enum": ["api", "psycoai", "whatsapp", "sms", "call"] }
},
"required": ["type"]
}
},
"required": ["chat", "id", "content", "from", "timestamp", "platform"]
}event: "chat.message.status.updated"
event: "chat.message.status.updated"Fired when a message’s status changes, such as when it is sent, delivered, or read.
Full JSON Payload Example:
{
"event": "chat.message.status.updated",
"timestamp": "2024-05-21T15:00:00.005Z",
"data": {
"messageId": "000000",
"status": "delivered",
"timestamp": "2024-05-21T13:00:00.005Z",
"error": false,
"chatId": "00000000-00000000-00000000-00000000",
"userId": "00000000-00000000-00000000-00000000"
}
}event: "chat.tag.appended"
event: "chat.tag.appended"Triggered when a tag is added to a chat or message.
Full JSON Payload Example:
{
"event": "chat.message.status.updated",
"timestamp": "2024-05-21T15:00:00.005Z",
"data": {
"chatId": "00000000-00000000-00000000-00000000",
"tagId": "00000000-00000000-00000000-00000000",
"tagName": "Lead Interessado"
}
}