Exchange an upstream credential for an EdgeKit session
const url = 'https://your-tenant-host/v1/id/session/exchange';const options = { method: 'POST', headers: {'x-edgekit-site-id': 'site_example', 'Content-Type': 'application/json'}, body: '{"subject_token":"example","subject_token_type":"example"}'};
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://your-tenant-host/v1/id/session/exchange \ --header 'Content-Type: application/json' \ --header 'x-edgekit-site-id: site_example' \ --data '{ "subject_token": "example", "subject_token_type": "example" }'RFC 8693 in shape and in name. dual only: external_only mints no session, and a call in any other mode answers 404 rather than 403 so the surface does not confirm the route exists elsewhere. A browser sends the credential on its cookie; a native client sends subject_token in the body, because there is no cookie jar for get-session to read. Each call mints a new session; a 503 carries Retry-After and is safe to retry.
Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.
Example
site_exampleThe site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.
Request Body
Section titled “Request Body”object
Example generated
{ "subject_token": "example", "subject_token_type": "example"}Responses
Section titled “Responses”The user is signed in on this device.
object
object
object
Example
{ "user": { "id": "01926f3a-8b4c-7d2e-9f10-2a3b4c5d6e7f", "email": "user@example.com", "emailVerified": true, "name": "Ada Lovelace", "firstName": "Ada", "lastName": "Lovelace", "image": null }, "session": { "id": "01926f3a-8b4d-7a11-8c22-3d4e5f6a7b8c", "kind": "edgekit", "expiresAt": "2026-08-30T09:00:00.000Z" }}Invalid request.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Missing or invalid credential.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Not allowed.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Resource not found.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Request validation failed.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}Unexpected error.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}With Retry-After, briefly unavailable; without it, not configured.
object
object
Example
{ "error": { "code": "unauthorized", "message": "Invalid or missing API key." }}