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

# 批量查询子账户认证信息

> 仅限代理商：查询本人及所有直属子账户的优选池认证账号、密码。没有优选池账号的用户不返回；key 固定为空字符串。

使用**代理商的 appKey**，一次获取代理商本人及其所有直属子账户的**优选池代理认证账号和密码**。无需传入子账户的 `appKey` 或 `params`。

返回的 `data.users` 中，每项包含：

| 字段 | 说明 |
| - | - |
| `account` | 优选池代理认证账号，对应创建接口的 `proxyUser` |
| `password` | 优选池代理认证密码，对应创建接口的 `proxyPass` |
| `name` | 平台用户名，对应创建时的 `params.username` |
| `key` | 兼容历史响应的字段，固定为空字符串 |

> [!NOTE]
>
> 接口路径沿用历史名称 `getSubAccountKeys`，当前返回优选池认证凭据。`key` 不是子账户的 `appKey`，也不用于优选池代理认证。

没有子账户时，只要代理商本人有优选池认证账号，仍会返回本人。没有优选池认证账号的用户会被跳过；所有目标账户均无有效记录时，返回 `users: []`。历史标准池认证信息不会返回。

只有代理商可以调用此接口，且只能查询本人及其直属子账户。检查响应中的 `code` 判断业务是否成功：`0` 表示成功，`400` 表示 `appKey` 无效或调用方不是代理商。

创建新子账户时，也可以直接从[创建子账户](/api-reference/agent/addUser.md)的成功响应获取认证凭据。


## OpenAPI

````yaml POST /account/getSubAccountKeys
openapi: 3.0.1
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://apiv1.cakeip.com/openapi
security: []
paths:
  /account/getSubAccountKeys:
    post:
      description: 仅限代理商：查询本人及所有直属子账户的优选池认证账号、密码。没有优选池账号的用户不返回；key 固定为空字符串。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubAccountKeysRequest'
      responses:
        '200':
          description: 检查 code 判断业务结果：0 为成功，非 0 为失败
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/SubAccountKeysResponse'
                  - $ref: '#/components/schemas/AccountApiError'
              examples:
                success:
                  summary: 成功响应
                  value:
                    code: 0
                    msg: Success
                    data:
                      users:
                        - account: Jagent01
                          password: Pagent01
                          name: agent@example.com
                          key: ''
                        - account: Jchild01
                          password: Pchild01
                          name: child@example.com
                          key: ''
                invalidAppKey:
                  summary: appKey 无效
                  value:
                    code: 400
                    msg: appKey 无效
                    data: null
components:
  schemas:
    SubAccountKeysRequest:
      type: object
      properties:
        appKey:
          type: string
          description: 代理商的 appKey
          example: YOUR_AGENT_APP_KEY
      required:
        - appKey
    SubAccountKeysResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 0
          example: 0
        msg:
          type: string
          description: 响应消息
          example: Success
        data:
          type: object
          properties:
            users:
              type: array
              description: 本人及直属子账户的优选池认证信息；无有效记录时为空数组
              items:
                type: object
                properties:
                  account:
                    type: string
                    description: 优选池代理认证账号，对应 proxyUser
                    example: Jexample
                  password:
                    type: string
                    description: 优选池代理认证密码，对应 proxyPass
                    example: Pexample
                  name:
                    type: string
                    description: 平台用户名
                    example: child@example.com
                  key:
                    type: string
                    description: 历史兼容字段，固定为空字符串
                    enum:
                      - ''
                    example: ''
                required:
                  - account
                  - password
                  - name
                  - key
          required:
            - users
        logId:
          type: string
          description: 请求标识，用于问题排查
      required:
        - code
        - msg
        - data
    AccountApiError:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 400
            - -1
          description: 业务错误码
        msg:
          type: string
          description: 错误原因
        data:
          type: object
          nullable: true
          example: null
      required:
        - code
        - msg
        - data

````

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