> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo-platform/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo-platform/_mcp/server.

# Exchange a workload identity subject token

POST https://host.com/apis/auth/token
Content-Type: application/x-www-form-urlencoded

Exchange a configured workload identity subject token for a NeMo Platform access token.

Reference: https://docs.nvidia.com/nemo-platform/nemo-platform/documentation/reference/api-reference/workload-identity/token-exchange-apis-auth-token-post

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Nemo Platform API
  version: 1.0.0
paths:
  /apis/auth/token:
    post:
      operationId: token-exchange-apis-auth-token-post
      summary: Exchange a workload identity subject token
      description: >-
        Exchange a configured workload identity subject token for a NeMo
        Platform access token.
      tags:
        - workloadIdentity
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkloadTokenExchangeResponse'
        '400':
          description: RFC 8693 token exchange error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkloadTokenExchangeErrorResponse'
        '401':
          description: OAuth 2.0 invalid_client error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkloadTokenExchangeErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                grant_type:
                  $ref: >-
                    #/components/schemas/ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaGrantType
                  description: OAuth 2.0 token exchange grant type.
                client_id:
                  type: string
                  description: Workload token exchange OAuth client ID.
                subject_token:
                  type: string
                  description: JWT subject token to exchange.
                subject_token_type:
                  $ref: >-
                    #/components/schemas/ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaSubjectTokenType
                  description: Token type identifier for the subject token.
                requested_token_type:
                  $ref: >-
                    #/components/schemas/ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaRequestedTokenType
                  default: urn:ietf:params:oauth:token-type:access_token
                  description: Requested token type identifier for the issued token.
                audience:
                  type: string
                  description: Requested audience for the issued access token.
                scope:
                  type: string
                  description: >-
                    Space-separated scopes requested for the issued access
                    token.
              required:
                - grant_type
                - client_id
                - subject_token
                - subject_token_type
servers:
  - url: https://host.com
    description: Default
components:
  schemas:
    ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaGrantType:
      type: string
      enum:
        - urn:ietf:params:oauth:grant-type:token-exchange
      description: OAuth 2.0 token exchange grant type.
      title: >-
        ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaGrantType
    ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaSubjectTokenType:
      type: string
      enum:
        - urn:ietf:params:oauth:token-type:jwt
      description: Token type identifier for the subject token.
      title: >-
        ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaSubjectTokenType
    ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaRequestedTokenType:
      type: string
      enum:
        - urn:ietf:params:oauth:token-type:access_token
      default: urn:ietf:params:oauth:token-type:access_token
      description: Requested token type identifier for the issued token.
      title: >-
        ApisAuthTokenPostRequestBodyContentApplicationXWwwFormUrlencodedSchemaRequestedTokenType
    WorkloadTokenExchangeResponse:
      type: object
      properties:
        access_token:
          type: string
          description: JWT access token minted for the workload identity.
        issued_token_type:
          type: string
          description: Token type identifier for the issued token.
        token_type:
          type: string
          description: OAuth token type used in Authorization headers.
        expires_in:
          type: integer
          description: Lifetime of the access token in seconds.
        scope:
          type: string
          description: Space-separated scopes granted to the access token.
      required:
        - access_token
        - issued_token_type
        - token_type
        - expires_in
      description: RFC 8693 token exchange response for workload identity access tokens.
      title: WorkloadTokenExchangeResponse
    WorkloadTokenExchangeErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: >-
            OAuth 2.0 or RFC 8693 token exchange error code, such as
            invalid_client, invalid_request, invalid_grant, invalid_scope, or
            invalid_target.
        error_description:
          type: string
          description: >-
            Human-readable ASCII text providing additional information about the
            error.
        error_uri:
          type: string
          description: >-
            URI identifying a human-readable web page with information about the
            error.
      required:
        - error
      description: RFC 8693 token exchange error response.
      title: WorkloadTokenExchangeErrorResponse

```

## Examples



**Request**

```json
{
  "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
  "client_id": "nemo-client-12345",
  "subject_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ3b3JrbG9hZC1pZC10b2tlbiIsImF1ZCI6Im5lbW8tcGxhdGZvcm0iLCJleHAiOjE2ODU0MjQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "subject_token_type": "urn:ietf:params:oauth:token-type:jwt"
}
```

**Response**

```json
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJuZW1vLWFjY2VzcyIsInNjb3BlIjoicmVhZCB3cml0ZSIsImV4cCI6MTY4NTQyODQwMCwiaXNzIjoibmVtby1hdXRoLXNlcnZlciJ9.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
  "issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "read write"
}
```

**SDK Code**

```python
import requests

url = "https://host.com/apis/auth/token"

payload = ""
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://host.com/apis/auth/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  body: new URLSearchParams('')
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://host.com/apis/auth/token"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://host.com/apis/auth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://host.com/apis/auth/token")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://host.com/apis/auth/token', [
  'form_params' => null,
  'headers' => [
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://host.com/apis/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/x-www-form-urlencoded"]

let request = NSMutableURLRequest(url: NSURL(string: "https://host.com/apis/auth/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```