Skip to main content
POST/message/send_message_as_user/

Send message as user

Send messages on chat on behalf of your users. Depending on your needs, you can create new conversations for your users or add messages to the existing conversations. In case of mismatching user_id with conversation id, the message won't be sent and a proper response will appear.

Attributes

Optional unless marked required

conversationinteger
A unique identifier for the conversation which is given by User (when conversation id is not provided - the request will create new converstaion for the user specified by user_id or user_custom_id).
* conversation is required if in the same payload "state" key is used.
user_idintegerrequired
A unique identifier for the user which is given by User automatically.
user_custom_idstringrequired
The unique identifier for the user which is provided by the client.
contentstringrequired
Content of a message.
statestring
Conversation status. You can choose between: 'snoozed', 'close' and 'active'.
snoozed_todate
Required if the 'snoozed' state is chosen.
sourceinteger
Where the message was sent from: 1 chat, 2 email, 3 API (the default), 4 SMS, 8 Facebook, 9 Instagram, 10 ChatAI. See Message source types.

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/message/send_message_as_user/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"conversation": 12345,
"user_id": 12345,
"content": "Thanks, that helps!"
}'

Response examples​

{
"id": 1,
"assigned_to": {
"id": 1,
"key": "g7lvoickax9e",
"name": "Jane Agent",
"email": "agent@example.com"
},
"active": true,
"agent": {
"id": 1,
"name": "Jane Agent"
},
"messages": 1
}

Response fields​

Fields returned in the 201 Created response body.

idinteger
A unique identifier for the conversation which is given by User automatically.
assigned_toobject
A unique identifier for the agent which is given by User automatically.
assigned_to.idinteger
A unique identifier for the conversation which is given by User automatically.
assigned_to.keystring
The contact's user_key: a 12-character identifier assigned by User.
assigned_to.namestring
The contact's name.
assigned_to.emailstring
The contact's email address, or null if they have none.
activeboolean
Whether the conversation is open. false once it is closed.
agentobject
The agent group the conversation is assigned to, or null.
agent.idinteger
A unique identifier for the conversation which is given by User automatically.
agent.namestring
Name of the agent group.
messagesinteger
Number of messages in the conversation.
note

Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.