RedditapisRedditapis
Listings & Search

List a Subreddit's Post Flair Templates

List a subreddit's post flair templates (id, text, editable, colours, mod-only) so you can pass a flair id when you create a post.

GET/api/reddit/sub/:name/flairs$0.0015 / call

A subreddit's post (link) flair templates: the flairs a post in that community can carry. Pass a template's id as flair_id to POST /api/reddit/submit, and, when the template is editable, your own flair_text with it. Many subreddits remove a post that has no flair, so read this before posting there.

Who reads it

Reddit serves this list only to signed-in accounts, so the call always reads it as a session, never anonymously. It uses the first of these that applies:

  1. your session headers, x-reddit-session and x-reddit-loid, when you send them (Authenticated reads);
  2. otherwise your stored Reddit session, if one is connected.

With neither, the call answers 503 with code: "SESSION_REQUIRED" before Reddit is asked, and is not charged. Connecting a stored session once is the simplest way to make sure it always answers.

When the list is read as a session (yours or your stored one), a moderator of the subreddit gets every template, mod-only ones included. Any other account gets the templates Reddit offers it on its own submit page, which is exactly the set it can post with; those are listed with mod_only: false, and fields Reddit does not send for them (max_emojis, allowable_content, and sometimes the colours) are null.

Path Parameters

ParameterTypeRequiredDescription
namestringYesSubreddit name (no r/ prefix), 1 to 21 letters, digits or underscores

Optional Headers

HeaderDescription
x-reddit-sessionYour reddit_session cookie, to read the list as your account
x-reddit-loidYour loid cookie, sent alongside x-reddit-session

Example

curl -H "Authorization: Bearer $TOKEN" \
  "https://api.redditapis.com/api/reddit/sub/SaaS/flairs"
const response = await fetch(
  "https://api.redditapis.com/api/reddit/sub/SaaS/flairs",
  { headers: { Authorization: "Bearer TOKEN" } }
);
const { flairs } = await response.json();
// Post with the first template that is not mod-only:
const flair = flairs.find((f) => !f.mod_only);
import requests

response = requests.get(
    "https://api.redditapis.com/api/reddit/sub/SaaS/flairs",
    headers={"Authorization": "Bearer TOKEN"},
)
flairs = response.json()["flairs"]

Response Shape

{
  "subreddit": "SaaS",
  "flairs": [
    {
      "id": "a1b2c3d4-0000-11ee-8000-000000000001",
      "text": "Question",
      "editable": false,
      "type": "text",
      "background_color": "#0079d3",
      "text_color": "light",
      "css_class": "q",
      "mod_only": false,
      "max_emojis": 10,
      "allowable_content": "all",
      "richtext": []
    }
  ],
  "count": 1
}

Response Fields

FieldTypeNotes
subredditstringThe name you asked for
countnumberHow many templates are listed
flairs[].idstringThe template id. Send it as flair_id to POST /api/reddit/submit
flairs[].textstringThe flair's text ("" for a richtext-only flair)
flairs[].editablebooleanWhen true, you may send your own flair_text with this id
flairs[].typestringtext or richtext
flairs[].background_colorstring | nullHex colour, or null when the subreddit set none
flairs[].text_colorstring | nulldark or light
flairs[].css_classstring | nullThe template's CSS class, if any
flairs[].mod_onlybooleanModerators only. Reddit refuses it for anyone else at submit time
flairs[].max_emojisnumber | nullMost emojis the flair text may hold
flairs[].allowable_contentstring | nullall, text or emoji
flairs[].richtextarrayReddit's richtext parts for the flair (empty for a plain text flair)

A subreddit with no post flairs returns flairs: [], which is billed like any answer. A template Reddit sends without an id is left out, because it cannot be posted with.

Errors

StatusWhen
400The name is not a valid subreddit name. Charged as one read, like every route's own validation error
401 REAUTH_REQUIREDReddit no longer accepts the session's cookies. Reconnect it
403 PERMISSION_DENIEDReddit refused this account on this subreddit (private, banned or restricted). Charged as one read, like every Reddit refusal
404The subreddit does not exist. Charged as one read, like every Reddit refusal. Without any session the call never reaches Reddit, so a missing subreddit then gets the unbilled 503 SESSION_REQUIRED instead
503 SESSION_REQUIREDYou sent no session headers and have no stored session, so Reddit was not asked. Not charged
503A temporary failure on our side (retry_after says when to retry). Not charged

Independent third-party API for developers and researchers. Not affiliated with, endorsed by, or sponsored by Reddit, Inc.

On this page