Skip to content
Dashboard
API Reference

Upload Flow ​

How asset uploads work for video, audio, and image inputs.

Some agent nodes accept images, audio, or videos as parameters. Use these endpoints to upload files and get UUIDs that you can pass to update_params when running agents.

Flow ​

text
POST /uploads/{type}/get_upload_url  →  POST file to upload_url  →  POST /uploads/{type}/finalize_upload
  1. Call get_upload_url to get a signed URL and the asset UUID
  2. POST your file to that URL (include upload_fields as form data)
  3. Call finalize_upload to confirm the upload

Use the returned UUID in update_params:

json
{
  "update_params": {
    "NODE_ID": {
      "audio_id": "your-uploaded-uuid"
    }
  }
}

Full Example ​

Upload audio and use it in update_params:

python
import requests

API_KEY = "mk_your_api_key"
BASE = "https://api.mosaic.so"

# 1. Get upload URL
data = requests.post(f"{BASE}/uploads/audio/get_upload_url",
    headers={"Authorization": f"Bearer {API_KEY}"}).json()

# 2. Upload file
with open("music.mp3", "rb") as f:
    requests.post(data["upload_url"], data=data["upload_fields"], files={"file": f})

# 3. Finalize
result = requests.post(f"{BASE}/uploads/audio/finalize_upload",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"audio_id": data["audio_id"]}).json()

# 4. Use in update_params
run = requests.post(f"{BASE}/agent/YOUR_AGENT_ID/run",
    headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
    json={
        "video_urls": ["https://youtube.com/watch?v=dQw4w9WgXcQ"],
        "update_params": {
            "AUDIO_NODE_ID": {"audio_id": result["audio_id"]}
        }
    }).json()

print(f"Run ID: {run['run_id']}")
javascript
const API_KEY = "mk_your_api_key";
const BASE = "https://api.mosaic.so";

// 1. Get upload URL
const data = await fetch(`${BASE}/uploads/audio/get_upload_url`, {
  method: "POST",
  headers: { "Authorization": `Bearer ${API_KEY}` }
}).then(r => r.json());

// 2. Upload file
const formData = new FormData();
Object.entries(data.upload_fields).forEach(([k, v]) => formData.append(k, v));
formData.append("file", audioFile);
await fetch(data.upload_url, { method: "POST", body: formData });

// 3. Finalize
const result = await fetch(`${BASE}/uploads/audio/finalize_upload`, {
  method: "POST",
  headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ audio_id: data.audio_id })
}).then(r => r.json());

// 4. Use in update_params
const run = await fetch(`${BASE}/agent/YOUR_AGENT_ID/run`, {
  method: "POST",
  headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    video_urls: ["https://youtube.com/watch?v=dQw4w9WgXcQ"],
    update_params: {
      "AUDIO_NODE_ID": { audio_id: result.audio_id }
    }
  })
}).then(r => r.json());

console.log(`Run ID: ${run.run_id}`);

Supported Formats ​

TypeFormatsMax SizeMax Duration
VideoMP4, MOV, AVI, WebM, MKV, M4V5 GBPlan-based: 2 hours on Standard, 5 hours on Professional/Enterprise
AudioMP3, WAV, M4A, FLAC, OGG, AAC, Opus500 MB5 hours
ImagePNG, JPEG, GIF, WebP, SVG50 MB-

Errors ​

ErrorCause
404Upload ID not found or expired
400File not uploaded before finalize
413File exceeds size limit