## List API Keys

`client.APIKeys.List(ctx, query) (*Cursor[APIKey], error)`

**get** `/v1/api_keys`

List all API keys

### Parameters

- `query APIKeyListParams`

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request

  - `Limit param.Field[int64]`

    Maximum number of items to return

### Returns

- `type APIKey struct{…}`

  API Key response.

  - `ID string`

    API Key ID.

  - `CreatedAt Time`

    When the API Key was created.

  - `ExpiresAt Time`

    When the API Key expires and is no longer valid.

  - `Managed bool`

    Whether this API key is system-managed.

  - `Name string`

    API Key name.

  - `Permissions []APIKeyPermission`

    Scoped permissions for this API key.

    - `Permission APIPermissionLevel`

      Permission level: "read" or "edit".

      - `const APIPermissionLevelRead APIPermissionLevel = "read"`

      - `const APIPermissionLevelEdit APIPermissionLevel = "edit"`

    - `ResourceType APIPermissionResourceType`

      Resource type this permission applies to.

      - `const APIPermissionResourceTypeVM APIPermissionResourceType = "vm"`

      - `const APIPermissionResourceTypeVPC APIPermissionResourceType = "vpc"`

      - `const APIPermissionResourceTypeVolume APIPermissionResourceType = "volume"`

      - `const APIPermissionResourceTypeConnectConnection APIPermissionResourceType = "connect_connection"`

      - `const APIPermissionResourceTypeRPCNodeDedicated APIPermissionResourceType = "rpc_node_dedicated"`

      - `const APIPermissionResourceTypeRPCNodeFlex APIPermissionResourceType = "rpc_node_flex"`

      - `const APIPermissionResourceTypeNKSCluster APIPermissionResourceType = "nks_cluster"`

      - `const APIPermissionResourceTypeNKSNodePool APIPermissionResourceType = "nks_node_pool"`

      - `const APIPermissionResourceTypeProject APIPermissionResourceType = "project"`

      - `const APIPermissionResourceTypeAPIKey APIPermissionResourceType = "api_key"`

      - `const APIPermissionResourceTypeOrganization APIPermissionResourceType = "organization"`

      - `const APIPermissionResourceTypeAuditLog APIPermissionResourceType = "audit_log"`

      - `const APIPermissionResourceTypeUsage APIPermissionResourceType = "usage"`

  - `ProjectIDs []string`

    Project IDs this API key is scoped to.

  - `SourceIPRule SourceIPRuleResponse`

    IP filter rules.

    - `Allowed []string`

      List of IPv4 CIDR addresses to allow.

    - `Blocked []string`

      List of IPv4 CIDR addresses to deny.

  - `Status APIKeyStatus`

    Status of the API Key.

    - `const APIKeyStatusActive APIKeyStatus = "active"`

    - `const APIKeyStatusInactive APIKeyStatus = "inactive"`

    - `const APIKeyStatusExpired APIKeyStatus = "expired"`

  - `Tags []string`

    Tags to attach to the API Key.

  - `UpdatedAt Time`

    When the API Key was updated.

  - `Key string`

    API Key. Only returned on creation.

  - `StartsAt Time`

    When the API Key starts to be valid.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/api_keys"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.APIKeys.List(context.TODO(), api_keys.APIKeyListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "created_at": "2025-01-01T00:00:00Z",
      "expires_at": "2025-01-01T00:00:00Z",
      "managed": false,
      "name": "My API Key",
      "permissions": [
        {
          "permission": "edit",
          "resource_type": "vm"
        }
      ],
      "project_ids": [
        "string"
      ],
      "source_ip_rule": {
        "allowed": [
          "192.168.1.0/24",
          "10.0.0.0/8"
        ],
        "blocked": [
          "192.168.1.100/32"
        ]
      },
      "status": "active",
      "tags": [
        "production",
        "ethereum"
      ],
      "updated_at": "2025-01-01T00:00:00Z",
      "key": "6r17s0jy_b0_RbSofrrNvawFQcaN-VbGtUM7cKCW7_k",
      "starts_at": "2025-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```
