# Media (/growsocmed/docs/developers/media)

Upload photos, videos and PDF documents into the media library, in one request, in parts, from a URL, or through an upload link.

Posts, ideas and DMs use files from the workspace's media library by their id. After an upload, each file is checked in the background (type, size, dimensions, duration); its `status` goes from `pending` to `ready`, or to `failed` with a `fail_reason`. Only `ready` files can be posted.

| Type | Formats | Largest file |
| --- | --- | --- |
| Image | JPEG, PNG | 8 MB |
| Video | MP4, MOV | your plan's video limit (at most 2 GB) |
| Document | PDF (LinkedIn document posts) | 100 MB |

Uploads also count against the plan's storage and its uploads per hour. Each platform then has its own limits, see [Platforms](/growsocmed/docs/platforms).

## Four ways to upload [#four-ways-to-upload]

### One request (up to 100 MB) [#one-request-up-to-100-mb]

```bash
curl -X POST https://socmed.growpaces.com/api/v1/media/upload \
  -H "Authorization: Bearer gs_..." \
  -F "file=@photo.jpg"
```

The response is `201` with the new `media` (status `pending`). Files over 100 MB are refused with `413`; use parts.

### In parts (large videos) [#in-parts-large-videos]

1. Start: [`POST /media/uploads`](/growsocmed/docs/api-reference/media/start-chunked-upload) with `file_name`, `mime_type` and `size_bytes`. The answer gives the `media` id, `part_size` (16 MB) and `part_count`.
2. Send each part as raw bytes: `PUT /media/{id}/parts/{n}`, numbered from 1. Every part is exactly `part_size` bytes except the last. Parts can be sent in any order and sent again.
3. Finish: [`POST /media/{id}/complete`](/growsocmed/docs/api-reference/media/complete-upload). The parts are joined and the file is checked. A missing part gives `409 conflict` with `details.missing_parts`.

```bash
# part 1 of a 40 MB video (part_size 16777216)
curl -X PUT https://socmed.growpaces.com/api/v1/media/0193…/parts/1 \
  -H "Authorization: Bearer gs_..." \
  --data-binary @part-1.bin
```

### From a public URL [#from-a-public-url]

[`POST /media/from-url`](/growsocmed/docs/api-reference/media/upload-media-from-url) with `url` (and optionally `file_name`) copies a JPEG, PNG, MP4 or MOV from a public `https://` address. Up to three redirects are followed; addresses on private networks are refused. A video's server must send its size (`Content-Length`).

### Upload links (no API key) [#upload-links-no-api-key]

[`POST /media/upload-links`](/growsocmed/docs/api-reference/media/create-upload-link) returns an `upload_url` that uploads into the workspace without any other credential: handy for an AI agent that can run a terminal command, or for a person you send it to.

```bash
# one or more files, up to 100 MB each (at most 10 per request)
curl -F "file=@photo.jpg" https://socmed.growpaces.com/api/public/uploads/…

# a bigger video: the raw bytes, with its name
curl -X PUT --data-binary @video.mp4 "https://socmed.growpaces.com/api/public/uploads/…?name=video.mp4"
```

A link works for 30 minutes after its last use, and at most 6 hours after it was made. Treat it like a password while it works.

The older presigned flow ([`POST /media`](/growsocmed/docs/api-reference/media/start-presigned-upload): `PUT` the file to the returned `upload_url`, then `complete`) still works.

## Manage the library [#manage-the-library]

- [`GET /media`](/growsocmed/docs/api-reference/media/list-media): newest first, filter with `type`; page with `before` set to the previous `next_cursor`.
- [`PATCH /media/{id}`](/growsocmed/docs/api-reference/media/update-media): change `alt_text` (read by screen readers), `original_name`, or `keep`.
- [`DELETE /media/{id}`](/growsocmed/docs/api-reference/media/delete-media) and [`POST /media/bulk-delete`](/growsocmed/docs/api-reference/media/bulk-delete-media): not while a scheduled post uses the file.
- [`GET /media/usage`](/growsocmed/docs/api-reference/media/get-storage-usage): storage used across all workspaces of the owner, and the plan's limit.

Files are deleted automatically when nothing needs them any more (`expires_at` tells when, `null` means never):

- a file no post uses: 7 days after upload;
- a file of published or canceled posts: the workspace's retention period after the last of them finished;
- a file of a failed or partly published post: 30 days, so the post can be retried;
- an upload that never finished: one day after it started.

Files marked `keep`, files of an idea and files of posts that have not finished are never deleted automatically. File `url`s are signed and valid for one hour: read them again instead of storing them.