Skip to main content
POST
Create New Role

Create Role

Create a new custom user role with specific permissions.

Endpoint

Description

This endpoint allows administrators to create new custom user roles. Custom roles can have specific permissions tailored to your organization’s needs. You can specify the role name, description, and permissions during creation.

Authentication

Required: API Key with admin privileges

Request Body

Example Request

Success Response

Status Code: 201 Created

Response Fields

Example Usage

JavaScript

Python

cURL

Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

409 Conflict

429 Too Many Requests

Available Permission Sections

Available Permission Levels

Use Cases

  • Custom Roles: Create roles tailored to your organization’s needs
  • Access Control: Define specific permissions for different user types
  • Security: Implement least-privilege access principles
  • Compliance: Create roles that meet regulatory requirements
  • Integration: Define roles for third-party system integration

Rate Limits

  • Default: 50 requests per minute
  • Daily: 5,000 requests per day
  • Monthly: 150,000 requests per month

Notes

  • Admin Only: This endpoint requires admin privileges
  • Required Fields: name, displayName, and description are required
  • Permission Structure: Permissions are objects with section and level properties
  • System Roles: Custom roles are never system roles
  • Flat Response: Response is not nested under data object
  • Creator Info: Shows who created the role
  • User Count: Starts at 0 for new roles
  • Role names must be unique within the system
  • The role is immediately available for user assignment

授权

Authorization
string
header
必填

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

请求体

application/json
name
string
必填

Role name (lowercase, no spaces)

示例:

"custom_role"

displayName
string
必填

Display name for the role

示例:

"Custom Role"

description
string
必填

Role description

示例:

"Custom role with specific permissions"

hasAdminPanelAccess
boolean
默认值:false

Whether role has admin panel access

示例:

true

permissions
object[]

Array of permission objects

示例:
canInteractWithAI
boolean
默认值:true

Whether role can interact with AI

示例:

true

canUseChat
boolean
默认值:true

Whether role can use chat

示例:

true

响应

Role created successfully

success
boolean
示例:

true

message
string
示例:

"Role created successfully"

role
object