> ## Documentation Index
> Fetch the complete documentation index at: https://docs.photon.codes/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use Stable documentation by default. Honor an explicit Beta request or a URL under /docs/beta/. If the requested version conflicts with the installed CLI package or API origin, clarify the target before writing integration code.
> Pages under /docs/beta/ document Beta; other product pages document Stable. Keep the CLI package, commands, API origin, and credentials within the selected version. State the documentation version in your answer.
> For MCP search, always pass version: Stable or version: Beta. Unfiltered search mixes both versions. For filesystem reads, keep Beta queries under /beta/ and exclude /beta/ from Stable queries; discover paths before reading them.
> The public docs base is https://photon.codes/docs. Convert MCP page paths to public URLs under that base, preserving /beta/ when present. Read https://photon.codes/docs/skill.md for version selection and https://photon.codes/docs/llms.txt for the version indexes.

# API contract versioning

> Select the Photon HTTP API contract with the Photon-Version request header.

Photon's public HTTP API selects its contract from the `Photon-Version` request
header. Send the header on every request:

```
Photon-Version: 2026-07-01
```

`2026-07-01` is the only supported API date today. The date is independent of
the version of the TypeScript, Python, Rust, or Go package. Package SemVer
controls the generated client code; it does not select an HTTP API contract.

## Send a date

The API matches the value exactly. It does not normalize the value, choose the
nearest date, or read the old `X-Photon-Version` header. A raw HTTP request can
set the date like this:

```sh theme={null}
curl https://api.photon.codes/v1/account \
  -H "Authorization: Bearer $PHOTON_API_KEY" \
  -H "Photon-Version: 2026-07-01"
```

## Read the response

When a versioned endpoint accepts an explicit date, it echoes the selected date
in the `Photon-Version` response header. The echo is present on successful
responses and on application errors raised after the date is selected. Responses
also include `Vary: Photon-Version`.

```http theme={null}
HTTP/1.1 200 OK
Photon-Version: 2026-07-01
Vary: Photon-Version
```

An error that rejects the date before selection, such as an invalid date or an
exact retired date, has no `Photon-Version` response header. The same is true
for the current missing-header fallback: a request without the header is
served as `2026-07-01`, but its response has no date echo.

The missing-header fallback is being removed. Starting 2026-11-23, Photon
removes it one API at a time. Once it is removed from an API, a request to that
API without `Photon-Version` returns `400 INVALID_API_VERSION`. Send the header
now:

* **API clients and your own HTTP code:** set the header on every request, as
  shown in [Set the date in an API client](#set-the-date-in-an-api-client).
* **Photon CLI:** update to 3.2.0 or later, which sends the header.
* **Local MCP server (`@photon-ai/mcp`):** a release that sends the header
  comes out before the switch. Update to it then. The hosted MCP server needs
  no change.

## Handle version errors

Version errors are RFC 9457 problem documents. They include `type`, `code`,
`title`, and `status`; `detail` and `requestId` can also be present. Version
errors include `supportedVersions`, which lists the dates supported by that
endpoint.

| Request | Status | Code | Detail |
| - | -: | - | - |
| Missing header after the fallback is removed | `400` | `INVALID_API_VERSION` | `The Photon-Version header is required.` |
| Invalid, unknown, or non-exact date | `400` | `INVALID_API_VERSION` | `The version must match a catalog entry exactly.` |
| Exact retired date | `410` | `RETIRED_API_VERSION` | `The requested version has retired.` |

For example, an invalid date returns a body like this:

```json theme={null}
{
  "type": "https://photon.codes/docs/problems/invalid-api-version",
  "code": "INVALID_API_VERSION",
  "title": "Invalid API Version",
  "status": 400,
  "detail": "The version must match a catalog entry exactly.",
  "supportedVersions": ["2026-07-01"]
}
```

See [Handling errors](https://docs.photon.codes/docs/beta/problems/handling-errors.md) for the common problem
fields and matching rules.

## Set the date in an API client

The generated clients do not send `Photon-Version` by default. Set it as a
client-wide extra header so every request uses the same date.

```typescript TypeScript theme={null}
import { Photon } from "@photon-ai/api";

const photon = new Photon({
  headers: {
    Authorization: `Bearer ${process.env.PHOTON_API_KEY}`,
    "Photon-Version": "2026-07-01",
  },
});
```

```python Python theme={null}
import os

from photon_api import Photon

photon = Photon(
    headers={
        "Authorization": f"Bearer {os.environ['PHOTON_API_KEY']}",
        "Photon-Version": "2026-07-01",
    }
)
```

```rust Rust theme={null}
use reqwest::header::{HeaderMap, HeaderValue};
use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};

let mut headers = HeaderMap::new();
headers.insert("Photon-Version", HeaderValue::from_static("2026-07-01"));

let client = PhotonClientBuilder::new()
    .static_headers(headers)
    .credential("accountServiceKey", Credential::Bearer(SecretString::from(api_key)))
    .build()?;
```

```go Go theme={null}
client := photonapi.NewClient(
    photonapi.WithAPIKey(apiKey),
    photonapi.WithHeader("Photon-Version", "2026-07-01"),
)
```

TypeScript also accepts extra headers in a call's second argument. Python accepts
headers in an operation's generated input when that operation declares them.
Rust accepts dynamic headers with `PhotonClientBuilder::headers`, and Go accepts
per-call headers with `WithRequestHeader`. Client-wide headers are the simplest
way to make the date consistent across all requests.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.