Permissions
Manage fine-grained permissions
Use the permission client to define fine-grained permissions that roles can grant.
Model permissions for resources in your app, then attach them to roles.
createPermission
Section titled “createPermission”#asynccreatePermission
Creates a new permission defining a specific action users can perform.
Permission object containing:
Created permission with ID and timestamps
await scalekit.permission.createPermission({ name: 'read:invoices', description: 'View invoice details'});getPermission
Section titled “getPermission”#asyncgetPermission
Retrieves complete information for a specific permission.
Permission identifier (e.g., ‘read:documents’)
Permission details including description and timestamps
const response = await scalekit.permission.getPermission('read:invoices');console.log('Description:', response.permission.description);listPermissions
Section titled “listPermissions”#asynclistPermissions
Lists all permissions with pagination support.
Optional. Token for retrieving the next page
Optional. Number of permissions per page (max: 100)
Paginated list of permissions
const response = await scalekit.permission.listPermissions();response.permissions.forEach(perm => { console.log(`${perm.name}: ${perm.description}`);});updatePermission
Section titled “updatePermission”#asyncupdatePermission
Updates an existing permission’s attributes.
Permission to update
Updated permission properties
Updated permission details
await scalekit.permission.updatePermission('read:invoices', { name: 'read:invoices', description: 'View invoice details and history (updated)'});deletePermission
Section titled “deletePermission”#asyncdeletePermission
Permanently removes a permission.
Permission identifier to delete
Empty response on success
await scalekit.permission.deletePermission('deprecated:feature');listRolePermissions
Section titled “listRolePermissions”#asynclistRolePermissions
Lists direct permissions assigned to a role (excluding inherited permissions).
Role to examine
List of directly assigned permissions only
const response = await scalekit.permission.listRolePermissions('editor');console.log('Direct permissions:', response.permissions);addPermissionsToRole
Section titled “addPermissionsToRole”#asyncaddPermissionsToRole
Grants additional permissions to a role without removing existing assignments.
Target role to enhance
Array of permission identifiers to add
Updated list of all role permissions
await scalekit.permission.addPermissionsToRole('editor', [ 'read:documents', 'write:documents', 'edit:documents']);removePermissionFromRole
Section titled “removePermissionFromRole”#asyncremovePermissionFromRole
Revokes a specific permission from a role, restricting access for all assigned users.
Role to modify
Permission to remove
Empty response on success
await scalekit.permission.removePermissionFromRole('editor', 'delete:documents');listEffectiveRolePermissions
Section titled “listEffectiveRolePermissions”#asynclistEffectiveRolePermissions
Lists all effective permissions for a role including both direct and inherited permissions.
Role to analyze
Complete list including inherited permissions
const response = await scalekit.permission.listEffectiveRolePermissions('senior_editor');
console.log('Total effective permissions:', response.permissions.length);