Roles

envless.roles.listAll()

Collect every role in the workspace into one array

ts
listAll(options?: RoleListOptions): Promise<Array<RoleResource>>

Walks every page and resolves with the flattened array. Because a workspace is capped at 25 custom roles, this is a single request in practice and is the convenient way to build a name to id map before inviting members.

The trap is options.limit: it sets the page size used while walking, not a cap on how many roles come back. Asking for a limit of 5 still returns every role, in more round trips. System roles lead the array, so do not rely on index position to find a custom role.

Example

ts
const roles = await envless.roles.listAll()

const viewer = roles.find((role) => role.systemKey === 'viewer')

console.log(viewer?.id)

Parameters

ParameterTypeRequiredDescription
options.limitnumberNoPage size used while walking, clamped to 100.
options.offsetnumberNoRow to start the walk from.
options.searchstringNoCase insensitive substring match against role name and description.
options.sortByRoleSortNoOrder within each group: name (the default) is A to Z, updated and created are newest first. System roles always come first.
options.signalAbortSignalNoCancels every request in the walk.

Returns

Array<RoleResource> holding every role in the workspace, system roles first.

Reads the roles collection. list returns one page as { items, pagination }, listAll collects every page into an array, and iterate streams one item at a time without buffering the whole set.

Worth knowing

  • Page size defaults to the API maximum of 100 and is clamped there, so a larger limit buys nothing.
  • Match system roles on systemKey, which is owner, admin or viewer, rather than on name, since names are display text.

Required scopes

roles:read

Underlying endpoint

GET /roles

Request and response schema, every error code, and a live playground.

In Python

envless.roles.list_all()

The same method in envless-sdk, the Python SDK, with the same request, retries and errors.

In Ruby

Envless.roles.list_all

The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.

In PHP

$envless->roles->listAll()

The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.