> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vmarea.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Attach a VM to a private network

> Adds a NIC on the VM tied to this network's VNet and reserves a DHCP-assigned private IP. VM and network must reside in the same region.



## OpenAPI

````yaml https://api.vmarea.com/api/public/v1/openapi.json post /api/public/v1/networks/{id}/attachments
openapi: 3.1.0
info:
  title: VMArea Public API
  version: 1.0.0
  description: >-
    The VMArea Public API lets you provision and manage VMs, networks,
    firewalls, SSH keys, backups, and webhooks programmatically. Authenticate
    every request with an API token (`x-api-key` header) created in the
    dashboard. Tokens carry coarse scopes (e.g. `vms:write`); endpoints reject
    calls that lack the scope they require.
  contact:
    name: VMArea Support
    url: https://vmarea.com/support
servers:
  - url: https://api.vmarea.com/api/v1
    description: Production
security:
  - ApiKey: []
paths:
  /api/public/v1/networks/{id}/attachments:
    post:
      tags:
        - Networks
      summary: Attach a VM to a private network
      description: >-
        Adds a NIC on the VM tied to this network's VNet and reserves a
        DHCP-assigned private IP. VM and network must reside in the same region.
      operationId: attachVmToNetwork
      parameters:
        - schema:
            type: string
          in: path
          name: id
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vmId:
                  type: string
                  pattern: ^[cC][^\s-]{8,}$
                privateIp:
                  type: string
                  pattern: >-
                    ^(?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d?\d)$
              required:
                - vmId
              additionalProperties: false
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      vmId:
                        type: string
                      networkId:
                        type: string
                      privateIp:
                        type: string
                      netInterface:
                        type: string
                      attachedAt:
                        type: string
                        format: date-time
                      vm:
                        type: object
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          hostname:
                            type: string
                            nullable: true
                          status:
                            type: string
                        required:
                          - id
                          - name
                          - hostname
                          - status
                        additionalProperties: false
                    required:
                      - id
                      - vmId
                      - networkId
                      - privateIp
                      - netInterface
                      - attachedAt
                    additionalProperties: false
                required:
                  - success
                  - data
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '409':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '422':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
        '502':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: string
                required:
                  - success
                  - error
                additionalProperties: false
      security:
        - ApiKey: []
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      name: x-api-key
      in: header
      description: >-
        Long-lived API token created at
        https://vmarea.com/dashboard/settings/api-keys. Tokens are
        scope-restricted; this spec lists the scope each endpoint requires.

````