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.
/api/reddit/sub/:name/flairs$0.0015 / callA 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:
- your session headers,
x-reddit-sessionandx-reddit-loid, when you send them (Authenticated reads); - 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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Subreddit name (no r/ prefix), 1 to 21 letters, digits or underscores |
Optional Headers
| Header | Description |
|---|---|
x-reddit-session | Your reddit_session cookie, to read the list as your account |
x-reddit-loid | Your 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
| Field | Type | Notes |
|---|---|---|
subreddit | string | The name you asked for |
count | number | How many templates are listed |
flairs[].id | string | The template id. Send it as flair_id to POST /api/reddit/submit |
flairs[].text | string | The flair's text ("" for a richtext-only flair) |
flairs[].editable | boolean | When true, you may send your own flair_text with this id |
flairs[].type | string | text or richtext |
flairs[].background_color | string | null | Hex colour, or null when the subreddit set none |
flairs[].text_color | string | null | dark or light |
flairs[].css_class | string | null | The template's CSS class, if any |
flairs[].mod_only | boolean | Moderators only. Reddit refuses it for anyone else at submit time |
flairs[].max_emojis | number | null | Most emojis the flair text may hold |
flairs[].allowable_content | string | null | all, text or emoji |
flairs[].richtext | array | Reddit'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
| Status | When |
|---|---|
400 | The name is not a valid subreddit name. Charged as one read, like every route's own validation error |
401 REAUTH_REQUIRED | Reddit no longer accepts the session's cookies. Reconnect it |
403 PERMISSION_DENIED | Reddit refused this account on this subreddit (private, banned or restricted). Charged as one read, like every Reddit refusal |
404 | The 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_REQUIRED | You sent no session headers and have no stored session, so Reddit was not asked. Not charged |
503 | A 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.
Can I Post
Before posting, check whether a post in a subreddit can go through: allowed true, false or unknown, a reason code per block, the posting requirements and the post rules.
Subreddit Moderators
Fetch a subreddit's moderator team by name, each moderator's username, id, mod permissions, flair text, and the time they were added.
