Media

Upload media

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

// 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

// 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.
post/v1/media/create-upload-url

Request body

mime_type'image/png' | 'image/jpeg' | 'video/mp4' | 'video/quicktime' | 'application/pdf' required

The MIME type of the media file

size_bytesnumber required

The size of the media file in bytes

namestring required

The original name of the file (for extension)

Example request

{
  "mime_type": "image/png",
  "size_bytes": 1234567,
  "name": "myphoto.png"
}

Response

Signed upload URL and media record created successfully.

media_idstring required

The unique media record ID

upload_urlstring required

The signed upload URL for the client to upload the file

namestring required

The provided name of the media file

Changes

No recorded changes to this endpoint across all 1 revision of this API.