> This page is for Multi-Tenant, version v3.0 (default).
> For other versions, use one of these documentation indexes:
> - v3.0 (default): https://docs.nvidia.com/run-ai/multi-tenant/v3.0/llms.txt
> - v2.26: https://docs.nvidia.com/run-ai/multi-tenant/v2.26/llms.txt
> - v2.25: https://docs.nvidia.com/run-ai/multi-tenant/v2.25/llms.txt
> - v2.24: https://docs.nvidia.com/run-ai/multi-tenant/v2.24/llms.txt

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

# Create an access token v1

POST http://localhost:8080/api/v1/token
Content-Type: application/json

Create tokens using the `grant_type` parameter.
This endpoint is deprecated. Use `/api/v2/token` instead.


Reference: https://docs.nvidia.com/run-ai/multi-tenant/reference/rest-api/endpoints/authentication-and-authorization/tokens/grant-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication

## Request

### Body (application/json)

This endpoint expects a TokenRequest.

- `grantType` (enum, optional)
  - Allowed values: `client_credentials`, `refresh_token`, `exchange_token`, `password`, `external_token_exchange`
- `code` (string, optional)
- `redirectUri` (string, optional)
- `refreshToken` (string, optional)
- `username` (string, optional)
- `password` (string, optional)
- `clientID` (string, optional)
- `clientSecret` (string, optional)
- `externalToken` (string, optional)
- `codeVerifier` (string, optional)

## Response

### 200

Executed successfully.

- `accessToken` (string, optional)
- `idToken` (string, optional)
- `refreshToken` (string, optional)
- `expiresIn` (integer, optional) — Token lifetime in seconds

## Errors

### 400 Bad Request Error

Bad request.

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 500 Internal Server Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

### 503 Service Unavailable Error

unexpected error

- `code` (integer, required)
- `message` (string, required)
- `details` (string, optional)

## Examples

### client_credentials

**Request**

```json
{
  "grantType": "client_credentials",
  "clientID": "clientID",
  "clientSecret": "clientSecret"
}
```

**Response**

```json
{
  "accessToken": "string",
  "idToken": "string",
  "refreshToken": "string",
  "expiresIn": 1
}
```

**SDK Code**

```python client_credentials
import requests

url = "http://localhost:8080/api/v1/token"

payload = {
    "grantType": "client_credentials",
    "clientID": "clientID",
    "clientSecret": "clientSecret"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript client_credentials
const url = 'http://localhost:8080/api/v1/token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"grantType":"client_credentials","clientID":"clientID","clientSecret":"clientSecret"}'
};

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

```go client_credentials
package main

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

func main() {

	url := "http://localhost:8080/api/v1/token"

	payload := strings.NewReader("{\n  \"grantType\": \"client_credentials\",\n  \"clientID\": \"clientID\",\n  \"clientSecret\": \"clientSecret\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("http://localhost:8080/api/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grantType\": \"client_credentials\",\n  \"clientID\": \"clientID\",\n  \"clientSecret\": \"clientSecret\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"grantType\": \"client_credentials\",\n  \"clientID\": \"clientID\",\n  \"clientSecret\": \"clientSecret\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/token', [
  'body' => '{
  "grantType": "client_credentials",
  "clientID": "clientID",
  "clientSecret": "clientSecret"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp client_credentials
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grantType\": \"client_credentials\",\n  \"clientID\": \"clientID\",\n  \"clientSecret\": \"clientSecret\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift client_credentials
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "grantType": "client_credentials",
  "clientID": "clientID",
  "clientSecret": "clientSecret"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```

### refresh_token

**Request**

```json
{
  "grantType": "refresh_token",
  "refreshToken": "refreshToken",
  "clientID": "clientID"
}
```

**Response**

```json
{
  "accessToken": "string",
  "idToken": "string",
  "refreshToken": "string",
  "expiresIn": 1
}
```

**SDK Code**

```python refresh_token
import requests

url = "http://localhost:8080/api/v1/token"

payload = {
    "grantType": "refresh_token",
    "refreshToken": "refreshToken",
    "clientID": "clientID"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript refresh_token
const url = 'http://localhost:8080/api/v1/token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"grantType":"refresh_token","refreshToken":"refreshToken","clientID":"clientID"}'
};

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

```go refresh_token
package main

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

func main() {

	url := "http://localhost:8080/api/v1/token"

	payload := strings.NewReader("{\n  \"grantType\": \"refresh_token\",\n  \"refreshToken\": \"refreshToken\",\n  \"clientID\": \"clientID\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("http://localhost:8080/api/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grantType\": \"refresh_token\",\n  \"refreshToken\": \"refreshToken\",\n  \"clientID\": \"clientID\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"grantType\": \"refresh_token\",\n  \"refreshToken\": \"refreshToken\",\n  \"clientID\": \"clientID\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/token', [
  'body' => '{
  "grantType": "refresh_token",
  "refreshToken": "refreshToken",
  "clientID": "clientID"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp refresh_token
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grantType\": \"refresh_token\",\n  \"refreshToken\": \"refreshToken\",\n  \"clientID\": \"clientID\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift refresh_token
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "grantType": "refresh_token",
  "refreshToken": "refreshToken",
  "clientID": "clientID"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```

### exchange_token

**Request**

```json
{
  "grantType": "exchange_token",
  "code": "code",
  "redirectUri": "redirectUri",
  "clientID": "clientID"
}
```

**Response**

```json
{
  "accessToken": "string",
  "idToken": "string",
  "refreshToken": "string",
  "expiresIn": 1
}
```

**SDK Code**

```python exchange_token
import requests

url = "http://localhost:8080/api/v1/token"

payload = {
    "grantType": "exchange_token",
    "code": "code",
    "redirectUri": "redirectUri",
    "clientID": "clientID"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript exchange_token
const url = 'http://localhost:8080/api/v1/token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"grantType":"exchange_token","code":"code","redirectUri":"redirectUri","clientID":"clientID"}'
};

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

```go exchange_token
package main

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

func main() {

	url := "http://localhost:8080/api/v1/token"

	payload := strings.NewReader("{\n  \"grantType\": \"exchange_token\",\n  \"code\": \"code\",\n  \"redirectUri\": \"redirectUri\",\n  \"clientID\": \"clientID\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("http://localhost:8080/api/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grantType\": \"exchange_token\",\n  \"code\": \"code\",\n  \"redirectUri\": \"redirectUri\",\n  \"clientID\": \"clientID\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"grantType\": \"exchange_token\",\n  \"code\": \"code\",\n  \"redirectUri\": \"redirectUri\",\n  \"clientID\": \"clientID\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/token', [
  'body' => '{
  "grantType": "exchange_token",
  "code": "code",
  "redirectUri": "redirectUri",
  "clientID": "clientID"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp exchange_token
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grantType\": \"exchange_token\",\n  \"code\": \"code\",\n  \"redirectUri\": \"redirectUri\",\n  \"clientID\": \"clientID\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift exchange_token
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "grantType": "exchange_token",
  "code": "code",
  "redirectUri": "redirectUri",
  "clientID": "clientID"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```

### external_token_exchange

**Request**

```json
{
  "grantType": "external_token_exchange",
  "externalToken": "access token from external idp"
}
```

**Response**

```json
{
  "accessToken": "string",
  "idToken": "string",
  "refreshToken": "string",
  "expiresIn": 1
}
```

**SDK Code**

```python external_token_exchange
import requests

url = "http://localhost:8080/api/v1/token"

payload = {
    "grantType": "external_token_exchange",
    "externalToken": "access token from external idp"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript external_token_exchange
const url = 'http://localhost:8080/api/v1/token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"grantType":"external_token_exchange","externalToken":"access token from external idp"}'
};

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

```go external_token_exchange
package main

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

func main() {

	url := "http://localhost:8080/api/v1/token"

	payload := strings.NewReader("{\n  \"grantType\": \"external_token_exchange\",\n  \"externalToken\": \"access token from external idp\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

}
```

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

url = URI("http://localhost:8080/api/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grantType\": \"external_token_exchange\",\n  \"externalToken\": \"access token from external idp\"\n}"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"grantType\": \"external_token_exchange\",\n  \"externalToken\": \"access token from external idp\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/token', [
  'body' => '{
  "grantType": "external_token_exchange",
  "externalToken": "access token from external idp"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp external_token_exchange
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grantType\": \"external_token_exchange\",\n  \"externalToken\": \"access token from external idp\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift external_token_exchange
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "grantType": "external_token_exchange",
  "externalToken": "access token from external idp"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```