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

# Attach interface

> Attach interface to instance



## OpenAPI

````yaml /api-reference/services_documented/cloud_api.yaml post /cloud/v1/instances/{project_id}/{region_id}/{instance_id}/attach_interface
openapi: 3.1.0
info:
  title: Gcore OpenAPI – Cloud API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-14T07:00:22.640261+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: Bare Metal
    x-displayName: Bare Metal
  - name: Container as a Service
    x-displayName: Container as a Service
  - name: Cost Reports
    x-displayName: Cost Reports
  - name: DDoS Protection
    x-displayName: DDoS Protection
  - name: Everywhere Inference
    x-displayName: Everywhere Inference
  - name: Everywhere Inference Apps
    x-displayName: Everywhere Inference Apps
  - name: File Shares
    x-displayName: File Shares
  - name: Floating IPs
    x-displayName: Floating IPs
  - name: Function as a Service
    x-displayName: Function as a Service
  - name: GPU Bare Metal
    x-displayName: GPU Bare Metal
  - name: GPU Virtual
    x-displayName: GPU Virtual
  - name: IP Ranges
    x-displayName: IP Ranges
  - name: Images
    x-displayName: Images
  - name: Instances
    x-displayName: Instances
  - name: Load Balancers
    x-displayName: Load Balancers
  - name: Logging
    x-displayName: Logging
  - name: Managed Kubernetes
    x-displayName: Managed Kubernetes
  - name: Managed PostgreSQL
    x-displayName: Managed PostgreSQL
  - name: Networks
    x-displayName: Networks
  - name: Placement Groups
    x-displayName: Placement Groups
  - name: Projects
    x-displayName: Projects
  - name: Quotas
    x-displayName: Quotas
  - name: Regions
    x-displayName: Regions
  - name: Registry
    x-displayName: Registry
  - name: Reservations
    x-displayName: Reservations
  - name: Reserved IPs
    x-displayName: Reserved IPs
  - name: Routers
    x-displayName: Routers
  - name: SSH Keys
    x-displayName: SSH Keys
  - name: Secrets
    x-displayName: Secrets
  - name: Security Groups
    x-displayName: Security Groups
  - name: Snapshot Schedules
    x-displayName: Snapshot Schedules
  - name: Snapshots
    x-displayName: Snapshots
  - name: Tasks
    x-displayName: Tasks
  - name: User Actions
    x-displayName: User Actions
  - name: User Role Assignments
    x-displayName: User Role Assignments
  - name: Volumes
    x-displayName: Volumes
paths:
  /cloud/v1/instances/{project_id}/{region_id}/{instance_id}/attach_interface:
    post:
      tags:
        - Instances
      summary: Attach interface
      description: Attach interface to instance
      operationId: AttachInterfaceHandler.post
      parameters:
        - in: path
          name: project_id
          required: true
          description: Project ID
          schema:
            type: integer
        - in: path
          name: region_id
          required: true
          description: Region ID
          schema:
            type: integer
        - in: path
          name: instance_id
          required: true
          description: Instance ID
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: >-
                    #/components/schemas/NewInterfaceExternalExtendSchemaWithDdos
                - $ref: '#/components/schemas/NewInterfaceSpecificSubnetSchema'
                - $ref: '#/components/schemas/NewInterfaceAnySubnetSchema'
                - $ref: '#/components/schemas/NewInterfaceReservedFixedIpSchema'
              discriminator:
                propertyName: type
                mapping:
                  external:
                    $ref: >-
                      #/components/schemas/NewInterfaceExternalExtendSchemaWithDdos
                  subnet:
                    $ref: '#/components/schemas/NewInterfaceSpecificSubnetSchema'
                  any_subnet:
                    $ref: '#/components/schemas/NewInterfaceAnySubnetSchema'
                  reserved_fixed_ip:
                    $ref: '#/components/schemas/NewInterfaceReservedFixedIpSchema'
      responses:
        '200':
          description: Created task
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskIDsSerializer'
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from gcore import Gcore

            client = Gcore(
                api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
            )
            task_id_list = client.cloud.instances.interfaces.attach(
                instance_id="instance_id",
                project_id=0,
                region_id=0,
            )
            print(task_id_list.tasks)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/G-Core/gcore-go\"\n\t\"github.com/G-Core/gcore-go/cloud\"\n\t\"github.com/G-Core/gcore-go/option\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttaskIDList, err := client.Cloud.Instances.Interfaces.Attach(\n\t\tcontext.TODO(),\n\t\t\"instance_id\",\n\t\tcloud.InstanceInterfaceAttachParams{\n\t\t\tProjectID: gcore.Int(0),\n\t\t\tRegionID:  gcore.Int(0),\n\t\t\tOfNewInterfaceExternalExtendSchemaWithDDOS: &cloud.InstanceInterfaceAttachParamsBodyNewInterfaceExternalExtendSchemaWithDDOS{\n\t\t\t\tType: gcore.String(\"external\"),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", taskIDList.Tasks)\n}\n"
components:
  schemas:
    NewInterfaceExternalExtendSchemaWithDdos:
      type: object
      properties:
        ddos_profile:
          type:
            - 'null'
            - object
          description: Advanced DDoS protection.
          allOf:
            - $ref: '#/components/schemas/DeprecatedCreateDdosProfileSchema'
        interface_name:
          type: string
          maxLength: 37
          description: Interface name
        ip_family:
          type: string
          enum:
            - dual
            - ipv4
            - ipv6
          description: 'Which subnets should be selected: IPv4, IPv6 or use dual stack.'
        port_group:
          type: integer
          minimum: 0
          maximum: 3
          description: Each group will be added to the separate trunk.
        security_groups:
          type: array
          description: List of security group IDs
          items:
            $ref: '#/components/schemas/MandatoryIdSchema'
        type:
          type: string
          default: external
          description: Must be 'external'. Union tag
      description: Instance will be attached to default external network
      example:
        type: external
        ip_family: dual
        security_groups:
          - id: 4536dba1-93b1-492e-b3df-270b6b9f3650
          - id: cee2ca1f-507a-4a31-b714-f6c1ffb4bdfa
        ddos_profile:
          profile_template: 29
          fields: []
    NewInterfaceSpecificSubnetSchema:
      type: object
      properties:
        ddos_profile:
          type:
            - 'null'
            - object
          description: Advanced DDoS protection.
          allOf:
            - $ref: '#/components/schemas/DeprecatedCreateDdosProfileSchema'
        interface_name:
          type: string
          maxLength: 37
          description: Interface name
        port_group:
          type: integer
          minimum: 0
          maximum: 3
          description: Each group will be added to the separate trunk.
        security_groups:
          type: array
          description: List of security group IDs
          items:
            $ref: '#/components/schemas/MandatoryIdSchema'
        subnet_id:
          type: string
          description: Port will get an IP address from this subnet
        type:
          type: string
          default: subnet
          description: Must be 'subnet'
      required:
        - subnet_id
      description: Instance will be attached to specified subnet
      example:
        subnet_id: e3c6ee77-48cb-416b-b204-11b492cc776e3
        type: subnet
        security_groups:
          - id: 4536dba1-93b1-492e-b3df-270b6b9f3650
          - id: cee2ca1f-507a-4a31-b714-f6c1ffb4bdfa
        ddos_profile:
          profile_template: 29
          fields: []
        interface_name: my-subnet-interface
    NewInterfaceAnySubnetSchema:
      type: object
      properties:
        ddos_profile:
          type:
            - 'null'
            - object
          description: Advanced DDoS protection.
          allOf:
            - $ref: '#/components/schemas/DeprecatedCreateDdosProfileSchema'
        interface_name:
          type: string
          maxLength: 37
          description: Interface name
        ip_family:
          type: string
          enum:
            - dual
            - ipv4
            - ipv6
          description: 'Which subnets should be selected: IPv4, IPv6 or use dual stack.'
        network_id:
          type: string
          description: Port will get an IP address in this network subnet
        port_group:
          type: integer
          minimum: 0
          maximum: 3
          description: Each group will be added to the separate trunk.
        security_groups:
          type: array
          description: List of security group IDs
          items:
            $ref: '#/components/schemas/MandatoryIdSchema'
        type:
          type: string
          default: any_subnet
          description: Must be 'any_subnet'
      required:
        - network_id
      description: >-
        Instance will be attached to the network subnet with the largest count
        of available ips
      example:
        network_id: e3c6ee77-48cb-416b-b204-11b492cc776e3
        type: any_subnet
        security_groups:
          - id: 4536dba1-93b1-492e-b3df-270b6b9f3650
          - id: cee2ca1f-507a-4a31-b714-f6c1ffb4bdfa
        profile_template: 29
        fields: []
        interface_name: my-any-subnet-interface
    NewInterfaceReservedFixedIpSchema:
      type: object
      properties:
        ddos_profile:
          type:
            - 'null'
            - object
          description: Advanced DDoS protection.
          allOf:
            - $ref: '#/components/schemas/DeprecatedCreateDdosProfileSchema'
        interface_name:
          type: string
          maxLength: 37
          description: Interface name
        port_group:
          type: integer
          minimum: 0
          maximum: 3
          description: Each group will be added to the separate trunk.
        port_id:
          type: string
          description: Port ID
        security_groups:
          type: array
          description: List of security group IDs
          items:
            $ref: '#/components/schemas/MandatoryIdSchema'
        type:
          type: string
          default: reserved_fixed_ip
          description: Must be 'reserved_fixed_ip'. Union tag
      required:
        - port_id
      description: |-
        Instance will be attached to the given port.
        Floating IP will be created and attached to that IP
      example:
        port_id: 59905c8e-2619-420a-b046-536096473370
        type: reserved_fixed_ip
        security_groups:
          - id: 4536dba1-93b1-492e-b3df-270b6b9f3650
          - id: cee2ca1f-507a-4a31-b714-f6c1ffb4bdfa
        ddos_profile:
          profile_template: 29
          fields: []
        interface_name: my-rfip-interface
    TaskIDsSerializer:
      properties:
        tasks:
          description: >-
            List of task IDs representing asynchronous operations. Use these IDs
            to monitor operation progress:

            - `GET /v1/tasks/{task_id}` - Check individual task status and
            details

            Poll task status until completion (`FINISHED`/`ERROR`) before
            proceeding with dependent operations.
          example:
            - d478ae29-dedc-4869-82f0-96104425f565
          examples:
            - - d478ae29-dedc-4869-82f0-96104425f565
          items:
            type: string
          title: Tasks
          type: array
      required:
        - tasks
      title: TaskIDsSerializer
      type: object
    DeprecatedCreateDdosProfileSchema:
      type: object
      properties:
        fields:
          type: array
          default: []
          writeOnly: true
          description: Protection parameters.
          items:
            $ref: '#/components/schemas/DeprecatedCreateClientProfileFieldSchema'
        profile_template:
          type: integer
          writeOnly: true
          description: DDoS profile template ID.
        profile_template_name:
          type: string
          writeOnly: true
          description: DDoS profile template name.
      required:
        - profile_template
      example:
        profile_template: 29
        fields: []
    MandatoryIdSchema:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Resource ID
      required:
        - id
      description: MandatoryIdSchema schema
      example:
        id: ae74714c-c380-48b4-87f8-758d656cdad6
    DeprecatedCreateClientProfileFieldSchema:
      type: object
      properties:
        base_field:
          type: integer
          writeOnly: true
          description: ID of DDoS profile field
        field_value:
          writeOnly: true
          description: Complex value for the DDoS profile field
        value:
          type:
            - string
            - 'null'
          writeOnly: true
          maxLength: 500
          description: >-
            Basic type value. Only one of 'value' or 'field_value' must be
            specified.
      required:
        - base_field
      example:
        field_value:
          - 45046
          - 45047
        base_field: 10
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````