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

# Elencare le chiavi API

> Usa CometAPI GET /api/token/ per elencare le chiavi API dell'account autenticato con paginazione.

Usa questo endpoint per elencare le chiavi API che appartengono all'account CometAPI autenticato. Le chiavi più recenti vengono restituite per prime.

<Note>
  Genera un personal access token in [Console → Personal Settings](https://www.cometapi.com/console/personal), quindi invialo come valore raw dell'header `Authorization`. Non anteporre `Bearer`.
</Note>

## Paginazione

| Query parameter | Description                                                               |
| --------------- | ------------------------------------------------------------------------- |
| `p`             | Numero di pagina. Il valore predefinito è `1`.                            |
| `page_size`     | Elementi per pagina. I valori superiori a `100` vengono limitati a `100`. |

## Stato della chiave API

| Status | Meaning      |
| ------ | ------------ |
| `1`    | Abilitata    |
| `2`    | Disabilitata |
| `3`    | Scaduta      |
| `4`    | Esaurita     |

## Campi restituiti

| Field                  | Type           | Description                                                                                                                                                                                                       |
| ---------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | integer        | ID numerico della chiave API. Usa questo valore con [Ottenere una singola chiave API](./get-api-key), [Aggiornare una chiave API](./update-api-key) e [Eliminare una chiave API](./delete-api-key).               |
| `key`                  | string         | Valore della chiave API restituito dalla management API. Trattalo come un segreto e usalo come `Authorization: Bearer $COMETAPI_KEY` per le richieste ai model.                                                   |
| `status`               | integer        | Stato operativo. Solo `1` indica che la chiave è abilitata per le richieste ai model.                                                                                                                             |
| `name`                 | string         | Nome visualizzato della chiave leggibile dall'utente.                                                                                                                                                             |
| `created_time`         | integer        | Timestamp Unix in secondi che indica quando è stata creata la chiave.                                                                                                                                             |
| `accessed_time`        | integer        | Timestamp Unix in secondi che indica quando la chiave è stata usata l'ultima volta.                                                                                                                               |
| `expired_time`         | integer        | Timestamp Unix in secondi che indica quando la chiave scade. `-1` significa nessuna scadenza.                                                                                                                     |
| `remain_quota`         | integer        | Quota rimanente nelle unità di quota interne di CometAPI.                                                                                                                                                         |
| `used_quota`           | integer        | Quota già consumata da questa chiave nelle unità di quota interne di CometAPI.                                                                                                                                    |
| `unlimited_quota`      | boolean        | Indica se la chiave ignora i controlli sulla quota residua.                                                                                                                                                       |
| `model_limits_enabled` | boolean        | Indica se le restrizioni sui model sono attive per questa chiave.                                                                                                                                                 |
| `model_limits`         | string         | model ID separati da virgole consentiti da questa chiave quando `model_limits_enabled` è `true`. Vuoto significa che non è configurato alcun elenco di model.                                                     |
| `allow_ips`            | string or null | Allowlist di IP come singola stringa separata da newline. Ogni voce può essere un singolo indirizzo IPv4, un singolo indirizzo IPv6, un CIDR IPv4 o un CIDR IPv6. `null` o `""` significa nessuna restrizione IP. |
| `group`                | string         | Restrizione del gruppo dell'account. Vuoto significa nessuna restrizione esplicita del gruppo.                                                                                                                    |
| `cross_group_retry`    | boolean        | Indica se il tentativo tra gruppi è abilitato per il routing automatico del gruppo.                                                                                                                               |


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

````