Skip to content
TrapGod
Sign in Create profile

TrapGod / Documentation / Badge grant and revoke

Badge grant and revoke

POST the badge call to add or remove a member badge, mint, and group.

Badge actions

grant puts this app's avatar on that person's TrapGod profile and adds the app group. revoke takes a member badge off. The call does not upload a picture. The avatar is the image already saved on the app.

Request

POST https://trapgod.net/api/link_app_badge.php
X-Trapgod-Application: tgaid_0123456789abcdef01234567
X-Trapgod-Key: TRAPGOD_KEY
Content-Type: application/json

{"username":"theirtrapgodname","handle":"name_on_this_app","action":"grant"}

Revoke uses the same headers and changes action:

POST https://trapgod.net/api/link_app_badge.php
X-Trapgod-Application: tgaid_0123456789abcdef01234567
X-Trapgod-Key: TRAPGOD_KEY
Content-Type: application/json

{"username":"theirtrapgodname","handle":"name_on_this_app","action":"revoke"}
FieldRequiredRule
usernameyesTrapGod username. Lookup is case-insensitive. Max 40 characters.
handleno on grantName on the partner app. Letters, numbers, and underscores, 1 to 40 characters. If omitted on grant, TrapGod uses the TrapGod username when that name matches the same pattern.
actionnogrant or revoke. Anything else is treated as grant.

Body max is 4096 bytes.

What grant does

  1. Finds the TrapGod user.
  2. Rejects the handle when tg_link_app_mint_conflict says that name is already claimed on TrapGod, OG Brokerage, or any link app. The person's own TrapGod username, and their own linked OG Brokerage username, are allowed on the first mint. A second app cannot mint that same name.
  3. Inserts a link_app_members row with role member, or updates the handle if a row already exists.
  4. Stores the mint and syncs the TrapGod group.

A grant for someone who is already staff or a sub admin updates the handle. It does not demote them.

What revoke does

Success

HTTP 200. The body does not include trace_id.

{"ok":true,"action":"grant","profile":"https://trapgod.net/u/theirname"}

action is grant or revoke.

Errors

ConditionHTTPerror
Not POST405POST only.
Body is not JSON400Send JSON.
Body larger than 4096 bytes413That body is too large.
No application id, or no key401That webhook key was rejected.
Application id and key are not the same active app401That webhook key was rejected.
Header and body application ids differ401That webhook key was rejected.
Missing username400Send the TrapGod username.
Handle has a character other than letters, numbers, or underscore400The app username can use letters, numbers, and underscores.
No TrapGod user404No TrapGod user has that username.
Handle conflicts with a claimed name409Message from the mint check.
Handle already used on this app by someone else409That app username is already used here.
Revoke of staff or sub admin403That badge is managed in TrapGod admin.

Failure JSON:

{"ok":false,"error":"No TrapGod user has that username.","trace_id":"TRACE_ID"}

The trace action is link_app.badge_grant, link_app.badge_revoke, or link_app.badge_deny. Role on the trace is partner.

Create a payment