
# Inline media

When writing pages with [POST /sites/{siteId}/pages](/api/pages/post-pages) or [POST /sites/{siteId}/pages/batch](/api/pages/post-pages-batch), attach files to the request as multipart form data and reference them in your Markdown with the `file:` prefix. The server replaces each reference with the final media URL before saving.

Uploading this way needs only the `content` [scope](/api/authentication#scopes), not `media`.

Send `Content-Type: multipart/form-data` with a `payload` field containing the JSON body, plus one or more file parts. The `payload` field takes whatever shape the route it is sent to takes, so a one-page create with an inline image needs no envelope:

```bash
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages \
  -H "Authorization: Bearer $TOKEN" \
  -F payload='{"pages": [{"title": "Beach day", "content": "Great sunset.\n\n![sunset](file:sunset.jpg)\n\nDownload the [album](file:album.zip)"}]}' \
  -F files=@sunset.jpg \
  -F files=@album.zip
```

`file:sunset.jpg` matches the filename of the attached part. The same file can be referenced from several pages of a [batch](/api/pages/post-pages-batch), and every reference resolves to the same URL.

## Response

When files are uploaded, the response includes a `media` array:

```json
{
  "pages": [...],
  "media": [
    {"filename": "sunset.jpg", "url": "https://media.example.com/media/.../a1b2c3d4.webp"},
    {"filename": "album.zip", "url": "https://media.example.com/media/.../e5f6a7b8.zip"}
  ]
}
```

Each `url` is the same value the `file:` references in your content were replaced with. A file takes the protection of the pages that show it: on a password-protected or workspace site, or on a page that has its own password once the request is written, the file is protected and its `url` is a `/media/...` path that opens only for visitors who can open that page. Any other file gets an absolute public URL.

## Limits and processing

You can attach up to 500 files per request. The whole request, the payload and every file together, is limited to 100 MB, and each file to 10 MB on the free plan. To publish a larger file, upload it first with a [direct upload](/api/media/post-uploads) and put the `url` it returns in your content.

Images (JPEG, PNG, GIF, WebP) are converted to WebP at their original dimensions. Metadata is stripped from images, videos, and PDFs. MOV files are transcoded to MP4. Large files finish processing shortly after the request returns. The [supported file types](/api/media/post-media) are the same as for standalone uploads.

## Errors

A `file:` reference that matches no attached file rejects the request with the page index:

```json
{
  "error": "unresolved file references",
  "code": "validation_failed",
  "details": {
    "0": {"unresolvedCount": 1}
  }
}
```

Check that the filename in your content exactly matches the attached file's name. A disallowed file type is a 422 naming the file by index. More than 500 files in one request is a 400. A request over 100 MB, or a file over your plan's limit, is a 413. Send fewer files per request, or upload large files with [POST /uploads](/api/media/post-uploads) and reference their URLs. A request body over 100 MB can be refused before it reaches the API, in which case the 413 has no JSON body.

A request that is refused can leave some of its files already stored. The error envelope then carries the same `media` array the success response lists, naming the files already uploaded. They are in the library and count against your storage quota, so a retry should not attach those bytes again.