> 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 /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/v0.3.0/documentation/reference/api-reference/workload-identity/token-exchange-apis-auth-token-post

## Request

### Body (application/x-www-form-urlencoded)

- `grant_type` (enum, required) — OAuth 2.0 token exchange grant type.
  - Allowed values: `urn:ietf:params:oauth:grant-type:token-exchange`
- `client_id` (string, required) — Workload token exchange OAuth client ID.
- `subject_token` (string, required) — JWT subject token to exchange.
- `subject_token_type` (enum, required) — Token type identifier for the subject token.
  - Allowed values: `urn:ietf:params:oauth:token-type:jwt`
- `requested_token_type` (enum, optional, default: urn:ietf:params:oauth:token-type:access_token) — Requested token type identifier for the issued token.
  - Allowed values: `urn:ietf:params:oauth:token-type:access_token`
- `audience` (string, optional) — Requested audience for the issued access token.
- `scope` (string, optional) — Space-separated scopes requested for the issued access token.

## Response

### 200

Successful Response

- `access_token` (string, required) — JWT access token minted for the workload identity.
- `issued_token_type` (string, required) — Token type identifier for the issued token.
- `token_type` (string, required) — OAuth token type used in Authorization headers.
- `expires_in` (integer, required) — Lifetime of the access token in seconds.
- `scope` (string, optional) — Space-separated scopes granted to the access token.

## Examples

**Request**

```json
{
  "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
  "client_id": "string",
  "subject_token": "string",
  "subject_token_type": "urn:ietf:params:oauth:token-type:jwt"
}
```

**Response**

```json
{
  "access_token": "string",
  "issued_token_type": "string",
  "token_type": "string",
  "expires_in": 1,
  "scope": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.example.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://api.example.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://api.example.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://api.example.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://api.example.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://api.example.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://api.example.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://api.example.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()
```