---
title: "Create a new Binding"
method: POST
path: "/api/v1/bindings"
tags: ["Bindings"]
---

# Create a new Binding

`POST /api/v1/bindings`

Creates a binding that associates a service with a port or interface.

### Binding Types

- **Interface binding**: Service is present at an interface (IP address) without a specific port.
  Used for non-port-bound services like gateways.
- **Port binding (specific ip_address)**: Service listens on a specific port on a specific interface.
- **Port binding (all ip_addresses)**: Service listens on a specific port on all ip_addresses
  (`ip_address_id: null`).

### Validation and Deduplication Rules

- **Conflict detection**: Interface bindings conflict with port bindings on the same interface.
  A port binding on all ip_addresses conflicts with any interface binding for the same service.
- **All-interfaces precedence**: When creating a port binding with `ip_address_id: null`,
  any existing specific-interface bindings for the same port are automatically removed,
  as they are superseded by the all-interfaces binding.

## Request body

- union
  - object — Association between a service and a port / interface that the service is listening on
    - `ip_address_id` string, uuid, required — The IP address the service is present at.
    - `type` 'IPAddress', required
    - `network_id` string, uuid, required — The network this entity belongs to.
    - `service_id` string, uuid, required — The service this entity refers to.
    - `created_at` string, date-time, required — When this record was first created.
    - `first_discovery_id` string, uuid, nullable — The discovery that first observed this entity.
    - `id` string, uuid, required — Server-assigned unique identifier.
    - `last_discovery_id` string, uuid, nullable — The most recent discovery that observed this entity.
    - `last_seen_at` string, date-time — When a discovery last observed this entity.
    - `lineage_id` string, uuid, nullable — Stable identifier shared by every revision of the same entity across its history.
    - `updated_at` string, date-time, required — When this record was last modified.
    - `valid_from` string, date-time — Start of the interval this revision was current for (SCD2 history).
    - `valid_to` string, date-time, nullable — End of the interval this revision was current for. `null` while it is the live revision.
  - object — Association between a service and a port / interface that the service is listening on
    - `ip_address_id` string, uuid, nullable, required — The IP address this port binding applies to. If `null`, the binding applies to all IP addresses on the host (and supersedes specific-IP-address bindings for this port).
    - `port_id` string, uuid, required — The port the service listens on.
    - `type` 'Port', required
    - `network_id` string, uuid, required — The network this entity belongs to.
    - `service_id` string, uuid, required — The service this entity refers to.
    - `created_at` string, date-time, required — When this record was first created.
    - `first_discovery_id` string, uuid, nullable — The discovery that first observed this entity.
    - `id` string, uuid, required — Server-assigned unique identifier.
    - `last_discovery_id` string, uuid, nullable — The most recent discovery that observed this entity.
    - `last_seen_at` string, date-time — When a discovery last observed this entity.
    - `lineage_id` string, uuid, nullable — Stable identifier shared by every revision of the same entity across its history.
    - `updated_at` string, date-time, required — When this record was last modified.
    - `valid_from` string, date-time — Start of the interval this revision was current for (SCD2 history).
    - `valid_to` string, date-time, nullable — End of the interval this revision was current for. `null` while it is the live revision.

## Response `200`

Binding created (superseded bindings may be removed)

- ApiResponseBinding
  - `data` union
    - object — Association between a service and a port / interface that the service is listening on
      - `ip_address_id` string, uuid, required — The IP address the service is present at.
      - `type` 'IPAddress', required
      - `network_id` string, uuid, required — The network this entity belongs to.
      - `service_id` string, uuid, required — The service this entity refers to.
      - `created_at` string, date-time, required — When this record was first created.
      - `first_discovery_id` string, uuid, nullable — The discovery that first observed this entity.
      - `id` string, uuid, required — Server-assigned unique identifier.
      - `last_discovery_id` string, uuid, nullable — The most recent discovery that observed this entity.
      - `last_seen_at` string, date-time — When a discovery last observed this entity.
      - `lineage_id` string, uuid, nullable — Stable identifier shared by every revision of the same entity across its history.
      - `updated_at` string, date-time, required — When this record was last modified.
      - `valid_from` string, date-time — Start of the interval this revision was current for (SCD2 history).
      - `valid_to` string, date-time, nullable — End of the interval this revision was current for. `null` while it is the live revision.
    - object — Association between a service and a port / interface that the service is listening on
      - `ip_address_id` string, uuid, nullable, required — The IP address this port binding applies to. If `null`, the binding applies to all IP addresses on the host (and supersedes specific-IP-address bindings for this port).
      - `port_id` string, uuid, required — The port the service listens on.
      - `type` 'Port', required
      - `network_id` string, uuid, required — The network this entity belongs to.
      - `service_id` string, uuid, required — The service this entity refers to.
      - `created_at` string, date-time, required — When this record was first created.
      - `first_discovery_id` string, uuid, nullable — The discovery that first observed this entity.
      - `id` string, uuid, required — Server-assigned unique identifier.
      - `last_discovery_id` string, uuid, nullable — The most recent discovery that observed this entity.
      - `last_seen_at` string, date-time — When a discovery last observed this entity.
      - `lineage_id` string, uuid, nullable — Stable identifier shared by every revision of the same entity across its history.
      - `updated_at` string, date-time, required — When this record was last modified.
      - `valid_from` string, date-time — Start of the interval this revision was current for (SCD2 history).
      - `valid_to` string, date-time, nullable — End of the interval this revision was current for. `null` while it is the live revision.
  - `error` string, nullable — Human-readable failure message. Omitted on success.
  - `meta` ApiMeta, required — API metadata included in all responses
    - `api_version` integer, required — API version (integer, increments on breaking changes)
    - `server_version` string, required — Server version (semver)
  - `success` boolean, required — `true` when the request succeeded. `false` responses carry `error` instead of `data`.

## Other responses

- `400` — Referenced port or ip_address does not exist
- `409` — Conflict with existing binding type

---

[API](https://skmtc.net/scanopy/apis/scanopy-api.md) · [All operations](https://skmtc.net/scanopy/apis/scanopy-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/scanopy/scanopy-api/revisions/2df1fc47dfa7/schema)
