Skip to content
Primary navigation

Retrieve organization role

client.Admin.Organization.Roles.Get(ctx, roleID) (*Role, error)
GET/organization/roles/{role_id}

Retrieves an organization role.

ParametersExpand Collapse
roleID string
ReturnsExpand Collapse
type Role struct{…}

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

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 []string

Permissions granted by the role.

PredefinedRole bool

Whether the role is predefined and managed by OpenAI.

ResourceType string

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

Retrieve organization role

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Roles.Get(context.TODO(), "role_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}
{
    "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": "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
}