> For the complete documentation index, see [llms.txt](https://developers.docstudio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.docstudio.com/introduction/authentication-and-application-tokens.md). Agents can also search and read this documentation through its [MCP server](https://developers.docstudio.com/~gitbook/mcp).

# Authentication and application tokens

This document explains how to authenticate DocStudio API requests with application and temporary authorization tokens.

### Choose a token type

<table><thead><tr><th width="259">Token type</th><th>Use for</th></tr></thead><tbody><tr><td>Application token</td><td>Server-side integrations, backend services, automation, and long-running API access</td></tr><tr><td>Temporary authorization token</td><td>Testing, short-lived sessions, or requests that use user credentials</td></tr></tbody></table>

### Authentication header

Use the same header format for both token types.

```
Authorization: Bearer {token}
```

The token identifies the caller. Endpoint permissions still control access to a mailbox, account, envelope, template, dictionary, domain, or attachment.

### Manage application tokens

Use application tokens without sending a user password in every request. Store them only in secure server-side storage.

Do not expose token values in client-side code, mobile applications, repositories, logs, screenshots, tickets, shared documents, or frontend environment variables.

Application token endpoints return an application token object. The object includes the token ID, name, value, creation time, expiration time, and last-used time.

#### List application tokens

| Method | Endpoint        |
| ------ | --------------- |
| `GET`  | `/api/v1/token` |

**Response**

Returns an array of application token objects.

#### Create application token

| Method | Endpoint        |
| ------ | --------------- |
| `POST` | `/api/v1/token` |

**Request body**

```json
{
  "name": "string",
  "expireAt": "2026-07-21T13:42:40.621Z"
}
```

<table><thead><tr><th>Field</th><th width="121">Type</th><th width="124.5555419921875">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>string</td><td>Yes</td><td>Application token name</td></tr><tr><td><code>expireAt</code></td><td>date-time</td><td>Yes</td><td>Token expiration date and time</td></tr></tbody></table>

**Response**

Returns an application token object. Copy and store the returned token value securely.

#### Revoke application token

| Method   | Endpoint             |
| -------- | -------------------- |
| `DELETE` | `/api/v1/token/{id}` |

**Path parameters**

| Parameter | Type | Required | Description          |
| --------- | ---- | -------- | -------------------- |
| `id`      | UUID | Yes      | Application token ID |

**Response**

Returns `200 OK`.

#### Configuration restriction

Application token endpoints can be disabled by configuration. In that case, the API returns **405 Method Not Allowed** with the following response body.

```json
{
  "code": 0,
  "message": "string",
  "messageLocalized": "string",
  "messageArgs": [
    "string"
  ],
  "data": "string"
}
```

<table><thead><tr><th width="251.5555419921875">Field</th><th width="124.22216796875">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>code</code></td><td>integer</td><td>Error code</td></tr><tr><td><code>message</code></td><td>string</td><td>Error message</td></tr><tr><td><code>messageLocalized</code></td><td>string</td><td>Localized error message</td></tr><tr><td><code>messageArgs</code></td><td>array</td><td>Dynamic arguments used to build the message</td></tr><tr><td><code>data</code></td><td>any</td><td>Additional error data</td></tr></tbody></table>

{% hint style="info" %}
This response schema applies to disabled application token methods only.
{% endhint %}

### Temporary authorization tokens

Use POST /api/login to obtain a temporary authorization token with user credentials. The token expires after 3 hours. For the required headers, request and response fields, examples, and status codes, see [Authorization](https://developers.docstudio.com/api-reference/authorization.md).

### Resolve authentication and access errors

<table><thead><tr><th width="226.4444580078125">Code</th><th>Meaning</th><th>Action</th></tr></thead><tbody><tr><td><code>401 Not authorized</code></td><td>The request is not authenticated</td><td>Check the header, token value, and token expiration</td></tr><tr><td><code>403 Forbidden</code></td><td>The token cannot access the resource or action</td><td>Check access to the required account, mailbox, or requested object</td></tr><tr><td><code>90035 Not a token owner</code></td><td>The current user cannot access the application token</td><td>Use a token from the correct user and account</td></tr></tbody></table>

### Checklist

1. Confirm that the `Authorization` header uses the `Bearer {token}` format.
2. Confirm that the token value is valid and has not expired.
3. Confirm that the token and requested resource use the expected account and mailbox.

### Related topics

* [API token security](https://developers.docstudio.com/introduction/api-token-security.md)
* [Send your first envelope](https://developers.docstudio.com/introduction/send-your-first-envelope.md)
* [Authorization](https://developers.docstudio.com/api-reference/authorization.md)
