# Volumes Actions

## Attach Volume to a Server

Attaches a Volume to a Server. Works only if the Server is in the same Location as the Volume.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;
long serverId = 38911232;

Action action = await hetznerCloudClient.VolumeAction.Attach(volumeId, serverId);
```

## Detach Volume

Detaches a Volume from the Server it’s attached to. You may attach it to a Server again at a later time.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;

Action action = await hetznerCloudClient.VolumeAction.Detach(volumeId);
```

## Resize Volume

Changes the size of a Volume. Note that downsizing a Volume is not possible.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;
long size = 101; // Volume size in GB
Action action = await hetznerCloudClient.VolumeAction.Resize(volumeId, size);
```

## Change Volume Protection

Changes the protection configuration of a Volume.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;
bool protection = true; // True => Enable protection | False => Disable protection
Action action = await hetznerCloudClient.VolumeAction.ChangeProtection(volumeId, protection);
```

## Get all Actions for a Volume

Returns all Action objects for a Volume.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;

List<Action> list = await hetznerCloudClient.VolumeAction.GetAllActions(volumeId);
```

## Get an Action for a Volume

Returns a specific Action for a Volume.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long volumeId = 100051962;
long actionId = 1236866267;

Action action = await hetznerCloudClient.VolumeAction.GetAction(volumeId, actionId);
```

## Get all Actions

Returns all Action objects.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

List<Action> list = await hetznerCloudClient.VolumeAction.GetAllActions();
```

## Get an Action

Returns a specific Action.

```csharp
HetznerCloudClient hetznerCloudClient = new HetznerCloudClient("ApiKey");

long actionId = 1236866267;

Action action = await hetznerCloudClient.VolumeAction.GetAction(actionId);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hetzner.ljchuello.com/functions-and-methods/volumes/volumes-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
