Renew a terminal sign-in

Exchange the newest refresh token for a new pair

POST/v1/cli/tokens/renew

Exchanges the newest refreshToken for a new pair: a new access token for the next hour, and a new refresh token that replaces the one sent. There is no bearer: the refresh token is in the body, and the route reads no x-mapier-version.

Renew before the access token expires. An access token already issued keeps working until its own expiry, so a call or a stream holding it is not cut off. Keep only the newest refresh token. One already replaced, sent again, ends the whole sign-in, unless it comes within 30 seconds of its replacement: then it is only refused, so two processes renewing at once cost one of them a retry with the pair the other stored. Renewing never widens the sign-in's scopes, and never moves refreshTokenExpiresAt, when the sign-in ends.

Every refusal is the same 401, whatever its reason: an unknown, replaced or expired refresh token, a revoked sign-in, or one whose owner left the organization.

Example request

curl -X POST https://api.mapier.ai/v1/cli/tokens/renew \
  -H "Content-Type: application/json" \
  -d '{ "refreshToken": "mp_refresh_example-not-a-real-token" }'

Response

200 OK
{
  "accessToken": "mp_pat_example-not-a-real-token-2",
  "accessTokenExpiresAt": "2026-09-02T16:10:00.000Z",
  "refreshToken": "mp_refresh_example-not-a-real-token-2",
  "refreshTokenExpiresAt": "2026-11-01T14:12:00.000Z",
  "tokenId": "0192a7f3-6f70-7182-9d93-0f1a2b3c4d5e"
}

Errors

StatusCodeReasonWhenChannels
400bad_requestThe body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing.All
401invalid_credentialsThe API key or personal access token is missing, malformed, unknown, revoked or expired.All
413payload_too_largeThe body is over 65,536 bytes.All
422validation_failedA field is wrong, and details names each one at its path.All
429rate_limitedToo many requests for this route's budget.All
500internal_errorMapier failed on its side, and has been alerted.All
503upstream_unavailableThe channel did not take the command, or gave no answer Mapier could use.All