Create chat

Create a single chat on behalf of a specific customer
Written by Konstantine
Updated 7 months ago

You can create a chat on behalf of a customer with this method. To post a message to this chat, please use the Create message method. 

It is not recommended to create empty chats without messages

➡️ Request

URL https://api.helpcrunch.com/v1/chats
Method POST
Headers Authorization: Bearer <your_api_key>

Read more about authorization header here.

To create a chat you should specify customer id (required) in the body of your POST request.

You can also specify chat assignee (optional), department (optional) and application (REQUIRED):

{
    "customer": 8738438,
    "assignee": 4188,
    "department": 233048,
    "application": 3838
}

How to get agent/assignee id
How to get department id
How to get application id

✅ Successful Response

If your request has succeeded, you'll get a 201 Created success status code together with the following response body.

{
    "id": 5215766,
    "closedBy": null,
    "lastCustomerMessageAt": null,
    "status": "empty",
    "closedAt": null,
    "rating": null,
    "createdAt": 1601556114,
    "lastMessageAt": null,
    "snoozedUntil": null,
    "lastMessageText": null,
    "lastMessageId": null,
    "lastCommunicatedAgentId": null,
    "agents": [],
    "customer": {
        "id": 8738438,
        "name": "John Doe",
        "email": "john@example.com",
        "userId": "myusers_4188"
    },
    "assignee": {
        "id": 4188,
        "name": "Derek Swanson",
        "email": "derek.swanson@company.com",
        "role": "admin"
    },
    "department": null
}

You can get details on every Chat Object field in the Chat model article.

🛑 Error Responses

You may get one of the following error status codes and responses. More info on the errors is available here.

401 Unauthorized

{
    "errors": [
        {
            "code": "invalid_token",
            "message": "Invalid token"
        }
    ]
}

429 Too Many Requests

{
    "errors": [
        {
            "code": "too_many_requests",
            "message": "You have exceeded your requests limit"
        }
    ]
}

If you have any questions regarding the REST API, feel free to chat us any time.

👩‍💻 Happy Coding! 👨‍💻

Did this answer your question?