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

# API キーを一覧表示

> 認証済みアカウントの API キーをページネーション付きで一覧表示するには、CometAPI の GET /api/token/ を使用します。

このエンドポイントを使用すると、認証済みの CometAPI アカウントに属する API キーを一覧表示できます。新しいキーから順に返されます。

<Note>
  個人アクセストークンは [Console → Personal Settings](https://www.cometapi.com/console/personal) で生成し、そのままの `Authorization` ヘッダー値として送信してください。`Bearer` を先頭に付けないでください。
</Note>

## ページネーション

| Query parameter | Description                              |
| --------------- | ---------------------------------------- |
| `p`             | ページ番号。デフォルトは `1` です。                     |
| `page_size`     | 1 ページあたりの項目数。`100` を超える値は `100` に制限されます。 |

## API キーのステータス

| Status | Meaning |
| ------ | ------- |
| `1`    | 有効      |
| `2`    | 無効      |
| `3`    | 期限切れ    |
| `4`    | 枯渇      |

## 返されるフィールド

| Field                  | Type           | Description                                                                                                                 |
| ---------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | integer        | 数値の API キー ID。[単一の API キーを取得](./get-api-key)、[API キーを更新](./update-api-key)、[API キーを削除](./delete-api-key) でこの値を使用します。        |
| `key`                  | string         | 管理 API によって返される API キーの値。秘密情報として扱い、モデルリクエストでは `Authorization: Bearer $COMETAPI_KEY` として使用してください。                            |
| `status`               | integer        | 動作ステータス。`1` の場合のみ、そのキーはモデルリクエストに対して有効です。                                                                                    |
| `name`                 | string         | キーのユーザー向け表示名。                                                                                                               |
| `created_time`         | integer        | キーが作成された時刻の Unix タイムスタンプ（秒）。                                                                                                |
| `accessed_time`        | integer        | キーが最後に使用された時刻の Unix タイムスタンプ（秒）。                                                                                             |
| `expired_time`         | integer        | キーの有効期限を示す Unix タイムスタンプ（秒）。`-1` は有効期限なしを意味します。                                                                              |
| `remain_quota`         | integer        | CometAPI の内部クォータ単位での残りクォータ。                                                                                                 |
| `used_quota`           | integer        | このキーによってすでに消費された、CometAPI の内部クォータ単位でのクォータ。                                                                                  |
| `unlimited_quota`      | boolean        | このキーが残りクォータのチェックをバイパスするかどうか。                                                                                                |
| `model_limits_enabled` | boolean        | このキーに対して model 制限が有効かどうか。                                                                                                   |
| `model_limits`         | string         | `model_limits_enabled` が `true` のときに、このキーで許可される model ID のカンマ区切り一覧。空の場合は、設定済みのモデル一覧がないことを意味します。                             |
| `allow_ips`            | string or null | 改行区切り 1 文字列としての IP 許可リスト。各項目には、単一の IPv4 アドレス、単一の IPv6 アドレス、IPv4 CIDR、または IPv6 CIDR を指定できます。`null` または `""` は IP 制限なしを意味します。 |
| `group`                | string         | アカウントグループ制限。空の場合は明示的なグループ制限がないことを意味します。                                                                                     |
| `cross_group_retry`    | boolean        | 自動グループルーティングのために cross-group retry が有効かどうか。                                                                                 |


## OpenAPI

````yaml api/openapi/api-keys/list-api-keys.openapi.json GET /api/token/
openapi: 3.1.0
info:
  title: List API Keys
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - accessTokenAuth: []
paths:
  /api/token/:
    get:
      summary: List API keys
      description: >-
        List API keys for the authenticated account. The newest keys are
        returned first.
      operationId: listApiKeys
      parameters:
        - name: p
          in: query
          required: false
          description: Page number to return. Defaults to `1`.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: page_size
          in: query
          required: false
          description: >-
            Number of keys per page. Values above `100` are capped at `100` by
            the backend.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
      responses:
        '200':
          description: Paginated API key list.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - message
                  - data
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: object
                    required:
                      - page
                      - page_size
                      - total
                      - items
                    properties:
                      page:
                        type: integer
                      page_size:
                        type: integer
                      total:
                        type: integer
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/ApiKey'
              examples:
                success:
                  summary: API key list
                  value:
                    success: true
                    message: ''
                    data:
                      page: 1
                      page_size: 20
                      total: 1
                      items:
                        - id: 1234
                          user_id: 5678
                          key: $COMETAPI_KEY
                          status: 1
                          name: production
                          created_time: 1766102400
                          accessed_time: 1766102400
                          expired_time: -1
                          remain_quota: 100000
                          unlimited_quota: false
                          model_limits_enabled: false
                          model_limits: ''
                          allow_ips: null
                          used_quota: 0
                          group: ''
                          cross_group_retry: false
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl "https://api.cometapi.com/api/token/?p=1&page_size=20" \
              -H "Authorization: your-access-token"
components:
  schemas:
    ApiKey:
      $ref: '#/components/schemas/ApiKeyObject'
    ApiKeyObject:
      type: object
      properties:
        id:
          type: integer
          description: >-
            Numeric API key ID. Use this value with the get, update, and delete
            endpoints.
          example: 1234
        user_id:
          type: integer
          description: Account user ID that owns the key.
          example: 5678
        key:
          type: string
          description: >-
            API key value returned by the management API. Treat it as a secret
            and use it as `Authorization: Bearer $COMETAPI_KEY` for model
            requests.
          example: $COMETAPI_KEY
        status:
          type: integer
          description: >-
            Operational status for the key. `1` means enabled, `2` disabled, `3`
            expired, and `4` exhausted. Only enabled keys are accepted by model
            endpoints.
          enum:
            - 1
            - 2
            - 3
            - 4
          example: 1
        name:
          type: string
          description: User-readable display name for the API key.
          example: production
          maxLength: 50
        created_time:
          type: integer
          description: Unix timestamp in seconds when the key was created.
          example: 1766102400
        accessed_time:
          type: integer
          description: >-
            Unix timestamp in seconds when the key was last used. Newly created
            keys may show the creation time until first use.
          example: 1766102400
        expired_time:
          type: integer
          description: >-
            Unix timestamp in seconds when the key expires. `-1` means no
            expiration.
          example: -1
        remain_quota:
          type: integer
          description: >-
            Remaining quota for this key in CometAPI internal quota units. When
            this reaches `0` and `unlimited_quota` is `false`, model requests
            are rejected as quota exhausted.
          example: 100000
        unlimited_quota:
          type: boolean
          description: Whether the key bypasses remaining-quota checks.
          example: false
        model_limits_enabled:
          type: boolean
          description: >-
            Whether model restrictions are active for this key. When `false`,
            `model_limits` is ignored.
          example: false
        model_limits:
          type: string
          description: >-
            Comma-separated model IDs allowed by this key when
            `model_limits_enabled` is `true`. Empty means no configured model
            list.
          example: ''
        allow_ips:
          type:
            - string
            - 'null'
          description: >-
            Optional IP allowlist stored as one newline-separated string. Each
            entry can be a single IPv4 address, single IPv6 address, IPv4 CIDR,
            or IPv6 CIDR. Example:
            `198.51.100.10\n203.0.113.0/24\n2001:db8::/32`. `null` or `""` means
            IP restrictions are disabled.
          example: |-
            198.51.100.10
            203.0.113.0/24
            2001:db8::/32
        used_quota:
          type: integer
          description: Quota already consumed by this key in CometAPI internal quota units.
          example: 0
        group:
          type: string
          description: >-
            Account group restriction for this key. Empty means no explicit
            group restriction.
          example: ''
        cross_group_retry:
          type: boolean
          description: >-
            Whether cross-group retry is enabled for automatic group routing.
            This is only meaningful when the key uses an auto-routed group such
            as `auto`.
          example: false
      additionalProperties: true
  securitySchemes:
    accessTokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Personal access token copied from CometAPI Console > Personal Settings.
        Send the raw token value; do not prefix it with `Bearer`.

````