Assign organization role to user
client.admin.organization.users.roles.create(stringuserID, RoleCreateParams { role_id } body, RequestOptionsoptions?): RoleCreateResponse { object, role, user }
POST/organization/users/{user_id}/roles
Assign organization role to user
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.users.roles.create('user_id', { role_id: 'role_id' });
console.log(role.object);{
"object": "user.role",
"user": {
"object": "organization.user",
"id": "user_abc123",
"name": "Ada Lovelace",
"email": "ada@example.com",
"role": "owner",
"added_at": 1711470000
},
"role": {
"object": "role",
"id": "role_01J1F8ROLE01",
"name": "API Group Manager",
"description": "Allows managing organization groups",
"permissions": [
"api.groups.read",
"api.groups.write"
],
"resource_type": "api.organization",
"predefined_role": false
}
}
Returns Examples
{
"object": "user.role",
"user": {
"object": "organization.user",
"id": "user_abc123",
"name": "Ada Lovelace",
"email": "ada@example.com",
"role": "owner",
"added_at": 1711470000
},
"role": {
"object": "role",
"id": "role_01J1F8ROLE01",
"name": "API Group Manager",
"description": "Allows managing organization groups",
"permissions": [
"api.groups.read",
"api.groups.write"
],
"resource_type": "api.organization",
"predefined_role": false
}
}