Batch job fails with 401 despite refresh_token grant

Docs state: “If the access token expires, use the refresh_token to obtain a new one.” Running a 10k record batch import via POST /api/v2/analytics/conversations/details/summary. Job fails at record 4002 with HTTP 401 Unauthorized.

curl -X POST https://api.mypurecloud.com/oauth/token \
 -d 'grant_type=refresh_token&refresh_token={token}'

Response is 200 OK with new access_token. Re-running the batch fails again at the same spot. Why isn’t the new token sticking?

Refresh tokens expire too. Your script grabs a new access token but probably doesn’t update the header for subsequent requests. The batch keeps sending the old, expired token. Check the expires_in value and rotate the header before each chunk.