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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 更新账户组

> 更新现有账户组的名称、商户 ID 或上级组

更新现有账户组的详情：名称、商户 ID，或其所嵌套的组。

仅更改请求体中包含的字段。`parent_code` 有三种状态：省略它以保持上级组不变；发送 `null` 以分离该组并使其重新成为根组；或发送另一个组的 `id`，将该组嵌套在其下。嵌套仅是结构上的，不会授予或撤销任何权限。


## OpenAPI

````yaml openapi/zh-hans/organizations/update-account-group.json PATCH /organizations/account-groups/{account_group_id}
openapi: 3.1.0
info:
  title: Account Groups API - Update
  version: 1.0.0
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /organizations/account-groups/{account_group_id}:
    patch:
      summary: 更新账户组
      description: >-
        更新账户组。所有字段均为可选，仅更改请求体中包含的字段。


        `parent_code` 将该组嵌套到同一组织的另一个组之下。它有三种状态：**省略**则保持当前父组不变；**`null`**
        则分离该组，并将其连同挂在其下的所有子组一起提升回根组；**组 `id`**
        则将该组嵌套到该组之下。嵌套仅是结构上的，不授予也不撤销任何权限，因此移动组不会影响任何现有权限。
      operationId: update-account-group
      parameters:
        - name: account_group_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: 账户组 UUID。
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: 账户组名称（min=1，max=255）。
                merchant_id:
                  type: string
                  description: 本地标识符（min=1，max=255）。
                parent_code:
                  type:
                    - string
                    - 'null'
                  format: uuid
                  description: >-
                    要将该组嵌套到其下的组的 `id`。省略则保持父组不变；发送 `null`
                    则分离该组并使其重新成为根组。父组必须属于同一组织，且不得是该组本身或其后代。
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  merchant_id:
                    type: string
                  parent_code:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    description: 该组所嵌套的父组的 `id`。根（顶层）组为 `null`。
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
        '400':
          description: |-
            请求错误。`code` 字段说明原因：

            - `PARENT_NOT_FOUND`：此组织中不存在具有该 `parent_code` 的组。
            - `INVALID_PARENT`：该组被指定为其自身的父组。
            - `PARENT_IS_DESCENDANT`：目标父组位于该组自身的子树内，因此移动会形成循环。
            - `MAX_NESTING_DEPTH`：移动会使树超过 20 层的最大深度。
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: 机器可读的错误代码。
                  messages:
                    type: array
                    items:
                      type: string
                    description: 人类可读的详细信息。
              example:
                code: PARENT_IS_DESCENDANT
                messages:
                  - >-
                    Account group [LATAM] is inside [Acme], so it cannot become
                    its parent.
        '404':
          description: 未找到：此组织中不存在具有该 `account_group_id` 的账户组。
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: PUBLIC-API-KEY
      x-default: <Your PUBLIC-API-KEY>
    sec1:
      type: apiKey
      in: header
      name: PRIVATE-SECRET-KEY
      x-default: <Your PRIVATE-SECRET-KEY>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.