# The CrushMFT API

CrushMFT 27 has an API for scripts, integrations and AI tools at `/WebInterface/api/v1` on the server's HTTP and HTTPS ports. It covers what an administrator does in the WebInterface: the server itself (its status, updates and its own Java), users and groups, preferences, sessions and bans, listeners, keys and certificates, AS2, jobs, reports, events, and a user's own files and account.

```bash
curl -H "Authorization: Bearer $TOKEN" https://server.example.com/WebInterface/api/v1/users/MainUsers
```

## What it is like

- **JSON in and out**, real HTTP status codes, and one error shape with a stable `code` a program can switch on.
- **The same rights as the WebInterface.** Every operation needs the permission its WebInterface command needs, decided by the server's roles. Nothing new can be done through it that could not be done before.
- **Access tokens** that carry only what a script or an agent needs: some permissions, on some users or folders, for some time, from some addresses, read-only if you like.
- **Safe changes.** `?dry_run=true` shows what a change would do without doing it; `If-Match` refuses a change when someone else changed the object first; `Idempotency-Key` makes a retried request harmless.
- **Push.** A live event stream and webhooks, instead of polling.
- **For AI tools:** a way to ask "may I do this", an MCP endpoint, and tokens whose changes wait for a person to approve them.
- **No stored secret ever comes back.** A password field reads `{"set": true}`.

The `command=` interface the WebInterface uses stays. It is called the legacy interface now: see [The legacy interface](API-Legacy.md), which also names the three commands CrushMFT 27 no longer has.

## Start here

1. [Getting started](API-Getting-Started.md): turn the API on, make a token, the first calls.
2. [Credentials](API-Authentication.md): tokens, a user name and password, a browser session.
3. [Conventions](API-Conventions.md): paths, lists, conflicts, dry runs, long work, limits.
4. [Errors](API-Errors.md): the error shape and every code.

Then the reference, an area at a time (the menu on the left), or all of it on [one page](API-Reference.md).

## The description

The reference on these pages is made from the server's own description of the API, which every build writes and uploads here. A server also hands out its own description to a logged-in administrator:

| What | Where |
|---|---|
| OpenAPI 3.1, for client generators and API tools | [openapi.json](API/openapi.json) here, or `GET /WebInterface/api/v1/openapi.json` on a server |
| Only what this credential may use now | `GET /WebInterface/api/v1/openapi.json?mine=true` |
| One Markdown file, for AI tools | `GET /WebInterface/api/v1/docs.md` |
| A plain HTML page | `GET /WebInterface/api/v1/docs` |

> [!TIP]
> An AI agent that is new to a server should start with `GET /whoami` (what may I do), then `GET /openapi.json?mine=true` (the operations I may use), and ask `POST /explain` before a change it is not sure of. See [AI agents](API-AI-Agents.md).
