> 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/auth.md).

# Authentication

Both SDKs authenticate with an **Orchard API key** (`orc_…`), a bearer token you mint in the console under **Access → API keys**, or with [`keys.create()`](/guides/scoped-api-keys.md). A JWT access token works too (same `Authorization: Bearer` scheme), but API keys are the right choice for scripts and services: they are long-lived and can be [scoped](/guides/scoped-api-keys.md).

## Configuration

Both clients read the same environment variables:

| Variable          | Meaning                                                                                               |
| ----------------- | ----------------------------------------------------------------------------------------------------- |
| `ORCHARD_API_URL` | Control-plane URL, e.g. `https://orchard.example.com`. (`ORCHARD_URL` is accepted as a legacy alias.) |
| `ORCHARD_API_KEY` | Your API key (`orc_…`) or a JWT access token.                                                         |
| `ORCHARD_ORG`     | Optional organization slug. Ignored for API keys (they are bound to the org they were minted in).     |
| `ORCHARD_WS`      | Optional workspace slug.                                                                              |

{% tabs %}
{% tab title="Python" %}

```python
from orchard_sdk import Orchard

# From the environment:
orchard = Orchard.from_env()

# ...or explicitly:
orchard = Orchard(
    url="https://orchard.example.com",
    token="orc_live_xxx",
    org="acme",        # optional
    ws="default",      # optional
)
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
import { Orchard } from "@orchard/sdk";

// From the environment (Node):
const orchard = Orchard.fromEnv();

// ...or explicitly:
const client = new Orchard({
  url: "https://orchard.example.com",
  token: "orc_live_xxx",
  org: "acme",         // optional
  ws: "default",       // optional
});
```

{% endtab %}
{% endtabs %}

## Tenancy

An API key is bound to the organization it was created in; the `org` option (and the `X-Orchard-Org` header the SDK sends) is ignored for keys. Use `ws` to pin a workspace when your org has more than one.

## Keep keys secret

A key is a bearer credential: anyone holding it acts as you, within its scope. Store it in a secret manager, never in source control. In the browser, prefer a [scoped key](/guides/scoped-api-keys.md) or proxy calls through your own backend.


---

# 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/auth.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.
