Media
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"import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("studio-tour.mp4")], { type: "video/mp4" }), "studio-tour.mp4");
form.append("folder", "tours");
const res = await fetch("https://postkea.com/api/v1/media", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.POSTKEA_API_KEY}` },
body: form,
});
const { data } = await res.json();
console.log(data[0].mediaItem);import os, requests
with open("studio-tour.mp4", "rb") as f:
r = requests.post(
"https://postkea.com/api/v1/media",
headers={"Authorization": f"Bearer {os.environ['POSTKEA_API_KEY']}"},
files={"file": ("studio-tour.mp4", f, "video/mp4")},
data={"folder": "tours"},
)
print(r.json()["data"][0]["mediaItem"])The response is a list of library items. Width, height, duration and a thumbnail are read from the file automatically.
{
"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"
}'const res = await fetch("https://postkea.com/api/v1/media/import", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.POSTKEA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://cdn.example.com/launch.png",
altText: "The new dashboard in dark mode",
folder: "launch",
}),
});
const { data: item } = await res.json();
console.log(item);import os, requests
r = requests.post(
"https://postkea.com/api/v1/media/import",
headers={"Authorization": f"Bearer {os.environ['POSTKEA_API_KEY']}"},
json={
"url": "https://cdn.example.com/launch.png",
"altText": "The new dashboard in dark mode",
"folder": "launch",
},
)
item = r.json()["data"]
print(item)POST /v1/downloads with saveToLibrary: true instead. See Downloads and jobs.Manage the library
GET /v1/medialists items. Filter bytype(image,video,gif,document,audio),folderorq, and paginate withcursor.PATCH /v1/media/{id}changesaltText,folderortags.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.
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"
}'const res = await fetch("https://postkea.com/api/v1/media/med_4Jq81vXc/transform", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.POSTKEA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
operation: "vertical",
fit: "crop",
}),
});
const { data: item } = await res.json();
console.log(item);import os, requests
r = requests.post(
"https://postkea.com/api/v1/media/med_4Jq81vXc/transform",
headers={"Authorization": f"Bearer {os.environ['POSTKEA_API_KEY']}"},
json={
"operation": "vertical",
"fit": "crop",
},
)
item = r.json()["data"]
print(item)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.
{
"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
}