Sample - OpenAI API
POST/projects/{project_id}/roles

Create a project role

Creates a custom role for a project. Supply role_name and permissions, and optionally include description to document the role's purpose.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 3 body fields
project_idstringrequired
The ID of the project where you want to create the role.

Parameters for the project role you want to create.

role_namestringrequired
Unique name for the role.
permissionsarray<string>required
Permissions to grant to the role.
descriptionstringoptional
Optional description of the role.

2 status codes
200Returns the created role with its identifier, name, description, granted permissions, resource type, and predefined-role status.
objectstringrequired
Always `role`.
Allowed:role
idstringrequired
Identifier for the role.
namestringrequired
Unique name for the role.
descriptionstringrequired
Optional description of the role.
permissionsarray<string>required
Permissions granted by the role.
resource_typestringrequired
Resource type the role is bound to (for example `api.organization` or `api.project`).
predefined_rolebooleanrequired
Whether the role is predefined and managed by OpenAI.
429Returned when the request was rejected because a rate limit was exceeded.
errorobjectrequired

Error handling

A 429 is returned when the request exceeds the applicable rate limit. role_name and permissions are required, and description may be a string or null.