Logo Site EngageLab Mark Colored TransparentDocument
Search

How to Send Messages to the API Channel

Since API Channel does not support implicit contact creation. LivedDesk uses API Channel in three steps:

  1. Create a contact
  2. Create a conversation based on contact information
  3. Send a message

Create a Contact

API Endpoint

https://livedesk-api.engagelab.com/api/v2/accounts/contacts

Request Example

curl -X POST https://livedesk-api.engagelab.com/api/v2/accounts/contacts \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic base64(api_key:api_secret)' \ { "inbox_id": 407, "name": "Test", // Optional "email": "alice@acme.inc", "phone_number": "+123456789", "avatar_url": "https://example.com/avatar.png", "identifier": "1234567890", }
              
              curl -X POST https://livedesk-api.engagelab.com/api/v2/accounts/contacts \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)' \
{
    "inbox_id": 407,
    "name": "Test",                   // Optional
    "email": "alice@acme.inc",
    "phone_number": "+123456789", 
    "avatar_url": "https://example.com/avatar.png",
    "identifier": "1234567890",
}

            
This code block in the floating window

Request Headers

Field Type Description
Authorization string Use Authorization: Basic base64(API Key:API Secret) for authentication. Please go to the API Key page to obtain API Key and API Secret, and concatenate them with a colon before Base64 encoding.
Content-Type application/json Data type, use application/json for plain text messages.

Request Body Parameters

Field Type Required Description
inbox_id String Yes channel ID. Corresponding to the Channel ID in "Project Settings-Channels-Specific channel-Settings".
name String No Contact name.
email String No Email address.
phone_number String No Contact method.
avatar_url String No Attachment link.
identifier String No User identifier.

Response Example

{ "payload": { "contact": { "additional_attributes": {}, "availability_status": "offline", "email": null, "id": 2219259, "name": "Test", "phone_number": null, "blocked": false, "identifier": null, "thumbnail": "", "custom_attributes": {}, "created_at": 1766571703, "contact_inboxes": [] }, "contact_inbox": { "inbox": null, "source_id": null } } }
              
              {
    "payload": {
        "contact": {
            "additional_attributes": {},
            "availability_status": "offline",
            "email": null,
            "id": 2219259,
            "name": "Test",
            "phone_number": null,
            "blocked": false,
            "identifier": null,
            "thumbnail": "",
            "custom_attributes": {},
            "created_at": 1766571703,
            "contact_inboxes": []
        },
        "contact_inbox": {
            "inbox": null,
            "source_id": null
        }
    }
}

            
This code block in the floating window

Response Parameters

Field Type Required Description
additional_attributes Object No Attachment attributes.
availability_status String No Online status, default is offline.
email String No Email address.
id String No Contact ID.
name String No Name
phone_number String No Phone number.
blocked String No Whether locked, default is false.
identifier String No User identifier.
thumbnail String No User identifier.
custom_attributes String No Customer attributes.
created_at String No Creation timestamp.
contact_inboxes Array No User identifier.
inbox String No channel channel.
source_id String No Source ID.

Create a Conversation

API Endpoint

https://livedesk-api.engagelab.com/api/v2/accounts/conversations

Request Example

curl -X POST https://livedesk-api.engagelab.com/api/v2/accounts/conversations \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic base64(api_key:api_secret)' \ { "inbox_id": 407, // Required "contact_id": 2219256, // Either contact_id or source_id can be passed, but it must correctly identify the sender "source_id": "123456789" }
              
              curl -X POST https://livedesk-api.engagelab.com/api/v2/accounts/conversations \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)' \
{
  "inbox_id": 407,              // Required
  "contact_id": 2219256,        // Either contact_id or source_id can be passed, but it must correctly identify the sender
  "source_id": "123456789"
}

            
This code block in the floating window

Request Headers

Field Type Description
Authorization string Use Authorization: Basic base64(API Key:API Secret) for authentication. Please go to the API Key page to obtain API Key and API Secret, and concatenate them with a colon before Base64 encoding.
Content-Type application/json Data type, use application/json for plain text messages.

Request Body Parameters

Field Type Required Description
inbox_id String Yes channel ID. Same as the ID used in the contact creation interface.
contact_id String No Contact ID. The id from the contact creation interface response
source_id String No Source ID.

Response Example

{ "meta": { "sender": { "additional_attributes": {}, "availability_status": "offline", "email": null, "id": 2219256, "name": "Test", "phone_number": null, "blocked": false, "identifier": null, "thumbnail": "", "custom_attributes": {}, "created_at": 1766571624 }, "channel": "Channel::Api", "hmac_verified": false }, "id": 40, "messages": [], "account_id": 17623000010928, "uuid": "660ce36f-46bb-4153-948c-8a26e6dab634", "inbox_id": 407, "additional_attributes": {}, "agent_last_seen_at": 0, "assignee_last_seen_at": 0, "can_reply": true, "contact_last_seen_at": 0, "custom_attributes": {}, "labels": [], "muted": false, "snoozed_until": null, "status": "open", "priority": null, "conversation_category": "chat", "chat_mode": "private_chat", "is_forum": false, "created_at": 1766572062, "updated_at": 1766572062.5803902, "timestamp": 1766572062, "first_reply_created_at": 0, "unread_count": 0, "last_non_activity_message": null, "last_activity_at": 1766572062, "waiting_since": 1766572062, "sla_policy_id": null, "ticket_id": null, "over_limit": false, "content_preview": { "content": null, "message_type": null, "created_at": null }, "platform": { "channel_type": "Channel::Api", "inbox_name": "JennyApi", "inbox_id": 407 }, "account_info": { "contact_name": "Test", "contact_email": null, "contact_phone": null, "contact_id": 2219256, "contact_avatar": "" }, "assignment": { "assignee_id": null, "assignee_name": null, "assignee_email": null, "team_id": null, "team_name": null } }
              
              {
    "meta": {
        "sender": {
            "additional_attributes": {},
            "availability_status": "offline",
            "email": null,
            "id": 2219256,
            "name": "Test",
            "phone_number": null,
            "blocked": false,
            "identifier": null,
            "thumbnail": "",
            "custom_attributes": {},
            "created_at": 1766571624
        },
        "channel": "Channel::Api",
        "hmac_verified": false
    },
    "id": 40,
    "messages": [],
    "account_id": 17623000010928,
    "uuid": "660ce36f-46bb-4153-948c-8a26e6dab634",
    "inbox_id": 407,
    "additional_attributes": {},
    "agent_last_seen_at": 0,
    "assignee_last_seen_at": 0,
    "can_reply": true,
    "contact_last_seen_at": 0,
    "custom_attributes": {},
    "labels": [],
    "muted": false,
    "snoozed_until": null,
    "status": "open",
    "priority": null,
    "conversation_category": "chat",
    "chat_mode": "private_chat",
    "is_forum": false,
    "created_at": 1766572062,
    "updated_at": 1766572062.5803902,
    "timestamp": 1766572062,
    "first_reply_created_at": 0,
    "unread_count": 0,
    "last_non_activity_message": null,
    "last_activity_at": 1766572062,
    "waiting_since": 1766572062,
    "sla_policy_id": null,
    "ticket_id": null,
    "over_limit": false,
    "content_preview": {
        "content": null,
        "message_type": null,
        "created_at": null
    },
    "platform": {
        "channel_type": "Channel::Api",
        "inbox_name": "JennyApi",
        "inbox_id": 407
    },
    "account_info": {
        "contact_name": "Test",
        "contact_email": null,
        "contact_phone": null,
        "contact_id": 2219256,
        "contact_avatar": ""
    },
    "assignment": {
        "assignee_id": null,
        "assignee_name": null,
        "assignee_email": null,
        "team_id": null,
        "team_name": null
    }
}

            
This code block in the floating window

Response Parameters

Field Type Required Description
meta Object No Metadata object.
sender Object No Sender information.
additional_attributes Object No Additional attributes.
availability_status String No Availability status.
email Null No Email.
id Number No Contact ID.
name String No Sender name.
phone_number Null No Phone number.
blocked Boolean No Whether blocked.
identifier Null No User attribute identifier.
thumbnail String No Thumbnail.
custom_attributes Object No Custom attributes.
created_at Number No Conversation creation timestamp.
channel String No Channel type.
hmac_verified Boolean No HMAC verification status.
id Number No Conversation ID.
messages Array No Message array.
account_id Number No Project ID
uuid String No Unique identifier.
inbox_id Number No Channel ID.
additional_attributes Object No Additional attributes.
agent_last_seen_at Number No Agent last processed time.
assignee_last_seen_at Number No Assignee last processed time.
can_reply Boolean No Whether can reply.
contact_last_seen_at Number No Contact last seen time.
custom_attributes Object No Custom attributes.
labels Array No Label array.
muted Boolean No Whether muted.
snoozed_until Null No Until when paused.
status String No Status.
priority Null No Priority.
conversation_category String No Conversation category.
chat_mode String No Chat mode.
is_forum Boolean No Whether it is a forum.
created_at Number No Creation timestamp.
updated_at Number No Update timestamp.
timestamp Number No Timestamp.
first_reply_created_at Number No First reply creation time.
unread_count Number No Unread count.
last_non_activity_message Null No Last non-activity message.
last_activity_at Number No Last activity time.
waiting_since Number No Waiting start time.
sla_policy_id Null No SLA policy ID.
ticket_id Null No Ticket ID.
over_limit Boolean No Whether over limit.
content_preview Object No Content preview.
content_preview.content Null No Preview content.
content_preview.message_type Null No Message type.
content_preview.created_at Null No Creation time.
platform Object No Platform information.
channel_type String No Channel type.
inbox_name String No Inbox name.
inbox_id Number No Inbox ID.
account_info Object No Account information.
contact_name String No Contact name.
contact_email Null No Contact email.
contact_phone Null No Contact phone.
contact_id Number No Contact ID.
contact_avatar String No Contact avatar.
assignment Object No Assignment information.
assignee_id Null No Assignee ID.
assignee_name Null No Assignee name.
assignee_email Null No Assignee email.
team_id Null No Team ID.
team_name Null No Team name.

Send a Message

API Endpoint

https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages

Request Example

curl -X POST 'https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages' \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic base64(api_key:api_secret)' \ -d '{ "content": "Customer service sends a message, is it normal?", "private": false, "message_type": "incoming", "content_attributes": { "in_reply_to": 29 } }'
              
              curl -X POST 'https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)' \
-d '{
    "content": "Customer service sends a message, is it normal?",  
    "private": false,
    "message_type": "incoming",
    "content_attributes": {
        "in_reply_to": 29   
    }
}'

            
This code block in the floating window

Request Headers

Field Type Description
Authorization string Use Authorization: Basic base64(API Key:API Secret) for authentication. Please go to the API Key page to obtain API Key and API Secret, and concatenate them with a colon before Base64 encoding.
Content-Type application/json Data type, use application/json for plain text messages.

Request Body Parameters

Field Type Required Description
content String No channel ID. Corresponding to the Channel ID in "Project Settings-Channels-Specific channel-Settings".
private String No Contact name.
message_type String No Message type, outgoing or incoming. Representing customer service sending or user sending respectively. Defaults to outgoing if not passed.
content_attributes String No Content attributes.
in_reply_to String No Reply content.
Icon Solid Transparent White Qiyu
Contact Sales