Skip to content
API Reference

Exchange Token

client.organizations.exchangeToken(stringorganizationID, OrganizationExchangeTokenParams { xClientRequestID } params?, RequestOptionsoptions?): TokenResponse { access_token, token_type, expires_in }
POST/organizations/{organization_id}/token

Exchange user token for organization-scoped M2M token

ParametersExpand Collapse
organizationID: string

Organization ID or label identifier

minLength1
maxLength255
params: OrganizationExchangeTokenParams { xClientRequestID }
xClientRequestID?: string

Unique request identifier specified by the originating caller and passed along by proxies.

formatuuid
ReturnsExpand Collapse
TokenResponse { access_token, token_type, expires_in }

OAuth2-style token response for M2M tokens

access_token: string

The M2M access token

token_type: string

Token type (always "Bearer")

expires_in?: number

Token expiration time in seconds

Exchange Token

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI();

const tokenResponse = await client.organizations.exchangeToken('x');

console.log(tokenResponse.access_token);
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}
Returns Examples
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}