Hosting Media
When you attach an image or video to a post, the Buffer API doesn't accept a file upload. Instead, you pass a publicly accessible URL in the assets array.
Why media must be hosted
The url field on each asset (image or video) must point to a file that is reachable over the public internet without authentication.
This means the URL must work for anyone, not just you. Links that require a viewer to be signed in - for example a Google Drive or Dropbox "share" link - will not work.
Where to host your media
You can use any host that serves files at a direct, public URL. If you don't already have one, these options have a free tier and work well:
- Cloudinary - A media management platform with a generous free tier. After you upload a file you get a direct, publicly accessible URL you can use right away. It also offers optional on-the-fly image and video transformations.
- Cloudflare R2 - Object storage with a free tier. A good fit if you already use Cloudflare or are comfortable with a slightly more technical setup. Upload your file and configure the bucket for public access, and the file is ready to use.
Verifying that a URL works
Before using a URL with the API, open it in a private/incognito browser window:
- If the file loads directly without asking you to log in, it will work with the API.
- If you see a login prompt, a preview page, or an error, the URL won't work - host the file somewhere that serves it directly.
Using the media URL
Once your file is hosted, pass its URL in the assets array on createPost or editPost:
mutation CreatePost {
createPost(
input: {
text: "Check out our latest update!"
channelId: "some_channel_id"
schedulingType: automatic
mode: addToQueue
assets: [
{
image: {
url: "https://your-host.example.com/photo.jpg"
}
}
]
}
) {
... on PostActionSuccess {
post { id }
}
... on MutationError {
message
}
}
}
For complete walkthroughs, see the Create an image post and Create a video post examples.