Get all departments

Fetch a list of all departments for your account
Written by Konstantine
Updated 2 years ago

You can get a list of all departments for your HelpCrunch account. You may need this to get the id of the department you want to assign the chat to.

➡️ Request

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

Read more about authorization header here.


✅ Successful Response

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

{
    "data": [
        {
            "id": 233046,
            "name": "Support",
            "agents": [
                {
                    "id": 6692,
                    "name": "Borat",
                    "email": "borat.sagdiyev@example.net",
                    "role": "admin"
                },
                {
                    "id": 6668,
                    "name": "Ali",
                    "email": "ali.g@indahouse.com",
                    "role": "admin"
                },
                {
                    "id": 3279,
                    "name": "Brüno",
                    "email": "bruno@example.net",
                    "role": "admin"
                }
            ]
        },
        {
            "id": 142139,
            "name": "Marketing",
            "agents": [
                {
                    "id": 6668,
                    "name": "Ali",
                    "email": "ali.g@indahouse.com",
                    "role": "admin"
                },
                {
                    "id": 6677,
                    "name": "Benny",
                    "email": "benny.hill@example.net",
                    "role": "superviser"
                },
                {
                    "id": 4188,
                    "name": "Mr. Bean",
                    "email": "bean@example.net",
                    "role": "admin"
                }
            ]
        }
    ]
}

You can get details on every Department Object field in the Department 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"
        }
    ]
}

404 Not Found

{
    "errors": [
        {
            "code": "entity_not_found",
            "message": "Department not found"
        }
    ]
}

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?