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

# Uploading media

> Add pictures and videos to the media library and attach them to posts.

Pictures and videos live in a company's **media library** as **assets**. An asset is the library item (name, type, folder), and its picture or video is a **file** attached to it.

## Add a picture to a post

### 1. Create an asset

```bash cURL theme={null}
curl --request POST https://api.followr.ai/api/companies/1287/assets \
  --header "Authorization: Bearer $FOLLOWR_API_KEY" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{"name": "Holiday latte launch", "type": "image"}'
```

You get `201` with the asset's `id`. Use `"type": "video"` for a video. Clients can't create assets, and a full storage answers `402` with `entity: bytes`.

### 2. Upload the file

The file never goes in the API request itself. Use [`POST /assets/{id}/image`](https://docs.followr.ai/api-reference/files/upload-an-asset-picture), or `/video` for a video, in one of two ways:

> [tab] Upload URL
>
> Start the upload with the file's name and type:
>
> ```bash cURL theme={null}
> curl --request POST https://api.followr.ai/api/assets/66120/image \
>   --header "Authorization: Bearer $FOLLOWR_API_KEY" \
>   --header "Accept: application/json" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "filename": "holiday-latte.png",
>     "mime_type": "image/png",
>     "visibility": "public"
>   }'
> ```
>
> Then `PUT` the bytes to the `presigned_url` from the answer within 10 minutes, with the file's content type. Don't send your API key there. There's no confirm call.
>
> ```bash cURL theme={null}
> curl --request PUT "$PRESIGNED_URL" \
>   --header "Content-Type: image/png" \
>   --header "x-ms-blob-type: BlockBlob" \
>   --data-binary @holiday-latte.png
> ```

> [tab] From a public URL
>
> Send the file's address as `url`, and Followr downloads it during the request:
>
> ```bash cURL theme={null}
> curl --request POST https://api.followr.ai/api/assets/66120/image \
>   --header "Authorization: Bearer $FOLLOWR_API_KEY" \
>   --header "Accept: application/json" \
>   --header "Content-Type: application/json" \
>   --data '{
>     "filename": "holiday-latte.png",
>     "url": "https://www.northside.example/media/holiday-latte.png",
>     "visibility": "public"
>   }'
> ```
>
> The URL must be public `http` or `https`. The file must be an image, video or audio file up to 50 MB, and download within 15 seconds with at most 5 redirects.

Uploading again replaces the file. Use `"visibility": "public"` for anything you publish: public files get a stable CDN URL, private ones a signed URL that expires after 12 hours.

### 3. Check processing

```bash cURL theme={null}
curl "https://api.followr.ai/api/assets/66120?include=image.thumbnail" \
  --header "Authorization: Bearer $FOLLOWR_API_KEY" \
  --header "Accept: application/json"
```

`data.image.status` goes from `pending` to `analyzing` to `analyzed` (or `error`), usually in 1 to 2 minutes. Publishing doesn't wait for it. A file that stays `pending` never got its bytes: upload it again.

### 4. Attach it to a post

```bash cURL theme={null}
curl --request POST https://api.followr.ai/api/postGroups/88412/posts \
  --header "Authorization: Bearer $FOLLOWR_API_KEY" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '{
    "social_network_type": "instagram",
    "description": "Our holiday latte is back. Come say hi.",
    "assets_ids": [66120]
  }'
```

Media appears in the order of `assets_ids`. On update, the list replaces the old one. See [Publishing posts](https://docs.followr.ai/guides/publishing-posts.md).

## Video covers

Instagram, YouTube and Pinterest can show a cover picture on a video. Upload it to the post with [`POST /posts/{id}/cover`](https://docs.followr.ai/api-reference/files/upload-a-post-cover), the same way.

## Organize the library

* **Folders**: create with `POST /companies/{company_id}/folders`, then set an asset's `folder_id`. [Move many assets](https://docs.followr.ai/api-reference/assets/move-assets-to-a-folder.md) with `PUT /companies/{company_id}/assets/bulk`.
* **Delete** an asset with `DELETE /assets/{id}`, or only its file with `DELETE /files/{id}`.

## Other uploads

The same two ways work for:

| What | Endpoint |
| - | - |
| A company logo | `POST /companies/{id}/image` |
| A profile picture | `POST /users/{id}/image` |
| An avatar's picture and scenes | `POST /avatars/{id}/image`, `POST /avatars/{id}/scenes` |
| A voice sample | `POST /voices/{id}/audio` |
| A Creative Studio reference picture | `POST /uploads/creative-reference` |


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