Upload MIDI file

May 15, 2025

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Model
  5. Examples
  6. Try It

This endpoint uploads a MIDI file that can be used as a base for music generation in the POST music/song endpoint.

POST raw content using Make.com and similar nocode tools.

https://api.useapi.net/v1/tempolor/music/midi/?…

Request Headers
Authorization: Bearer {API token}
Content-Type: audio/midi or audio/x-midi
  • API token is required, see Setup useapi.net for details.
  • Content-Type is required, must be audio/midi or audio/x-midi.
Query Parameters
  • user_id is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • name is required. Specify a name for your MIDI file.

Responses
  • 200 OK

    The MIDI file is immediately available to use in POST music/song by providing the returned midiItemId.

    {
      "isFirst": false,
      "midiRenderVO": {
        "opType": "upload",
        "ucid": "100198329",
        "midiItemId": "user:12345-tempolor:user_id-midi:abcdef123456789",
        "name": "my background music",
        "midiUrl": "https://..."
      }
    }
    
  • 400 Bad Request

    {
      "error": "Content-Type must be audio/midi or audio/x-midi",
      "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
Model
{   // TypeScript, all fields are optional
    isFirst: boolean
    midiRenderVO: {
        opType: string
        ucid: string
        midiItemId: string
        name: string
        midiUrl: string
    }
    error: string
    code: number
}
Examples
  • curl "https://api.useapi.net/v1/tempolor/music/midi/?name=my-background-music&user_id=<user_id>" \
      -H "Authorization: Bearer …" \
      -H "Content-Type: audio/midi" \
      --data-binary @/path/to/your/background-music.mid
    
  • const token = "API token";
    const user_id = "Previously configured account"; 
    const name = "my-background-music"; 
    const apiUrl = `https://api.useapi.net/v1/tempolor/music/midi/?name=${name}&user_id=${user_id}`; 
    let blob;
    
    /* 
        // Example 1: Fetch MIDI from URL
        const midiUrl = "https://example.com/midi-files/background-music.mid";
        const responseMidi = await fetch(midiUrl);
        blob = await responseMidi.blob();
    */
    
    /* 
        // Example 2: Load MIDI from local file (Node.js)
        const fs = require('fs');
        const midiFileName = "./background-music.mid";
        blob = new Blob([fs.readFileSync(midiFileName)], { type: "audio/midi" });
    */
    
    /*
        // Example 3: Load from input file html element
        // <input id="midi-file" type="file" accept=".mid,.midi"> 
        const midiFile = document.getElementById(`midi-file`);
        if (midiFile.files[0])
            blob = midiFile.files[0];
    */
    
    const response = await fetch(apiUrl, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "audio/midi"
      },
      body: blob
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    user_id = "Previously configured account"
    name = "my-background-music"
    apiUrl = f"https://api.useapi.net/v1/tempolor/music/midi/?name={name}&user_id={user_id}"
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'audio/midi'
    }
    
    # # Example 1: Fetch MIDI from URL
    # midi_url = "https://example.com/midi-files/background-music.mid"
    # response_midi = requests.get(midi_url)
    # file_content = response_midi.content
    
    # # Example 2: Load MIDI from local file
    midi_file_path = "./background-music.mid"
    with open(midi_file_path, 'rb') as midi_file:
        file_content = midi_file.read()
    
    response = requests.post(apiUrl, headers=headers, data=file_content)
    print(response, response.json())
    
Try It