# API Keys

## Create API Key

`$ nirvana api-keys create`

**post** `/v1/api_keys`

Create a new API key

### Parameters

- `--expires-at: string`

  When the API Key expires and is no longer valid.

- `--name: string`

  API Key name.

- `--permission: array of object { permission, resource_type }`

  Scoped permissions for this API key. At least one is required.

- `--project-id: array of string`

  Project IDs this API key is scoped to. At least one is required.

- `--source-ip-rule: optional object { allowed, blocked }`

  IP filter rules.

- `--starts-at: optional string`

  When the API Key starts to be valid.

- `--tag: optional array of string`

  Tags to attach to the API Key.

### Returns

- `api_key: object { id, created_at, expires_at, 10 more }`

  API Key response.

  - `id: string`

    API Key ID.

  - `created_at: string`

    When the API Key was created.

  - `expires_at: string`

    When the API Key expires and is no longer valid.

  - `managed: boolean`

    Whether this API key is system-managed.

  - `name: string`

    API Key name.

  - `permissions: array of APIKeyPermission`

    Scoped permissions for this API key.

    - `permission: "read" or "edit"`

      Permission level: "read" or "edit".

      - `"read"`

      - `"edit"`

    - `resource_type: "vm" or "vpc" or "volume" or 10 more`

      Resource type this permission applies to.

      - `"vm"`

      - `"vpc"`

      - `"volume"`

      - `"connect_connection"`

      - `"rpc_node_dedicated"`

      - `"rpc_node_flex"`

      - `"nks_cluster"`

      - `"nks_node_pool"`

      - `"project"`

      - `"api_key"`

      - `"organization"`

      - `"audit_log"`

      - `"usage"`

  - `project_ids: array of string`

    Project IDs this API key is scoped to.

  - `source_ip_rule: object { allowed, blocked }`

    IP filter rules.

    - `allowed: array of string`

      List of IPv4 CIDR addresses to allow.

    - `blocked: array of string`

      List of IPv4 CIDR addresses to deny.

  - `status: "active" or "inactive" or "expired"`

    Status of the API Key.

    - `"active"`

    - `"inactive"`

    - `"expired"`

  - `tags: array of string`

    Tags to attach to the API Key.

  - `updated_at: string`

    When the API Key was updated.

  - `key: optional string`

    API Key. Only returned on creation.

  - `starts_at: optional string`

    When the API Key starts to be valid.

### Example

```cli
nirvana api-keys create \
  --api-key 'My API Key' \
  --expires-at "'2025-12-31T23:59:59Z'" \
  --name 'My API Key' \
  --permission '{permission: edit, resource_type: vm}' \
  --project-id 123e4567-e89b-12d3-a456-426614174000 \
  --project-id 123e4567-e89b-12d3-a456-426614174001
```

#### Response

```json
{
  "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"
}
```

## Get API Key Details

`$ nirvana api-keys get`

**get** `/v1/api_keys/{api_key_id}`

Get details about an API key

### Parameters

- `--api-key-id: string`

  API Key ID

### Returns

- `api_key: object { id, created_at, expires_at, 10 more }`

  API Key response.

  - `id: string`

    API Key ID.

  - `created_at: string`

    When the API Key was created.

  - `expires_at: string`

    When the API Key expires and is no longer valid.

  - `managed: boolean`

    Whether this API key is system-managed.

  - `name: string`

    API Key name.

  - `permissions: array of APIKeyPermission`

    Scoped permissions for this API key.

    - `permission: "read" or "edit"`

      Permission level: "read" or "edit".

      - `"read"`

      - `"edit"`

    - `resource_type: "vm" or "vpc" or "volume" or 10 more`

      Resource type this permission applies to.

      - `"vm"`

      - `"vpc"`

      - `"volume"`

      - `"connect_connection"`

      - `"rpc_node_dedicated"`

      - `"rpc_node_flex"`

      - `"nks_cluster"`

      - `"nks_node_pool"`

      - `"project"`

      - `"api_key"`

      - `"organization"`

      - `"audit_log"`

      - `"usage"`

  - `project_ids: array of string`

    Project IDs this API key is scoped to.

  - `source_ip_rule: object { allowed, blocked }`

    IP filter rules.

    - `allowed: array of string`

      List of IPv4 CIDR addresses to allow.

    - `blocked: array of string`

      List of IPv4 CIDR addresses to deny.

  - `status: "active" or "inactive" or "expired"`

    Status of the API Key.

    - `"active"`

    - `"inactive"`

    - `"expired"`

  - `tags: array of string`

    Tags to attach to the API Key.

  - `updated_at: string`

    When the API Key was updated.

  - `key: optional string`

    API Key. Only returned on creation.

  - `starts_at: optional string`

    When the API Key starts to be valid.

### Example

```cli
nirvana api-keys get \
  --api-key 'My API Key' \
  --api-key-id api_key_id
```

#### Response

```json
{
  "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"
}
```

## Update API Key

`$ nirvana api-keys update`

**patch** `/v1/api_keys/{api_key_id}`

Update an existing API key

### Parameters

- `--api-key-id: string`

  API Key ID

- `--name: optional string`

  API Key name.

- `--permission: optional array of object { permission, resource_type }`

  Scoped permissions for this API key. When provided, replaces the entire set. At least one is required.

- `--project-id: optional array of string`

  Project IDs this API key is scoped to. When provided, replaces the entire set. At least one is required.

- `--source-ip-rule: optional object { allowed, blocked }`

  IP filter rules.

- `--tag: optional array of string`

  Tags to attach to the API Key.

### Returns

- `api_key: object { id, created_at, expires_at, 10 more }`

  API Key response.

  - `id: string`

    API Key ID.

  - `created_at: string`

    When the API Key was created.

  - `expires_at: string`

    When the API Key expires and is no longer valid.

  - `managed: boolean`

    Whether this API key is system-managed.

  - `name: string`

    API Key name.

  - `permissions: array of APIKeyPermission`

    Scoped permissions for this API key.

    - `permission: "read" or "edit"`

      Permission level: "read" or "edit".

      - `"read"`

      - `"edit"`

    - `resource_type: "vm" or "vpc" or "volume" or 10 more`

      Resource type this permission applies to.

      - `"vm"`

      - `"vpc"`

      - `"volume"`

      - `"connect_connection"`

      - `"rpc_node_dedicated"`

      - `"rpc_node_flex"`

      - `"nks_cluster"`

      - `"nks_node_pool"`

      - `"project"`

      - `"api_key"`

      - `"organization"`

      - `"audit_log"`

      - `"usage"`

  - `project_ids: array of string`

    Project IDs this API key is scoped to.

  - `source_ip_rule: object { allowed, blocked }`

    IP filter rules.

    - `allowed: array of string`

      List of IPv4 CIDR addresses to allow.

    - `blocked: array of string`

      List of IPv4 CIDR addresses to deny.

  - `status: "active" or "inactive" or "expired"`

    Status of the API Key.

    - `"active"`

    - `"inactive"`

    - `"expired"`

  - `tags: array of string`

    Tags to attach to the API Key.

  - `updated_at: string`

    When the API Key was updated.

  - `key: optional string`

    API Key. Only returned on creation.

  - `starts_at: optional string`

    When the API Key starts to be valid.

### Example

```cli
nirvana api-keys update \
  --api-key 'My API Key' \
  --api-key-id api_key_id
```

#### Response

```json
{
  "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"
}
```

## Delete API Key

`$ nirvana api-keys delete`

**delete** `/v1/api_keys/{api_key_id}`

Delete an API key

### Parameters

- `--api-key-id: string`

  API Key ID

### Example

```cli
nirvana api-keys delete \
  --api-key 'My API Key' \
  --api-key-id api_key_id
```

## List API Keys

`$ nirvana api-keys list`

**get** `/v1/api_keys`

List all API keys

### Parameters

- `--cursor: optional string`

  Pagination cursor returned by a previous request

- `--limit: optional number`

  Maximum number of items to return

### Returns

- `api_key_list: object { items, pagination }`

  - `items: array of APIKey`

    - `id: string`

      API Key ID.

    - `created_at: string`

      When the API Key was created.

    - `expires_at: string`

      When the API Key expires and is no longer valid.

    - `managed: boolean`

      Whether this API key is system-managed.

    - `name: string`

      API Key name.

    - `permissions: array of APIKeyPermission`

      Scoped permissions for this API key.

      - `permission: "read" or "edit"`

        Permission level: "read" or "edit".

        - `"read"`

        - `"edit"`

      - `resource_type: "vm" or "vpc" or "volume" or 10 more`

        Resource type this permission applies to.

        - `"vm"`

        - `"vpc"`

        - `"volume"`

        - `"connect_connection"`

        - `"rpc_node_dedicated"`

        - `"rpc_node_flex"`

        - `"nks_cluster"`

        - `"nks_node_pool"`

        - `"project"`

        - `"api_key"`

        - `"organization"`

        - `"audit_log"`

        - `"usage"`

    - `project_ids: array of string`

      Project IDs this API key is scoped to.

    - `source_ip_rule: object { allowed, blocked }`

      IP filter rules.

      - `allowed: array of string`

        List of IPv4 CIDR addresses to allow.

      - `blocked: array of string`

        List of IPv4 CIDR addresses to deny.

    - `status: "active" or "inactive" or "expired"`

      Status of the API Key.

      - `"active"`

      - `"inactive"`

      - `"expired"`

    - `tags: array of string`

      Tags to attach to the API Key.

    - `updated_at: string`

      When the API Key was updated.

    - `key: optional string`

      API Key. Only returned on creation.

    - `starts_at: optional string`

      When the API Key starts to be valid.

  - `pagination: object { next_cursor, previous_cursor, total_count }`

    Pagination response details.

    - `next_cursor: string`

    - `previous_cursor: string`

    - `total_count: number`

### Example

```cli
nirvana api-keys list \
  --api-key 'My API Key'
```

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

## Domain Types

### API Key

- `api_key: object { id, created_at, expires_at, 10 more }`

  API Key response.

  - `id: string`

    API Key ID.

  - `created_at: string`

    When the API Key was created.

  - `expires_at: string`

    When the API Key expires and is no longer valid.

  - `managed: boolean`

    Whether this API key is system-managed.

  - `name: string`

    API Key name.

  - `permissions: array of APIKeyPermission`

    Scoped permissions for this API key.

    - `permission: "read" or "edit"`

      Permission level: "read" or "edit".

      - `"read"`

      - `"edit"`

    - `resource_type: "vm" or "vpc" or "volume" or 10 more`

      Resource type this permission applies to.

      - `"vm"`

      - `"vpc"`

      - `"volume"`

      - `"connect_connection"`

      - `"rpc_node_dedicated"`

      - `"rpc_node_flex"`

      - `"nks_cluster"`

      - `"nks_node_pool"`

      - `"project"`

      - `"api_key"`

      - `"organization"`

      - `"audit_log"`

      - `"usage"`

  - `project_ids: array of string`

    Project IDs this API key is scoped to.

  - `source_ip_rule: object { allowed, blocked }`

    IP filter rules.

    - `allowed: array of string`

      List of IPv4 CIDR addresses to allow.

    - `blocked: array of string`

      List of IPv4 CIDR addresses to deny.

  - `status: "active" or "inactive" or "expired"`

    Status of the API Key.

    - `"active"`

    - `"inactive"`

    - `"expired"`

  - `tags: array of string`

    Tags to attach to the API Key.

  - `updated_at: string`

    When the API Key was updated.

  - `key: optional string`

    API Key. Only returned on creation.

  - `starts_at: optional string`

    When the API Key starts to be valid.

### API Key List

- `api_key_list: object { items, pagination }`

  - `items: array of APIKey`

    - `id: string`

      API Key ID.

    - `created_at: string`

      When the API Key was created.

    - `expires_at: string`

      When the API Key expires and is no longer valid.

    - `managed: boolean`

      Whether this API key is system-managed.

    - `name: string`

      API Key name.

    - `permissions: array of APIKeyPermission`

      Scoped permissions for this API key.

      - `permission: "read" or "edit"`

        Permission level: "read" or "edit".

        - `"read"`

        - `"edit"`

      - `resource_type: "vm" or "vpc" or "volume" or 10 more`

        Resource type this permission applies to.

        - `"vm"`

        - `"vpc"`

        - `"volume"`

        - `"connect_connection"`

        - `"rpc_node_dedicated"`

        - `"rpc_node_flex"`

        - `"nks_cluster"`

        - `"nks_node_pool"`

        - `"project"`

        - `"api_key"`

        - `"organization"`

        - `"audit_log"`

        - `"usage"`

    - `project_ids: array of string`

      Project IDs this API key is scoped to.

    - `source_ip_rule: object { allowed, blocked }`

      IP filter rules.

      - `allowed: array of string`

        List of IPv4 CIDR addresses to allow.

      - `blocked: array of string`

        List of IPv4 CIDR addresses to deny.

    - `status: "active" or "inactive" or "expired"`

      Status of the API Key.

      - `"active"`

      - `"inactive"`

      - `"expired"`

    - `tags: array of string`

      Tags to attach to the API Key.

    - `updated_at: string`

      When the API Key was updated.

    - `key: optional string`

      API Key. Only returned on creation.

    - `starts_at: optional string`

      When the API Key starts to be valid.

  - `pagination: object { next_cursor, previous_cursor, total_count }`

    Pagination response details.

    - `next_cursor: string`

    - `previous_cursor: string`

    - `total_count: number`

### API Key Permission

- `api_key_permission: object { permission, resource_type }`

  API Key permission.

  - `permission: "read" or "edit"`

    Permission level: "read" or "edit".

    - `"read"`

    - `"edit"`

  - `resource_type: "vm" or "vpc" or "volume" or 10 more`

    Resource type this permission applies to.

    - `"vm"`

    - `"vpc"`

    - `"volume"`

    - `"connect_connection"`

    - `"rpc_node_dedicated"`

    - `"rpc_node_flex"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

    - `"project"`

    - `"api_key"`

    - `"organization"`

    - `"audit_log"`

    - `"usage"`

### API Permission Level

- `api_permission_level: "read" or "edit"`

  Permission level: "read" or "edit".

  - `"read"`

  - `"edit"`

### API Permission Resource Type

- `api_permission_resource_type: "vm" or "vpc" or "volume" or 10 more`

  Resource type this permission applies to.

  - `"vm"`

  - `"vpc"`

  - `"volume"`

  - `"connect_connection"`

  - `"rpc_node_dedicated"`

  - `"rpc_node_flex"`

  - `"nks_cluster"`

  - `"nks_node_pool"`

  - `"project"`

  - `"api_key"`

  - `"organization"`

  - `"audit_log"`

  - `"usage"`
