POST/sessions/{session_id}/tokens/{template_name}

Create a session token from a JWT template

Creates a JSON Web Token (JWT) for the specified session using a JWT template defined for your instance. Use template_name to select the template and optionally set expires_in_seconds to override the token lifetime, between 30 and 315360000 seconds.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 parameters · 1 body field
session_idstringrequired
The unique identifier of the session for which to create a token.
template_namestringrequired
The name of a JWT template defined for your instance, such as `custom_hasura`.

Optional settings for the JWT.

expires_in_secondsintegeroptional
Use this parameter to override the JWT lifetime.

3 status codes
200Returns a token object containing the generated JWT.
objectstringoptional
Allowed:token
jwtstringoptional
401Returned when authentication is invalid.
errorsarray<object>required
metaobjectoptional
clerk_trace_idstringoptional
404Returned when the session or template resource is not found.
errorsarray<object>required
metaobjectoptional
clerk_trace_idstringoptional

Error handling

A 401 is returned when authentication is invalid, and a 404 when the session or template resource is not found. The session_id path parameter must identify an existing session, and the template_name path parameter must name a JWT template defined for your instance. If supplied, expires_in_seconds must be between 30 and 315360000.