Skip to content
Primary navigation

Retrieve project user role

admin.organization.projects.users.roles.retrieve(strrole_id, RoleRetrieveParams**kwargs) -> RoleRetrieveResponse
GET/projects/{project_id}/users/{user_id}/roles/{role_id}

Retrieves a project role assigned to a user.

ParametersExpand Collapse
project_id: str
user_id: str
role_id: str
ReturnsExpand Collapse
class RoleRetrieveResponse: …

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

id: str

Identifier for the role.

assignment_sources: Optional[List[AssignmentSource]]

Principals from which the role assignment is inherited, when available.

principal_id: str
principal_type: str
created_at: Optional[int]

When the role was created.

formatunixtime
created_by: Optional[str]

Identifier of the actor who created the role.

created_by_user_obj: Optional[Dict[str, object]]

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

description: Optional[str]

Description of the role.

metadata: Optional[Dict[str, object]]

Arbitrary metadata stored on the role.

name: str

Name of the role.

permissions: List[str]

Permissions associated with the role.

predefined_role: bool

Whether the role is predefined by OpenAI.

resource_type: str

Resource type the role applies to.

updated_at: Optional[int]

When the role was last updated.

formatunixtime

Retrieve project user role

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
)
role = client.admin.organization.projects.users.roles.retrieve(
    role_id="role_id",
    project_id="project_id",
    user_id="user_id",
)
print(role.id)
{
    "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": null,
    "metadata": {},
    "assignment_sources": null
}
Returns Examples
{
    "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": null,
    "metadata": {},
    "assignment_sources": null
}