Skip to content

Session URL Reference

This page documents the URL format and callback metadata for the browser-based session flow.

Session URL Format

The session URL follows this structure:

https://x.cartridge.gg/session?public_key={public_key}&policies={policies}&rpc_url={rpc_url}&redirect_uri={redirect_uri}

Or, when using a preset:

https://x.cartridge.gg/session?public_key={public_key}&preset={preset}&rpc_url={rpc_url}&redirect_uri={redirect_uri}
ParameterRequiredDescription
public_keyYesThe public key generated by the native application
policiesYes (unless preset is provided)JSON-encoded session policies object
presetYes (unless policies is provided)Preset name to resolve policies from @cartridge/presets
rpc_urlYesThe RPC URL for the target chain
redirect_uriNoURL to redirect after session creation
redirect_query_nameNoQuery parameter name for the redirect
callback_uriNoURL to POST session data after creation

Policy Structure

Each policy object defines which contract methods the session key is authorized to call:

{
  "target": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
  "method": "transfer"
}

The policies parameter should be a JSON array of these objects.

Session Metadata

After successful session creation, the following metadata is available:

FieldTypeDescription
addressstringThe user's Controller contract address
ownerGuidstringUnique identifier for the account owner
expiresAtnumberSession expiration timestamp (Unix seconds)
usernamestring?The user's Cartridge username
sessionIdstring?Unique identifier for this session
appIdstring?The application identifier
isRevokedbooleanWhether the session has been revoked

Additional Fields for Already-Registered Sessions

When a session is already registered and authorized, the callback payload includes additional session identifiers:

FieldTypeDescription
allowedPoliciesRootstringRoot hash of the allowed policies for this session
metadataHashstringHash of the session metadata
sessionKeyGuidstringUnique identifier for the session key
guardianKeyGuidstringUnique identifier for the guardian key
alreadyRegisteredbooleanFlag indicating this is an existing session

These fields are only included when returning an existing authorized session (when alreadyRegistered is true). For new session registrations, only the basic metadata fields are returned.

Fields marked with ? are only populated when creating sessions via the subscription API flow (createFromSubscribe). When creating sessions directly with the constructor, these fields will be null.