> ## Documentation Index
> Fetch the complete documentation index at: https://developer.audioshake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload a File

> Upload a local file and use it in a Task

If your media is local rather than a public URL, upload it first to create an Asset. Then reference the returned `assetId` when creating a Task.

> [!WARNING]
>
> Set the file's MIME type on the upload (e.g. `audio/wav`). Clients like curl and Postman default to `application/octet-stream`, which fails with `400 "File upload failed"`.

## Upload and create a Task

```python upload_and_process.py theme={null}
import requests

API_KEY = "your_api_key"

# 1. Upload the file (the tuple's third element sets the MIME type — required)
upload_res = requests.post(
    "https://api.audioshake.ai/assets",
    headers={"x-api-key": API_KEY},
    files={"file": ("song.mp3", open("song.mp3", "rb"), "audio/mpeg")}
)

asset_id = upload_res.json()["id"]
print(f"Asset created: {asset_id}")

# 2. Create a Task using the assetId
task_res = requests.post(
    "https://api.audioshake.ai/tasks",
    headers={"Content-Type": "application/json", "x-api-key": API_KEY},
    json={
        "assetId": asset_id,
        "targets": [
            {"model": "vocals", "formats": ["wav"]},
            {"model": "instrumental", "formats": ["wav"]}
        ]
    }
)

task_id = task_res.json()["id"]
print(f"Task created: {task_id}")
```

```javascript uploadAndProcess.js theme={null}
const API_KEY = "your_api_key";

// 1. Upload the file — the Blob must carry the file's MIME type.
// Browser File objects set it automatically; construct Blobs explicitly elsewhere.
const fileBlob = new Blob([fileBytes], { type: "audio/mpeg" });
const formData = new FormData();
formData.append("file", fileBlob, "song.mp3");

const uploadRes = await fetch("https://api.audioshake.ai/assets", {
  method: "POST",
  headers: { "x-api-key": API_KEY },
  body: formData
});

const { id: assetId } = await uploadRes.json();
console.log(`Asset created: ${assetId}`);

// 2. Create a Task using the assetId
const taskRes = await fetch("https://api.audioshake.ai/tasks", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": API_KEY
  },
  body: JSON.stringify({
    assetId,
    targets: [
      { model: "vocals", formats: ["wav"] },
      { model: "instrumental", formats: ["wav"] }
    ]
  })
});

const { id: taskId } = await taskRes.json();
console.log(`Task created: ${taskId}`);
```

```bash curl theme={null}
# 1. Upload the file (";type=..." sets the MIME type — required)
curl -X POST "https://api.audioshake.ai/assets" \
  -H "x-api-key: $AUDIOSHAKE_API_KEY" \
  -F 'file=@song.mp3;type=audio/mpeg'

# 2. Create a Task with the returned assetId
curl -X POST "https://api.audioshake.ai/tasks" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $AUDIOSHAKE_API_KEY" \
  -d '{
    "assetId": "your_asset_id",
    "targets": [
      { "model": "vocals", "formats": ["wav"] },
      { "model": "instrumental", "formats": ["wav"] }
    ]
  }'
```

Then [check Task status](https://developer.audioshake.ai/check-task-status.md) to monitor progress and download results.

> [!NOTE]
>
> Maximum file size is 5GB. Uploaded Assets expire after 72 hours.

See the [Formats](https://developer.audioshake.ai/api-reference/formats.md) page for supported input file types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.