TrapGod / Documentation / API keys
API keys
Send the TrapGod application id and a TrapGod API key. The Backout key stays on the app.
Keys
Send a key on every partner call. The server accepts two kinds. Both use the same header. Store the key on the partner server. Do not put it in browser JavaScript, a query string, or a git file.
Header
Use one of these:
X-Trapgod-Key: TRAPGOD_KEY
Authorization: Bearer TRAPGOD_KEYAlso send the application id. Both are required. A key from one app does not work with another app's application id.
X-Trapgod-Application: tgaid_0123456789abcdef01234567APPLICATION_ID is tgaid_ plus 24 hex characters. Copy it from the Application id field on /admin/apps/people/?id=APP_ID. Staff can see it. It is not the number in that URL, not the slug, and not the 24-character tenant id.
You can send application_id in the JSON body instead of the header. If the header and the body both have an application id and they differ, the call is rejected. A missing application id is rejected the same way a missing key is rejected. The error does not say which part failed.
X-Trapgod-App and X-Trapgod-Tenant do not authenticate the call. If you still send app or tenant, they must match the app that owns that application id.
Kind 1 - webhook key
One webhook key is stored on the app row (link_apps.webhook_secret). A super admin or that app's sub admin copies it from /admin/apps/people/?id=APP_ID. Staff see the steps and not the key. A super admin rotates it from /admin/apps/?id=APP_ID. Rotation replaces the old webhook key. Generated tgapp_ keys are separate and keep working.
Kind 2 - generated API key
A super admin or that app's sub admin creates these at /admin/apps/keys/?id=APP_ID.
- The secret is
tgapp_plus 48 hex characters. - It is shown once, then only the first 14 characters stay on the list.
- TrapGod stores
sha256of the secret, not the secret. - An app can have 8 active keys. Revoke one before creating a ninth.
- Revoke sets
statustorevoked. A revoked key is rejected. - The same key works on the badge webhook, checkout create, and the payment record.
Kind 3 - Backout key (not a TrapGod call key)
The Backout key is bo_live_, bo_test_, or bo_s2s_ plus hex. A sub admin pastes it on the keys page so TrapGod can route that app's charges to a Backout structure. The partner does not send this key to TrapGod. link_app_checkout.php reads the saved key on the server and sends it to Backout. The response does not include it. link_app_payment.php does not use it. A blank field on save keeps the saved key. The remove checkbox clears it. A pasted key wins over the remove checkbox if both are sent.
Rejected call
HTTP 401, JSON:
{"ok":false,"error":"That webhook key was rejected.","trace_id":"TRACE_ID"}The payment URL says That key was rejected. The badge URL says That webhook key was rejected. Neither body tells you whether the application id or the key was wrong.
GET on either URL is HTTP 405, POST only.
Staff of that app can open API calls and see rejected keys, bursts, and probe flags. The address is not stored. A short caller code groups repeats.
