# OpenAPI

Source: https://modulify.ai/docs/api/openapi

The machine readable description of every method, for Postman, Insomnia and client generators.

`https://api.modulify.ai/v1/openapi.json` describes the whole API in OpenAPI 3.1. Tools that read OpenAPI can turn it into a collection of ready-made requests, documentation or a typed client in the language you use.

```bash
curl https://api.modulify.ai/v1/openapi.json -o modulify-openapi.json
```

It needs no token to read, because it describes the methods without exposing anything of yours.

## What it contains

| Part | What it holds |
| --- | --- |
| `info` | The title, the version of the server that built it and a support contact |
| `externalDocs` | A link to these pages |
| `servers` | `https://api.modulify.ai/v1`, so every path is a method name |
| `security` | A bearer token in the `Authorization` header, for every operation |
| `paths` | One `post` operation per method, plus `get` operations for `/tools` and `/token` |
| `tags` | The area each method belongs to, such as `sites` or `chat`, with a description of each, so tools can group them |
| `components` | The bearer token scheme, the `Idempotency-Key` header, the response headers, schemas for the envelope, the method list and the token, and the shared answers for success and each error status |

Every method's operation carries:

| Field | What it holds |
| --- | --- |
| `operationId` | The method name, such as `list_sites` |
| `summary` | The method's title |
| `description` | What it does, the same text `GET /v1/tools` returns |
| `requestBody` | Its arguments as a JSON Schema, with the required ones marked |
| `parameters` | The optional `Idempotency-Key` header, on methods that change something. Read-only methods have none, since they ignore the key |
| `responses` | The envelope for success, and each error status it can answer with, including `413` for a body over 100 MB and `503` when Modulify could not finish a check. Methods that change something also list `201` and `202` as successes, and the `409` and `422` an `Idempotency-Key` can cause |
| `x-modulify-scope` | The main scope a token needs to call it |
| `x-modulify-scopes` | Every scope a token needs to call it, the main one first, such as `credentials:reveal` and `domains:write` for `get_domain_transfer_code` |
| `x-modulify-read-only` | `true` when it only reads |
| `x-modulify-destructive` | `true` when it deletes or overwrites something that cannot be brought back |

The `x-modulify-` fields are extensions: tools that do not know them ignore them, and your own code can use them, for example to refuse destructive methods unless a person confirmed.

## Caching

The description changes when the methods change, or when a limit that a method's description mentions is changed. It is served with `Cache-Control: public, max-age=300` and an `ETag`. Send the `ETag` back in `If-None-Match` and an unchanged description answers `304 Not Modified` with no body.

```bash
curl -i https://api.modulify.ai/v1/openapi.json -H 'If-None-Match: "ETAG_VALUE"'
```

`info.version` is the version of the Modulify server that built it, the same value as `version` in every response.

## Generate a client

Any OpenAPI 3.1 generator works. Give it the address or the downloaded file, then set the bearer token once on the generated client. Generated code names each call after its `operationId`, so `list_sites` becomes a `list_sites` function or method.

Because every method is a `POST` with a JSON body, a generator is optional. A ten-line helper that posts to `https://api.modulify.ai/v1/` plus a name works for every method. See [Requests and responses](https://modulify.ai/docs/api/requests-and-responses).

## The method list as JSON

`GET /v1/tools` returns the same methods without the OpenAPI wrapping, limited to the ones the token's scopes allow, each with its `name`, `title`, `description`, `scope`, `scopes`, `readOnly`, `destructive`, `method`, `path` and `inputSchema`. Use it to check at run time what a particular token can do.

## Discovery from modulify.ai

Tools that look for an API on a domain, instead of being given its address, can start at `https://modulify.ai/.well-known/api-catalog`. It is an API catalog in the RFC 9727 format: a small JSON link set that lists the HTTP API and the MCP server. For the API it links this description as `service-desc`, and for both it links these docs and the guide for agents at `https://modulify.ai/agents.md` as `service-doc`. Like the description, it needs no token.

```bash
curl https://modulify.ai/.well-known/api-catalog
```

## Next

- [Testing](https://modulify.ai/docs/api/testing) for importing the description into Postman or Insomnia.
- [Versioning](https://modulify.ai/docs/api/versioning) for what can change in it over time.