# OpenAPI

An OpenAPI document generated from your config so the spec matches the API.

Charter builds one OpenAPI 3.1.0 document from the live registry. When you change resources or fields, the next request to the spec endpoints sees the update. There is no separate per-resource spec URL.

To fetch the JSON document from a running server:

```sh
curl -sS http://127.0.0.1:3000/openapi.json | head
```

You may import that URL into Postman, Insomnia, Redoc, Swagger UI, or any OpenAPI 3.1 client.

## Endpoints

| Path | Format |
| --- | --- |
| `/openapi.json` | JSON |
| `/openapi.yaml` | YAML |
| `/.well-known/api-catalog` | API catalog (linkset) |

Both spec paths describe the enabled `/v1/...` resource paths, auth, `POST /v1/mcp` (Resource MCP), `POST /mcp` (Admin MCP), and the other HTTP routes that ship with the binary.

`GET /.well-known/api-catalog` returns this server's [API catalog](https://www.rfc-editor.org/rfc/rfc9727). The document is `application/linkset+json`. The anchor is the base URL plus `/v1`. `service-desc` links to `/openapi.json` and `/openapi.yaml`. When docs are enabled, `service-doc` links to `/docs`. When `/llms.txt` is enabled, `service-meta` links to it. Every link is absolute and uses `CHARTER_BASE_URL`. `HEAD` on the same path returns a `Link` header:

```
Link: </.well-known/api-catalog>; rel="api-catalog"
```

No credential is required. The catalog does not include registry paths. Those stay on `/openapi.json?registry=true`.

Add registry (operator) paths with a query flag. The caller must present an admin credential:

```
/openapi.json?registry=true
```

## Disable

Turn the spec and the API catalog off with `--no-openapi` or `CHARTER_DISABLE_OPENAPI`. See [Environment variables](/docs/environment-variables/) and the [CLI](/docs/cli/) reference.

## Using the spec

Relation fields may carry an `x-charter-relation` extension with the target resource, cardinality, and optional include alias. Many-to-one and one-to-one properties are a UUID string. One-to-many and many-to-many properties are an array of UUID strings.

Human-readable try-it docs for the same registry live at `/docs` on the running server (separate from this marketing site). Agents can also read `/llms.txt`.
