Media

The media library holds the images, videos and PDFs you post. Upload files, import them from a URL, and convert them for each network: crop to 9:16, compress, trim, grab a thumbnail. Every library item comes with a ready to use mediaItem.

Upload files

Send a multipart request to POST /v1/media with one or more file fields (up to 20 files of up to 1 GB each), plus an optional folder and altText.

curl -X POST https://postkea.com/api/v1/media \
  -H "Authorization: Bearer $POSTKEA_API_KEY" \
  -F "[email protected]" \
  -F "folder=tours"

The response is a list of library items. Width, height, duration and a thumbnail are read from the file automatically.

A library item
{
  "id": "med_4Jq81vXc",
  "type": "video",
  "url": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.mp4",
  "thumbnailUrl": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.jpg",
  "filename": "studio-tour.mp4",
  "mimeType": "video/mp4",
  "size": 18874368,
  "width": 1080,
  "height": 1920,
  "durationSec": 31.4,
  "altText": null,
  "source": "upload",
  "folder": "tours",
  "tags": [],
  "mediaItem": {
    "type": "video",
    "url": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.mp4",
    "mediaId": "med_4Jq81vXc",
    "thumbnail": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.jpg",
    "mimeType": "video/mp4",
    "width": 1080,
    "height": 1920,
    "durationSec": 31.4,
    "size": 18874368
  }
}

Import from a URL

POST /v1/media/import downloads an image, video, audio file or PDF from a direct file URL into the library.

curl -X POST "https://postkea.com/api/v1/media/import" \
  -H "Authorization: Bearer $POSTKEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://cdn.example.com/launch.png",
  "altText": "The new dashboard in dark mode",
  "folder": "launch"
}'
To save the video of a social post page (a TikTok, a YouTube video, a Reel), use POST /v1/downloads with saveToLibrary: true instead. See Downloads and jobs.

Manage the library

  • GET /v1/media lists items. Filter by type (image, video, gif, document, audio), folder or q, and paginate with cursor.
  • PATCH /v1/media/{id} changes altText, folder or tags.
  • DELETE /v1/media/{id} deletes the file. Posts that already published are not affected.

Convert for each network

POST /v1/media/{id}/transform creates a new library item from an existing one. It is free. Images support vertical, square, landscape, compress and jpeg; videos support every operation.

OperationDescription
vertical1080 by 1920 (9:16), for Reels, TikTok and Shorts.
square1080 by 1080.
landscape1920 by 1080 (16:9).
compressRe-encode to fit under maxMb (50 MB by default).
thumbnailA still image from the frame at at seconds (1 by default).
audioExtract the soundtrack as an m4a file.
muteRemove the soundtrack.
gifAn animated GIF from start to end, up to 15 seconds.
trimKeep only the part from start to end.
jpegConvert an image to JPEG.
NameTypeDescription
operationrequiredvertical | square | landscape | compress | thumbnail | audio | mute | gif | trim | jpegWhat to do.
fitcrop | padFor aspect changes: crop fills the frame and cuts the edges (default), pad keeps everything and adds black bars.
startnumberStart time in seconds, for gif and trim.
endnumberEnd time in seconds, for gif and trim.
atnumberTime in seconds, for thumbnail.
maxMbnumberTarget size in MB, for compress.
curl -X POST "https://postkea.com/api/v1/media/med_4Jq81vXc/transform" \
  -H "Authorization: Bearer $POSTKEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "vertical",
  "fit": "crop"
}'

Using media in posts

Put the item's mediaItem straight into a post's mediaItems. Because it carries the size, dimensions and duration, validation can tell you before publishing that a video is too long for X or too large for Bluesky. See Posting for every network's limits.

A post with a library video
{
  "content": "A quick tour of the studio.",
  "mediaItems": [
    {
      "type": "video",
      "url": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.mp4",
      "mediaId": "med_4Jq81vXc",
      "thumbnail": "https://postkea.com/files/media/org_4kq1/med_4Jq81vXc.jpg",
      "mimeType": "video/mp4",
      "width": 1080,
      "height": 1920,
      "durationSec": 31.4,
      "size": 18874368
    }
  ],
  "platforms": [
    {
      "accountId": "acc_tt_9w3e"
    },
    {
      "accountId": "acc_ig_5t1p"
    },
    {
      "accountId": "acc_yt_6b8n",
      "platformSpecificData": {
        "title": "Studio tour"
      }
    }
  ],
  "publishNow": true
}