---
title: "Upload media"
method: POST
path: "/v1/media/create-upload-url"
tags: ["Media"]
---

# Upload media

`POST /v1/media/create-upload-url`

To upload media to attach to your post, make a `POST` request to the `/media/create-upload-url` endpoint. 

You'll receive the ID of your media item (which can be used anywhere that `media_id` is referenced) and will include an `upload_url` which is a signed URL of the storage location for uploading your file to. 

This URL is unique and publicly signed for a short time, so make sure to upload your files in a timely manner.

**Example flow using JavaScript and the Fetch API:**

**Request an upload URL**

   ```js
   // Step 1: Request an upload URL from your API
   const response = await fetch('https://api.post-bridge.com/v1/media/create-upload-url', {
     method: 'POST',
     headers: {
       'Content-Type': 'application/json'
     },
     body: JSON.stringify({
       name: 'photo.jpg',
       mime_type: 'image/jpeg',
       size_bytes: 123456
     })
   });

   const { media_id, upload_url } = await response.json();
   ```

**Upload your file to the signed URL**

   ```js
   // Step 2: Upload your file to the signed URL
   const file = /* your File or Blob object, e.g., from an <input type="file"> */;
   await fetch(upload_url, {
     method: 'PUT',
     headers: {
       'Content-Type': 'image/jpeg'
     },
     body: file
   });
   ```

**Use the `media_id` in your post or wherever a media reference is required.**

**Rate limit note**

- API keys currently have a general limit of **10 requests per second per key**.
- There is no bulk endpoint for requesting multiple upload URLs at once.
- If you are uploading many files, keep your aggregate request rate under the limit and retry `429` responses with backoff.

## Request body

- CreateUploadUrlDto
  - `mime_type` 'image/png' | 'image/jpeg' | 'video/mp4' | 'video/quicktime' | 'application/pdf', required — The MIME type of the media file
  - `size_bytes` number, required — The size of the media file in bytes
  - `name` string, required — The original name of the file (for extension)

## Response `200`

Signed upload URL and media record created successfully.

- CreateUploadUrlResponseDto
  - `media_id` string, required — The unique media record ID
  - `upload_url` string, required — The signed upload URL for the client to upload the file
  - `name` string, required — The provided name of the media file

---

[API](https://skmtc.dev/post-bridge/apis/post-bridge-api.md) · [All operations](https://skmtc.dev/post-bridge/apis/post-bridge-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/post-bridge/post-bridge-api/revisions/97ae826701f6/schema)
