> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useautumn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange Token

> Exchanges a workload's platform OIDC token (GitHub Actions, GCP, AWS, Azure, GitLab, Vercel, Kubernetes or your own issuer) for a short-lived `am_wit_` access token, following RFC 8693. The token must match a trust rule in your organization; the access token carries that rule's scopes. Send it as a form body or JSON; no secret key is needed.

### Body Parameters

Always the RFC 8693 token exchange grant.

The OIDC token your platform issued to this workload.

The subject token is a JWT.

Your Autumn workload audience, as shown in Settings → Workload Identity ([https://api.useautumn.com/workload/ORG\_ID/ENV](https://api.useautumn.com/workload/ORG_ID/ENV), where ENV is sandbox or live). Required when the subject token's aud is your own application, as with Azure managed identities.

### Response

Short-lived Autumn credential, prefixed `am_wit_`.

Seconds until the access token expires.

Space-separated scopes the matching trust rule grants.

```json 200 theme={null}
{
  "access_token": "am_wit_...",
  "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "balances:write customers:read"
}
```


## OpenAPI

````yaml openapi POST /v1/auth.exchange_token
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.6.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/auth.exchange_token:
    post:
      tags:
        - auth
      description: >-
        Exchanges a workload's platform OIDC token (GitHub Actions, GCP, AWS,
        Azure, GitLab, Vercel, Kubernetes or your own issuer) for a short-lived
        `am_wit_` access token, following RFC 8693. The token must match a trust
        rule in your organization; the access token carries that rule's scopes.
        Send it as a form body or JSON; no secret key is needed.
      operationId: exchangeToken
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.6.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  const: urn:ietf:params:oauth:grant-type:token-exchange
                  description: Always the RFC 8693 token exchange grant.
                subject_token:
                  type: string
                  minLength: 1
                  maxLength: 8192
                  description: The OIDC token your platform issued to this workload.
                subject_token_type:
                  enum:
                    - urn:ietf:params:oauth:token-type:jwt
                    - urn:ietf:params:oauth:token-type:id_token
                  type: string
                  description: The subject token is a JWT.
                audience:
                  type: string
                  minLength: 1
                  maxLength: 500
                  description: >-
                    Your Autumn workload audience, as shown in Settings →
                    Workload Identity
                    (https://api.useautumn.com/workload/ORG_ID/ENV, where ENV is
                    sandbox or live). Required when the subject token's aud is
                    your own application, as with Azure managed identities.
              required:
                - grant_type
                - subject_token
                - subject_token_type
              title: ExchangeTokenParams
              examples:
                - grant_type: urn:ietf:params:oauth:grant-type:token-exchange
                  subject_token: <your platform OIDC token>
                  subject_token_type: urn:ietf:params:oauth:token-type:jwt
          application/json:
            schema:
              type: object
              properties:
                grant_type:
                  const: urn:ietf:params:oauth:grant-type:token-exchange
                  description: Always the RFC 8693 token exchange grant.
                subject_token:
                  type: string
                  minLength: 1
                  maxLength: 8192
                  description: The OIDC token your platform issued to this workload.
                subject_token_type:
                  enum:
                    - urn:ietf:params:oauth:token-type:jwt
                    - urn:ietf:params:oauth:token-type:id_token
                  type: string
                  description: The subject token is a JWT.
                audience:
                  type: string
                  minLength: 1
                  maxLength: 500
                  description: >-
                    Your Autumn workload audience, as shown in Settings →
                    Workload Identity
                    (https://api.useautumn.com/workload/ORG_ID/ENV, where ENV is
                    sandbox or live). Required when the subject token's aud is
                    your own application, as with Azure managed identities.
              required:
                - grant_type
                - subject_token
                - subject_token_type
              title: ExchangeTokenParams
              examples:
                - grant_type: urn:ietf:params:oauth:grant-type:token-exchange
                  subject_token: <your platform OIDC token>
                  subject_token_type: urn:ietf:params:oauth:token-type:jwt
            example:
              grant_type: urn:ietf:params:oauth:grant-type:token-exchange
              subject_token: <your platform OIDC token>
              subject_token_type: urn:ietf:params:oauth:token-type:jwt
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    type: string
                    description: Short-lived Autumn credential, prefixed `am_wit_`.
                  issued_token_type:
                    const: urn:ietf:params:oauth:token-type:access_token
                  token_type:
                    const: Bearer
                  expires_in:
                    type: number
                    description: Seconds until the access token expires.
                  scope:
                    type: string
                    description: Space-separated scopes the matching trust rule grants.
                required:
                  - access_token
                  - issued_token_type
                  - token_type
                  - expires_in
                  - scope
                examples:
                  - access_token: am_wit_...
                    issued_token_type: urn:ietf:params:oauth:token-type:access_token
                    token_type: Bearer
                    expires_in: 3600
                    scope: balances:write customers:read
              example:
                access_token: am_wit_...
                issued_token_type: urn:ietf:params:oauth:token-type:access_token
                token_type: Bearer
                expires_in: 3600
                scope: balances:write customers:read
        '400':
          description: The request isn't an RFC 8693 token exchange.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    enum:
                      - invalid_request
                required:
                  - message
                  - code
              example:
                message: >-
                  Invalid token exchange request: grant_type must be
                  urn:ietf:params:oauth:grant-type:token-exchange
                code: invalid_request
        '401':
          description: The subject token is invalid, expired, or matches no trust rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    enum:
                      - invalid_grant
                  details:
                    type: object
                    properties:
                      reason:
                        type: string
                        description: >-
                          Why the token was rejected, e.g. no_matching_rule or
                          token_expired.
                    required:
                      - reason
                required:
                  - message
                  - code
                  - details
              example:
                message: 'Workload token rejected: no_matching_rule'
                code: invalid_grant
                details:
                  reason: no_matching_rule
        '429':
          description: Too many exchanges from this client or organization.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    enum:
                      - rate_limit_exceeded
                required:
                  - message
                  - code
              example:
                message: Too many token exchanges, retry shortly
                code: rate_limit_exceeded
        '500':
          description: Autumn couldn't issue a token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    enum:
                      - internal_error
                required:
                  - message
                  - code
              example:
                message: Internal server error
                code: internal_error
      security: []
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.auth.exchangeToken({
              grantType: "urn:ietf:params:oauth:grant-type:token-exchange",
              subjectToken: "<your platform OIDC token>",
              subjectTokenType: "urn:ietf:params:oauth:token-type:jwt",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

            autumn = Autumn(secret_key="am_sk_test...")

            res = autumn.auth.exchange_token(
                subject_token="<your platform OIDC token>",
                subject_token_type="urn:ietf:params:oauth:token-type:jwt",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.