Skip to main content
POST/users/:user_id/conversations/

Create conversation

You can create a conversation with your user starting with a message. Message content can be just plain text or HTML.

Hi <b>user</b>, enjoy our product!

The message will be shown as follow:

Hi user, enjoy our product!

Attributes

Optional unless marked required

user_idintegerrequired
A unique identifier for the user which is given by User automatically.
userinteger
A unique identifier for the agent (an author of the message) which is given by User automatically.
contentstringrequired
A content of a message sent to the user.
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.
source_contextstring
An additional context for your source (only visible for you).

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/users/:user_id/conversations/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"content": "Hi! This is a test message from the API docs check.",
"source": 3,
"user": 2
}'

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 200 OK response body.

idinteger
A unique identifier for the conversation which is given by User automatically.
assigned_toobject
The contact the conversation is with.
assigned_to.idinteger
ID of the contact.
assigned_to.keystring
The contact's user_key: a 12-character identifier assigned by User.
assigned_to.namestring
The contact's name.
assigned_to.emailstringnullable
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
ID of the agent group.
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.