Targets

Create a new Target associated with an Upstream

Changed on

Create a new Target associated with an Upstream

post/{workspace}/upstreams/{UpstreamIdForTarget}/targets

Request

  • Base URL
    http://localhost:8001
  • Auth
    API key in header Kong-Admin-Token

Path parameters

UpstreamIdForTarget, string required

ID or target of the Target to lookup

workspace, string required
Example:team-payments

The name of the workspace

Request body

TargetWithoutParents required

A target is an ip address/hostname with a port that identifies an instance of a backend service. Every upstream can have many targets, and the targets can be dynamically added, modified, or deleted. Changes take effect on the fly. To disable a target, post a new one with weight=0; alternatively, use the DELETE convenience method to accomplish the same. The current target object definition is the one with the latest created_at.

created_at, number nullable

Unix epoch when the resource was created.

failover, boolean nullable

Whether to use this target only as backup or not.

id, string nullable

A string representing a UUID (universally unique identifier).

tags, string[] nullable

An optional set of strings associated with the Target for grouping and filtering.

target, string nullable required

The target address (ip or hostname) and port. If the hostname resolves to an SRV record, the port value will be overridden by the value from the DNS record.

updated_at, number nullable

Unix epoch when the resource was last updated.

upstream, object nullable

The unique identifier or the name of the upstream for which to update the target.

weight, integer nullable

The weight this target gets within the upstream loadbalancer (0-65535). If the hostname resolves to an SRV record, the weight value will be overridden by the value from the DNS record.

Example request

{
  "id": "089292a7-ba3d-4d88-acf0-97b4b2e2621a",
  "target": "203.0.113.42",
  "weight": 100
}

Response

Successfully created Target

Target required

A target is an ip address/hostname with a port that identifies an instance of a backend service. Every upstream can have many targets, and the targets can be dynamically added, modified, or deleted. Changes take effect on the fly. To disable a target, post a new one with weight=0; alternatively, use the DELETE convenience method to accomplish the same. The current target object definition is the one with the latest created_at.

created_at, number nullable

Unix epoch when the resource was created.

failover, boolean nullable

Whether to use this target only as backup or not.

id, string nullable

A string representing a UUID (universally unique identifier).

tags, string[] nullable

An optional set of strings associated with the Target for grouping and filtering.

target, string nullable required

The target address (ip or hostname) and port. If the hostname resolves to an SRV record, the port value will be overridden by the value from the DNS record.

updated_at, number nullable

Unix epoch when the resource was last updated.

upstream, object nullable

The unique identifier or the name of the upstream for which to update the target.

weight, integer nullable

The weight this target gets within the upstream loadbalancer (0-65535). If the hostname resolves to an SRV record, the weight value will be overridden by the value from the DNS record.

Example response

{
  "id": "089292a7-ba3d-4d88-acf0-97b4b2e2621a",
  "target": "203.0.113.42",
  "upstream": {
    "id": "5f1d7e76-2fed-4806-a6af-869984f025cb"
  },
  "weight": 100
}

Changes