400 Bad Request on Analytics Conversations Aggregates query via Zapier

My configuration keeps failing… I am trying to build a custom interval report using POST /api/v2/analytics/conversations/aggregates/query from a Zapier custom action but receive a 400 Bad Request. The payload structure seems correct according to the docs but the error response is generic.

  • Endpoint: /api/v2/analytics/conversations/aggregates/query
  • Method: POST
  • Auth: OAuth2 Client Credentials

Here is the query body I am sending:

{
 "interval": "2023-10-01T00:00:00.000Z/2023-10-02T00:00:00.000Z",
 "viewId": "standard",
 "groupings": [{"type": "metric", "id": "conversationCount"}]
}

The response body says invalid request. Is the groupings object schema different for aggregates vs summary queries?

2 Likes

You need to stop sending the query as a JSON body. The analytics endpoint strictly requires the query definition in the request body. Zapier’s custom action builder often defaults to a GET-like structure or ignores the body for POST requests, which triggers the 400 error because the parser expects a specific JSON payload.

  1. Switch the request type to POST.
  2. Ensure the JSON payload is sent in the Body section of your Zapier step, not as query parameters.
  3. Ensure the dateRange object is structured correctly within the JSON body as per the schema.

The documentation implies a body for complex queries, and the actual API spec for aggregates confirms it is body-based. Here is the correct curl equivalent to verify the structure before hardcoding it into Zapier:

curl -X POST "https://api.mypurecloud.com/api/v2/analytics/conversations/aggregates/query" \
 -H "Authorization: Bearer <token>" \
 -H "Content-Type: application/json" \
 -d '{
  "dateRange": {
    "startDate": "2023-10-01T00:00:00.000Z",
    "endDate": "2023-10-02T00:00:00.000Z"
  },
  "groupBy": [
    {
      "name": "conversation:direction"
    }
  ]
}'

Check the raw request log in Zapier. If you see query parameters instead of a JSON body, it will fail.

3 Likes

This looks like a parameter serialization issue common in low-code integrations.

The analytics aggregates endpoint expects the query parameters in the request body, not as URL-encoded query strings. Zapier often mishandles this encoding for POST requests.

Use this curl structure to validate the correct syntax: curl -X POST "https://api.mypurecloud.com/api/v2/analytics/conversations/aggregates/query" -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d '{"dateRange": {"start": "2023-01-01T00:00:00.000Z", "end": "2023-01-02T00:00:00.000Z"}, "groupBy": ["queue"]}'.

Check your Zapier step configuration because the platform strictly rejects JSON bodies for this GET endpoint. The parser ignores the body entirely, causing the 400 error. Move dateRange and groupBy to the Query Params section. This aligns with the previous suggestion and ensures proper URL encoding for the analytics API.

3 Likes

Make sure you verify the token scope includes analytics:conversation:view.

The documentation states, “The access token must contain the required scopes for the requested resource.”

Check your client credentials grant response to confirm the scope is present.