# Drum Engine API

> Every function of the ChordMuse drum engine over HTTP: grooves, arrangements, songs, drum packs and drum loops as General MIDI, with the same results as the ChordMuse apps.

## Your first call

Send your Drum Engine API key in the `Authorization` header and a JSON request. Drum Engine API keys start `cmd_` and come from [your dashboard](https://developers.chordmuse.app/dashboard?api=drums); Chord Engine API keys don't work here. Keep them on your servers, never in a website's or app's code.

```sh
curl https://drums.engine-api.chordmuse.app/v1/loop \
  -H "Authorization: Bearer $CHORDMUSE_DRUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"style": "funk_16ths"}'
```

## Functions

Drum Engine API 0.1.1. The full schemas are in the OpenAPI 3.1 spec: https://drums.engine-api.chordmuse.app/v1/openapi.json. Interactive reference: https://drums.engine-api.chordmuse.app/docs.

- `GET /v1/health`
- `POST /v1/arrangement`: One groove's full-track arrangement for one song form, exactly as pack writes it for a pack of that groove and that form.
- `POST /v1/bar-signatures`: The distinct bar signatures of MIDI files (read as the reference's originality check reads them): pass them as `avoid` to keep a new pack clear of existing ones.
- `POST /v1/catalogue`: Everything the engine can make: grooves, song parts, song forms, loop styles and feels, kit presets and swaps, and the defaults.
- `POST /v1/groove`: One variation of one groove's song part: the file a pack writes at GENRE/FEEL/GROOVE/part/Variation_NN.mid.
- `POST /v1/loop`: One drum loop of one style in one feel.
- `POST /v1/loop-pack`: A loop pack: every feel × style × take with metadata.json, and optionally 1–64 songs built from the styles.
- `POST /v1/pack`: A whole drum pack: every selected groove × song part × variation, metadata.json, and either an arrangement per groove and song form or 1–64 songs, with arrangements.json.
- `POST /v1/song`: One song from a groove or a loop style, exactly as a pack or loop pack with that song in its list writes it.

## Files

- Send `Accept: audio/midi` to `groove`, `arrangement`, `song` or `loop` for the clip's MIDI file itself, with its file name in `Content-Disposition` and its length in `ChordMuse-Duration-Seconds`.
- Send `Accept: application/zip` to `pack` or `loop-pack` for every file as one ZIP, laid out as the pack's folder. That needs the files, so `includeFiles: false` with it is a `400`.
- Errors are JSON whatever the `Accept` header.

## Errors and limits

- Errors are `{"error": {"code", "message"}}`. Check the `code`; the message is for people and may change.
- `400` for a request the engine can't use (`unknown_groove`, `invalid_seed`…), `401` for a missing or unknown key, `403` for a revoked key, `413` for a request over the largest size, `429` over your plan's limit: `rate_limited` for calls per minute, `quota_exceeded` for calls per day.
- Every response carries `RateLimit-Remaining` and `RateLimit-Reset` for the minute, and, when your plan has a daily quota, `ChordMuse-Daily-Remaining` and `ChordMuse-Daily-Reset` for the day (UTC). A `429` also carries `Retry-After` in seconds.
- The same request and `seed` always give the same result, and every response gives the `seed` it used; the `ChordMuse-Drum-Engine-Version` header says which engine answered.

## AI assistants

`GET /v1/tools` lists every function as a tool definition (name, description, input schema) for an AI model. For assistants that speak MCP, add the drum engine as a remote MCP server (Streamable HTTP) with your key. The `pack` and `loopPack` tools leave out the files' data unless `includeFiles` is `true`, to keep results small. MCP calls count against your plan like any other.

### Claude Code

```sh
claude mcp add --transport http chordmuse-drums https://drums.engine-api.chordmuse.app/mcp \
  --header "Authorization: Bearer <your key>"
```

### Cursor, VS Code and other tools that take a URL with headers

```json
{
  "mcpServers": {
    "chordmuse-drums": {
      "url": "https://drums.engine-api.chordmuse.app/mcp",
      "headers": { "Authorization": "Bearer <your key>" }
    }
  }
}
```

### Claude Desktop

Its custom connectors can't send a key yet, so connect through `mcp-remote`: Settings → Developer → Edit Config, then restart Claude Desktop.

```json
{
  "mcpServers": {
    "chordmuse-drums": {
      "command": "npx",
      "args": ["mcp-remote", "https://drums.engine-api.chordmuse.app/mcp", "--header", "Authorization:${AUTH}"],
      "env": { "AUTH": "Bearer <your key>" }
    }
  }
}
```