> For the complete documentation index, see [llms.txt](https://docs.orchard.airoverflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orchard.airoverflow.com/api/authentication.md).

# Authentication

## API keys (programmatic)

Mint a key in the console under **Access > API keys**. It is shown once; store it as `ORCHARD_API_KEY`. Send it on every request:

```
Authorization: Bearer orc_...
```

A key is bound to the organization it was created in and cannot act in another. A key may be scoped to a subset of features; a call outside that scope returns `403` naming the missing feature.

## JWT (username and password)

The console signs in with a JSON Web Token pair.

### `POST /auth/token`

```bash
curl -X POST https://orchard.example.com/api/auth/token \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "password": "..."}'
```

```json
{ "access": "<jwt>", "refresh": "<jwt>" }
```

Send the access token as `Authorization: Bearer <access>`. It is short-lived.

### `POST /auth/token/refresh`

```json
{ "refresh": "<jwt>" }   ->   { "access": "<jwt>" }
```

### `POST /auth/token/verify`

Returns `200` if the token is still valid, `401` otherwise.

## Which to use

* Scripts, CI, the SDKs and the CLI: an **API key**. It never expires on its own and needs no refresh dance.
* A browser session: the **JWT** pair, refreshed transparently.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.orchard.airoverflow.com/api/authentication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
