Posts
Publish text, link, image, gallery and native video posts to Reddit, with flair, NSFW and spoiler tags, plus every platformSpecificData field.
A plain post becomes a text post (a self post) in the account's default subreddit.
The first line of content becomes the title and the rest becomes the body. Reddit Markdown works in the body.
Fields in platformSpecificData on the Reddit entry pick the subreddit, turn the post into a link post, and set flair, NSFW and spoiler tags.
Text post
import Zernio from '@zernio/node';
const zernio = new Zernio();
const { data: published } = await zernio.posts.createPost({
body: {
content: 'Tips for learning a new programming language\n\nHere is what worked for me:\n\n1. Start with the official tutorial\n2. Build a small project immediately\n3. Read other people\'s code',
platforms: [
{
platform: 'reddit',
accountId: '66b2e19d8c3f5a7e9d0b1c2d',
platformSpecificData: { subreddit: 'learnprogramming' }
}
],
publishNow: true
}
});
console.log(published.post.platforms[0].platformPostUrl);Response (201):
{
"post": {
"_id": "65f1c0a9e2b5af0012ab34cd",
"status": "published",
"platforms": [
{
"platform": "reddit",
"status": "published",
"platformPostUrl": "https://www.reddit.com/r/learnprogramming/comments/..."
}
]
}
}Every sample below changes only the mediaItems or the platforms entry of this request.
Link post
url turns the post into a link post; content becomes the title:
{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": {
"subreddit": "programming",
"url": "https://example.com/api-design-article"
}
}When a link post fails with NO_LINKS because the subreddit allows text posts only, Zernio retries it as a text post with the URL in the body.
Image post
A single image; content becomes the title:
"mediaItems": [
{ "type": "image", "url": "https://cdn.example.com/hiking-photo.jpg" }
]Gallery
2 or more images publish as a gallery, up to 20.
Images past the 20th are dropped, without an error, so trim the list yourself when you have more.
Not every subreddit allows galleries:
"mediaItems": [
{ "type": "image", "url": "https://cdn.example.com/step1.jpg" },
{ "type": "image", "url": "https://cdn.example.com/step2.jpg" },
{ "type": "image", "url": "https://cdn.example.com/step3.jpg" },
{ "type": "image", "url": "https://cdn.example.com/finished.jpg" }
]Native video
A video uploads to Reddit's CDN and publishes as a native video that plays in Reddit's embedded player.
Reddit transcodes it server-side with a 1080p and 30 fps cap.
The post content, or the Reddit entry’s customContent override, becomes the original video post’s Markdown body.
If body text is present, upload failures and subreddit video restrictions fail the post without converting it to a link. Automatic link fallback applies only to videos without body text.
nativeVideo: false skips the upload and posts the video URL as an external link instead:
"mediaItems": [
{ "type": "video", "url": "https://cdn.example.com/demo.mp4" }
]For a native video with an explanation and CTA URL, send a request like this to POST /v1/posts:
{
"content": "How the product works\n\nTry it: https://example.com/product",
"mediaItems": [
{ "type": "video", "url": "https://cdn.example.com/demo.mp4" }
],
"platforms": [
{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": {
"subreddit": "your_community",
"title": "A short product demo",
"nativeVideo": true
}
}
],
"publishNow": true
}Leave forceSelf unset for this combination. forceSelf: true creates a text-only self post and skips native media uploads.
Adding body text does not bypass a subreddit's video restrictions.
Zernio extracts the video's first frame as the poster. videoPosterUrl replaces it:
{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": {
"subreddit": "videos",
"videoPosterUrl": "https://cdn.example.com/poster.jpg"
}
}videogif: true submits the same upload as a silent looping clip. The video is still uploaded natively. Only Reddit's kind changes:
{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": { "subreddit": "gifs", "videogif": true }
}Flair
Some subreddits require a post flair. List the flairs with List subreddit flairs, then pass the id as flairId:
const { data: flairs } = await zernio.connect.getRedditFlairs({
path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d' },
query: { subreddit: 'socialmedia' }
});
console.log(flairs.flairs);Response (200):
{
"flairs": [
{ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "text": "Discussion", "textColor": "dark", "backgroundColor": "#edeff1" },
{ "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901", "text": "News", "textColor": "light", "backgroundColor": "#ff4500" }
]
}{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": {
"subreddit": "socialmedia",
"flairId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}If the subreddit requires a flair and the request has no flairId, Zernio uses the first available flair.
To change the flair of a post that is already live, call Set Reddit post flair.
NSFW and spoiler tags
nsfw: true marks the post as over 18.
spoiler: true marks it as a spoiler. It takes effect only when the subreddit has spoiler tagging enabled:
{
"platform": "reddit",
"accountId": "66b2e19d8c3f5a7e9d0b1c2d",
"platformSpecificData": { "subreddit": "television", "spoiler": true }
}Edit a published post
POST /v1/posts/{postId}/edit with platform: "reddit" and the new content replaces the body of a published text post.
Reddit keeps the same post id, and there is no time window.
A link post has no editable body and is rejected with a 400 before the write. The title can never be edited.
curl -X POST "https://zernio.com/api/v1/posts/65f1c0a9e2b5af0012ab34cd/edit" \
-H "Authorization: Bearer $ZERNIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "platform": "reddit", "content": "Updated write-up, with the benchmark numbers." }'Response (200):
{
"success": true,
"id": "1abcd2",
"url": "https://www.reddit.com/r/learnprogramming/comments/1abcd2/tips/",
"message": "reddit post edited successfully"
}Platform fields
All fields go in platformSpecificData on the Reddit entry.
| Field | Type | Default | Description |
|---|---|---|---|
subreddit | string | account default | Target subreddit without the r/ prefix. |
title | string | first line of content | Post title, at most 300 characters. Cannot be edited after posting. |
url | string (URL) | Makes a link post instead of a text post. | |
forceSelf | boolean | false | Makes a text-only self post and skips native media uploads, even when media is provided. Omit for native video with body text. |
nativeVideo | boolean | true | Uploads video to Reddit's CDN for the embedded player. false explicitly publishes an external link instead. When body text is present, upload failures or subreddit video restrictions fail the post without falling back to a link. |
videogif | boolean | false | Submits the native video as a silent looping clip. |
videoPosterUrl | string (URL) | first frame | Poster image for a native video. |
flairId | string | Flair id from List subreddit flairs. Required by some subreddits. | |
flairText | string | Free-text flair for subreddits that allow it. Ignored when flairId is set. | |
nsfw | boolean | false | Marks the post as over 18. |
spoiler | boolean | false | Marks the post as a spoiler. The subreddit must have spoiler tagging enabled. |
sendreplies | boolean | true | false stops comment replies from reaching the account's Reddit inbox. |