JWT Templates
Your claims, in our token
A JWT template merges claims you define into the session token BillDog issues. It is how you make a BillDog session acceptable to something that expects its own shape — a third-party API, a database's row-level security, a legacy service that reads a particular claim.
Applying one
Set it once, on the client — not per call.
const auth = createBillDogAuth({
apiKey: 'bd_public_live_…',
jwtTemplate: 'supabase',
});Why per-client rather than per-call
A template name that matches nothing yields the ordinary token, never an error. An authoring mistake degrades the claims; it cannot stop anyone signing in.
Reserved claims are refused at save
A template may not define any claim BillDog owns. The rejection happens when you save the template, not silently at mint time, so you find out while you are looking at it:
iss sub sid aud exp iat nbf jti
fva sts env ent ent_truncated cus trs o actNor the nine system permissions
org:sys_* permissions power the merchant dashboard and are not session claims. A template must not smuggle them in: a host seeing them in a token would reasonably read them as granted authority rather than as UI hints, and act on it.The rule is enforced twice — at save and again at mint — so a template that somehow reached storage with a reserved name still cannot override a platform claim.
Custom token lifetime
A template may set ttlSeconds, between 30 seconds and 24 hours. Anything outside that range is refused at save.
The default of 90 seconds is short on purpose: a verified token proves it was valid when issued, not that the session is still live, so the token's lifetime is exactly the window in which a revoked session still passes offline verification. A 24-hour token means a sign-out can take up to a day to bite. Lengthen it only for a consumer that genuinely cannot refresh, and prefer introspect() where you need certainty.
Two ways to manage templates
| Door | Authenticates with | For |
|---|---|---|
| Dashboard | Your signed-in session, owner or admin | Authoring by hand — Project Settings → Auth → JWT templates |
manage-jwt-templates | A project secret key | Scripting, CI, infrastructure-as-code |
A browser must never hold a secret key
Preview before you ship
The dashboard offers a preview that renders a template against a sample session, so you can see the claim set a consumer will actually receive. Use it — a template is one of the few things here whose mistakes are invisible until a third-party service starts rejecting your users' tokens.
Next
- Sessions and tokens — the platform claims in full.
- SCIM provisioning
Was this page helpful?
Or rate this page: