> ## 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.

# 查询授权用户

列出调用方账户中的授权用户。结果始终限定在调用方的账户范围内——Bearer 令牌使用该令牌所属的账户；Basic（API key）调用方使用应用程序已配置的运营商账户。`OWNER` 的角色分配将被排除。

两个筛选器都是可选的，可通过 `email` 和/或 `phone` 进一步缩小结果范围。

🔒 受限访问

此查询需要 `VIEW_SUBUSERS` 范围。它同时支持 Bearer（用户访问令牌）和 Basic（`<API_KEY>`）认证。

```graphql theme={null}
query AuthorizedUsers(
  $email: String
  $phone: String
) {
  authorizedUsers(
    email: $email
    phone: $phone
  ) {
    authUserId
    roles
    status
    email
    phone
    firstName
    lastName
  }
}
```

<br />

### 参数

| Parameter | Type   | Required | Description     |
| :-------- | :----- | :------- | :-------------- |
| email     | String | No       | 按授权用户的电子邮箱地址筛选。 |
| phone     | String | No       | 按授权用户的电话号码筛选。   |

<br />

### 响应

#### 成功响应

```json theme={null}
{
  "data": {
    "authorizedUsers": [
      {
        "authUserId": "8b2c1e0a-7d4f-4a9b-9c2d-1f3e4a5b6c7d",
        "roles": ["MANAGER", "VIEWER"],
        "status": "ACTIVE",
        "email": "teammate@example.com",
        "phone": "+15555555555",
        "firstName": "Ada",
        "lastName": "Lovelace"
      }
    ]
  }
}
```

<br />

### 响应字段

| Field        | Type              | Description                                         |
| :----------- | :---------------- | :-------------------------------------------------- |
| `authUserId` | UUID              | 授权用户 ID（UAC 角色分配 ID）。将此值传递给 `removeAuthorizedUser`。 |
| `roles`      | \[UACRoleType]    | 分配给该用户在账户上的角色。                                      |
| `status`     | UACRoleStatusType | 角色分配的状态：`PENDING`、`ACTIVE`、`INACTIVE` 或 `DECLINED`。 |
| `email`      | String            | 授权用户的电子邮箱地址。                                        |
| `phone`      | String            | 授权用户的电话号码。                                          |
| `firstName`  | String            | 授权用户的名。                                             |
| `lastName`   | String            | 授权用户的姓。                                             |

<br />

### 示例请求

```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": "query AuthorizedUsers($email: String, $phone: String) { authorizedUsers(email: $email, phone: $phone) { authUserId roles status email phone firstName lastName } }",
  "variables": {
    "email": "teammate@example.com"
  }
}'
```

```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: `
      query AuthorizedUsers(
        $email: String
        $phone: String
      ) {
        authorizedUsers(
          email: $email
          phone: $phone
        ) {
          authUserId
          roles
          status
          email
          phone
          firstName
          lastName
        }
      }
    `,
    variables: {
      email: "teammate@example.com"
    }
  })
});

const data = await response.json();
console.log('Authorized users:', data.data.authorizedUsers);
```

### 错误代码

| Code        | Message                                                 | Description                                                |
| :---------- | :------------------------------------------------------ | :--------------------------------------------------------- |
| `AUTH-0008` | Invalid user access                                     | 无法根据访问令牌或 API key 解析调用方，或使用 Basic 认证的应用未配置运营商账户。请验证您的认证凭证。 |
| `AUTH-0031` | The requested scopes must be granted by the user first. | 该令牌缺少列出授权用户所需的 `VIEW_SUBUSERS` 范围。                         |

<br />
