> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scanova.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建自定义角色

> POST /multi-users/access-levels/

每个共享用户都会被分配一个角色——Scanova 仪表盘在内部将其称为"访问级别"（access levels），这个术语在本端点中始终沿用。在通过 [`POST /multi-users/`](/zh/api-reference/management-api/shared-users/invite) 邀请团队成员之前，使用此端点查询可用的角色，或从您自己的系统中创建自定义角色。

<Note>
  此端点此前未被记录过文档。它需要一个拥有 `MANAGEMENT_API`（或 `MANAGEMENT_API_SANDBOX`）配额的 Management API 密钥——参见 [Management API 概览](/zh/api-reference/management-api/overview)。关于每个角色实际授予团队成员的权限，请参见面向人类读者的[角色与权限](/zh/team/roles-and-permissions)指南——本页仅记录数据格式。
</Note>

<Warning>
  创建自定义角色需要账户套餐上的专属配额（与隐藏仪表盘 **Roles** 标签页——针对不支持该功能的套餐——的门槛相同，参见[自定义角色受套餐限制](/zh/team/roles-and-permissions#custom-roles-are-plan-gated)）。此处返回 403 说明该套餐不包含此功能。
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://management.scanova.io/multi-users/access-levels/' \
    --header 'Authorization: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "Regional Support",
      "permissions": [23, 24, 31]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": 42,
    "name": "Regional Support",
    "slug": null,
    "permissions": [
      { "id": 23, "code": "QR_CODE_CAN_VIEW", "name": "Can view QR Code", "description": "Allows viewing QR code details.", "is_boolean": true },
      { "id": 24, "code": "ANALYTICS_CAN_VIEW", "name": "Can view Analytics", "description": "Allows viewing analytics.", "is_boolean": true },
      { "id": 31, "code": "LEAD_GENERATION_CAN_VIEW", "name": "Can view Lead Lists", "description": "Allows viewing lead lists.", "is_boolean": true }
    ],
    "is_custom": true
  }
  ```
</ResponseExample>

<ParamField body="name" type="string" required>
  角色名称。在该账户的角色中必须唯一——重复的名称会返回一个 400 错误，内容为 `{"name": ["Can not create another user role with the same name."]}`。
</ParamField>

<ParamField body="permissions" type="array" required>
  要授予的权限 ID，来自上方列表响应中的 `permissions[].id` 值。
</ParamField>

<Note>
  Management API 上没有独立于角色之外的"列出所有可用权限"批量端点——要发现权限 ID，请从某个现有角色的 `permissions` 数组中读取（每个账户至少可以查看 6 个系统角色）。
</Note>

## 相关内容

* [列出角色](/zh/api-reference/management-api/shared-users/roles-list) — 同一端点的另一个操作。
* [邀请共享用户](/zh/api-reference/management-api/shared-users/invite) —— 在邀请或更新团队成员时，从此列表中分配一个角色 ID。
* [更新共享用户](/zh/api-reference/management-api/shared-users/update) —— 在邀请或更新团队成员时，从此列表中分配一个角色 ID。
* [角色与权限](/zh/team/roles-and-permissions) —— 面向人类读者的说明，介绍每个角色授予的权限，包括自定义角色的套餐门槛。
* [共享用户](/zh/team/shared-users) —— 仪表盘的 Users 表格，这些角色在其中通过界面进行分配。


## OpenAPI

````yaml api-reference/openapi/management-api.json POST /multi-users/access-levels/
openapi: 3.1.0
info:
  title: Scanova Management API (v2)
  description: >-
    The complete Scanova Management API — every endpoint available at
    management.scanova.io (QR codes, folders, tags, leads, forms, analytics,
    plans, shared users & roles), plus the token-creation and usage-stats
    endpoints used to authenticate against it. Every path and request/response
    shape below was verified live against a real API key and the actual running
    backend (Phase 7, 2026-08-16) — not guessed from reading urls.py alone.
  version: 2.0.0
servers:
  - url: https://management.scanova.io
    description: Management API — QR/folder/tag/lead/form/analytics/plans endpoints
security:
  - apiKeyAuth: []
paths:
  /multi-users/access-levels/:
    post:
      summary: Create a custom role
      operationId: createManagedAccessLevel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                permissions:
                  type: array
                  items:
                    type: integer
                  description: >-
                    Permission IDs from an existing role's permissions[].id
                    values.
              required:
                - name
                - permissions
            example:
              name: Regional Support
              permissions:
                - 23
                - 24
                - 31
      responses:
        '201':
          description: Custom role created. Requires the account's custom-roles plan quota.
          content:
            application/json:
              example:
                id: 42
                name: Regional Support
                slug: null
                permissions:
                  - id: 23
                    code: QR_CODE_CAN_VIEW
                    name: Can view QR Code
                    description: Allows viewing QR code details.
                    is_boolean: true
                is_custom: true
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Send your Management API key as the raw value of the Authorization
        header — no "Bearer " or "Token " prefix, and no other characters.
        Example: `Authorization: 401f7ac837da42b97f613d789819ff93537bee6a`. A
        header containing more than one space-separated part is rejected
        outright. Requests also require the request's Host header to be the
        management API host (e.g. management.scanova.io) — the same key sent to
        the regular API host will not authenticate.

````