> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Reddit API

> Options for posting using the Reddit API

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

## Posting to Reddit

The following are required body parameters for posting using the Reddit API. Please be sure the subreddit allows automated posting.
Please see [Reddit Media Guidelines](/media-guidelines/reddit) and [Reddit Authorization](/dashboard/connect-social-accounts/reddit) for more information.

```json Reddit Post theme={"system"}
{
  "post": "Reddit post", // empty string is allowed
  "platforms": ["reddit"], // required
  "redditOptions": {
    "title": "Reddit Post Title", // required
    "subreddit": "test", // required (no "/r/" needed)
    "link": "https://www.website.com" // optional: post a link
  }
}
```

<ul class="custom-bullets">
  <li>`title` (required): The title of the post on Reddit.</li>

  <li>
    `subreddit` (required): The subreddit to send the post. Please be sure to follow the subreddit's
    posting guidelines. A good subreddit to use for testing is */r/test/* and can be viewed at:
    [https://www.reddit.com/r/test/](https://www.reddit.com/r/test/)
  </li>

  <li>
    `link` (optional): If posting to Reddit and you want to post a link instead of text to the
    subreddit. While the `post` parameter text is still required, it is not included in the post
    since Reddit links can't have a text body.
  </li>
</ul>

<Warning>
  Always check the rules of the subreddit before posting. Some subreddits have a karma threshold,
  require membership for a time period, limit the frequency of posting, don't allow images, or
  require flair to be added. Also, most subreddits have specific rules on spam and self-promotion.
  Not following these rules can result in being banned by the subreddit or Reddit.
</Warning>

## Posting an Image to Reddit

Post an image to Reddit either by including the image URL in the `mediaUrl` parameter or the `link` parameter of `redditOptions`. Images posted as a `link` will resolve to the full image.

The `post` parameter text is ignored, but is still required to successfully submit the post. Reddit restricts posting images and text together to their online "fancy pants" editor. This means either an image or text can be posted, but not both at the same time.

```json Reddit Post with Image theme={"system"}
{
  "post": "Reddit post", // required, but not added to the post
  "platforms": ["reddit"], // required
  "mediaUrls": "https://my-media-url.com",
  "redditOptions": {
    "title": "Reddit Post Title", // required
    "subreddit": "test" // required (no "/r/" needed)
  }
}
```

## Add Reddit Flair

Some subreddits require flair. Subreddit moderators pre-define the flair and each flair has a unique ID. In the Reddit post to Ayrshare add the flair ID and an optional flair text if the text can be overridden.

```json Reddit Post with Flair theme={"system"}
{
  "redditOptions": {
    "flairId": "jM8nH92enjswas", // Id of the flair
    "flairText": "My New Flair text" // Override the flair text if allowed by flair
  }
}
```

You can find the flair ID of a subreddit by calling the [/post/redditFlair](/apis/utils/reddit-get-flair) endpoint.

## Check if a Subreddit Exists

Check if a subreddit exists with the [/validate endpoint](/apis/validate/check-subreddit).

## Add rich text formatting to Reddit posts

If you want to add bold, italic, or superscript text to a Reddit post, use [Reddit-flavored Markdown](https://www.reddit.com/wiki/markdown#wiki_new_reddit-flavored_markdown).

```json Reddit Post with Rich Text theme={"system"}
{
  "post": "For example, this can be *italic* or **bold** or ^super ",
  "platforms": ["reddit"],
  "redditOptions": {
    "title": "Rich Text Post",
    "subreddit": "test"
  }
}
```

## Reddit Mentions

Mention another Reddit user or subreddit.

<ul class="custom-bullets">
  <li>Mention a Reddit user by adding `@subreddit` or `u/username` in the post text.</li>
  <li>Mention a subreddit by adding `r/subreddit` in the post text.</li>
</ul>

For example:

```json Reddit Post with Mention theme={"system"}
{
  "post": "The best Reddit post ever for user @ayrshare and subreddit r/SiliconValleyHBO",
  "platforms": ["reddit"]
}
```

<Warning>
  Please review the [important rules](/testing/post-verification#mentions) on mentions.
</Warning>

## Character Limits

Please see [Reddit Character Limits](/help-center/technical-support/character_limits#reddit-character-limits) for more information.

## Additional Endpoints

<Card title="Get Reddit Flair" icon="code" href="/apis/utils/reddit-get-flair" horizontal />
