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

# Uploading files

> Upload drafts, documents and images of any supported size, straight to storage.

Files never pass through our API servers. You ask for an upload, send the bytes straight to storage, then tell us you are done. This works for every media `purpose` and every file size up to the purpose's limit, including multi-GB draft videos.

The examples use `API_BASE_URL` for your API base URL and `API_KEY` for your key (see the [quickstart](https://docs.creatorcore.co/quickstart.md)).

## 1. Start the upload

[`POST /api/v2/media/uploads`](https://docs.creatorcore.co/api-reference/media/start-a-direct-upload) with the file's name, type and size:

```bash theme={null}
curl -X POST "$API_BASE_URL/api/v2/media/uploads" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "purpose": "campaign_draft",
    "filename": "draft-v2.mp4",
    "contentType": "video/mp4",
    "sizeBytes": 734003200,
    "context": { "campaignId": "6f1c…" }
  }'
```

We check your key's permission, the purpose's size and type limits, and the campaign, then answer `201` with an upload target:

```json theme={null}
{
  "success": true,
  "upload": {
    "id": "eyJrIjoi…",
    "pathname": "orgs/…/campaigns/6f1c…/drafts/2b9e…-draft-v2.mp4",
    "contentType": "video/mp4",
    "maxBytes": 2147483648,
    "expiresAt": "2026-11-06T15:04:05.000Z",
    "completeBy": "2026-11-07T15:04:05.000Z",
    "method": "PUT",
    "url": "https://…",
    "headers": { "authorization": "Bearer …", "x-content-type": "video/mp4", "…": "…" },
    "storage": {
      "provider": "vercel_blob",
      "access": "public",
      "clientToken": "…",
      "multipartRecommendedAboveBytes": 104857600
    }
  }
}
```

The target only accepts one file: at `pathname`, of exactly `contentType`, up to `maxBytes`, until `expiresAt`.

## 2. Send the bytes

Send the raw file as the body of `PUT {url}`, with every header in `headers`, unchanged:

```bash theme={null}
curl -X PUT "$UPLOAD_URL" \
  -H "authorization: $UPLOAD_AUTHORIZATION" \
  -H "x-api-version: 12" \
  -H "x-vercel-blob-access: public" \
  -H "x-vercel-blob-store-id: $UPLOAD_STORE_ID" \
  -H "x-content-type: video/mp4" \
  --data-binary @draft-v2.mp4
```

For large videos, prefer the `@vercel/blob` SDK's multipart upload with `storage.clientToken`. It sends parts in parallel and retries each part on its own:

```ts theme={null}
import { put } from "@vercel/blob/client";

await put(upload.pathname, file, {
  access: upload.storage.access,
  token: upload.storage.clientToken,
  contentType: upload.contentType,
  multipart: true,
});
```

## 3. Complete the upload

```bash theme={null}
curl -X POST "$API_BASE_URL/api/v2/media/uploads/$UPLOAD_ID/complete" \
  -H "Authorization: Bearer $API_KEY"
```

We read the file's real size and type from storage. Your earlier claims are not trusted. A file that breaks the upload's limits is deleted and rejected. Then we run post-upload processing and answer `201` with the media asset:

* HEIC photos become JPEG for purposes that normalize images.
* `.mov` drafts up to 200MB become MP4. Larger ones are kept as uploaded.
* Draft videos get a poster image. `thumbnailUrl` is its `/api/v2/media/{id}` path.

Serve the file from `media.url` (`/api/v2/media/{id}`), never from the storage URL.

> [!TIP]
>
> Completing twice is safe. The second call returns the same asset with `200`. If you complete before the bytes have arrived, you get `409` with code `upload_incomplete`. Retry once the PUT has finished. Converting a large `.mov` can take a while. If you retry while the first call is still running, the retry waits for it and returns the same asset. If that takes longer than about 20 seconds, you get `409` with code `upload_in_progress`; retry a few seconds later.

## Limits

| Purpose | Max size |
| - | - |
| `campaign_draft` | 2GB |
| `campaign_document`, `campaign_brief` | 500MB |
| `payout_invoice` | 50MB |
| Image purposes (logos, covers, media kits) | 20MB |

Branding logos have tighter per-kind limits: 4MB for `external-logo`, and 2MB for `internal-logo` and `favicon`. Pass the kind as `context.kind`.

Send the file's real `contentType`. If you only know the filename, leave `contentType` out and we use the extension. Generic types such as `application/octet-stream` are rejected.

## Small files: multipart upload

Multipart `POST /api/v2/media` (and `PUT /api/v2/media/{id}` to replace a file) still works for small files, up to 4MB (4,000,000 bytes). Use a direct upload for anything larger.

A file over 4MB gets a `413` with a JSON body pointing you at direct uploads:

```json theme={null}
{
  "success": false,
  "error": "File too large for a form upload — max 4MB. Larger files go through a direct upload: POST /api/v2/media/uploads.",
  "code": "file_too_large",
  "maxBytes": 4000000,
  "directUpload": "/api/v2/media/uploads"
}
```

A request body over about 4.5MB (4,500,000 bytes) can be rejected by our hosting platform before it reaches the API. That `413` is plain text (`FUNCTION_PAYLOAD_TOO_LARGE`), not JSON, so treat any `413` from these endpoints as "use a direct upload".


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