---
title: "Add media"
method: POST
path: "/media"
tags: ["Media"]
---

# Add media

`POST /media`

## Request

- Base URL: `https://api.rizamo.com/v1`
- URL: `https://api.rizamo.com/v1/media`
- Auth: HTTP bearer

With `contentType` and `size` (up to 4 GB), the answer says where to send the file: PUT each part, then call `complete` if there is one, and the media is `ready`. With `url`, Rizamo downloads the file and the media is ready in the answer. Media is yours until a post uses it, and then belongs to that post's profile (or to `profileId` at once): keys and people limited to some profiles reach their own media and their profiles'. Media not used by a post within 7 days is deleted.

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `url` string, uri: Import: a public http or https address. Rizamo downloads the file during this call; `contentType` and `size` are then ignored.
  - `contentType` 'image/jpeg' | 'image/png' | 'image/webp' | 'video/mp4' | 'video/quicktime' | 'application/pdf': Upload: the file's type, such as image/jpeg or video/mp4, with `size`.
  - `size` integer: Upload: the file's bytes, up to 4 GB. With `contentType`.
  - `alt` string: Describes the image for people who cannot see it.
  - `profileId` string: Optional: a profile you reach, which the media joins at once. Left out, the media is yours (the person, key or agent that added it) until a post uses it, and then joins that post's profile.

## Response `201`

OK

- object
  - `media` Media, required
    - `id` string, required
    - `type` 'image' | 'video' | 'document', required: document: a PDF, which LinkedIn publishes as a document post.
    - `url` string, nullable, required: A link that expires after a few hours: get the media again for a fresh one. Null until the file is uploaded.
    - `alt` string, required
    - `status` 'uploading' | 'ready' | 'failed', required: uploading: waiting for its file. Only ready media can go on a post.
    - `contentType` string, required
    - `size` integer, required: Bytes, once uploaded.
    - `width` integer, nullable, required: Pixels, as shown: read from the file once it is uploaded.
    - `height` integer, nullable, required
    - `duration` number, nullable, required: Seconds, for video.
    - `pages` integer, nullable, required: Pages, for a PDF: read from the file once it is uploaded. Null when they could not be read.
    - `profileId` string, nullable, required: The profile it belongs to: the one it was added for, or else the first post that used it. Null until then, when only whoever added it and people who reach every profile reach it. Keys and people limited to some profiles reach their own media and their profiles'.
  - `upload` object, nullable, required
    - `parts` object[], required: The file's bytes in order: the first part takes the first `size` bytes, and so on. Files up to 64 MB are one part. Parts can go up at the same time.
      - `url` string, required
      - `method` 'PUT', required
      - `headers` object, required
      - `size` integer, required
    - `complete` object, nullable, required: For a file in several parts: call it once every part is up, and the media is ready. Null for one part, which finishes on its own.
      - `url` string, required
      - `method` 'POST', required
    - `expiresAt` string, date-time, required

## Other responses

- `400`: `invalid_request`: A field is missing or wrong, or the request cannot be done as asked: the message names the field or says what to change.
- `401`: `unauthorized`: No API key or sign-in, or the key does not work: it was deleted, or it expired.
- `403`: `forbidden`: The caller may not do this: the key or agent lacks the scope (the message names it), or the action needs another role or a fresh sign-in.
- `404`: `not_found`: No such object, or it is outside your team or the profiles your key reaches.
- `409`: `conflict`: The object's state does not allow it now, such as an account that needs a new login. `queue_empty`: A post with `queue: true` whose profile has no posting times: set them, or give a `scheduledAt`. `queue_full`: No posting time free for the post's accounts in the next 90 days: add times, or give a `scheduledAt`. `idempotency_key_in_use`: A request with this `Idempotency-Key` is still running: try again in a moment.
- `413`: `payload_too_large`: The body is over 1 MB: files go up through the upload links of `POST /v1/media`.
- `415`: `unsupported_media_type`: The body is not JSON: send it with `Content-Type: application/json`.
- `422`: `capability_missing`: The account cannot do this: see its `capabilities`. `idempotency_key_reused`: This `Idempotency-Key` was used for a different request in the last 24 hours: send a new key.
- `429`: `rate_limited`: Over one of Rizamo's limits, or a network asked Rizamo to slow down: wait for `Retry-After` seconds, or as long as the message says.
- `500`: `internal`: Our side failed: retry, and send the `requestId` if it keeps failing.
- `501`: `not_implemented`: The feature is not set up where the call went, such as a local copy of the API.
- `503`: `timeout`: The request took too long to work out, most often a report: try again in a moment, or ask a report for a shorter period or one profile.

---

[API](https://skmtc.dev/rizamo/apis/rizamo-api.md) - [All operations](https://skmtc.dev/rizamo/apis/rizamo-api/llms.txt) - [OpenAPI document](https://skmtc.dev/rizamo/apis/rizamo-api/revisions/31b0c1b1ffb5?raw)
