> This page is for Agent Filesystem.

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

# Create an app token; tenant grants coming soon

POST https://api.dropboxapi.com/oauth2/token
Content-Type: application/x-www-form-urlencoded

Authenticate with the Agent Filesystem app key and secret. The grant type
determines the returned credential:

* `client_credentials` returns a short-lived app access token.
* **Coming soon:** `authorization_code` exchanges the single-use code
  returned by `tenants/create` for a tenant access token and an offline
  refresh token.
* **Coming soon:** `refresh_token` refreshes the tenant access token.

Agent runtime tokens are minted at `agents/access_token/mint`.
Managed-user tokens are minted at `users/access_token/mint` using
HTTP Basic authentication with the app key and secret.


Reference: https://docs.dropboxapi.com/agentfs/api-reference/authorization/exchange-agent-fs-oauth-token

## Request

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

This endpoint expects an OAuthTokenRequest.

- `grant_type` (enum, required)
  - Allowed values: `client_credentials`, `authorization_code`, `refresh_token`
- `code` (string, optional) — Required for `authorization_code`.
- `refresh_token` (string, optional) — Required for `refresh_token`.

## Response

### 200

Issued access token

- `access_token` (string, required)
- `token_type` (enum, required)
  - Allowed values: `bearer`
- `expires_in` (integer, required)
- `refresh_token` (string, optional) — Coming soon: returned only when the tenant authorization code is exchanged.
- `scope` (string, optional)

## Examples

### Create an app access token

**Request**

```json
{
  "grant_type": "client_credentials"
}
```

**Response**

```json
{
  "access_token": "example-access-token",
  "token_type": "bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python Create an app access token
import os
import requests

response = requests.post(
    "https://api.dropboxapi.com/oauth2/token",
    auth=(os.environ["DROPBOX_APP_KEY"], os.environ["DROPBOX_APP_SECRET"]),
    data={"grant_type": "client_credentials"},
    timeout=30,
)
response.raise_for_status()
print(response.json())

```

```javascript Create an app access token
const url = 'https://api.dropboxapi.com/oauth2/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 Create an app access token
package main

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

func main() {

	url := "https://api.dropboxapi.com/oauth2/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 Create an app access token
require 'uri'
require 'net/http'

url = URI("https://api.dropboxapi.com/oauth2/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 Create an app access token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Create an app access token
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Create an app access token
using RestSharp;

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

```swift Create an app access token
import Foundation

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

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

### Establish tenant access — Coming soon

**Request**

```json
{
  "grant_type": "authorization_code",
  "code": "one-time-tenant-authorization-code"
}
```

**Response**

```json
{
  "access_token": "example-access-token",
  "token_type": "bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python Establish tenant access — Coming soon
import os
import requests

response = requests.post(
    "https://api.dropboxapi.com/oauth2/token",
    auth=(os.environ["DROPBOX_APP_KEY"], os.environ["DROPBOX_APP_SECRET"]),
    data={
        "grant_type": "authorization_code",
        "code": os.environ["TENANT_AUTHORIZATION_CODE"],
    },
    timeout=30,
)
response.raise_for_status()
print(response.json())

```

```javascript Establish tenant access — Coming soon
const url = 'https://api.dropboxapi.com/oauth2/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 Establish tenant access — Coming soon
package main

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

func main() {

	url := "https://api.dropboxapi.com/oauth2/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 Establish tenant access — Coming soon
require 'uri'
require 'net/http'

url = URI("https://api.dropboxapi.com/oauth2/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 Establish tenant access — Coming soon
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Establish tenant access — Coming soon
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Establish tenant access — Coming soon
using RestSharp;

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

```swift Establish tenant access — Coming soon
import Foundation

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

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

### Refresh tenant access — Coming soon

**Request**

```json
{
  "grant_type": "refresh_token",
  "refresh_token": "encrypted-tenant-refresh-token"
}
```

**Response**

```json
{
  "access_token": "example-access-token",
  "token_type": "bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python Refresh tenant access — Coming soon
import os
import requests

response = requests.post(
    "https://api.dropboxapi.com/oauth2/token",
    auth=(os.environ["DROPBOX_APP_KEY"], os.environ["DROPBOX_APP_SECRET"]),
    data={
        "grant_type": "refresh_token",
        "refresh_token": os.environ["TENANT_REFRESH_TOKEN"],
    },
    timeout=30,
)
response.raise_for_status()
print(response.json())

```

```javascript Refresh tenant access — Coming soon
const url = 'https://api.dropboxapi.com/oauth2/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 Refresh tenant access — Coming soon
package main

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

func main() {

	url := "https://api.dropboxapi.com/oauth2/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 Refresh tenant access — Coming soon
require 'uri'
require 'net/http'

url = URI("https://api.dropboxapi.com/oauth2/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 Refresh tenant access — Coming soon
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

```php Refresh tenant access — Coming soon
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Refresh tenant access — Coming soon
using RestSharp;

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

```swift Refresh tenant access — Coming soon
import Foundation

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

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