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

# Create a token

POST https://api.sandbox.monite.com/v1/auth/token
Content-Type: application/json

Create a new access token based on client ID and client secret.

Reference: https://docs.monite.com/api/access-tokens/post-auth-token

## Servers

- `https://api.sandbox.monite.com/v1` (sandbox, default)
- `https://api.monite.com/v1` (eu_production)
- `https://us.api.monite.com/v1` (na_production)

## Request

### Headers

- `x-monite-version` (string, required)

### Body (application/json)

This endpoint expects an object.

- `client_id` (string, required) — Your partner [client ID](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client IDs.
- `client_secret` (string, required) — Your partner [client secret](https://docs.monite.com/get-started/credentials#get-credentials) obtained from the "API Credentials" section of Monite Partner Portal. Note that the sandbox and production environment use different client secrets.
- `grant_type` (enum, required) — The type of the access token to generate: * `client_credentials` - partner-level access token, * `entity_user` - entity user token.
  - Allowed values: `client_credentials`, `entity_user`
- `entity_user_id` (string, optional) — ID of the entity user to generate the access token for. Used only if `grant_type` is `entity_user`.

## Response

### 200

Successful Response

- `access_token` (string, required) — The access token. Send it in the `Authorization: Bearer ACCESS_TOKEN` header in subsequent API calls.
- `expires_in` (integer, required) — The token expiration time, in seconds.
- `token_type` (string, required) — Always "Bearer".

## Errors

### 400 Post Auth Token Request Bad Request Error

Possible reasons: * The specified client ID, client secret, or entity user ID is not found. Make sure you're using credentials for the correct environment (sandbox or production). * `entity_user_id` is not provided for `grant_type` = `entity_user`.

- `any`

### 422 Post Auth Token Request Unprocessable Entity Error

A required request field is missing, or some field value has an invalid format.

- `detail` (list of ValidationError, optional)

### 429 Post Auth Token Request Too Many Requests Error

API rate limit has been exceeded. Check the response headers for the rate limit information.

- `any`

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItem

## Examples

### Partner token

**Request**

```json
{
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "client_credentials"
}
```

**Response**

```json
{
  "access_token": "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg",
  "expires_in": 86400,
  "token_type": "Bearer"
}
```

**SDK Code**

```python Partner token
import requests

url = "https://api.sandbox.monite.com/v1/auth/token"

payload = {
    "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
    "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
    "grant_type": "client_credentials"
}
headers = {
    "x-monite-version": "2024-05-25",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Partner token
const url = 'https://api.sandbox.monite.com/v1/auth/token';
const options = {
  method: 'POST',
  headers: {'x-monite-version': '2024-05-25', 'Content-Type': 'application/json'},
  body: '{"client_id":"eb959578-a74d-4ac3-8b25-bf0910027857","client_secret":"14c84a34-282b-4fd8-8af6-86b5b5f2c212","grant_type":"client_credentials"}'
};

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

```go Partner token
package main

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

func main() {

	url := "https://api.sandbox.monite.com/v1/auth/token"

	payload := strings.NewReader("{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"client_credentials\"\n}")

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

	req.Header.Add("x-monite-version", "2024-05-25")
	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 Partner token
require 'uri'
require 'net/http'

url = URI("https://api.sandbox.monite.com/v1/auth/token")

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

request = Net::HTTP::Post.new(url)
request["x-monite-version"] = '2024-05-25'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"client_credentials\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.sandbox.monite.com/v1/auth/token")
  .header("x-monite-version", "2024-05-25")
  .header("Content-Type", "application/json")
  .body("{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"client_credentials\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sandbox.monite.com/v1/auth/token', [
  'body' => '{
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "client_credentials"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-monite-version' => '2024-05-25',
  ],
]);

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

```csharp Partner token
using RestSharp;

var client = new RestClient("https://api.sandbox.monite.com/v1/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("x-monite-version", "2024-05-25");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"client_credentials\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Partner token
import Foundation

let headers = [
  "x-monite-version": "2024-05-25",
  "Content-Type": "application/json"
]
let parameters = [
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "client_credentials"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sandbox.monite.com/v1/auth/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()
```

### Entity user token

**Request**

```json
{
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "entity_user",
  "entity_user_id": "7abd8744-507c-40e6-a5ca-34aa480b3991"
}
```

**Response**

```json
{
  "access_token": "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg",
  "expires_in": 86400,
  "token_type": "Bearer"
}
```

**SDK Code**

```python Entity user token
import requests

url = "https://api.sandbox.monite.com/v1/auth/token"

payload = {
    "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
    "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
    "grant_type": "entity_user",
    "entity_user_id": "7abd8744-507c-40e6-a5ca-34aa480b3991"
}
headers = {
    "x-monite-version": "2024-05-25",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Entity user token
const url = 'https://api.sandbox.monite.com/v1/auth/token';
const options = {
  method: 'POST',
  headers: {'x-monite-version': '2024-05-25', 'Content-Type': 'application/json'},
  body: '{"client_id":"eb959578-a74d-4ac3-8b25-bf0910027857","client_secret":"14c84a34-282b-4fd8-8af6-86b5b5f2c212","grant_type":"entity_user","entity_user_id":"7abd8744-507c-40e6-a5ca-34aa480b3991"}'
};

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

```go Entity user token
package main

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

func main() {

	url := "https://api.sandbox.monite.com/v1/auth/token"

	payload := strings.NewReader("{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"entity_user\",\n  \"entity_user_id\": \"7abd8744-507c-40e6-a5ca-34aa480b3991\"\n}")

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

	req.Header.Add("x-monite-version", "2024-05-25")
	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 Entity user token
require 'uri'
require 'net/http'

url = URI("https://api.sandbox.monite.com/v1/auth/token")

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

request = Net::HTTP::Post.new(url)
request["x-monite-version"] = '2024-05-25'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"entity_user\",\n  \"entity_user_id\": \"7abd8744-507c-40e6-a5ca-34aa480b3991\"\n}"

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

```java Entity user token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sandbox.monite.com/v1/auth/token")
  .header("x-monite-version", "2024-05-25")
  .header("Content-Type", "application/json")
  .body("{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"entity_user\",\n  \"entity_user_id\": \"7abd8744-507c-40e6-a5ca-34aa480b3991\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sandbox.monite.com/v1/auth/token', [
  'body' => '{
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "entity_user",
  "entity_user_id": "7abd8744-507c-40e6-a5ca-34aa480b3991"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-monite-version' => '2024-05-25',
  ],
]);

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

```csharp Entity user token
using RestSharp;

var client = new RestClient("https://api.sandbox.monite.com/v1/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("x-monite-version", "2024-05-25");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"client_id\": \"eb959578-a74d-4ac3-8b25-bf0910027857\",\n  \"client_secret\": \"14c84a34-282b-4fd8-8af6-86b5b5f2c212\",\n  \"grant_type\": \"entity_user\",\n  \"entity_user_id\": \"7abd8744-507c-40e6-a5ca-34aa480b3991\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Entity user token
import Foundation

let headers = [
  "x-monite-version": "2024-05-25",
  "Content-Type": "application/json"
]
let parameters = [
  "client_id": "eb959578-a74d-4ac3-8b25-bf0910027857",
  "client_secret": "14c84a34-282b-4fd8-8af6-86b5b5f2c212",
  "grant_type": "entity_user",
  "entity_user_id": "7abd8744-507c-40e6-a5ca-34aa480b3991"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sandbox.monite.com/v1/auth/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()
```