Upload a cover image for your song
February 25, 2025
Table of contents
POST raw content using Make.com and similar nocode tools.
https://api.useapi.net/v1/riffusion/music/upload-image/?…
Request Headers
Authorization: Bearer {API token}
Content-Type: select from the table below
API token
is required, see Setup useapi.net for details.Content-Type
is required, select from the table below:
Content-Type | File Extension |
---|---|
image/png | png |
image/jpeg | jpeg |
image/gif | gif |
image/webp | webp |
Query Parameters
user_id
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.
Responses
-
Use the returned
image_id
in POST music/create-compose.{ "Key": "riffs/a1b2c3d4-ef12-3456-789a-bcdef0123456/image/12345678-90ab-cdef-1234-567890abcdef.jpg", "Id": "87654321-0fed-cba9-4321-0fedcba98765", "image_id": "12345678-90ab-cdef-1234-567890abcdef", "url": "https://api.riffusion.com/storage/v1/object/public/riffs/a1b2c3d4-ef12-3456-789a-bcdef0123456/image/12345678-90ab-cdef-1234-567890abcdef.jpg" }
-
{ "error": "<Error message>", "code": 400 }
-
{ "error": "Unauthorized", "code": 401 }
-
596 Pending error
API was unable to refresh your cookie. Please resolve this issue by using the POST accounts endpoint before making any new API calls.
{ "error": "Your Riffusion account has pending error. Please address this issue at https://useapi.net/docs/api-riffusion-v1/post-riffusion-accounts before making any new API calls." }
Model
{ // TypeScript, all fields are optional
Key: string
Id: string
image_id: string
url: string
error: string
code: number
}
Examples
-
curl "https://api.useapi.net/v1/riffusion/music/upload-image/?user_id=<user_id>" \ -H "Authorization: Bearer …" \ -H "Content-Type: audio/mpeg" \ --data-binary /path/to/your/my-music-track.mp3
-
const token = "API token"; const user_id = "Previously configured account"; const apiUrl = `https://api.useapi.net/v1/riffusion/music/upload-image/?user_id=${user_id}`; let blob; /* // Example 1: Fetch audio from URL const audioUrl = "https://upload.wikimedia.org/wikipedia/commons/my-music-track.mp3"; const responseAudio = await fetch(audioUrl); blob = await responseAudio.blob(); */ /* // Example 2: Load audio from local file (Blob) const fsp = require('fs').promises; const audioFileName = "./my-music-track.mp3"; blob = new Blob([await fsp.readFile(audioFileName)]); */ /* // Example 3: Load from input file html element // <input id="audio-file" type="file"> const audioFile = document.getElementById(`audio-file`); if (audioFile.files[0]) blob = audioFile.files[0]); */ const response = await fetch(apiUrl, { method: "POST" headers: { "Authorization": `Bearer ${token}`, }, body: blob }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" user_id = "Previously configured account" apiUrl = f"https://api.useapi.net/v1/riffusion/music/upload-image/?user_id={user_id}" headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'audio/mpeg' } # # Example 1: Fetch audio from URL # audio_url = "https://upload.wikimedia.org/wikipedia/commons/my-music-track.mp3" # response_audio = requests.get(audio_url) # file_content = response_audio.content # # Example 2: Load audio from local file # audio_file_path = "./my-music-track.mp3" # with open(audio_file_path, 'rb') as audio_file: # file_content = audio_file.read() response = requests.post(api_url, headers=headers, data=file_content) print(response, response.json())