Skip to main content
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).

1. Start the upload

POST /api/v2/media/uploads with the file’s name, type and size:
We check your key’s permission, the purpose’s size and type limits, and the campaign, then answer 201 with an upload target:
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:
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:

3. Complete the upload

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.
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

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:
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”.