---
title: "Upload a small base64-encoded image, video, or document"
description: "PubNio API media.uploadInline: upload a small base64-encoded image, video, or document. Request fields, examples in five clients, errors, and idempotency."
---

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

# Upload a small base64-encoded image, video, or document

Upload a small base64-encoded image, video, or document with [`POST /api/v1/media/inline`](https://pubnio.com/api/v1/docs#tag/media/POST/api/v1/media/inline). Requires an API key with the `read` scope or a signed-in workspace member.

## Request

JSON upload for small files (maximum 8 MiB after base64 decoding). Uses the same workspace storage and returns the shared MediaIntake result.

The decoded file must be 1 byte to 8 MiB, otherwise `upload-too-large`; send larger files with [`POST /api/v1/media`](https://pubnio.com/api/v1/docs#tag/media/POST/api/v1/media). The bytes must start with the signature of the declared `mimeType`, otherwise `bad-request`.

| Parameter     | In    | Type | Required |
| ------------- | ----- | ---- | -------- |
| `workspaceId` | query | UUID | Yes      |

| Body field | Type             | Required |
| ---------- | ---------------- | -------- |
| `data`     | string           | Yes      |
| `mimeType` | one of 8 strings | Yes      |
| `filename` | string           | No       |

## Response

- HTTP 201: `MediaIntake` with `mediaId`, `status`, `asset`, `issue`, `upload`, `idempotencyKey`, `retryAfterSeconds`.
  - `status`: `awaiting_upload`, `processing`, `ready`, `failed`

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

The TypeScript SDK has no method for this operation yet; send it over HTTP as the cURL tab shows.

### Python

```python
result = workspace.media.upload_inline(
    data="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
    mime_type="image/png",
    filename="pixel.png",
)
```

### cURL

```sh
curl -X POST "https://pubnio.com/api/v1/media/inline?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==","mimeType":"image/png","filename":"pixel.png"}'
```

### CLI

No `pnio` command calls this operation.

### MCP execute

```js
async () => {
  // One key per intent; reuse it only to retry this same request.
  const idempotencyKey = crypto.randomUUID();
  const response = await codemode.request({
    method: "POST",
    path: "/api/v1/media/inline",
    query: { workspaceId: codemode.workspaceId },
    headers: { "Idempotency-Key": idempotencyKey },
    body: {
      data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",
      mimeType: "image/png",
      filename: "pixel.png",
    },
  });
  return response.data;
};
```

## Errors

- [`idempotency-conflict`](https://pubnio.com/docs/problems/idempotency-conflict/): HTTP 409, Idempotency key already used
- [`media-upload-conflict`](https://pubnio.com/docs/problems/media-upload-conflict/): HTTP 409, Media upload conflict
- [`upload-too-large`](https://pubnio.com/docs/problems/upload-too-large/): HTTP 413, Content Too Large

It also declares the problems [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

Optional. A retry with the same `Idempotency-Key` returns the first result for 24 hours. Make one key per intent, such as `crypto.randomUUID()` or Python's `uuid4()`, and reuse it only to retry the same request. See [Idempotency](https://pubnio.com/docs/concepts/idempotency/).

## Limits

- Field lengths and ranges are in the [OpenAPI document](https://pubnio.com/api/v1/openapi).

## Related

- [Media operations](https://pubnio.com/docs/reference/#media)
- [Publishing](https://pubnio.com/docs/publishing/)

Source: https://pubnio.com/docs/reference/media-upload-inline/index.mdx
