# REST API overview

What the plnnrly REST API is, where it lives, how you authenticate and how you get a token.

The REST API lets your own code read and change your plnnrly data: projects, work items, hours, Drive documents, customers, invoices, leave, planning and more. It speaks JSON over HTTPS, on your organisation's own plnnrly address.

## Connection details

| Setting            | Value                                                                |
| ------------------ | -------------------------------------------------------------------- |
| **Base URL**       | `https://<your-url>/api/v2`                                          |
| **Authentication** | `Authorization: Bearer <token>`                                      |
| **Format**         | JSON. Send `Content-Type: application/json` with every request body. |
| **Contract**       | [OpenAPI 3.1 document](https://developers.plnnrly.com/openapi.json)  |

Replace `<your-url>` with the address you sign in to plnnrly on, such as `acme.plnnrly.com`. If your organisation uses its own domain, use that domain: the API answers only on that exact address and never redirects. There is no shared `api.plnnrly.com`.

In plnnrly, **API access** in the user menu opens the **API tokens** page, which shows your base URL, ready to copy.

## Two ways to authenticate

| You are building                                           | Use                                                                                                                                                                                                                                                          |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Scripts and integrations for yourself or your organisation | A personal access token that you create in plnnrly. See [API tokens](https://developers.plnnrly.com/en/docs/api/v2/guides/tokens/).                                                                                                                          |
| An app that other people install and sign in to            | OAuth sign-in: authorization code with PKCE, and the app registers itself. For desktop and command-line apps; the person signing in needs **Manage API tokens**. See [Sign in with OAuth](https://developers.plnnrly.com/en/docs/api/v2/guides/oauth-apps/). |

Either way, every request acts as one person, with their permissions and nothing more. Apps that use OAuth sign-in cannot delete through the REST API.

## Get a token

1. In plnnrly, open **API access** in the user menu (top right, under your name) and choose **Create token**.
2. Give the token a **Name**.
3. Under **Scopes**, choose **Read**, **Write** or **Delete**; the list only offers what your permissions allow. Write includes read, and Delete includes write and read. The token stores them as `api:read`, `api:write` and `api:destroy`, or per resource, such as `api:read:projects`, when you fill in **Resources**.
4. Leave **Resources** empty to grant the scopes on every resource, or pick the parts of plnnrly the token is limited to. The list only offers parts you have permissions for.
5. Set **Expires**. It is required, starts at 90 days from today and can be at most 12 months away.
6. Copy the token. It is shown once.

**API access** only appears in the user menu while the REST API is on and you hold the **Manage API tokens** permission. See [who may create tokens](https://developers.plnnrly.com/en/docs/administration/#permissions). You can have ten active tokens at a time.

**Scopes** is the token's scope: what the token may do. It is not the same as the permissions your role gives you. Both apply, so a token never does more than you can do in plnnrly. [API tokens](https://developers.plnnrly.com/en/docs/api/v2/guides/tokens/) covers rolling, revoking and the full form.

## Every operation states what it needs

Each operation page in the [reference](https://developers.plnnrly.com/en/docs/api/v2/) names the token scope and the plnnrly permission it needs, and its rate cost. The scope and the permission are checked on every request, and the type of a `403` tells you what refused it:

- [insufficient-token-scope](https://developers.plnnrly.com/en/docs/api/v2/guides/errors/#insufficient-token-scope): the token's scope does not cover the operation. Use a token with a wider scope.
- [insufficient-permission](https://developers.plnnrly.com/en/docs/api/v2/guides/errors/#insufficient-permission): your role lacks the permission. Ask an administrator to change your role.
- [forbidden-by-policy](https://developers.plnnrly.com/en/docs/api/v2/guides/errors/#forbidden-by-policy): you may not do this to this particular record.

## See what your organisation exposes

The [discovery](https://developers.plnnrly.com/en/docs/api/v2/discovery/) request lists what your organisation exposes: every resource with its URLs and operations. Any personal API token can call it; it needs no permission.

```bash
curl https://<your-url>/api/v2/ \
  -H "Authorization: Bearer <token>" \
  -H "Accept: application/json"
```

The `Accept` header is optional: leave it out, or send `application/json`.

Discovery leaves out areas your organisation does not use, such as billing. It does not check which resources your token's scope or your role covers, so a resource it lists can still answer `403`.

## When the API is switched off

An administrator can switch the REST API off under **Settings › Administration › MCP & API**. While it is off, every request answers `404` [endpoint-not-found](https://developers.plnnrly.com/en/docs/api/v2/guides/errors/#endpoint-not-found), including requests with a token that worked before. See [what happens when a switch is off](https://developers.plnnrly.com/en/docs/administration/#when-switched-off).

## Where to go next

- [Getting started](https://developers.plnnrly.com/en/docs/api/v2/guides/getting-started/): from a token to your first write.
- [Reference overview](https://developers.plnnrly.com/en/docs/api/v2/): how the reference is organised, and every guide.
- [Errors and retries](https://developers.plnnrly.com/en/docs/api/v2/guides/errors/): every problem type and what to do about it.
- [/openapi.json](https://developers.plnnrly.com/openapi.json): the whole contract, for code generators and tools.

## For AI assistants

If you want an AI assistant to work with your plnnrly data, use the [MCP server](https://developers.plnnrly.com/en/docs/mcp/). It reaches the same operations you can, except file uploads, with no client to write.
