> ## 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       | 依授權使用者的 email 位址篩選。 |
| 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            | 授權使用者的 email 位址。                                    |
| `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 />
