> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Posts

Publish text, link, image, gallery and native video posts to Reddit, with flair, NSFW and spoiler tags, plus every platformSpecificData field.

<Callout type="warn">
**Reddit is temporarily unavailable** while Reddit blocks third-party API access: `POST /v1/posts` still accepts the post, but its Reddit part fails with a `Reddit is temporarily unavailable` error instead of publishing. See [Reddit](/platforms/reddit).
</Callout>

A plain post becomes a text (self) post in the account's default subreddit:

- The first line of `content` is the title.
- The rest is the body, in Reddit Markdown.

`platformSpecificData` on the Reddit entry picks the subreddit, makes a link post, and sets flair, NSFW and spoiler tags.

## Text post

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
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);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

published = client.posts.create_post(
    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"}
        }
    ],
    publish_now=True
)

print(published["post"]["platforms"][0]["platformPostUrl"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "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
  }'
```
</Tab>
</Tabs>

Response (`201`):

```json
{
  "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:

```json
{
  "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:

```json
"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:

```json
"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:

```json
"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`:

```json
{
  "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:

```json
{
  "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:

```json
{
  "platform": "reddit",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": { "subreddit": "gifs", "videogif": true }
}
```

## Flair

Some subreddits require a post flair. List the flairs with [List subreddit flairs](/connect/get-reddit-flairs), then pass the `id` as `flairId`:

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: flairs } = await zernio.connect.getRedditFlairs({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d' },
  query: { subreddit: 'socialmedia' }
});

console.log(flairs.flairs);
```
</Tab>
<Tab value="Python">
```python
flairs = client.connect.get_reddit_flairs(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    subreddit="socialmedia"
)

print(flairs["flairs"])
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/reddit-flairs?subreddit=socialmedia" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "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" }
  ]
}
```

```json
{
  "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](/connect/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:

```json
{
  "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.

```bash
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`):

```json
{
  "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](/connect/get-reddit-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. |