Skip to content
Primary navigation

Assign project role to group

client.admin.organization.projects.groups.roles.create(stringgroupID, RoleCreateParams { project_id, role_id } params, RequestOptionsoptions?): RoleCreateResponse { group, object, role }
POST/projects/{project_id}/groups/{group_id}/roles

Assigns a project role to a group within a project.

ParametersExpand Collapse
groupID: string
params: RoleCreateParams { project_id, role_id }
project_id: string

Path param: The ID of the project to update.

role_id: string

Body param: Identifier of the role to assign.

ReturnsExpand Collapse
RoleCreateResponse { group, object, role }

Role assignment linking a group to a role.

group: Group { id, created_at, name, 2 more }

Summary information about a group returned in role assignment responses.

id: string

Identifier for the group.

created_at: number

Unix timestamp (in seconds) when the group was created.

formatunixtime
name: string

Display name of the group.

object: "group"

Always group.

scim_managed: boolean

Whether the group is managed through SCIM.

object: "group.role"

Always group.role.

role: Role { id, description, name, 4 more }

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

id: string

Identifier for the role.

description: string | null

Optional description of the role.

name: string

Unique name for the role.

object: "role"

Always role.

permissions: Array<string>

Permissions granted by the role.

predefined_role: boolean

Whether the role is predefined and managed by OpenAI.

resource_type: string

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

Assign project role to group

import OpenAI from 'openai';

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

const role = await client.admin.organization.projects.groups.roles.create('group_id', {
  project_id: 'project_id',
  role_id: 'role_id',
});

console.log(role.group);
{
    "object": "group.role",
    "group": {
        "object": "group",
        "id": "group_01J1F8ABCDXYZ",
        "name": "Support Team",
        "created_at": 1711471533,
        "scim_managed": false
    },
    "role": {
        "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
    }
}
Returns Examples
{
    "object": "group.role",
    "group": {
        "object": "group",
        "id": "group_01J1F8ABCDXYZ",
        "name": "Support Team",
        "created_at": 1711471533,
        "scim_managed": false
    },
    "role": {
        "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
    }
}