# VPC


<style>
  span[class^="pill-"] {
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.6em;
    vertical-align: middle;
    margin-right: 12px;
    font-family: sans-serif;
    font-weight: bold;
    display: inline-block;
    line-height: 1;
  }
  span.pill-GET { background-color: #61affe; }
  span.pill-POST { background-color: #49cc90; }
  span.pill-PUT { background-color: #fca130; }
  span.pill-DELETE { background-color: #f93e3e; }
  span.pill-PATCH { background-color: #50e3c2; }
  span[class^="pill-"]:after {
    content: attr(data-label);
    font-size: 0.9rem;
  }
</style>

[BETA] Configure VPC subnets and attach instances to them

[Read more](https://community.exoscale.com/documentation/compute/)

## <span data-label="POST" class="pill-POST"></span>create-subnet

[BETA] Create a Subnet

```
POST /vpc/{vpc-id}/subnet
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `address-space` | string | **yes** | Subnet address space<br/><br/>Allowed values: `private`. |
| `addressfamily` | string | **yes** | Subnet address family<br/><br/>Allowed values: `inet4`. |
| `name` | string | **yes** | Subnet name<br/><br/>Min length: `1`. Max length: `255`. |
| `description` | string | no | Subnet description<br/><br/>Max length: `4096`. |
| `ipv4-block` | string | no | Subnet ipv4 CIDR |
| `labels` | object | no | Resource labels |

<details>
<summary>Example</summary>

```json
{
  "address-space": "private",
  "addressfamily": "inet4",
  "description": "string",
  "ipv4-block": "string",
  "labels": {},
  "name": "string"
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `create-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.CreateSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.create_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#createSubnet(java.util.UUID,com.exoscale.sdk.model.CreateSubnetRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api create-subnet`

## <span data-label="GET" class="pill-GET"></span>get-subnet

[BETA] Retrieve Subnet details

```
GET /vpc/{vpc-id}/subnet/{id}
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |
| `id` | `path` | Must be a valid UUID. |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `address-space` | string | Subnet address space<br/><br/>Allowed values: `private`. |
| `addressfamily` | string | Subnet address family<br/><br/>Allowed values: `inet4`, `dual`. |
| `created-at` | string | Subnet creation date<br/><br/>ISO 8601 date-time. |
| `description` | string | Subnet description<br/><br/>Max length: `4096`. |
| `id` | string | Subnet ID<br/><br/>Must be a valid UUID. |
| `instances` | array of [Instances](/reference/api/_schemas/subnet/#instances) | Instances attached to the subnet |
| `ipv4-block` | string | Subnet ipv4 CIDR |
| `labels` | object | Resource labels |
| `name` | string | Subnet name<br/><br/>Min length: `1`. Max length: `255`. |

<details>
<summary>Example output</summary>

```json
{
  "address-space": "private",
  "addressfamily": "inet4",
  "created-at": "2024-01-01T12:00:00Z",
  "description": "string",
  "id": "string",
  "instances": [
    {
      "id": "string",
      "ipv4": "string",
      "name": "string"
    }
  ],
  "ipv4-block": "string",
  "labels": {},
  "name": "string"
}
```
</details>


SDK reference for `get-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.GetSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.get_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#getSubnet(java.util.UUID,java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api get-subnet`

## <span data-label="PUT" class="pill-PUT"></span>update-subnet

[BETA] Update a Subnet

```
PUT /vpc/{vpc-id}/subnet/{id}
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |
| `id` | `path` | Must be a valid UUID. |

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | no | Subnet description<br/><br/>Max length: `4096`. |
| `labels` | object | no | Resource labels |
| `name` | string | no | Subnet name<br/><br/>Min length: `1`. Max length: `255`. |

<details>
<summary>Example</summary>

```json
{
  "description": "string",
  "labels": {},
  "name": "string"
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `address-space` | string | Subnet address space<br/><br/>Allowed values: `private`. |
| `addressfamily` | string | Subnet address family<br/><br/>Allowed values: `inet4`, `dual`. |
| `created-at` | string | Subnet creation date<br/><br/>ISO 8601 date-time. |
| `description` | string | Subnet description<br/><br/>Max length: `4096`. |
| `id` | string | Subnet ID<br/><br/>Must be a valid UUID. |
| `instances` | array of [Instances](/reference/api/_schemas/subnet/#instances) | Instances attached to the subnet |
| `ipv4-block` | string | Subnet ipv4 CIDR |
| `labels` | object | Resource labels |
| `name` | string | Subnet name<br/><br/>Min length: `1`. Max length: `255`. |

<details>
<summary>Example output</summary>

```json
{
  "address-space": "private",
  "addressfamily": "inet4",
  "created-at": "2024-01-01T12:00:00Z",
  "description": "string",
  "id": "string",
  "instances": [
    {
      "id": "string",
      "ipv4": "string",
      "name": "string"
    }
  ],
  "ipv4-block": "string",
  "labels": {},
  "name": "string"
}
```
</details>


SDK reference for `update-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.UpdateSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.update_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#updateSubnet(java.util.UUID,java.util.UUID,com.exoscale.sdk.model.UpdateSubnetRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api update-subnet`

## <span data-label="DELETE" class="pill-DELETE"></span>delete-subnet

[BETA] Delete a Subnet

```
DELETE /vpc/{vpc-id}/subnet/{id}
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |
| `id` | `path` | Must be a valid UUID. |

### Responses

Status: `200` - 200

Content-Type: `application/json`


<details>
<summary>Example output</summary>

```json
{}
```
</details>


SDK reference for `delete-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.DeleteSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.delete_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#deleteSubnet(java.util.UUID,java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api delete-subnet`


---

## Other Operations

## <span data-label="PUT" class="pill-PUT"></span>detach-instance-from-subnet

[BETA] Detach a Compute instance from a Subnet

```
PUT /vpc/{vpc-id}/subnet/{subnet-id}/detach
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |
| `subnet-id` | `path` | Must be a valid UUID. |

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `instance` | [Target Instance](/reference/api/_schemas/instance-ref/) | **yes** | Compute instance |

<details>
<summary>Example</summary>

```json
{
  "instance": {
    "id": "string"
  }
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `detach-instance-from-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.DetachInstanceFromSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.detach_instance_from_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#detachInstanceFromSubnet(java.util.UUID,java.util.UUID,com.exoscale.sdk.model.DetachInstanceFromSubnetRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api detach-instance-from-subnet`

## <span data-label="PUT" class="pill-PUT"></span>attach-instance-to-subnet

[BETA] Attach a Compute instance to a Subnet

```
PUT /vpc/{vpc-id}/subnet/{subnet-id}/attach
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |
| `subnet-id` | `path` | Must be a valid UUID. |

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `instance` | [Target Instance](/reference/api/_schemas/instance-ref/) | **yes** | Compute instance |
| `ipv4` | string | no | Instance IPv4<br/><br/>Must be a valid IPv4 address. |

<details>
<summary>Example</summary>

```json
{
  "instance": {
    "id": "string"
  },
  "ipv4": "string"
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `attach-instance-to-subnet`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.AttachInstanceToSubnet) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.attach_instance_to_subnet) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#attachInstanceToSubnet(java.util.UUID,java.util.UUID,com.exoscale.sdk.model.AttachInstanceToSubnetRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api attach-instance-to-subnet`

## <span data-label="GET" class="pill-GET"></span>list-subnets

[BETA] List Subnets

```
GET /vpc/{vpc-id}/subnet
```

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `vpc-id` | `path` | Must be a valid UUID. |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `subnets` | array of [Subnet](/reference/api/_schemas/list-subnet-entry/) |  |

<details>
<summary>Example output</summary>

```json
{
  "subnets": [
    {
      "address-space": "private",
      "addressfamily": "inet4",
      "created-at": "2024-01-01T12:00:00Z",
      "description": "string",
      "id": "string",
      "ipv4-block": "string",
      "labels": {},
      "name": "string"
    }
  ]
}
```
</details>


SDK reference for `list-subnets`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.ListSubnets) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.list_subnets) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#listSubnets(java.util.UUID))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api list-subnets`


