---
title: "get midi"
method: POST
path: "/api/v1/sonic/midi"
tags: ["sonic"]
---

# get midi

`POST /api/v1/sonic/midi`

## Request

- Base URL: `https://api.musicapi.ai`
- URL: `https://api.musicapi.ai/api/v1/sonic/midi`
- Auth: HTTP bearer

Get the MIDI JSON for a clip, plus a hosted URL for the .mid file.

Works on a full song's clip_id or a single instrumental track's clip_id
(after stems).

## This endpoint requires polling

Extraction runs asynchronously. A single call does not return the MIDI:

| Status | Meaning | What to do |
|---|---|---|
| `200` | MIDI is ready. `data.midi_url` and `data.instruments` are populated. | Done. |
| `202` | Still converting. Body is `{"type":"not_ready","message":"generating midi..."}` | Retry the same request in a few seconds. |
| `400` | Terminal. Either the source audio is too old to convert, or the conversion stalled and was stopped. | Do not retry this clip_id. |
| `403` | Not enough credits. | — |

Poll with the same request body until you get a 200 or a 400. A retry
resumes the existing job; it does not start a new one.

## Credits

**15 credits**, charged only on a successful `200`.

- A `202` costs nothing, so polling is free.
- Once a clip's MIDI has been extracted it is cached. Any later request for
  the same clip_id returns `200` immediately and also costs nothing.
- Net effect: 15 credits per clip, once, no matter how many times you poll.

## If a conversion never finishes

A conversion that has not completed after about 15 minutes is stopped and the
endpoint returns `400`. That is not a problem with your request — the
conversion stalled and would not have finished. Use a different clip_id, or
regenerate the track and convert the new clip.

Without this, a stalled clip would answer `202` indefinitely and there would
be no way to tell it apart from one that was still working.

## Request body

- object
  - `clip_id` string, required: music id

## Response `200`

- object
  - `code` integer, required
  - `data` object, required
    - `midi_url` string, required: We generate the online URL in midi format using the midi json returned by suno, for audition and reference only.
    - `instruments` object[], required: Array of detected instruments and their MIDI notes
      - `name` string, required: name of Instrument
      - `notes` object[], required: midi notes array
        - `end` number, required: end time in second
        - `pitch` integer, required: MIDI note number 0-127
        - `start` number, required: start time in second
        - `velocity` integer, required: Note intensity 0-1
  - `message` string, required

---

[API](https://skmtc.dev/musicapi/apis/musicapi-docs-suno-style-ai-music-generation-api.md) - [All operations](https://skmtc.dev/musicapi/apis/musicapi-docs-suno-style-ai-music-generation-api/llms.txt) - [OpenAPI document](https://skmtc.dev/musicapi/apis/musicapi-docs-suno-style-ai-music-generation-api/revisions/f94a2c7ed4a1?raw)
