# API and MCP (/docs/api-and-mcp)

Open **Settings → API & MCP** to create API keys and find the MCP server's address. Both are personal: they act as you, with the access your roles give you in each workspace.

## API keys [#api-keys]

Use an API key to automate backupd from CI pipelines or scripts.

### Create a key [#create-a-key]

1. Click **Create key**.
2. Give it a **Name**, for example `CI pipeline`.
3. Choose when it **Expires**: 30 days, 90 days, 1 year or Never. The default is 90 days.
4. Click **Create key** and copy it. **This is the only time it's shown.**

Store the key in a secret manager, never in source code. It acts as you, with access to every workspace you belong to.

### Use a key [#use-a-key]

Send the key in the `x-api-key` header. Requests are rate limited to 120 per minute.

```sh
curl -H "x-api-key: $BACKUPD_API_KEY" https://<api-address>/api-reference
```

Copy the exact address from **Example request** on the **API & MCP** page. The API reference served there lists every endpoint. A database's ID and its workspace are shown in the database's **Settings** tab, under **Identifiers**.

### Manage keys [#manage-keys]

Each key shows its name, the start of the key, when it was last used, and when it expires. Expired keys are marked **Expired**. Click **Revoke** to stop a key working straight away.

## MCP server [#mcp-server]

The MCP server lets Claude, Cursor and other MCP clients read your databases, backups and usage. Clients sign in with OAuth in your browser, so there is no key to paste.

### Connect a client [#connect-a-client]

Copy the **MCP URL** from **Settings → API & MCP** and add it to your client as a remote HTTP server. For Claude Code, copy the **Command** shown on the page:

```sh
claude mcp add --transport http backupd <MCP URL>
```

The first time the client connects, your browser opens to sign in to backupd and approve access.

### Tools [#tools]

All tools are read-only and only see workspaces you belong to.

| Tool | What it returns |
| --- | --- |
| `list_workspaces` | Workspaces you belong to, with your role. |
| `list_databases` | Databases backed up in a workspace: engine, host, schedule, retention and status. |
| `list_backups` | The most recent backup files with status and restore test result. Optionally only one database, by name. |
| `get_usage` | Plan, storage used against included, projected extra storage, spending cap, and whether backups are copied to your own buckets. |

Every tool except `list_workspaces` takes the workspace's slug, which `list_workspaces` returns.

### Example prompts [#example-prompts]

- "Which of my databases failed a backup this week?"
- "When did production last pass a restore test?"
- "How close is the Acme workspace to its included storage?"

## Discovery for agents [#discovery-for-agents]

Agents can find the API and the MCP server without reading these pages:

| Where | What |
| --- | --- |
| `https://backupd.dev/.well-known/api-catalog` | API catalog (RFC 9727): the OpenAPI description, reference and health check |
| `https://backupd.dev/.well-known/mcp/server-card.json` | MCP server card: endpoint, transport, sign-in and tools |
| `https://backupd.dev/.well-known/agent-skills/index.json` | An agent skill that explains how to use backupd |
| `https://api.backupd.dev/.well-known/oauth-protected-resource` | OAuth metadata for the MCP server |
| `https://backupd.dev/llms.txt` and `https://docs.backupd.dev/llms.txt` | Every page of the site and the docs, for language models |

Every page of the site and these docs also comes as Markdown: send `Accept: text/markdown`, or add `.md` to a docs URL.
