Skip to content
Primary navigation

List project roles

admin.organization.projects.roles.list(strproject_id, RoleListParams**kwargs) -> SyncNextCursorPage[Role]
GET/projects/{project_id}/roles

Lists the roles configured for a project.

ParametersExpand Collapse
project_id: str
after: Optional[str]

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

limit: Optional[int]

A limit on the number of roles to return. Defaults to 1000.

minimum0
maximum1000
order: Optional[Literal["asc", "desc"]]

Sort order for the returned roles.

One of the following:
"asc"
"desc"
ReturnsExpand Collapse
class Role: …

Details about a role that can be assigned through the public Roles API.

id: str

Identifier for the role.

description: Optional[str]

Optional description of the role.

name: str

Unique name for the role.

object: Literal["role"]

Always role.

permissions: List[str]

Permissions granted by the role.

predefined_role: bool

Whether the role is predefined and managed by OpenAI.

resource_type: str

Resource type the role is bound to (for example api.organization or api.project).

List project roles

import os
from openai import OpenAI

client = OpenAI(
    admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"),  # This is the default and can be omitted
)
page = client.admin.organization.projects.roles.list(
    project_id="project_id",
)
page = page.data[0]
print(page.id)
{
    "object": "list",
    "data": [
        {
            "object": "role",
            "id": "role_01J1F8PROJ",
            "name": "API Project Key Manager",
            "description": "Allows managing API keys for the project",
            "permissions": [
                "api.organization.projects.api_keys.read",
                "api.organization.projects.api_keys.write"
            ],
            "resource_type": "api.project",
            "predefined_role": false
        }
    ],
    "has_more": false,
    "next": null
}
Returns Examples
{
    "object": "list",
    "data": [
        {
            "object": "role",
            "id": "role_01J1F8PROJ",
            "name": "API Project Key Manager",
            "description": "Allows managing API keys for the project",
            "permissions": [
                "api.organization.projects.api_keys.read",
                "api.organization.projects.api_keys.write"
            ],
            "resource_type": "api.project",
            "predefined_role": false
        }
    ],
    "has_more": false,
    "next": null
}