Skip to content
Primary navigation

List project user role assignments

client.admin.organization.projects.users.roles.list(stringuserID, RoleListParams { project_id, after, limit, order } params, RequestOptionsoptions?): NextCursorPage<RoleListResponse { id, created_at, created_by, 8 more } >
GET/projects/{project_id}/users/{user_id}/roles

Lists the project roles assigned to a user within a project.

ParametersExpand Collapse
userID: string
params: RoleListParams { project_id, after, limit, order }
project_id: string

Path param: The ID of the project to inspect.

after?: string

Query param: Cursor for pagination. Provide the value from the previous response’s next field to continue listing project roles.

limit?: number

Query param: A limit on the number of project role assignments to return.

minimum0
maximum1000
order?: "asc" | "desc"

Query param: Sort order for the returned project roles.

One of the following:
"asc"
"desc"
ReturnsExpand Collapse
RoleListResponse { id, created_at, created_by, 8 more }

Detailed information about a role assignment entry returned when listing assignments.

id: string

Identifier for the role.

created_at: number | null

When the role was created.

formatunixtime
created_by: string | null

Identifier of the actor who created the role.

created_by_user_obj: Record<string, unknown> | null

User details for the actor that created the role, when available.

description: string | null

Description of the role.

metadata: Record<string, unknown> | null

Arbitrary metadata stored on the role.

name: string

Name of the role.

permissions: Array<string>

Permissions associated with the role.

predefined_role: boolean

Whether the role is predefined by OpenAI.

resource_type: string

Resource type the role applies to.

updated_at: number | null

When the role was last updated.

formatint64

List project user role assignments

import OpenAI from 'openai';

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

// Automatically fetches more pages as needed.
for await (const roleListResponse of client.admin.organization.projects.users.roles.list(
  'user_id',
  { project_id: 'project_id' },
)) {
  console.log(roleListResponse.id);
}
{
    "object": "list",
    "data": [
        {
            "id": "role_01J1F8PROJ",
            "name": "API Project Key Manager",
            "permissions": [
                "api.organization.projects.api_keys.read",
                "api.organization.projects.api_keys.write"
            ],
            "resource_type": "api.project",
            "predefined_role": false,
            "description": "Allows managing API keys for the project",
            "created_at": 1711471533,
            "updated_at": 1711472599,
            "created_by": "user_abc123",
            "created_by_user_obj": {
                "id": "user_abc123",
                "name": "Ada Lovelace",
                "email": "ada@example.com"
            },
            "metadata": {}
        }
    ],
    "has_more": false,
    "next": null
}
Returns Examples
{
    "object": "list",
    "data": [
        {
            "id": "role_01J1F8PROJ",
            "name": "API Project Key Manager",
            "permissions": [
                "api.organization.projects.api_keys.read",
                "api.organization.projects.api_keys.write"
            ],
            "resource_type": "api.project",
            "predefined_role": false,
            "description": "Allows managing API keys for the project",
            "created_at": 1711471533,
            "updated_at": 1711472599,
            "created_by": "user_abc123",
            "created_by_user_obj": {
                "id": "user_abc123",
                "name": "Ada Lovelace",
                "email": "ada@example.com"
            },
            "metadata": {}
        }
    ],
    "has_more": false,
    "next": null
}