Creating a post
A guide to publishing content via the API
Logging in
Before you can do any kind of interaction with the API, you must first make sure you have a valid API key or OAuth access token with the posts.manage_posts.write
permission. If you dont know what this means, please read our guide on authentication with the API by clicking below:
Creating a post programmatically
Making posts is a really simple process, all you need to do is send a few fields and we handle everything else. If you are sending any kind of data to Sponsus, it must be packaged into a JSON body. This allows us to accept data from almost every language without having to deal with compatability.
To find out what Markdown is and what you can do with it, click here to be taken to the Writing a post guide!
These fields are always needed in a post request as these determine how we handle the post. Title and content are pretty obvious as to what they do however the price_to_view
field controls how much someone would need to donate or sponsor in order to get access. The type field tells Sponsus what kind of post this is. It also helps with determining the required fields from other post types such as images
or video
.
If your request was successful, Sponsus will return this object:
The embeds field is processed after the post is created, check back after a few seconds to get the post embeds.
Locking a post
The old method of locking posts has been deprecated for the lock
method. Please read below as to how to use the new locking system.
Paywalling content is Sponsus's bread and butter. Its super simple to lock a post with the ability to extend it for advanced users.
When making a post (editing or creating a new one), you can send a "lock" object. This object tells Sponsus's API how to lock a post. This is a per-post basis to give you the most flexability.
Creating a media post (Image gallery & Video)
Since the first example is only a basic text post, lets go deeper into the API and create an image or video post. Most of the code used in the first example is reused here so I will only talk about the bits that have changed. The biggest thing that has changed with our media post is the fact that we are changing the type field to be either image or video.
Creating a image post
The images.src
field must be an array as Sponsus image posts are galleries. If you only want to show off a single image, then just put one image url in the array. Image url must be HTTPS urls as security is strict on Sponsus. If you need to upload images that require
Creating a video post
The video src field is different to the image src field as this takes a single video url as the input. The video urls that we support are YouTube, Twitch.tv (live only), Vimeo (public videos for now), and raw MP4 videos. If you try to use a url that is not supported, it will not show up on the website.
Publishing a post at a later date
It is possible to create a post and then have it be published later on. This is called a draft as the API waits until the signal to publish the post to the sponsors. You can do this in a few ways, you can set the publish_at
field during post creation to an UTC ISO datetime. You can also edit a post that is in the "draft" stage to have the publish_at field as well. If the post is not already published, then when the time reaches the publish_at time the API will publish it.
If you do not wish to have automattic publishing, you can opt for a programatic aproach by sending a GET request to /v1/posts/<userID>/post/<postID>/publish
.3123123
You will need to be authenticated with the API before you edit or publish a post! Both of these routes require posts.manage_posts.write
.
Last updated