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

# Attach floating IP to VM

> Attach a floating public IP to a virtual machine. Pick **one** of two modes:

## Option A — attach a reserved IP (use `ip_id`)

Pass `ip_id` set to a previously reserved IP (from `POST /api/v1/ips/reserve` or `GET /api/v1/ips?reserved=true`). The IP must:
- belong to the same account
- not be currently attached to another VM
- have `reserved: true`

No new billing — you're already paying for the reserved IP.

## Option B — auto-assign a new IP (use `type`)

Leave `ip_id` empty and pass `type` to allocate a fresh IP from the pool:
- `type: IPv4` (default if omitted)
- `type: IPv6`

A new IP is allocated and billed to your account from the moment of attach. Detach to release it back to the pool.

## Notes

- VM must not already have a public IP of the same family (detach first).
- Optionally pass `security_groups` (UUID array) to apply security groups to the new NIC.


<sub>Updated May 8, 2026</sub>


## OpenAPI

````yaml POST /api/v1/vms/{id}/ip
openapi: 3.0.3
info:
  title: Raff API
  description: >
    REST API for managing cloud infrastructure on Raff.


    ## Authentication

    Most endpoints require authentication via API key. Catalog endpoints under
    `/api/v1/public/` are open and require no authentication.


    ### API Key Authentication

    Include your API key in the `X-API-Key` header:
      ```
      curl -H "X-API-Key: YOUR_API_KEY" https://api.rafftechnologies.com/api/v1/vms
      ```

    ## Catalog

    Use the public catalog endpoints to discover available regions, OS
    templates, and pricing plans before creating resources:

    - `GET /api/v1/public/regions` — list available regions

    - `GET /api/v1/public/templates` — list OS templates (use the `id` as
    `template_id` when creating a VM)

    - `GET /api/v1/public/pricing/vm` — list VM pricing plans (use the `id` as
    `pricing_id` when creating a VM)

    - `GET /api/v1/public/pricing/volume` — volume storage pricing

    - `GET /api/v1/public/pricing/snapshot` — snapshot storage pricing

    - `GET /api/v1/public/pricing/backup` — backup storage pricing

    - `GET /api/v1/public/pricing/ip` — IP address pricing
  version: 1.0.0
  contact:
    name: Raff Technologies
    url: https://rafftechnologies.com
servers:
  - url: https://api.rafftechnologies.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Catalog
    description: >-
      Discover available regions, OS templates, and pricing plans. No
      authentication required.
  - name: Health
    description: Health check endpoints
  - name: Projects
    description: Organize resources into projects for billing and access control
  - name: Virtual Machines
    description: Create, manage, and control virtual machines
  - name: Networking
    description: >-
      Attach and detach VPCs, floating IPs, and security groups to VM network
      interfaces
  - name: Snapshots
    description: Point-in-time copies of VMs and volumes for quick rollback or cloning
  - name: Backups
    description: Scheduled and on-demand VM backups with restore capability
  - name: Backup Schedules
    description: Recurring daily or weekly backup schedules attached to a VM
  - name: SSH Keys
    description: Manage account-level SSH keys for VM provisioning
  - name: Members
    description: Account-level members — invite, list, update role, remove
  - name: Project Members
    description: Members of a specific project — same model as Members but project-scoped
  - name: Roles
    description: Custom roles bundling account or project permissions
  - name: Permissions
    description: List the catalog of permission strings used by roles
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Invitations
    description: Create and cancel email-based invitations to join the account or a project
paths:
  /api/v1/vms/{id}/ip:
    post:
      tags:
        - Networking
      summary: Attach floating IP to VM
      description: >
        Attach a floating public IP to a virtual machine. Pick **one** of two
        modes:


        ## Option A — attach a reserved IP (use `ip_id`)


        Pass `ip_id` set to a previously reserved IP (from `POST
        /api/v1/ips/reserve` or `GET /api/v1/ips?reserved=true`). The IP must:

        - belong to the same account

        - not be currently attached to another VM

        - have `reserved: true`


        No new billing — you're already paying for the reserved IP.


        ## Option B — auto-assign a new IP (use `type`)


        Leave `ip_id` empty and pass `type` to allocate a fresh IP from the
        pool:

        - `type: IPv4` (default if omitted)

        - `type: IPv6`


        A new IP is allocated and billed to your account from the moment of
        attach. Detach to release it back to the pool.


        ## Notes


        - VM must not already have a public IP of the same family (detach
        first).

        - Optionally pass `security_groups` (UUID array) to apply security
        groups to the new NIC.
      operationId: attachVMIP
      parameters:
        - $ref: '#/components/parameters/VMIDPath'
        - $ref: '#/components/parameters/ProjectIDHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachIPRequest'
      responses:
        '200':
          description: IP attached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachIPResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientBalance'
        '403':
          $ref: '#/components/responses/BillingValidationFailed'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    VMIDPath:
      name: id
      in: path
      required: true
      description: VM ID (UUID)
      schema:
        type: string
        format: uuid
    ProjectIDHeader:
      name: X-Project-ID
      in: header
      required: true
      description: >-
        Project ID. Required for all mutating operations (create, delete, power
        actions, resize).
      schema:
        type: string
        format: uuid
  schemas:
    AttachIPRequest:
      type: object
      description: >
        Provide **either** `ip_id` (attach an existing reserved IP) **or**
        `type` (auto-allocate a new IP). Don't combine — `ip_id` takes
        precedence and `type` is ignored when both are sent.
      properties:
        ip_id:
          type: string
          format: uuid
          description: >
            ID of a previously reserved IP. The IP must belong to the same
            account, be reserved, and not already attached to another VM. No new
            billing — you're already paying for the reserved IP.
        type:
          type: string
          enum:
            - IPv4
            - IPv6
          description: >
            IP family to auto-allocate. Used only when `ip_id` is omitted.
            Defaults to `IPv4`. A new IP is allocated from the pool and billed
            to your account from the moment of attach.
        security_groups:
          type: array
          items:
            type: string
            format: uuid
          description: Security group IDs (UUIDs) to apply to the new NIC.
    AttachIPResponse:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          type: object
          properties:
            vm_id:
              type: string
              format: uuid
              description: VM the IP was attached to.
            ip_address:
              type: string
              description: The attached IP address.
            nic_id:
              type: integer
              description: NIC identifier for this attachment. Use it when detaching.
            mac:
              type: string
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    BillingError:
      type: object
      description: >-
        Billing validation error response. Returned when the account is not in
        good standing for paid operations.
      required:
        - error
        - reason
      properties:
        error:
          type: string
          example: Billing validation failed
        message:
          type: string
          example: Payment failed. Please update your payment method.
        reason:
          type: string
          description: >
            Machine-readable reason code:

            - `banned` — account has been suspended

            - `failed` — last payment failed; balance top-up needed

            - `no_billing_customer` — billing has not been set up for this
            account
          enum:
            - banned
            - failed
            - no_billing_customer
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InsufficientBalance:
      description: >
        Account balance is insufficient for this operation. Top up the balance
        and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Payment Required
            message: Insufficient balance for subscription
    BillingValidationFailed:
      description: |
        Billing validation failed. The account is not in good standing.
        Check the `reason` field:
        - `banned` — account suspended
        - `failed` — last payment failed; top up the account balance
        - `no_billing_customer` — billing not set up
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BillingError'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication. Each key is bound to a specific account.

````