What are session profiles?
Session profiles are resources created by the parent organization that allow sessions to be issued with limited scope. When a session is issued with a session profile, the profile’s scope is evaluated on every request made with that session. If the scope evaluates tofalse, the request is denied.
Session profiles are immutable - once created, they cannot be edited or deleted. If you need to change a session profile, you must create a new one and update your login flows to use the new profile.
Session profiles can be created using the CreateSessionProfile activity, via the public API or the Turnkey dashboard.
Session profile structure
TheCreateSessionProfile activity has the following parameters:
sessionProfileName(required): A human-readable name for the session profile. This name will also be used as thesession_typein the resulting session JWT.scope(required): A string of policy language that is evaluated on every request made with this session. If the scope evaluates totrue, the request is allowed. If it evaluates tofalse, the request is denied.expirationSeconds(optional): The maximum duration in seconds for sessions created with this profile. If not set, the expiration is determined by the value passed into the login activity intent.notes(optional): Notes for the session profile.
Scope
Thescope field uses the same policy language as policy conditions and MFA conditions. It has access to the same keywords, including activity.type, activity.action, eth.tx, and others.
Examples:
A scope can restrict the target user only when the activity exposes it.
CREATE_AUTHENTICATORS_V2
and the API key activities expose activity.params.user_id, so a scope can pin them to a fixed
user ID, but no keyword refers to the session holder. A session scoped only to the activity kind
enrolls passkeys for the session holder alone while no policy allows the activity and the request
does not meet the root quorum. A policy that allows CREATE_AUTHENTICATORS_V2 without an
activity.params.user_id condition lets the session target other non-root users. See
Activities a user can perform on themselves.Scope when approving another activity
When a scoped session approves a pending activity withAPPROVE_ACTIVITY, the scope is evaluated against the activity being approved, not against APPROVE_ACTIVITY itself.
So a session scoped to signing:
SIGN_TRANSACTION_V2, but cannot approve a pending CREATE_API_KEYS_V2 or UPDATE_ROOT_QUORUM. The session’s authority follows it into the approval, and is judged on what is actually being authorized.
Expiration
The final session expiration is determined by taking the minimum of the login intent’s expiration and the session profile’s expiration:- If both are set: the shorter of the two is used
- If only the intent expiration is set: the intent expiration is used
- If only the profile expiration is set: the profile expiration is used
- If neither is set: a default expiration is used (900 seconds / 15 minutes)
Issuing sessions with a session profile
To issue a session with a session profile, pass thesessionProfileId into any login activity:
STAMP_LOGINOTP_LOGINOAUTH_LOGIN
sessionProfileId is passed, the session is issued as a default read-write session with no scope restrictions. A default session JWT looks like:
session_type is set to the session profile’s name, and scope reflects the scope expression from the profile. The client can decode this JWT to determine what kind of session it has and what activities the session is allowed to perform.
Querying session profiles
Session profiles can be queried using:GetSessionProfile: retrieve a single session profile by IDGetSessionProfiles: list all session profiles for an organization