<!-- Markdown twin of https://pixelvault.dev/docs/api/media/ -->

[API reference](/docs/api/)

# Media

Save a file from a URL or inline base64 without knowing what it is. Built for AI output that expires (Replicate, OpenAI, Runway, fal, Gemini): PixelVault reads the first bytes, stores the file as an image, PDF, MP4 or audio asset, and returns that asset's object with a permanent URL.

-   POST [Save media from a URL or base64, any type](#import_media)

## Save media from a URL or base64, any type

POST `/v1/media`

Save an image, PDF, MP4 video or audio file as a permanent asset without choosing the endpoint first. Send a public https `url` (for example a Replicate, fal, OpenAI or Runway result link that will expire) or inline `data` (base64 or a `data:` URL, up to 10 MB decoded, for providers that return bytes, such as Gemini or ElevenLabs).

PixelVault identifies the file from its first bytes, not from the URL or `Content-Type` (provider CDNs often send `application/octet-stream`), then stores it exactly as [`upload_image`](/docs/api/images/#upload_image), [`upload_video`](/docs/api/videos/#upload_video) or [`upload_audio`](/docs/api/audio/#upload_audio) would: the same validation, plan limits, quotas, posters, webhooks and `Idempotency-Key` replays. The response is that endpoint's object, so check `kind` (`image`, `document`, `video` or `audio`). URL imports record the host they came from as `source_host`.

A URL is requested twice: a short probe that reads the first 4 KB, then the import. Act within the link's lifetime; Replicate deletes outputs after an hour.

**Auth:** a secret API key. Images and PDFs follow the unverified-account allowance of [`upload_image`](/docs/api/images/#upload_image) (5 files); video and audio need a verified email.

**Supported:** JPEG, PNG, GIF, WebP, AVIF, SVG, PDF, MP4 (QuickTime files that declare MP4 compatibility count), MP3, WAV, M4A and OGG. MOV and WebM are converted to MP4 on ingest (up to 60 seconds and 100 MB, using the monthly video-optimization allowance; see [`upload_video`](/docs/api/videos/#upload_video)); a GIF stays an image here (send it to [`upload_video`](/docs/api/videos/#upload_video) to get an MP4). HEIC, FLAC, AAC and AVI return 415 with `detected_format` and a hint about what to convert to.

Options apply only to the types they belong to: `describe` and `dedupe` to images, `social_ready` and `normalize` to video, `collection_id` to video and audio.

### Authentication

API key, sent as `Authorization: Bearer <key>`.

### Headers

Headers

Name

Type

Required

Description

`Idempotency-Key`

string

Optional

Retry safety, up to 255 non-space printable ASCII characters. A repeat returns the asset the first request stored (`replayed: true`) under the same rules as the endpoint for its type.

max length 255 · pattern ^\[\\x21-\\x7e\]+$

### Request body

`application/json`, required

Request body

Name

Type

Required

Description

`url`

string (uri)

Optional

Public https URL of the file (up to 3 redirects). Video and audio sources must send `Content-Length`.

`data`

string

Optional

The file as base64 or a base64 `data:` URL, up to 10 MB decoded. Use `url` for anything larger.

`filename`

string

Optional

Original filename. Defaults to the URL's last path segment, or `image.<ext>`, `video.mp4` or `audio.<ext>` for `data`.

max length 255

`visibility`

string

Optional

`private` serves the asset only through signed URLs.

One of: `public`, `private`

Default: `public`

`sign_expires_in`

integer

Optional

Lifetime in seconds of the returned private URLs.

Default: `3600`

min 60 · max 2592000

`expires_in`

integer

Optional

Delete the asset after this many seconds. Omit to keep it permanently.

min 60 · max 2592000

`folder`

string

Optional

Folder (part of the CDN path for public images).

pattern ^\[A-Za-z0-9\_-\]{1,64}$

`collection_id`

string

Optional

Video and audio: an existing collection with the same visibility.

`metadata`

object

Optional

Custom metadata (max 50 top-level keys, 4 KB).

`describe`

boolean

Optional

Images: generate an AI description in the background (see [`upload_image`](/docs/api/images/#upload_image)).

Default: `false`

`dedupe`

boolean

Optional

Images: return an existing image with identical bytes instead of storing a copy. Cannot be combined with `Idempotency-Key`.

Default: `false`

`social_ready`

boolean

Optional

Video: also create a social-ready H.264/AAC copy (see [`upload_video`](/docs/api/videos/#upload_video)).

Default: `false`

`transcribe`

boolean

Optional

Audio: start transcription as soon as it is stored (see [`upload_audio`](/docs/api/audio/#upload_audio)). Ignored for other types.

Default: `false`

`normalize`

boolean

Optional

MP4 video: make the stored file play everywhere (see [`upload_video`](/docs/api/videos/#upload_video)). MOV and WebM are always converted. Ignored for other types.

Default: `false`

### Responses

-   200
    
    Nothing new was stored: an `Idempotency-Key` replay (`replayed: true`) or an image `dedupe` match (`deduplicated: true`).
    
-   201
    
    Stored. `data` is an Image (also for PDFs, `kind: "document"`), Video or Audio object.
    
-   400
    
    [`invalid_json`](/docs/errors/#invalid_json): the body is not a JSON object. [`validation_error`](/docs/errors/#validation_error): not exactly one of `url` and `data`, or a bad option. [`invalid_data`](/docs/errors/#invalid_data): `data` is not base64. [`invalid_url`](/docs/errors/#invalid_url), [`unsupported_scheme`](/docs/errors/#unsupported_scheme) (not https), [`blocked_host`](/docs/errors/#blocked_host) (private or internal address), [`url_fetch_failed`](/docs/errors/#url_fetch_failed) (network error, timeout, too many redirects or a non-2xx response, such as an expired link), [`url_length_required`](/docs/errors/#url_length_required) (a video or audio source sent no `Content-Length`): the URL could not be imported. [`invalid_file`](/docs/errors/#invalid_file), [`invalid_audio`](/docs/errors/#invalid_audio), [`unsupported_audio_codec`](/docs/errors/#unsupported_audio_codec), [`invalid_upload`](/docs/errors/#invalid_upload): the bytes failed the type's validation.
    
-   401
    
    [`missing_api_key`](/docs/errors/#missing_api_key): no `Authorization` header. [`invalid_api_key`](/docs/errors/#invalid_api_key): the key is unknown or revoked.
    
-   402
    
    [`upload_limit_reached`](/docs/errors/#upload_limit_reached), [`storage_limit_reached`](/docs/errors/#storage_limit_reached), [`private_limit_reached`](/docs/errors/#private_limit_reached): a plan quota is full.
    
-   403
    
    [`publishable_key_forbidden`](/docs/errors/#publishable_key_forbidden): use a secret key. [`email_verification_required`](/docs/errors/#email_verification_required): an unverified account has used its image allowance, or the file is video or audio. [`account_suspended`](/docs/errors/#account_suspended): the account is suspended.
    
-   404
    
    [`collection_not_found`](/docs/errors/#collection_not_found): no such collection in the project.
    
-   409
    
    [`idempotency_in_progress`](/docs/errors/#idempotency_in_progress): a video or audio import with this `Idempotency-Key` is still running. Retry later.
    
-   410
    
    [`idempotency_result_deleted`](/docs/errors/#idempotency_result_deleted): the asset created with this `Idempotency-Key` was deleted; use a new key.
    
-   413
    
    [`file_too_large`](/docs/errors/#file_too_large): over the plan's limit for the type, or `data` over 10 MB. [`url_too_large`](/docs/errors/#url_too_large): the remote file declares a size over the limit. [`optimization_source_too_large`](/docs/errors/#optimization_source_too_large): `social_ready` with a video over 100 MB. [`conversion_source_too_large`](/docs/errors/#conversion_source_too_large): a MOV or WebM over 100 MB.
    
-   415
    
    [`unsupported_media_type`](/docs/errors/#unsupported_media_type): the bytes are not a supported format. `detected_format` names it when recognized (`heic`, `flac`, `aac`, `avi`, `3gp`), otherwise `unknown`.
    
-   422
    
    [`idempotency_key_reuse`](/docs/errors/#idempotency_key_reuse): the `Idempotency-Key` was already used for a different file or options. [`collection_visibility_mismatch`](/docs/errors/#collection_visibility_mismatch): the collection's visibility differs from the asset's. [`conversion_duration_too_long`](/docs/errors/#conversion_duration_too_long) / [`conversion_failed`](/docs/errors/#conversion_failed): a MOV or WebM over 60 seconds, or one that could not be converted; nothing was stored.
    
-   429
    
    [`rate_limit_exceeded`](/docs/errors/#rate_limit_exceeded): more than 60 requests per minute for this key (or dashboard session) or 300 per minute for the project. Honour `Retry-After`.
    
-   503
    
    [`temporarily_unavailable`](/docs/errors/#temporarily_unavailable): storage did not accept the file after several retries; nothing was saved. Safe to retry after `Retry-After` (10 seconds).
    

Request

curlNode.jsPython

```
curl -X POST https://api.pixelvault.dev/v1/media \
  -H "Authorization: Bearer $PIXELVAULT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://replicate.delivery/xezq/abc123/out-0.webp",
  "data": "data:image/png;base64,iVBORw0KGgo...",
  "filename": "hero.webp",
  "folder": "generations",
  "metadata": {
    "model": "flux-schnell",
    "prompt_id": "42"
  }
}'
```

Response 201

```
{
  "data": {
    "id": "img_abc123",
    "kind": "image",
    "url": "https://img.pixelvault.dev/proj_xyz789/img_abc123.jpg",
    "branded_url": "https://media.example.com/img_abc123.jpg",
    "optimized_url": "https://img.pixelvault.dev/proj_xyz789/img_abc123.jpg?fmt=auto&q=85",
    "mime_type": "image/jpeg",
    "size": 245782,
    "width": 1920,
    "height": 1080,
    "filename": "photo.jpg",
    "folder": "blog",
    "metadata": {
      "env": "prod",
      "run": "42"
    },
    "source_host": "replicate.delivery",
    "description": {
      "status": "done",
      "alt": "A red fishing boat moored in a small harbour at sunset",
      "caption": "A small red fishing boat rests at a stone quay while the sun sets behind the harbour wall.",
      "ocr_text": "HARBOUR MASTER",
      "tags": [
        "boat",
        "harbour",
        "sunset"
      ],
      "model": "@cf/mistralai/mistral-small-3.1-24b-instruct",
      "described_at": "2026-11-16T12:00:04.000Z",
      "cached": false,
      "error": "describe_timeout"
    },
    "describe_skipped": "unsupported_type",
    "created_at": "2026-11-16T12:00:00.000Z",
    "expires_in": 86400,
    "temporary": true,
    "delete_token": "pv_del_3xQm9TzR1aB7cD2eF4gH6jK8lN0pS5uV",
    "deduplicated": true,
    "replayed": true
  }
}
```
