Analytics details query drops continuation tokens after page 2

Running the bulk details endpoint against our CT org and the continuation token dies consistently on the third request. First two pages return clean JSON. Third call throws a 400 with {"code":"invalid_continuation_token","message":"Token is no longer valid"}. Here’s what was tested. Shortened the interval to PT5M. It failed. Added the x-gc-locale header to match the org region. It failed. Switched payload to application/x-www-form-urlencoded. It failed. The extraction was scheduled for 02:00 CT to dodge the morning publish spike. Snowflake stage is just sitting there waiting for the full dump. Python requests session keeps the connection alive. Timeout is set to 120 seconds. The API docs mention a 15-minute window for token validity, but the entire job only takes about 4 minutes end-to-end. Checked the x-gc-request-id headers and they all route to the same analytics cluster. Can’t figure why the server invalidates it so fast. Anyone know if there’s a hidden page limit on the details endpoint or a specific header needed to keep the token alive?

curl -X POST https://api.mypurecloud.com/api/v2/analytics/details/query
-H “Authorization: Bearer $TOKEN”
-H “Content-Type: application/json”
-d ‘{“dateFrom”:“2024-05-14T02:00:00.000Z”,“dateTo”:“2024-05-14T06:00:00.000Z”,“interval”:“PT15M”,“view”:“default”,“groupings”:[{“type”:“wrapupCode”}],“continuationToken”:“abc123”}’

What’s the exact interval window and which analytics version endpoint are you hitting? The token expiry usually ties to how the backend batches the query response under load.

Don’t reuse a token across parallel workers. The GC API invalidates it the moment the next cursor gets generated server-side.

  1. Cache the continuation_token in a local map keyed by the report_id.
  2. Make sure your HTTP client handles rate limiting with a jitter backoff, not a fixed retry.
  3. Switch the payload to application/json instead of form-encoded. The bulk details parser drops state on the older content type.

Here’s a quick Go snippet to keep the cursor alive:

type TokenStore struct {
 mu sync.Mutex
 tokens map[string]string
}
// update token immediately after each 200 OK

The backend drops old cursors hard when the request pipeline stalls. Check your connection pool settings.

The suggestion above is correct. The token dies because backend batches query response under load. The docs never mention this. You have to cache continuation_token in local map keyed by report_id. If you reuse token across parallel workers, the GC API invalidates it the moment next cursor gets generated server-side. This happened in that WFM variance thread last week. Server just drops connection when interval is too wide. Look at this screenshot of the error payload from our legacy org. The config below saves the day. Also, check the x-gc-locale header. If it does not match org region, the token breaks instantly. The analytics version endpoint matters too. Using v1.0 causes silent failures on page three. Switch to v2.0 and add the strict mode flag. Shortening the interval to PT5M does not help. The backend still batches the response. You need to use PT1M. The payload must be application/x-www-form-urlencoded. If you use JSON, the token expires faster. The docs are a mess. They say the token lasts for 24 hours. This is a lie. The token dies after page two if the load is high. The screenshot shows the 400 error code. The message says Token is no longer valid. This is the same error from the SIP privacy header thread. The system is inconsistent. You have to handle this in the code. The config below works. The strict mode flag forces the server to return a valid token. Without this flag, the token breaks. Why is this not in the guide? Who knows.

The code block above shows the fix. You must also disable the retry logic. The system throws a 400 error when the retry hits the same expired token. It’s a loop of death. This matches the issue from the ServiceNow webhook post. The network path issues cause silent failures. Just stop the retry and handle the 400 manually. The continuation token is fragile. Treat it like glass.