Skip to content
API Reference

Exchange Token

client.Organizations.ExchangeToken(ctx, organizationID, body) (*TokenResponse, error)
POST/organizations/{organization_id}/token

Exchange user token for organization-scoped M2M token

ParametersExpand Collapse
organizationID string

Organization ID or label identifier

minLength1
maxLength255
body OrganizationExchangeTokenParams
XClientRequestID param.Field[string]optional

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

formatuuid
ReturnsExpand Collapse
type TokenResponse struct{…}

OAuth2-style token response for M2M tokens

AccessToken string

The M2M access token

TokenType string

Token type (always "Bearer")

ExpiresIn int64optional

Token expiration time in seconds

Exchange Token

package main

import (
  "context"
  "fmt"

  "github.com/keycardai/keycard-go"
)

func main() {
  client := keycard.NewClient(

  )
  tokenResponse, err := client.Organizations.ExchangeToken(
    context.TODO(),
    "x",
    keycard.OrganizationExchangeTokenParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", tokenResponse.AccessToken)
}
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}
Returns Examples
{
  "access_token": "access_token",
  "token_type": "Bearer",
  "expires_in": 3600
}