- Base URL:
https://permissions.sls.epilot.io - Full API Docs: https://docs.epilot.io/api/permissions
import { epilot } from '@epilot/sdk' epilot.authorize(() => '<token>') const { data } = await epilot.permissions.listCurrentRoles(...)
import { getClient, authorize } from '@epilot/sdk/permissions' const permissionsClient = getClient() authorize(permissionsClient, () => '<token>') const { data } = await permissionsClient.listCurrentRoles(...)
Roles
Assignments
Schemas
TokenRestrictionsGrantGrantWithDependenciesGrantConditionEqualsCurrentUserConditionNotEqualsCurrentUserConditionEqualsConditionNotEqualsConditionRoleIdBaseRoleBaseRoleForCreateUserRoleOrgRoleShareRolePartnerRolePortalRoleRoleRolePayloadAssignmentInternalAssignmentAssignmentsUserIdOrganizationIdSlugRoleSearchInputCreateRolePayloadError
Returns roles and grants assigned to current user.
GET /v1/permissions/me
const { data } = await client.listCurrentRoles()
Response
{
"roles": [
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}
],
"token_restrictions": {
"read_only": true,
"anonymize": true,
"allowed_actions": ["journey:*", "entity:view"],
"actor": {
"type": "agent",
"agent_id": "string",
"host_id": "string",
"purpose": "string"
}
}
}Returns list of all roles in organization
GET /v1/permissions/roles
const { data } = await client.listAllRoles()
Response
{
"roles": [
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}
]
}Create role
POST /v1/permissions/roles
const { data } = await client.createRole( null, {}, )
Response
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}Search Roles
POST /v1/permissions/roles:search
const { data } = await client.searchRoles( null, { role_ids: ['123:manager', '456:owner'], org_ids: ['123', '456'], slugs: ['manager', 'owner'], query: 'Administrator', limit: 1, offset: 1 }, )
Response
{
"hits": 0,
"results": [
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}
]
}Get role by id
GET /v1/permissions/roles/{roleId}
const { data } = await client.getRole({ roleId: 'example', })
Response
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}Create or update role
PUT /v1/permissions/roles/{roleId}
const { data } = await client.putRole( { roleId: 'example', }, { id: '123:owner', name: 'Owner', slug: 'owner', type: 'user_role', expires_at: '2028-07-21T17:32:28Z', organization_id: '123', grants: [ { action: 'entity-read', resource: 'entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947', effect: 'allow', conditions: [ { attribute: 'workflows.primary.task_name', operation: 'equals', values: ['Qualification'] } ] } ], parent_role: '123:owner', vendor_created: true }, )
Response
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}Delete role by id
DELETE /v1/permissions/roles/{roleId}
const { data } = await client.deleteRole({ roleId: 'example', })
Response
{
"id": "123:owner",
"name": "Owner",
"slug": "owner",
"type": "user_role",
"expires_at": "2028-07-21T17:32:28Z",
"organization_id": "123",
"grants": [
{
"action": "entity-read",
"resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
"effect": "allow",
"conditions": [
{
"attribute": "workflows.primary.task_name",
"operation": "equals",
"values": ["Qualification"]
}
]
}
],
"parent_role": "123:owner",
"vendor_created": true
}Makes sure the user has a role in the organization
GET /v1/permissions/refresh
const { data } = await client.refreshPermissions()
Get list of assigned roles by user id
GET /v1/permissions/assignments/{userId}
const { data } = await client.getAssignedRolesForUser({ userId: 'example', })
Response
["123:owner"]Assign / unassign roles to users.
PUT /v1/permissions/assignments/{userId}
const { data } = await client.assignRoles( { userId: 'example', }, ['123:owner'], )
Response
["123:owner"]Assign a user to a role.
POST /v1/permissions/assignments/{userId}/{roleId}
const { data } = await client.addAssignment({ userId: 'example', roleId: 'example', })
Response
{
"user_id": "1",
"roles": ["123:owner"]
}Remove role assignment from user
DELETE /v1/permissions/assignments/{userId}/{roleId}
const { data } = await client.removeAssignment({ userId: 'example', roleId: 'example', })
Response
{
"user_id": "1",
"roles": ["123:owner"]
}Returns list of all assignments in organization
GET /v1/permissions/assignments
const { data } = await client.listAllAssignments()
Response
{
"assignments": [
{
"user_id": "1",
"roles": ["123:owner"]
}
]
}Restrictions the calling token puts on top of its roles. Only present for restricted tokens.
type TokenRestrictions = { read_only?: boolean anonymize?: boolean allowed_actions?: string[] actor?: { type?: string agent_id?: string host_id?: string purpose?: string } }
type Grant = { action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }
type GrantWithDependencies = { action: string resource?: string effect?: "allow" | "deny" conditions?: object[] dependencies?: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> }
type GrantCondition = object
Check if any relation_user attribute on the entity contains the current user. When attribute is provided, only that specific attribute path is checked. When attributes is provided, it takes precedence over attribute and the condition passes when the current user appears in ANY of the listed attribut
type EqualsCurrentUserCondition = { attribute?: string attributes?: string[] operation: "equals_current_user" }
Check if the current user is absent from the relation_user attributes on the entity. When attribute is provided, only that specific attribute path is checked. When attributes is provided, it takes precedence over attribute and the condition passes only when the current user appears in NONE of the li
type NotEqualsCurrentUserCondition = { attribute?: string attributes?: string[] operation: "not_equals_current_user" }
Check if attribute equals to any of the values
type EqualsCondition = { attribute: string operation: "equals" values: unknown[] }
Passes when the attribute does not equal any of the values. Records where the attribute is missing or empty pass the condition.
type NotEqualsCondition = { attribute: string operation: "not_equals" values: unknown[] }
Format: <organization_id>:<slug>
type RoleId = string
type BaseRole = { id: string name: string slug: string type: string expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> }
type BaseRoleForCreate = { id?: string name: string slug: string type: string expires_at?: string // date-time organization_id?: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> }
type UserRole = { id: string name: string slug: string type: "user_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> parent_role?: object vendor_created?: boolean }
type OrgRole = { id: string name: string slug: string type: "org_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> pricing_tier?: string }
type ShareRole = { id: string name: string slug: string type: "share_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> }
type PartnerRole = { id: string name: string slug: string type: "partner_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> partner_org_id?: object vendor_enforced_user_limit?: number vendor_created?: boolean }
type PortalRole = { id: string name: string slug: string type: "portal_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> portal_id?: string }
type Role = { id: string name: string slug: string type: "user_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> parent_role?: object vendor_created?: boolean } | { id: string name: string slug: string type: "org_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> pricing_tier?: string } | { id: string name: string slug: string type: "share_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> } | { id: string name: string slug: string type: "partner_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> partner_org_id?: object vendor_enforced_user_limit?: number vendor_created?: boolean } | { id: string name: string slug: string type: "portal_role" expires_at?: string // date-time organization_id: string grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> portal_id?: string }
type RolePayload = { grants?: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] dependencies?: Array<{ action: { ... } resource?: { ... } effect?: { ... } conditions?: { ... } }> }> }
A role attached to an user
type Assignment = { user_id?: string roles?: string[] }
A role attached to an user
type InternalAssignment = { userId?: string roles?: string[] }
List of role ids attached to an user
type Assignments = string[]
Id of a user
type UserId = string
Id of an organization
type OrganizationId = string
Slug of a role; for a role with id = 123:manager -> 123 is org_id & manager is slug
type Slug = string
type RoleSearchInput = { role_ids?: string[] org_ids?: string[] slugs?: string[] query?: string limit?: number offset?: number }
type CreateRolePayload = { grants: Array<{ action: string resource?: string effect?: "allow" | "deny" conditions?: object[] }> id?: string name: string slug: string type: string expires_at?: string // date-time organization_id?: string }
Error response
type Error = { message: string }