You can post messages to any chat on behalf of a customer or an agent. To find a customer, use Search for customers method. To find a chat, use Search for chats method.
➡️ Request
URL | https://api.helpcrunch.com/v1/messages |
Method | POST |
Headers | Authorization: Bearer <your_api_key> |
Read more about authorization header here.
Chat id and message attributes should be placed to the body of your POST request. Check the example below.
{
"chat": 5215261,
"text": "Can you can a can as a canner can can a can?",
"markdownText": "Can you can a **can** as a canner can can a **can**",
"agent": 4188,
"type": "message"
}
chat, text, agent and type are required when you create a message from agent. For customer message, just skip the agent parameter.
If you want to create a message with the markdown (bold, italic, underline etc.), specify additionally the markdownText attribute.
✅ Successful Response
If your request has succeeded, you'll get a 200 OK success status code together with the following response body.
{
"id": 542335,
"agent": {
"id": 542335,
"name": "string",
"email": "string",
"role": "string"
},
"type": "tech",
"text": "string",
"read": true,
"createdAt": "1603885746",
"updatedAt": "1603885746",
"edited": true,
"broadcastType": "trigger",
"chat": 542335,
"from": "agent"
}
You can get details on every Message Object field in the Message model article.
🛑 Error Responses
You may get one of the following error status codes and responses. More info on the errors is available here.
400 Bad Request
{
"errors": [
{
"code": "invalid_request",
"message": "Invalid request"
},
{
"code": "customer",
"message": "This value should be of type numeric."
},
{
"code": "filter[0].field",
"message": "This value should not be blank."
}
]
}
401 Unauthorized
{
"errors": [
{
"code": "invalid_request",
"message": "Invalid request"
},
{
"code": "unauthorized",
"message": "Unauthorized"
}
]
}
429 Too Many Requests
{
"errors": [
{
"code": "invalid_request",
"message": "Invalid request"
},
{
"code": "too_many_requests",
"message": "Too many requests"
}
]
}
If you have any questions regarding the REST API, feel free to chat us any time.
👩💻 Happy Coding! 👨💻