<!-- https://bobabanana.com/docs/api/files/ · Send reference images, start frames, voice samples and audio to the BobaBanana API as file IDs, public https URLs or base64 data URIs. Formats and limits. -->

# Uploading reference images and voice samples

**Every image or audio input to the BobaBanana API can be given in three ways: a `file_id` from `POST /v1/files`, a public `https://` URL, or base64 data.** Uploading once and reusing the `file_id` is fastest when the same reference appears in many requests.

## Upload a file

```bash
curl https://bobabanana.com/api/v1/files \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -F "file=@portrait.jpg"
```

```json
{"id": "file_3f9c2a1b7d4e", "object": "file", "type": "image", "name": "portrait.jpg", "bytes": 802113, "created": 1795660000, "width": 1024, "height": 1280, "warnings": []}
```

Audio uploads return `duration` (seconds) instead of `width`/`height`, and `warnings` such as "Background noise detected".

`GET /v1/files/{id}` returns the same record plus a signed `url`. `DELETE /v1/files/{id}` deletes an upload; it is refused with `409 file_in_use` while an unfinished job uses it.

Uploads count toward your workspace's storage. An upload that no job uses is deleted after 24 hours (`expires_at`); once a job uses it, it is kept.

## Media inputs

Anywhere the docs say *media input*, you may send any of these:

| Form | Example |
|---|---|
| File ID string | `"file_3f9c2a1b7d4e"` |
| URL string | `"https://example.com/sofa.jpg"` |
| Data URI string | `"data:image/png;base64,iVBORw0..."` |
| Object | `{"file_id": "file_3f9c2a1b7d4e", "label": "a mustard yellow sofa"}` |
| Object with URL | `{"url": "https://example.com/sofa.jpg", "label": "..."}` |
| Object with base64 | `{"data": "iVBORw0...", "label": "..."}` |

Use exactly one of `file_id`, `url` or `data` in an object. `label` matters for `reference_images`: it tells the model what the picture shows.

## Supported formats and limits

| Kind | Formats | Max size | Notes |
|---|---|---|---|
| Images | PNG, JPG, WEBP, GIF, BMP | 25 MB | Scaled to at most 2048 px; EXIF rotation applied |
| Audio | WAV, MP3, M4A, OGG, FLAC, WEBM, AAC, OPUS | 60 MB | Converted to mono WAV |
| Voice samples | as audio | 60 MB | 2 to 60 s accepted, 5 to 30 s recommended |

## Rules for URL inputs

1. **https only.** `http://` URLs are refused.
1. **30 seconds in total** for all URL inputs of one request, and at most 2 downloads at once per workspace (`429 too_many_downloads`).
2. **Public addresses only.** URLs that resolve to private or local networks are refused.
3. **No redirects are followed.** Link to the final file.
4. **The URL must return the file directly** with HTTP 200, not an HTML page.

BobaBanana result links (`output.*.url`) are valid inputs, which makes chaining easy: image job → video job.

## Frequently asked questions

### How long are uploaded files kept?
An upload that no job uses is deleted after 24 hours. Once a job uses it, it is kept until you delete it with `DELETE /v1/files/{id}`. Result download links expire after 24 hours; request the job again for a fresh link.

### Can another API key use my file ID?
Keys of the same workspace can; keys of other workspaces cannot, and get `404 file_not_found`.

### How long can a download take?
Each request has 30 seconds in total to download all of its URL inputs. A slow server counts against that budget even if it keeps sending data. Inline `data` can be about 25 MB; upload larger files first.

### Why was my URL refused?
It was not `https`, it pointed to a private address, it redirected, or it did not return HTTP 200. Download it yourself and upload it, or send it as base64.
