Skip to main content
Each member can wear one piece of user flair next to their name in a Node. A Node owner can hand some flair to your app, and the app then puts it on members or takes it off by its own rules. For example, a check-in app can grant the first level after a 7-day streak and switch to the second level at 30 days. Both sides have to do their part: If either side is missing, nothing is granted. Granting flair through an app sends no notification and isn’t recorded in the Node’s mod log.

1. Request the permission

Add flair to scopes in app.json. It’s an ordinary permission. Once your submitted version is approved, you can use it without extra authorization from staff.
If more than one Node should be able to use the app, set placement to many so each Node’s post gets its own install and data. A single app can be placed in only one spot site-wide, so it suits a single Node.

2. Describe the levels

Your app can’t tell what a flair means. It can only use the owner’s order: the first item from api.flair.list() is level 1, the second is level 2, and so on. In readme.md, tell Node owners how many flair to create, in what order, and how to hand them to your app:
If the owner creates fewer flair than you have levels, grant from what’s there. With only 2 created, a member on a 30-day streak also gets the second one.

3. Grant flair in your handler

The three reads show the state when the call starts. They don’t include the effects you return in the same call. To show the new flair in the interface you return, use the result you computed.

Mini app in a post

The example below is a check-in mini app. When a member selects Check in, it records the streak and puts on the matching flair once a level is reached.
In a foreground call, kv stores the current member’s own data, so each member’s streak is separate. The check-in record and the flair go in the same response. If any effect is rejected, none of them apply, so a check-in is never recorded without its flair.

Node bot

A bot has no interface, so it grants flair on site events. A background call targets the member who triggered the event by default. The example below puts the first flair the owner handed to the app on a member when they post their 10th topic or reply in the Node. In app.json, set kind: "bot" and surface: "service", subscribe to topic_created and post_created, and request kv and flair.
In a background call, kv is the install’s shared area, so the key includes the member’s ID. To grant flair to another person involved in the event, such as the post’s author in post_liked, add user_id to the effect. user_id must be someone involved in this event.

4. Test

A test install isn’t in any Node. api.flair.list() returns [], and flair.set and flair.clear are validated but not applied. The response includes a notice with dry_run: true. In a test run you can check the check-in record and the interface, but no flair is actually put on. To test end to end, submit and publish a version. In a Node you manage, create the flair your readme describes and hand them to your app. Then start a topic in that Node and add the app with Add app in the More actions menu at the top of the topic (see Embed in a post), or install it as a Node bot. Use an account that has joined the Node and check that the flair appears next to its name.

Rules and limits

  • The app’s Node depends on where it’s installed. For an app in a post, it’s the post’s Node. For a Node bot, it’s the Node the bot is installed on. A site-wide install has no Node and can’t grant flair.
  • The target can only be the current member. In the foreground it’s the person using the app. In the background it’s the person who triggered the event by default, and user_id can only name someone involved in this event.
  • Each call can include at most one flair.set or flair.clear.
  • One app can change a member’s flair at most 10 times a day. Setting flair the member already wears succeeds without changing anything and doesn’t count.
  • The platform doesn’t add members to the Node. Check api.flair.member() before you declare flair.set.
  • flair.clear removes only flair this app granted. If the member wears flair from a moderator or flair they picked, it does nothing and doesn’t return an error.
  • After the owner switches a flair back to Moderators only, it no longer appears in api.flair.list(), and your app can’t grant or remove it.
For the full API list, see Handlers.