# Networks Actions

## Add a subnet to a Network

Adds a new subnet object to the Network. If you do not specify an ip\_range for the subnet we will automatically pick the first available /24 range for you if possible.

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

long networkId = 3553797;
string ipRange = "192.168.32.0/20";
string networkZone = "eu-central";

Action action = await hetznerCloudClient.NetworkAction.AddSubnetToNetwork(networkId, ipRange, networkZone);
```

## Delete a subnet from a Network

Deletes a single subnet entry from a Network. You cannot delete subnets which still have Servers attached. If you have Servers attached you first need to detach all Servers that use IPs from this subnet before you can delete the subnet.

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

long networkId = 3553797;
string ipRange = "192.168.32.0/20";

Action action = await hetznerCloudClient.NetworkAction.DeleteSubnetFromNetwork(networkId, ipRange);
```

## Change NetworkProtection

Changes the protection configuration of a Network.

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

long networkId = 2446116;
bool protection = true; // True => Enable protection | False => Disable protection
Action action = await hetznerCloudClient.NetworkAction.ChangeProtection(networkId, protection);
```

## Get all Actions for a Network

Returns all Action objects for a Network.

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

long networkId = 100051962;

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

## Get an Action for a Network

Returns a specific Action for a Network.

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

long networkId = 100051962;
long actionId = 1236866267;

Action action = await hetznerCloudClient.NetworkAction.GetAction(networkId, actionId);
```

## Get all Actions

Returns all Action objects.

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

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

## Get an Action

Returns a specific Action.

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

long actionId = 1236866267;

Action action = await hetznerCloudClient.NetworkAction.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/networks/networks-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.
