Facebook Pixel
APICreating Posts

Video post

Upload and publish a video to LinkedIn. Covers single-shot upload for small videos and chunked (multipart) upload for large ones.

A video post is init → upload → create, like an image — but upload/init decides whether you upload in one shot (SINGLE, small videos) or in chunks (MULTIPART, large videos), and create needs the recipes from the init response.

When to use

You're posting a video file (e.g. .mp4).

Small videos (SINGLE)

For smaller files, upload/init returns uploadType: "SINGLE" with a single uploadUrl.

Video post (SINGLE upload)
# 1. init -> uploadType, uploadUrl, assetUrn, recipes
curl -X POST https://api.connectsafely.ai/linkedin/posts/upload/init -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "mediaType": "video", "fileSize": 5242880, "filename": "clip.mp4" }'
# 2. upload the bytes to the returned uploadUrl
curl -X PUT "PASTE_uploadUrl" -H "Content-Type: video/mp4" --data-binary @clip.mp4
# 3. create -- pass the recipes array from step 1
curl -X POST https://api.connectsafely.ai/linkedin/posts/create -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "mediaType": "video", "assetUrn": "PASTE_assetUrn", "recipes": ["PASTE_recipe"], "text": "A 60-second tour of what we shipped this month." }'

Large videos (MULTIPART)

For large files, upload/init returns uploadType: "MULTIPART" with partUploadRequests (4 MB chunks), multipartMetadata, and mediaArtifactUrn. PUT each chunk, finalize with POST /posts/upload/complete, then create the post the same way as above.

Finalizing a multipart upload
// after init with uploadType === "MULTIPART"
const partUploadResponses = [];
for (const part of init.partUploadRequests) {
const chunk = bytes.subarray(part.firstByte, part.lastByte + 1);
const res = await fetch(part.uploadUrl, { method: "PUT", headers: part.headers, body: chunk });
partUploadResponses.push({ httpStatusCode: res.status, headers: Object.fromEntries(res.headers) });
}
await fetch(BASE + "/posts/upload/complete", {
method: "POST",
headers: { ...auth, "Content-Type": "application/json" },
body: JSON.stringify({
mediaArtifactUrn: init.mediaArtifactUrn,
multipartMetadata: init.multipartMetadata,
partUploadResponses,
}),
});
// then create the post with mediaType "video", init.assetUrn, init.recipes (as above)

Common mistakes

  • Forgetting recipes. Video create needs the recipes array returned by upload/init.
  • Skipping upload/complete for MULTIPART. Large videos aren't finalized until you call it.
  • Treating every video as SINGLE. Always branch on init.uploadType.

Reference