Skip to content
Docs
Roles

List roles

List roles

client.zones.roles.list(stringzoneID, RoleListParams { after, before, expand, 2 more } query?, RequestOptionsoptions?): RoleListResponse { items, pagination }
GET/zones/{zoneId}/roles

Returns the roles defined in the specified zone. The full result set is currently returned in a single page; the after/before/limit cursor parameters are reserved and not yet enforced, and pagination cursors are always null.

ParametersExpand Collapse
zoneID: string
query: RoleListParams { after, before, expand, 2 more }
after?: string

Cursor for forward pagination

minLength1
maxLength255
before?: string

Cursor for backward pagination

minLength1
maxLength255
expand?: "total_count" | Array<"total_count">
Accepts one of the following:
"total_count"
"total_count"
Array<"total_count">
"total_count"
identifier?: string

Filter roles by identifier

limit?: number

Maximum number of items to return

minimum1
maximum100
ReturnsExpand Collapse
RoleListResponse { items, pagination }
items: Array<Role { id, created_at, identifier, 4 more } >
id: string

Unique identifier of the role

created_at: string

Entity creation timestamp

formatdate-time
identifier: string

Role identifier: a lowercase slug (letters and digits separated by single hyphens or underscores), unique per owner type within a zone. Role identifiers surface in policy evaluation, so the slug restriction keeps them unambiguous in policy text.

minLength1
maxLength255
owner_type: "platform" | "customer"

Who owns this role. Platform-owned roles are managed by Keycard and cannot be modified or deleted via the API; customer-owned roles are user-created.

Accepts one of the following:
"platform"
"customer"
updated_at: string

Entity update timestamp

formatdate-time
zone_id: string

Zone this role belongs to

description?: string | null

Human-readable description

maxLength1000

List roles

import KeycardAPI from '@keycardai/api';

const client = new KeycardAPI({
  apiKey: process.env['KEYCARD_API_API_KEY'], // This is the default and can be omitted
});

const roles = await client.zones.roles.list('zoneId');

console.log(roles.items);
{
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "identifier": "identifier",
      "owner_type": "platform",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "zone_id": "zone_id",
      "description": "description"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}
Returns Examples
{
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "identifier": "identifier",
      "owner_type": "platform",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "zone_id": "zone_id",
      "description": "description"
    }
  ],
  "pagination": {
    "after_cursor": "x",
    "before_cursor": "x",
    "total_count": 0
  }
}