API reference › Connectivity › Token exchange
Exchange a platform key for an organization session token
POST /v1/token-exchange
- Scope
none:write
Signs in to one organization and returns a session token for it, for tooling that needs the in-app session rather than a key.
Platform tier and full access only. The key must be platform tier and hold the * scope. A scoped key is refused, because the token carries every permission its target holds. The key owner must be a Super Admin or a Fido Service Provider; a Super Admin chooses the user to sign in as, a Fido Service Provider signs in as themselves.
Do not send X-Tenant-ID. The organization is named in the body.
The token is a normal session: 24 hours, ending after 2 hours without use. Revoking the key does not end a session already issued. Every exchange is recorded in History & Logs against the real actor.
Parameters
None of its own.
Every call also sends Authorization and X-Tenant-ID; see Getting started.
Request body required
| Field | Type | Description |
|---|---|---|
organizationId required | string | The organization to sign in to. It must be published. Example |
userId | string or null | Super Admin only: the organization user to sign in as. Defaults to the organization's admin. Example |
Example
{
"organizationId": "ORG-AB12CD34",
"userId": "USR-AB12CD34"
}Example request
curl -X POST "https://api.fetchfido.ai/v1/token-exchange" \
-H "Authorization: Bearer $FIDO_API_KEY" \
-H "X-Tenant-ID: $FIDO_TENANT_ID" \
-H "Content-Type: application/json" \
-d '{"organizationId":"ORG-AB12CD34","userId":"USR-AB12CD34"}'Try it
Responses
200 Token issued
Token issued.
{
"success": true,
"message": "Token issued",
"data": {
"token": "string",
"tenant_id": "TNT-AB12CD34",
"user": {
"id": "string",
"name": "string",
"email": "string",
"role": "string",
"image": "string",
"onlineStatus": "string"
}
}
}Response fields (12)
| Field | Type | Description |
|---|---|---|
success | boolean | Example |
message | string | Example |
data | object | |
data.token | string | Bearer token for the organization session. |
data.tenant_id | string | Example |
data.user | object | |
data.user.id | string | |
data.user.name | string | |
data.user.email | string | |
data.user.role | string or null | |
data.user.image | string or null | |
data.user.onlineStatus | string |
401 Not signed in
Missing, invalid or expired API key.
{
"success": false,
"message": "Invalid API key. Org and user tier keys must send an X-Tenant-ID header naming the organization the key was issued for.",
"errors": null,
"code": "API_KEY_MISSING"
}Response fields (4)
| Field | Type | Description |
|---|---|---|
success | boolean | Example |
message | string | Example |
errors | any or null | Null on this status. |
code | string | Machine-readable reason, for branching on in client code. One of: |
403 Not allowed
Scope, tenant, IP allow-list or RBAC check failed.
{
"success": false,
"message": "You don't have permission to access this endpoint.",
"errors": null,
"code": ""
}Response fields (4)
| Field | Type | Description |
|---|---|---|
success | boolean | Example |
message | string | Example |
errors | any or null | Null on this status. |
code | string | Always empty on this status. Example |
404 Not found
The organization or the user was not found.
{
"success": false,
"message": "User not found in tenant",
"errors": null,
"code": ""
}Response fields (4)
| Field | Type | Description |
|---|---|---|
success | boolean | Example |
message | string | Example |
errors | any or null | Null on this status. |
code | string | Always empty on this status. Example |
429 Too many requests
Rate limit exceeded. See Retry-After.
{
"success": false,
"message": "You've exceeded this API key's rate limit of 120 requests per minute. Try again in 37 seconds.",
"errors": null,
"code": "RATE_LIMITED"
}Response fields (4)
| Field | Type | Description |
|---|---|---|
success | boolean | Example |
message | string | Example |
errors | any or null | Null on this status. |
code | string | Machine-readable reason, for branching on in client code. One of: |