# Public Cloud › Storage › Block Storage API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 6 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/storage/block-storage.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/storage/block-storage.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/storage/block/volume` — List volumes
- `GET /publicCloud/project/{projectId}/storage/block/volume/{id}` — Get a volume
- `POST /publicCloud/project/{projectId}/storage/block/volume` — Create a volume
- `POST /publicCloud/project/{projectId}/storage/block/volume/{id}/action` — Run an action on a volume
- `DELETE /publicCloud/project/{projectId}/storage/block/volume/{id}` — Delete a volume
- `PUT /publicCloud/project/{projectId}/storage/block/volume/{id}` — Update a volume

## List volumes

`GET /v2/publicCloud/project/{projectId}/storage/block/volume`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#getVolumes

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/get`

Returns the volumes of the project.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
[
  {
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "currentState": {
      "attachedInstances": [
        {
          "id": "00000000-0000-0000-0000-000000000000"
        }
      ],
      "bootable": true,
      "description": "string",
      "encryption": {
        "enabled": true,
        "kms": {
          "domainId": "00000000-0000-0000-0000-000000000000",
          "serviceKeyId": "00000000-0000-0000-0000-000000000000"
        }
      },
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
      "locked": true,
      "name": "string",
      "size": 0,
      "status": "ATTACHING",
      "volumeType": "CLASSIC"
    },
    "currentTasks": [
      {
        "errors": [
          {
            "message": "string"
          }
        ],
        "id": "00000000-0000-0000-0000-000000000000",
        "link": "string",
        "status": "ERROR",
        "type": "string"
      }
    ],
    "id": "00000000-0000-0000-0000-000000000000",
    "resourceStatus": "CREATING",
    "targetSpec": {
      "createFrom": {
        "backupId": "00000000-0000-0000-0000-000000000000",
        "imageId": "00000000-0000-0000-0000-000000000000",
        "snapshotId": "00000000-0000-0000-0000-000000000000"
      },
      "encryption": {
        "enabled": true,
        "kms": {
          "domainId": "00000000-0000-0000-0000-000000000000",
          "serviceKeyId": "00000000-0000-0000-0000-000000000000"
        }
      },
      "location": {
        "availabilityZone": "string",
        "region": "string"
      },
  …
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/storage/block/volume")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/storage/block/volume");

print_r($result);
?>
```

## Get a volume

`GET /v2/publicCloud/project/{projectId}/storage/block/volume/{id}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#getVolume

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/get`

Returns the volume configuration and its current state, including the instances it is attached to.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes | Id |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block | successful operation |
| 404 | object | Error 404 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "attachedInstances": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "bootable": true,
    "description": "string",
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "locked": true,
    "name": "string",
    "size": 0,
    "status": "ATTACHING",
    "volumeType": "CLASSIC"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}");

print_r($result);
?>
```

## Create a volume

`POST /v2/publicCloud/project/{projectId}/storage/block/volume`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#createVolume

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/create`

Creates a volume, blank or from a backup, a snapshot or an image. `volumeType` is required for a blank volume or one created from an image. The source and the encryption can only be set at creation.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.blockStorage.BlockCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | yes | Desired target specification for the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |

```json
{
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block | successful operation |
| 400 | object | Error 400 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "attachedInstances": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "bootable": true,
    "description": "string",
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "locked": true,
    "name": "string",
    "size": 0,
    "status": "ATTACHING",
    "volumeType": "CLASSIC"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.blockStorage.BlockCreation
result = client.post("/v2/publicCloud/project/{projectId}/storage/block/volume",
	targetSpec = None, # Desired target specification for the volume (type: publicCloud.blockStorage.BlockTargetSpec)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.blockStorage.BlockCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/storage/block/volume", array(
	targetSpec => null, // Desired target specification for the volume (type: publicCloud.blockStorage.BlockTargetSpec)
));

print_r($result);
?>
```

## Run an action on a volume

`POST /v2/publicCloud/project/{projectId}/storage/block/volume/{id}/action`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#postVolumeAction

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/runAction`

Runs an action on the volume. The only action available is `RESTORE_FROM_BACKUP`, which restores the volume from the backup given in `parameters.backupId`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes | Id |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.blockStorage.BlockActionRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string |  | Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). |
| `parameters` | publicCloud.blockStorage.BlockActionParameters |  | Parameters for the action |
| `parameters.backupId` | string |  | ID of the backup to restore from (for RESTORE_FROM_BACKUP) |
| `type` | publicCloud.blockStorage.VolumeActionTypeEnum | yes | The action to perform — one of `RESTORE_FROM_BACKUP` |

```json
{
  "checksum": "string",
  "parameters": {
    "backupId": "string"
  },
  "type": "RESTORE_FROM_BACKUP"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block | successful operation |
| 400 | object | Error 400 response |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "attachedInstances": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "bootable": true,
    "description": "string",
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "locked": true,
    "name": "string",
    "size": 0,
    "status": "ATTACHING",
    "volumeType": "CLASSIC"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume/{id}/action" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.blockStorage.BlockActionRequest
result = client.post("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}/action",
	checksum = None, # Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	parameters = None, # Parameters for the action (type: publicCloud.blockStorage.BlockActionParameters, nullable)
	type = None, # The action to perform (type: publicCloud.blockStorage.VolumeActionTypeEnum)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.blockStorage.BlockActionRequest
$result = $ovh->post("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}/action", array(
	checksum => null, // Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	parameters => null, // Parameters for the action (type: publicCloud.blockStorage.BlockActionParameters, nullable)
	type => null, // The action to perform (type: publicCloud.blockStorage.VolumeActionTypeEnum)
));

print_r($result);
?>
```

## Delete a volume

`DELETE /v2/publicCloud/project/{projectId}/storage/block/volume/{id}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#deleteVolume

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/delete`

Deletes the volume. An attached volume cannot be deleted: detach it first.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes | Id |
| `projectId` | path | string | yes | Project ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block | successful operation |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "attachedInstances": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "bootable": true,
    "description": "string",
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "locked": true,
    "name": "string",
    "size": 0,
    "status": "ATTACHING",
    "volumeType": "CLASSIC"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}");

print_r($result);
?>
```

## Update a volume

`PUT /v2/publicCloud/project/{projectId}/storage/block/volume/{id}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/storage/block-storage/#editVolume

**Status:** Stable production version  
**IAM actions:** `publicCloudProject:apiovh:volume/edit`

Replaces the volume's target specification as a whole. The body carries the complete desired state of every field `publicCloud.blockStorage.BlockUpdateTargetSpec` exposes (`name`, `size` and `volumeType`), so read the volume first and restate every value you want to keep: a field left out of `targetSpec` is cleared, not carried over from the stored specification.

The create-only fields `location`, `encryption` and `createFrom` cannot be changed once the volume exists. They are deliberately absent from the update model, and sending one is rejected with a 400.

`name` and `size` are both required. `size` can only grow: restate the volume's current size to keep it, or send a larger value to extend it, because shrinking a volume is not supported. Leaving `size` out, or sending 0, is rejected with a 400. Restate `volumeType` to keep it. Sending a different type triggers an online retype (migration).

The optional `checksum` guards against a lost update: when supplied it must match the volume's current checksum or the request is rejected with a 409 checksum mismatch. Omitting it skips the check and forces the write (last-write-wins).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes | Id |
| `projectId` | path | string | yes | Project ID |

### Request body (required)

Type: `publicCloud.blockStorage.BlockUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string |  | Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). |
| `targetSpec` | publicCloud.blockStorage.BlockUpdateTargetSpec | yes | Desired target specification for the volume |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB. The size can only be increased (extend). Shrinking a volume is not supported. Leaving it out, or sending 0, is rejected with a 400. |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Target volume type. Changing this triggers an online retype (migration). — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |

```json
{
  "checksum": "string",
  "targetSpec": {
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.blockStorage.Block | successful operation |
| 400 | object | Error 400 response |
| 404 | object | Error 404 response |
| 409 | object | Error 409 response |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Computed hash representing the current target specification value |
| `createdAt` | string (date-time) | read-only | Creation date of the volume |
| `currentState` | publicCloud.blockStorage.BlockCurrentState | read-only | Current observed state of the volume from the infrastructure |
| `currentState.attachedInstances` | publicCloud.blockStorage.BlockAttachedInstance[] | read-only | Instances currently attached to this volume |
| `currentState.attachedInstances[].id` | string (uuid) | read-only | Unique identifier of the instance |
| `currentState.bootable` | boolean | read-only | Whether the volume is bootable |
| `currentState.description` | string | read-only | Volume description |
| `currentState.encryption` | publicCloud.blockStorage.BlockEncryption | read-only | Encryption configuration of the volume |
| `currentState.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `currentState.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `currentState.location` | publicCloud.blockStorage.BlockLocation | read-only | Current location |
| `currentState.location.availabilityZone` | string |  | Availability zone within the region |
| `currentState.location.region` | string | yes | Region code |
| `currentState.locked` | boolean | read-only | Whether the volume is locked |
| `currentState.name` | string | read-only | Current volume name |
| `currentState.size` | integer | read-only | Current size of the volume in GB |
| `currentState.status` | publicCloud.blockStorage.VolumeStatusEnum | read-only | OpenStack volume status — one of `ATTACHING`, `AVAILABLE`, `AWAITING_TRANSFER`, `BACKING_UP`, `CREATING`, `DELETING`, `DETACHING`, `DOWNLOADING`, `ERROR`, `ERROR_BACKING_UP`, `ERROR_DELETING`, `ERROR_EXTENDING`, … |
| `currentState.volumeType` | publicCloud.blockStorage.VolumeTypeEnum | read-only | Current volume type — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `currentTasks` | common.CurrentTask[] | read-only | Ongoing asynchronous tasks related to the volume |
| `currentTasks[].errors` | common.TaskError[] | read-only | Errors that occurred on the task |
| `currentTasks[].errors[].message` | string | read-only | Error description |
| `currentTasks[].id` | string (uuid) | read-only | Identifier of the current task |
| `currentTasks[].link` | string | read-only | Link to the task details |
| `currentTasks[].status` | common.CurrentTaskStatusEnum | read-only | Current global status of the current task — one of `ERROR`, `PENDING`, `RUNNING`, `SCHEDULED`, `WAITING_USER_INPUT` |
| `currentTasks[].type` | string | read-only | Type of the current task |
| `id` | string (uuid) | read-only | Unique identifier of the volume |
| `resourceStatus` | common.ResourceStatusEnum | read-only | Volume readiness in the system — one of `CREATING`, `CREATION_PLANNED`, `DELETING`, `ERROR`, `OUT_OF_SYNC`, `READY`, `SUSPENDED`, `UNKNOWN`, `UPDATING` |
| `targetSpec` | publicCloud.blockStorage.BlockTargetSpec | read-only | Last target specification of the volume |
| `targetSpec.createFrom` | publicCloud.blockStorage.BlockCreateFrom |  | Optional source to create the volume from (backup or snapshot). Immutable after creation. |
| `targetSpec.createFrom.backupId` | string (uuid) |  | UUID of a backup to restore from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.createFrom.imageId` | string (uuid) |  | UUID of a Glance image to create the volume from. The resulting volume will be bootable. `volumeType` is required when using this field. |
| `targetSpec.createFrom.snapshotId` | string (uuid) |  | UUID of a snapshot to create from. `volumeType` and `encryption` may be specified explicitly. When omitted, they are inferred from the source volume when known. |
| `targetSpec.encryption` | publicCloud.blockStorage.BlockEncryption |  | Encryption configuration for the volume. When omitted on a create from a backup or snapshot, the source volume's encryption is used when known. |
| `targetSpec.encryption.enabled` | boolean | yes | Whether the volume is encrypted at rest with LUKS |
| `targetSpec.encryption.kms` | publicCloud.blockStorage.BlockEncryptionKms |  | Customer-managed OVH Key Management Service (OKMS) key used to encrypt the volume. When omitted and enabled is true, the volume is encrypted with an OVH-managed key (OMK). Ignored (must be absent) when enabled is false. Immutable after creation. |
| `targetSpec.location` | publicCloud.blockStorage.BlockLocation | yes | Target location |
| `targetSpec.location.availabilityZone` | string |  | Availability zone within the region |
| `targetSpec.location.region` | string | yes | Region code |
| `targetSpec.name` | string | yes | Desired volume name |
| `targetSpec.size` | integer | yes | Size of the volume in GB |
| `targetSpec.volumeType` | publicCloud.blockStorage.VolumeTypeEnum |  | Type of the volume. Required when creating a blank volume or from an image. Optional when creating from a backup or snapshot: an explicit value is honored, and when omitted the type is inferred from the source volume when known. — one of `CLASSIC`, `HIGH_SPEED`, `HIGH_SPEED_GEN2` |
| `updatedAt` | string (date-time) | read-only | Last update date of the volume |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "currentState": {
    "attachedInstances": [
      {
        "id": "00000000-0000-0000-0000-000000000000"
      }
    ],
    "bootable": true,
    "description": "string",
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "locked": true,
    "name": "string",
    "size": 0,
    "status": "ATTACHING",
    "volumeType": "CLASSIC"
  },
  "currentTasks": [
    {
      "errors": [
        {
          "message": "string"
        }
      ],
      "id": "00000000-0000-0000-0000-000000000000",
      "link": "string",
      "status": "ERROR",
      "type": "string"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "resourceStatus": "CREATING",
  "targetSpec": {
    "createFrom": {
      "backupId": "00000000-0000-0000-0000-000000000000",
      "imageId": "00000000-0000-0000-0000-000000000000",
      "snapshotId": "00000000-0000-0000-0000-000000000000"
    },
    "encryption": {
      "enabled": true,
      "kms": {
        "domainId": "00000000-0000-0000-0000-000000000000",
        "serviceKeyId": "00000000-0000-0000-0000-000000000000"
      }
    },
    "location": {
      "availabilityZone": "string",
      "region": "string"
    },
    "name": "string",
    "size": 0,
    "volumeType": "CLASSIC"
  },
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/storage/block/volume/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.blockStorage.BlockUpdate
result = client.put("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}",
	checksum = None, # Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	targetSpec = None, # Desired target specification for the volume (type: publicCloud.blockStorage.BlockUpdateTargetSpec)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.blockStorage.BlockUpdate
$result = $ovh->put("/v2/publicCloud/project/{projectId}/storage/block/volume/{id}", array(
	checksum => null, // Optional concurrency-control checksum. When supplied, it must match the resource's current checksum or the request is rejected with a 409 checksum-mismatch conflict. When omitted or empty, the concurrency check is skipped and the write is forced (last-write-wins). (type: string, nullable)
	targetSpec => null, // Desired target specification for the volume (type: publicCloud.blockStorage.BlockUpdateTargetSpec)
));

print_r($result);
?>
```
