Refresh the current session token
const url = 'https://example.com/v1/auth/refresh';const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/auth/refresh \ --header 'Authorization: Bearer <token>'Requires a session token (kgi_sk_*); bearer tokens are managed via /v1/tokens. The session token rotates: the new session keeps the person, scopes and expiry, and the provider is not called. OAuth 2.1 BCP refresh-token rotation: the OLD session token is invalidated (marked rotated) — reusing it after refresh returns 401 refresh-token-invalid so compliant clients can retry with the fresh token instead of prompting a re-auth. A browser session (the session cookie) is not refreshed: 400 cookie-session-not-refreshable, so a new token never reaches page scripts; it ends at its TTL. Nor is a session limited to a project or a role: 400 limited-session-not-refreshable; get a new one where you got this one.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Responses
Section titled “Responses”New session token.
object
Examplegenerated
{ "sessionToken": "example", "sessionId": "example", "expiresAt": "2026-04-15T12:00:00Z"}Caller presented a bearer token (refresh is session-only), a browser session (cookie), or a session limited to a project or a role (limited-session-not-refreshable).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Session no longer exists.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Idempotency-Key reused with a different body (idempotency-key-body-mismatch), or a retry of a request that succeeded: its answer carried a secret, which isn’t kept (idempotency-key-replay-withheld, with its status and at). Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Refresh with the provider failed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
- Error code
authz-backend-unavailable - Error code
database-busy - Error code
idempotency-key-body-mismatch - Error code
idempotency-key-in-flight - Error code
idempotency-key-replay-withheld - Error code
idempotency-store-unavailable - Error code
limited-session-not-refreshable - Error code
rate-limit-exceeded - Every error code