Skip to content

Create project role

POST/projects/{project_id}/roles

Creates a custom role for a project.

Path ParametersExpand Collapse
project_id: string
Body ParametersJSONExpand Collapse
permissions: array of string

Permissions to grant to the role.

role_name: string

Unique name for the role.

description: optional string

Optional description of the role.

ReturnsExpand Collapse
id: string

Identifier for the role.

description: string

Optional description of the role.

name: string

Unique name for the role.

object: "role"

Always role.

permissions: array of 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).

Create project role

curl https://api.openai.com/v1/projects/$PROJECT_ID/roles \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
          "permissions": [
            "string"
          ],
          "role_name": "role_name"
        }'
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}
Returns Examples
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}