Skip to main content

roles

Creates, updates, deletes, gets or lists a roles resource.

Overview

Nameroles
TypeResource
Idclickhouse.clickstack.roles

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringRole ID. (example: 507f1f77bcf86cd799439011)
namestringRole name. (example: Read Only)
created_atstring (date-time)Creation timestamp. (example: 2025-01-01T00:00:00.000Z) (wire: createdAt)
descriptionstringHuman-readable role description. (example: Read-only access to all resources)
is_predefinedbooleanWhether this is an immutable predefined/system role. (wire: isPredefined)
permissionsarrayThe CASL permissions granted by this role.
updated_atstring (date-time)Last update timestamp. (example: 2025-06-15T10:30:00.000Z) (wire: updatedAt)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectservice_id, click_stack_role_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves a specific role by ID.
listselectservice_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves all roles for the authenticated team, including predefined roles.
createinsertservice_id, organization_id, name, permissionsThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Creates a new custom role for the team.
updateupdateservice_id, click_stack_role_id, organization_id, permissionsThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Updates a custom role's permissions, name, and description. Predefined roles cannot be modified.
deletedeleteservice_id, click_stack_role_id, organization_idThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Deletes a custom role. Predefined roles, the team default user role, and roles assigned to users cannot be deleted.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
click_stack_role_idstringid parameter (wire: clickStackRoleId)
organization_idstringClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID)
service_idstring (uuid)ID of the ClickStack service. (wire: serviceId)

SELECT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Retrieves a specific role by ID.

SELECT
id,
name,
created_at,
description,
is_predefined,
permissions,
updated_at
FROM clickhouse.clickstack.roles
WHERE service_id = '{{ service_id }}' -- required
AND click_stack_role_id = '{{ click_stack_role_id }}' -- required
AND organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
;

INSERT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Creates a new custom role for the team.

INSERT INTO clickhouse.clickstack.roles (
name,
description,
permissions,
service_id,
organization_id
)
SELECT
'{{ name }}' /* required */,
'{{ description }}',
'{{ permissions }}' /* required */,
'{{ service_id }}',
'{{ organization_id }}'
RETURNING
request_id,
result,
status
;

UPDATE examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Updates a custom role's permissions, name, and description. Predefined roles cannot be modified.

UPDATE clickhouse.clickstack.roles
SET
name = '{{ name }}',
description = '{{ description }}',
permissions = '{{ permissions }}'
WHERE
service_id = '{{ service_id }}' --required
AND click_stack_role_id = '{{ click_stack_role_id }}' --required
AND organization_id = '{{ organization_id }}' --required unless CLICKHOUSE_ORG_ID is set
AND permissions = '{{ permissions }}' --required
RETURNING
request_id,
result,
status;

DELETE examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> ClickStack: Deletes a custom role. Predefined roles, the team default user role, and roles assigned to users cannot be deleted.

DELETE FROM clickhouse.clickstack.roles
WHERE service_id = '{{ service_id }}' --required
AND click_stack_role_id = '{{ click_stack_role_id }}' --required
AND organization_id = '{{ organization_id }}' --required unless CLICKHOUSE_ORG_ID is set
;