Skip to main content

role_assignments

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

Overview

Namerole_assignments
TypeResource
Idopenai_admin.users.role_assignments

Fields

The following fields are returned by SELECT queries:

User organization role assignments listed successfully.

NameDatatypeDescription
idstringIdentifier for the role.
namestringName of the role.
created_atinteger (unixtime)When the role was created.
created_bystringIdentifier of the actor who created the role.
created_by_user_objobjectUser details for the actor that created the role, when available.
descriptionstringDescription of the role.
metadataobjectArbitrary metadata stored on the role.
permissionsarrayPermissions associated with the role.
predefined_rolebooleanWhether the role is predefined by OpenAI.
resource_typestringResource type the role applies to.
updated_atinteger (int64)When the role was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectuser_idlimit, after, order
assigninsertuser_id, role_id
unassigndeleteuser_id, role_id

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
role_idstringThe ID of the organization role to remove from the user.
user_idstringThe ID of the user to modify.
afterstringCursor for pagination. Provide the value from the previous response's next field to continue listing organization roles.
limitintegerA limit on the number of organization role assignments to return.
orderstringSort order for the returned organization roles.

SELECT examples

User organization role assignments listed successfully.

SELECT
id,
name,
created_at,
created_by,
created_by_user_obj,
description,
metadata,
permissions,
predefined_role,
resource_type,
updated_at
FROM openai_admin.users.role_assignments
WHERE user_id = '{{ user_id }}' -- required
AND limit = '{{ limit }}'
AND after = '{{ after }}'
AND order = '{{ order }}'
;

INSERT examples

No description available.

INSERT INTO openai_admin.users.role_assignments (
role_id,
user_id
)
SELECT
'{{ role_id }}' /* required */,
'{{ user_id }}'
RETURNING
object,
role,
user
;

DELETE examples

No description available.

DELETE FROM openai_admin.users.role_assignments
WHERE user_id = '{{ user_id }}' --required
AND role_id = '{{ role_id }}' --required
;