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

# 移除授权用户

通过停用其角色分配，从调用方的账户中移除授权用户。该变更不会删除用户——它会将调用方账户上的角色分配设置为 `INACTIVE`，从而撤销其访问权限。账户所有者（`OWNER` 角色）无法通过此端点被移除。

目标账户始终根据调用方的凭据解析——Bearer 令牌使用令牌所属的账户；Basic（API key）调用方使用应用配置的运营者账户。`authUserId` 必须指向该账户上的一个角色分配；否则请求会被拒绝。

🔒 受限访问

此变更需要 `MANAGE_SUBUSERS` 范围。它同时支持 Bearer（用户访问令牌）和 Basic（`<API_KEY>`）身份验证。

```graphql theme={null}
mutation RemoveAuthorizedUser(
  $authUserId: UUID!
) {
  removeAuthorizedUser(
    authUserId: $authUserId
  ) {
    success
    authUserId
    status
    error {
      code
      message
    }
  }
}
```

<br />

### Parameters

| Parameter  | Type | Required | Description                                                             |
| :--------- | :--- | :------- | :---------------------------------------------------------------------- |
| authUserId | UUID | Yes      | 要停用的授权用户 ID（UAC 角色分配 ID）。可从 `authorizedUsers` 或 `addAuthorizedUser` 获取。 |

<br />

### Response

#### Success Response

```json theme={null}
{
  "data": {
    "removeAuthorizedUser": {
      "success": true,
      "authUserId": "8b2c1e0a-7d4f-4a9b-9c2d-1f3e4a5b6c7d",
      "status": "INACTIVE",
      "error": null
    }
  }
}
```

<br />

### Response Fields

| Field        | Type                | Description                                        |
| :----------- | :------------------ | :------------------------------------------------- |
| `success`    | Boolean             | 若角色分配成功被停用则为 `true`。                               |
| `authUserId` | UUID                | 已更新的授权用户 ID（UAC 角色分配 ID）。                          |
| `status`     | UACRoleStatusType   | 角色分配的更新状态。成功时为 `INACTIVE`。                         |
| `error`      | AuthorizedUserError | 若 `success` 为 false，则为包含 `code` 和 `message` 的错误对象。 |

<br />

<Note>
  此变更会在响应数据中返回错误，而不是作为 GraphQL 错误返回。请始终检查 `success` 字段，并在 `success` 为 false 时处理 `error` 对象。
</Note>

### Example Request

```curl theme={null}
curl -X POST https://transactional-graph.staging.fluzapp.com/api/v1/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_access_token>" \
  -d '{
  "query": "mutation RemoveAuthorizedUser($authUserId: UUID!) { removeAuthorizedUser(authUserId: $authUserId) { success authUserId status error { code message } } }",
  "variables": {
    "authUserId": "8b2c1e0a-7d4f-4a9b-9c2d-1f3e4a5b6c7d"
  }
}'
```

```typescript theme={null}
const response = await fetch('https://transactional-graph.staging.fluzapp.com/api/v1/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`
  },
  body: JSON.stringify({
    query: `
      mutation RemoveAuthorizedUser(
        $authUserId: UUID!
      ) {
        removeAuthorizedUser(
          authUserId: $authUserId
        ) {
          success
          authUserId
          status
          error {
            code
            message
          }
        }
      }
    `,
    variables: {
      authUserId: "8b2c1e0a-7d4f-4a9b-9c2d-1f3e4a5b6c7d"
    }
  })
});

const data = await response.json();

if (data.data.removeAuthorizedUser.success) {
  console.log('Authorized user removed:', data.data.removeAuthorizedUser);
} else {
  console.error('Remove authorized user failed:', data.data.removeAuthorizedUser.error);
}
```

### Error Codes

| Code        | Message                                                                             | Description                                                   |
| :---------- | :---------------------------------------------------------------------------------- | :------------------------------------------------------------ |
| `ARG-0002`  | Missing required arguments                                                          | 未提供 `authUserId`。                                             |
| `AUTH-0008` | Invalid user access                                                                 | 无法从访问令牌或 API key 解析调用方，或使用 Basic 身份验证的应用未配置运营者账户。请验证您的身份验证凭据。 |
| `AUTH-0031` | The requested scopes must be granted by the user first.                             | 令牌缺少管理授权用户所需的 `MANAGE_SUBUSERS` 范围。                           |
| `AUTH-0034` | No role assignment found for the provided authorized user on the specified account. | 调用方账户上不存在该 `authUserId`，或该分配已为 `INACTIVE`。                    |
| `AUTH-0036` | The account owner cannot be removed.                                                | 引用的角色分配持有 `OWNER` 角色，无法通过此端点移除。                               |
| `AUTH-0037` | Unable to manage authorized user. Please try again or contact support.              | 停用角色分配时发生一般性故障。请重试或联系支持。                                      |

<br />
