Facebook Pixel
APICreating Posts

Image post

Upload one image and publish it to LinkedIn. Three-step flow with cURL, JavaScript, and Python examples.

An image post is three steps: init the upload, PUT the bytes to LinkedIn, then create the post.

When to use

You're posting a single photo. For 2 or more images, see Image carousel.

Steps

  1. POST /posts/upload/init → returns an assetUrn and a one-time uploadUrl.
  2. PUT the file bytes to uploadUrl (this goes straight to LinkedIn, not to our API).
  3. POST /posts/create referencing the assetUrn.
Image post (full flow)
# 1. init -> returns assetUrn, uploadUrl, uploadHeaders
curl -X POST https://api.connectsafely.ai/linkedin/posts/upload/init -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "mediaType": "image", "fileSize": 184230, "filename": "photo.jpg" }'
# 2. upload the bytes to the returned uploadUrl
curl -X PUT "PASTE_uploadUrl" -H "Content-Type: image/jpeg" --data-binary @photo.jpg
# 3. create the post
curl -X POST https://api.connectsafely.ai/linkedin/posts/create -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "mediaType": "image", "assetUrn": "PASTE_assetUrn", "altText": "Our team at the offsite", "text": "Great week with the team!" }'

Common mistakes

  • Posting before uploading. Create only works after the PUT in step 2 succeeds.
  • Wrong Content-Type on the PUT. Match the file (image/jpeg, image/png, …).
  • Dropping uploadHeaders. Include whatever step 1 returned on the PUT.

Reference