Skip to content
Docs
Organizations

Exchange Token

Exchange Token

organizations.exchange_token(strorganization_id, OrganizationExchangeTokenParams**kwargs) -> TokenResponse
POST/organizations/{organization_id}/token

Exchange user token for organization-scoped M2M token

ParametersExpand Collapse
organization_id: str

Organization ID or label identifier

minLength1
maxLength255
x_client_request_id: Optional[str]
formatuuid
ReturnsExpand Collapse
class TokenResponse:

OAuth2-style token response for M2M tokens

access_token: str

The M2M access token

token_type: str

Token type (always "Bearer")

expires_in: Optional[int]

Token expiration time in seconds

Exchange Token

import os
from keycardai_api import KeycardAPI

client = KeycardAPI(
    api_key=os.environ.get("KEYCARD_API_API_KEY"),  # This is the default and can be omitted
)
token_response = client.organizations.exchange_token(
    organization_id="x",
)
print(token_response.access_token)
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}
Returns Examples
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}