---
title: "Upload a file directly"
method: POST
path: "/v1/media/upload-direct"
tags: ["Media"]
---

# Upload a file directly

`POST /v1/media/upload-direct`

## Request

- Base URL: `https://api.postzen.dev`
- URL: `https://api.postzen.dev/v1/media/upload-direct`
- Auth: HTTP bearer

Uploads a file in the request itself and returns a public URL, for cases where a two-step presign is inconvenient and the file is small — chiefly direct message attachments, where Meta fetches the URL itself. The stored object is deleted automatically after seven days, so it is not a substitute for `POST /v1/media/presign` when publishing posts. Maximum 25MB. Requires a read-write API key.

## Response `200`

File stored.

- MediaDirectUploadResponse
  - `url` string, uri, required: Publicly fetchable URL for the stored file. Pass it as `attachmentUrl` when sending a direct message.
  - `filename` string, required: Sanitized file name the object was stored under.
  - `contentType` string, required
  - `size` integer, required: Stored size in bytes.

## Other responses

- `400`: Invalid request.
- `401`: Missing or invalid API key.
- `403`: The API key does not have sufficient permission or profile access.
- `429`: Rate limit exceeded. Retry after the interval indicated by the `Retry-After` header.
- `500`: Unexpected server error.

---

[API](https://skmtc.dev/postzen/apis/postzen-public-api.md) · [All operations](https://skmtc.dev/postzen/apis/postzen-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/postzen/apis/postzen-public-api/revisions/40863e3710ec?raw)
