# Audio to MIDI API

> Upload a WAV, start a piano or melody job and download the .mid, from curl or your own code. The API comes with the Session Desk plan; jobs spend the same credits as in the studio, piano at 90 per minute and melody at 8 per file.

## Authentication

Every call sends your API key as a bearer token in the Authorization header. Keep it in an environment variable, never in code you share. Audio goes up as a 16-bit PCM WAV; convert other formats first, for example with ffmpeg.

```sh
export AUDIOTOMIDI_KEY="<your API key>"
ffmpeg -i song.mp3 -ac 1 -ar 22050 -c:a pcm_s16le song.wav
```

The body is the raw WAV file, up to 15 minutes. The optional X-File-Name header names it in your job list.

## One call: convert and start

Upload a WAV and start a melody job in one request. The answer is the job, with status pending.

```sh
curl -X POST "https://audiotomidi.dev/api/v1/convert?mode=melody&rights=confirmed" \
  -H "Authorization: Bearer $AUDIOTOMIDI_KEY" \
  -H "Content-Type: audio/wav" \
  -H "X-File-Name: riff.wav" \
  --data-binary @riff.wav
```

## Step by step

1. Upload the audio: the answer is a source id and the measured length.

```sh
curl -X POST "https://audiotomidi.dev/api/v1/audio" \
  -H "Authorization: Bearer $AUDIOTOMIDI_KEY" \
  -H "Content-Type: audio/wav" \
  -H "X-File-Name: piano.wav" \
  --data-binary @piano.wav
# → 201 {"id":"<source id>","fileName":"piano.wav","seconds":94.2}
```

2. Start a job on that source: mode piano or melody, rights set to true.

```sh
curl -X POST "https://audiotomidi.dev/api/v1/jobs" \
  -H "Authorization: Bearer $AUDIOTOMIDI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: piano-take-1" \
  -d '{"source_id":"<source id>","mode":"piano","rights":true}'
# → 202 {"id":"<job id>","status":"pending","credits":…}
```

3. Poll the job about every 20 seconds until the status is success or failed.

```sh
curl "https://audiotomidi.dev/api/v1/jobs/<job id>" \
  -H "Authorization: Bearer $AUDIOTOMIDI_KEY"
# → {"status":"success","hasMidi":true,…}
```

4. Download the MIDI file once hasMidi is true.

```sh
curl "https://audiotomidi.dev/api/v1/jobs/<job id>/midi" \
  -H "Authorization: Bearer $AUDIOTOMIDI_KEY" \
  -o piano.mid
```

## Endpoints

- `POST /api/v1/convert?mode=&rights=confirmed`: Upload a WAV body and start a job in one call. Query: mode (piano or melody) and rights=confirmed. Answers 202 with the job.
- `POST /api/v1/audio`: Upload a 16-bit PCM WAV body (up to 15 minutes). Answers 201 with the source id, file name and length in seconds.
- `POST /api/v1/jobs`: Start a job: JSON with source_id, mode and rights: true. An Idempotency-Key header makes retries safe. Answers 202.
- `GET /api/v1/jobs`: List your jobs, newest first.
- `GET /api/v1/jobs/:id`: One job: status, credits, refunded credits and hasMidi.
- `GET /api/v1/jobs/:id/midi`: The finished .mid file (audio/midi).

## Modes and credits

- `piano`: Piano transcription engine: chords and melody of a solo piano. 90 credits per started minute.
- `melody`: Notes of one instrument or voice. 8 credits per file.

Piano is billed by the started minute of the measured audio. A failed job is refunded automatically. Stem splits run in the web studio only. Results are deleted after 7 days.

## Errors

Errors answer JSON with a message you can show. Nothing is charged for a request that fails.

- **400**: Bad request: rights not confirmed, an unknown mode, audio that is too long, or a body that is not a 16-bit WAV.
- **401**: No API key, or the key is not valid.
- **402**: Not enough credits for this job. Top up on the pricing page.
- **403**: The key's account is not on Session Desk, or the account is restricted.
- **404**: No such job or source on this account.
- **410**: The MIDI file was deleted: results are kept for 7 days.
- **413**: The upload is too large.
- **429**: Too many requests at once. Wait a few seconds and retry.

## Prefer an AI assistant?

The same jobs are tools on our MCP server: Claude, ChatGPT, Cursor and VS Code can list your audio, convert it and read back the notes.

## API questions

### Which plan includes the API?

Session Desk, monthly or yearly. Other accounts get a 403 from the job endpoints.

### Can I send an MP3?

Not directly: the API takes a 16-bit PCM WAV. Convert with ffmpeg first, as in the sample above.

### Can the API split stems?

No. Stem splits run in the web studio, where each stem turns into MIDI in the browser. The API offers piano and melody jobs.

### What if I retry a request?

Send the same Idempotency-Key header and you get the first job back instead of a second charge.

### How long can I download the MIDI?

For 7 days after the job; after that the file answers 410.


---

Source: https://audiotomidi.dev/api-docs · Site index for AI agents: https://audiotomidi.dev/llms.txt · Full content: https://audiotomidi.dev/llms-full.txt
