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"}| Field | Required | Rule |
|---|---|---|
username | yes | TrapGod username. Lookup is case-insensitive. Max 40 characters. |
handle | no on grant | Name 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. |
action | no | grant or revoke. Anything else is treated as grant. |
Body max is 4096 bytes.
What grant does
- Finds the TrapGod user.
- Rejects the handle when
tg_link_app_mint_conflictsays 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. - Inserts a
link_app_membersrow with rolemember, or updates the handle if a row already exists. - 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
- Role
member: deletes that membership, clears the mint, and removes the group. - No membership row: still clears a mint and revokes the group, then returns success.
- Role
stafforsub_admin: HTTP 403,That badge is managed in TrapGod admin.The person stays staff.
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
| Condition | HTTP | error |
|---|---|---|
| Not POST | 405 | POST only. |
| Body is not JSON | 400 | Send JSON. |
| Body larger than 4096 bytes | 413 | That body is too large. |
| No application id, or no key | 401 | That webhook key was rejected. |
| Application id and key are not the same active app | 401 | That webhook key was rejected. |
| Header and body application ids differ | 401 | That webhook key was rejected. |
| Missing username | 400 | Send the TrapGod username. |
| Handle has a character other than letters, numbers, or underscore | 400 | The app username can use letters, numbers, and underscores. |
| No TrapGod user | 404 | No TrapGod user has that username. |
| Handle conflicts with a claimed name | 409 | Message from the mint check. |
| Handle already used on this app by someone else | 409 | That app username is already used here. |
| Revoke of staff or sub admin | 403 | That 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.
