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

FieldTypeDescription
organizationId requiredstring

The organization to sign in to. It must be published.

Example ORG-AB12CD34.

userIdstring or null

Super Admin only: the organization user to sign in as. Defaults to the organization's admin.

Example USR-AB12CD34.

Example

JSON
{
  "organizationId": "ORG-AB12CD34",
  "userId": "USR-AB12CD34"
}

Example request

Shell
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.

JSON
{
  "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)
FieldTypeDescription
successboolean

Example true.

messagestring

Example Token issued.

dataobject
data.tokenstring

Bearer token for the organization session.

data.tenant_idstring

Example TNT-AB12CD34.

data.userobject
data.user.idstring
data.user.namestring
data.user.emailstring
data.user.rolestring or null
data.user.imagestring or null
data.user.onlineStatusstring
401 Not signed in

Missing, invalid or expired API key.

JSON
{
  "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)
FieldTypeDescription
successboolean

Example false.

messagestring

Example Invalid API key. Org and user tier keys must send an X-Tenant-ID header naming the organization the key was issued for..

errorsany or null

Null on this status.

codestring

Machine-readable reason, for branching on in client code.

One of: API_KEY_MISSING, API_KEY_INVALID, API_KEY_EXPIRED. Example API_KEY_MISSING.

403 Not allowed

Scope, tenant, IP allow-list or RBAC check failed.

JSON
{
  "success": false,
  "message": "You don't have permission to access this endpoint.",
  "errors": null,
  "code": ""
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example You don't have permission to access this endpoint..

errorsany or null

Null on this status.

codestring

Always empty on this status.

Example .

404 Not found

The organization or the user was not found.

JSON
{
  "success": false,
  "message": "User not found in tenant",
  "errors": null,
  "code": ""
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example User not found in tenant.

errorsany or null

Null on this status.

codestring

Always empty on this status.

Example .

429 Too many requests

Rate limit exceeded. See Retry-After.

JSON
{
  "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)
FieldTypeDescription
successboolean

Example false.

messagestring

Example You've exceeded this API key's rate limit of 120 requests per minute. Try again in 37 seconds..

errorsany or null

Null on this status.

codestring

Machine-readable reason, for branching on in client code.

One of: RATE_LIMITED. Example RATE_LIMITED.