Update chat department

Change department the chat is assigned to
Written by Konstantine
Updated 7 months ago

You can change the assigned department for any chat by their id.

➡️ Request

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

Read more about authorization header here.

You should specify chat id (required) and department id (required) in the body of your PUT request.

{
    "id": 5215752,
    "department": 233048
}

How to get department id


✅ Successful Response

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

{
    "id": 5215752,
    "closedBy": null,
    "lastCustomerMessageAt": null,
    "status": "pending",
    "closedAt": null,
    "rating": null,
    "createdAt": 1597758468,
    "lastMessageAt": 1597762389,
    "snoozedUntil": null,
    "lastMessageText": "That was quick. Thanks.",
    "lastMessageId": 9577621,
    "lastCommunicatedAgentId": 4188,
    "agents": [],
    "customer": {
        "id": 8738438,
        "name": "Mike Storm",
        "email": "mike@example.com",
        "userId": "myusers_4188"
    },
    "assignee": null,
    "department": {
        "id": 233048,
        "name": "Test Department"
    }
}

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.

400 Bad Request

{
    "errors": [
        {
            "code": "invalid_chat_value",
            "message": "department value is invalid"
        }
    ]
}

401 Unauthorized

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

404 Not Found

{
    "errors": [
        {
            "code": "chat_not_found",
            "message": "Chat is missing"
        }
    ]
}

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?