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

# Files

> List the store's gallery images and videos, register media you host yourself, or copy a file from a public URL into the store's own storage.

The store's gallery holds the images and videos a merchant uses on products,
blog posts and pages. An app with `READ_FILES` can list it; one with
`WRITE_FILES` can add media to it.

The store is bound to your app token server-side. Never send a shop id.

## What the gallery contains

List results exclude paid digital files (`private: true`), because those belong
to a buyer rather than the store's media library. Cap covers and page images are
reached through the digital product instead.

## List files

```http theme={null}
GET /api/v1/files?page=1&limit=20
```

`limit` is capped at 100. Pass `type=image` or `type=video` to narrow by
mimetype. A store that has never uploaded anything answers with an empty list,
not `404`.

## Get one file

```http theme={null}
GET /api/v1/files/:id
```

## Register media you already host

```http theme={null}
POST /api/v1/files
```

```json theme={null}
{
  "url": "https://cdn.yourapp.com/hero.jpg",
  "originalName": "hero.jpg",
  "mimetype": "image/jpeg",
  "tags": ["campaign"]
}
```

This records a **link**, not the bytes: the file row is stored with `size: 0`
and the store keeps depending on your host. Only `image/*` and `video/*`
mimetypes are accepted.

Use it when your app generates media and serves it from its own CDN, and you
want it to appear in the merchant's gallery so they can pick it in the theme
editor.

## Copy a public URL into the store's storage

```http theme={null}
POST /api/v1/files/upload-from-url
```

```json theme={null}
{ "url": "https://example.com/photo.png", "file_name": "photo.png" }
```

This is the counterpart to the call above: Salesive fetches the URL once and
stores the bytes in the store's own bucket, so the gallery no longer depends on
somebody else's server. Use it when the merchant pastes a link from elsewhere.

Failures name the reason rather than a generic error:

| Status | Meaning |
| - | - |
| `400` | The URL cannot be fetched (malformed, not http or https). |
| `413` | The remote file is larger than the limit. |
| `415` | The remote file is not an image or video. |
| `502` | The remote host failed or refused the fetch. Retry later. |

## Update and delete

```http theme={null}
PUT /api/v1/files/:id
DELETE /api/v1/files/:id
```

Both need `WRITE_FILES`. Update changes the tags and name a merchant sees; it
does not replace the media.

> [!NOTE]
>
> Deleting a gallery file removes it from the merchant's library, so a product,
> blog post or page that still points at it will show a broken image. Check what
> references a file before removing it, and prefer registering a new file over
> overwriting one an app did not create.

## Scopes

| Scope | Grants |
| - | - |
| `READ_FILES` | `GET /files`, `GET /files/:id` |
| `WRITE_FILES` | `POST /files`, `POST /files/upload-from-url`, `PUT /files/:id`, `DELETE /files/:id` |


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