---
title: "Attach a network to a VM"
method: POST
path: "/virtual_machines/{virtual_machine_id}/network_attachments"
tags: ["Virtual machines"]
---

# Attach a network to a VM

`POST /virtual_machines/{virtual_machine_id}/network_attachments`

Attaches a virtual network (VLAN) to a Virtual Machine. Work runs asynchronously and returns 202 Accepted.

## Path parameters

- `virtual_machine_id` string, required

## Request body

- VirtualMachineNetworkAttachmentCreatePayload
  - `data` object, required
    - `type` 'virtual_machine_network_attachments', required
    - `attributes` object, required
      - `virtual_network_id` string, required — VLAN id_hash to attach (e.g. vlan_abc123).
      - `address` string — Optional static IPv4 address with prefix (e.g. 10.0.0.5/24) for the NIC inside the guest. When omitted the NIC is configured for DHCP without a default route. Applying the regenerated network configuration requires running `sudo cloud-init clean --logs --reboot` inside the guest. Warning: that command makes cloud-init treat the next boot as a first boot — it re-runs the instance user-data (e.g. runcmd scripts) and regenerates the SSH host keys, so SSH clients will see a host-key changed warning.

## Response `202`

Accepted

## Other responses

- `403` — Forbidden
- `404` — Not Found
- `422` — Unprocessable Entity

## Changes

- **2026-08-26** `9a52f6ec0b3d` — 2 info
  - added the new optional request property `data/attributes/address` (media type: application/json)
  - added the new optional request property `data/attributes/address` (media type: application/vnd.api+json)

[Change history](https://skmtc.dev/latitude/apis/latitude-sh-api/changes/virtual_machines/:virtual_machine_id/network_attachments/post.md)

---

[API](https://skmtc.dev/latitude/apis/latitude-sh-api.md) · [All operations](https://skmtc.dev/latitude/apis/latitude-sh-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/latitude/latitude-sh-api/revisions/c80535f26dd7/schema)
