Sessions & permissions
Sessions and permissions are core concepts in k-ID that determine what features and capabilities a user can access in your product.
Sessions
A k-ID Session contains the collection of permissions and age status for the current user and location. Every user requires an active Session. Your app should consult the active Session to determine whether features are allowed or disallowed in the app.
For detailed information about sessions, see Sessions.
Getting a session
You can retrieve a session two ways:
/session/get: Get a session bysessionIdorkuid/age-gate/check: Creates or updates a session as part of the age gate flow
Example request
GET /api/v1/session/get?sessionId=608616da-4fd2-4742-82bf-ec1d4ffd8187&etag=6d9d24fccd428f845b355122799948dd0a52fc5d
Authorization: Bearer your-api-keyThe /session/get API supports conditional requests by using the etag parameter. If the session hasn't changed since the last request, the API returns HTTP 304 (Not Modified), allowing you to avoid unnecessary data transfer.
Example response
{
"ageCategory": "adult",
"ageStatus": "LEGAL_ADULT",
"dateOfBirth": "2005-04-15",
"etag": "6d9d24fccd428f845b355122799948dd0a52fc5d",
"hasApproverEmail": false,
"jurisdiction": "US-CA",
"kuid": "12b9fa0e-6d6d-4903-a1fc-f2233027b71d",
"managedBy": "PLAYER",
"permissions": [
{
"enabled": true,
"managedBy": "PLAYER",
"name": "ai-generated-avatars"
},
{
"enabled": true,
"managedBy": "PLAYER",
"name": "text-chat-private"
}
],
"allowances": null,
"sessionId": "608616da-4fd2-4742-82bf-ec1d4ffd8187",
"status": "ACTIVE"
}Permissions
Permissions represent features or capabilities in your product that could require parental consent or have age restrictions. Each permission can be allowed or disallowed for a user based on:
- Their age and jurisdiction
- Parental consent (if required)
- The permission's configuration in the Compliance Studio
For detailed information about permissions, see Permissions.
Using permissions
The app code should use each k-ID Permission to control access to the corresponding features in the app. If the enabled field is true for a permission, this means that the feature can be enabled for the user in the app. If the enabled field is false, the feature must be turned off.
The managedBy field indicates who can allow or disallow this permission:
PLAYER: The user can enable/disable this permission themselvesGUARDIAN: Only a trusted adult can enable/disable this permissionPROHIBITED: This permission is never allowed for the current user in the current location
If a feature is never allowed for the current user in the current location regardless of their trusted adult's consent, the managedBy field contains the value PROHIBITED. In this case, it's appropriate for the app to just remove the prohibited feature entirely from the user experience rather than show it turned off.
Upgrading permissions
After a user has received a session with permissions, they might want to allow additional permissions. Use the /session/upgrade API to request additional permissions.
For more information, see Permissions Upgrade.
Presenting legal documents and data notices
/session/upgrade can present updated legal documents and data notices for the trusted adult to review and accept as part of the same consent moment. Pass the documents to present in the request materialChange:
materialChange.termsOfServiceDocument,materialChange.privacyPolicyDocument, andmaterialChange.additionalLegalLinks: the legal documents to present. Useterms-of-serviceandprivacy-policyfor the product's own Terms of Service and Privacy Policy, or a configured legal-document variant id. A document listed more than once is presented once.
termsOfServiceDocument, privacyPolicyDocument, and additionalLegalLinks are the canonical field names for legal-document variants across the k-ID API. The same three names are accepted by /age-gate/check and the hosted widget URL endpoints (/widget/generate-age-gate-url, /widget/generate-e2e-url, and /widget/generate-direct-notices-url), where they live under an options object. On /session/upgrade the same fields live under materialChange instead.
A challenge is created whenever the request asks for any of the following, so the documents can be reviewed and accepted:
- a guardian-managed permission that requires parental consent,
- one or more legal documents in
materialChange, or - a material-change re-consent (see below).
If none of these apply, permissions are granted directly without a challenge, exactly as before. Any data notices the session still needs consent for are included automatically, and accepting the challenge records consent for both the legal documents and the data notices.
The trusted adult reviews the exact documents on the approval page. To read the resolved documents, use the challenge.documents array on the upgrade response. Each entry carries the variant id, its localized name, a url for a legal document, and isDataNotice, which is true for a name-only data notice (a data notice has no url). On a re-consent chain (priorChallengeId) the array accumulates the prior challenge's documents, so the head challenge always carries the full set.
When the prior challenge is a CHALLENGE_SESSION_UPGRADE, requested permissions accumulate the same way. With priorChallengeId, send only the permissions you are adding: the trusted adult is also asked to approve the prior challenge's permissions that are still pending, leaving out any granted since or that the user can now manage themselves, and a CHALLENGE_SESSION_UPGRADE response lists the full set in challenge.permissions. A prior of another type, such as an age-assurance challenge, carries no permissions forward. To ask for fewer permissions instead, omit priorChallengeId so the upgrade creates a new challenge.
Requesting re-consent with a deadline (material change)
When a document has changed and you need the trusted adult to re-accept by a deadline, add an acceptanceDeadline to materialChange on the upgrade request:
materialChange.acceptanceDeadline: the RFC 3339 UTC datetime by which the adult must accept. Optional: omit it to present the documents without a deadline. When set, it must be in the future.materialChange.locale: the locale for the re-consent email (defaults toen).
Setting a deadline makes the upgrade an active, deadline-bound re-consent: the challenge carries the deadline (returned as expiresAt from /challenge/get-status), and the trusted adult is emailed a link to the same approval page. Without a deadline the documents are still presented for review on the approval page, but no acceptance deadline is enforced.
Using the permissions upgrade widget
When building custom VPC flows with the k-ID API, you can use the permissions upgrade widget to allow users to request additional permissions that require parental consent. The widget handles the consent workflow for permission upgrades.
Guardian-managed sessions only
The permissions upgrade widget only works for guardian-managed sessions. If a user's session is player-managed (where managedBy is "PLAYER"), permissions can be enabled directly via the /session/upgrade API without creating a challenge, so the widget isn't needed.
Parent authentication required
The manage session permissions widget must only be hosted in a parent-authenticated session. The widget doesn't provide its own parent authentication, so it should never be presented directly to a minor. Always ensure that the widget is only displayed to authenticated parents or trusted adults.
For general information about permissions upgrades, including when they're needed and how they work, see Permissions Upgrade in the Core concepts section.
Generating the permissions upgrade widget URL
Call the /widget/generate-manage-session-permissions-url API to create a permissions upgrade widget URL. This returns a unique URL for trusted adults to review and approve additional permissions.
Example request
POST /api/v1/widget/generate-manage-session-permissions-url
Content-Type: application/json
Authorization: Bearer your-api-key
{
"sessionId": "b1a6482d-5242-4b4a-aa88-3fa52595a672",
"email": "parent@example.com"
}Request parameters
| Property | Description | Required? |
|---|---|---|
sessionId | The ID of the session | Yes |
email | The email address of the trusted adult | Yes |
Example response
{
"url": "https://family.k-id.com/widget?token=eyJhbGciOiJFUzM4NCIs..."
}Embedding the widget
Use the returned URL to create an iframe in your website or app. Trusted adults can review and approve additional permissions through this interface:
<iframe
src="WIDGET_URL"
width="100%"
height="600"
frameborder="0">
</iframe>Receiving upgrade results
Permission upgrades are tracked as part of the session. When additional permissions are approved, the session is updated with the new permissions. You can check the updated permissions in the session by calling the /session/get API.
For real-time updates, you can also listen for session-related events:
JavaScript events (client-side)
For detailed information about the event structure, see Widget.ExitReview.
If the permissions upgrade widget is embedded in an iframe, you can listen for window messages from the widget:
window.addEventListener('message', (event) => {
if (!event.origin.endsWith('.k-id.com')) {
return;
}
const message = event.data;
// Handle widget completion events
if (message.eventType === 'Widget.ExitReview') {
// Permissions upgrade flow completed
console.log('Permissions upgrade completed');
handleUpgradeCompleted();
}
});Webhooks (server-side)
For detailed information about the webhook event structure, see Session.ChangePermissions.
Configure a webhook endpoint to receive session-related events. When permissions are upgraded, session changes are reflected in Session.ChangePermissions events. For more information, see Webhooks.
Permissions upgrade and sessions
When permissions are upgraded through the widget, the session is updated with the new permissions. The session tracks which permissions have been enabled and when they were enabled. You can retrieve the session by calling the /session/get API to check the updated permissions.
For more information about how permissions upgrades work with sessions, see Permissions Upgrade in the Core concepts section.
Session caching
The Session should be cached in local or cloud storage, and can be associated with a user's account. k-ID Sessions only change when a parent updates a permission, or a kid or teen "ages up" to the next age category, or it's deleted by the parent or user.
While it's recommended that the app refresh the Session from the /session/get API every time the app restarts, this isn't explicitly required. Additionally, k-ID Webhooks can be used to receive Session updates instead of calling the /session/get API.
Session webhooks
Configure webhooks to receive session-related events:
Session.ChangePermissions: Sent when permissions are modified by a parentSession.Delete: Sent when a session is deleted
For more information, see Webhooks.