Roles & Permissions
Configure role-based access control (RBAC) to manage what users and teams can do. Endpoints for roles, policies, and assignments plus the effective-permissions API.
Configure role-based access control (RBAC) to manage what users and teams can do.
Roles
List Roles
/roles List all roles in your organization.
Create Role
/roles Create a new role with a set of policies.
curl -X POST https://zopnight.com/api/roles \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "name": "Developer", "description": "Can view resources and manage schedules", "policies": [ "resources:read", "schedules:read", "schedules:write" ] }'{ "data": { "id": "role_dev456", "name": "Developer", "description": "Can view resources and manage schedules", "policies": [ "resources:read", "schedules:read", "schedules:write" ], "createdBy": "admin@company.com", "createdAt": "2025-02-20T14:00:00Z", "updatedAt": "2025-02-20T14:00:00Z" }}Get Role
/roles/{roleID} Get a role with its assigned policies.
Update Role
/roles/{roleID} Update role name, description, or policies.
Delete Role
/roles/{roleID} Delete a role. Existing assignments using this role are removed.
Policies
Policies are predefined permissions that can be assigned to roles. Each policy grants access to a specific action on a resource type.
List Policies
/policies List all available policies that can be assigned to roles.
Role Assignments
List Assignments
/assignments List all role assignments in your organization.
Create Assignment
/assignments Assign a role to a user, optionally scoped to a team or resource.
curl -X POST https://zopnight.com/api/assignments \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "email": "engineer@company.com", "roleID": "role_dev456", "scope": "team:team_abc123" }'{ "data": { "id": "asgn_789xyz", "email": "engineer@company.com", "roleID": "role_dev456", "scope": "team:team_abc123", "createdBy": "admin@company.com", "createdAt": "2025-02-20T14:30:00Z", "updatedAt": "2025-02-20T14:30:00Z" }}Update Assignment
/assignments/{assignmentID} Update a role assignment's role or scope.
Delete Assignment
/assignments/{assignmentID} Remove a role assignment.
Checking Permissions
Get Current User Permissions
/permissions Get the effective permissions for the currently authenticated user.
Get User Permissions
/users/{email}/permissions Get the effective permissions for a specific user.
Verify Permission
/users/{email}/permissions/verify Check whether a user has a specific permission. Pass action and resource as query parameters.
Query parameters: ?action=write&resource=schedules
Role Object
| Field | Type | Description |
|---|---|---|
id | string | Unique role ID |
name | string | Role display name |
description | string | Optional description |
policies | string[] | List of policy identifiers assigned to the role |
createdBy | string | Email of the creator |
createdAt | string | ISO 8601 creation timestamp |
updatedAt | string | ISO 8601 last update timestamp |