Hetzner Cloud icon

Hetzner Cloud

Manage servers, volumes, networks and more in Hetzner Cloud

Load Balancer → Add Target

AI-generated

Summary

Adds a target (server, label selector, or IP) to an existing Hetzner Cloud load balancer by POSTing to /v1/load_balancers/{id}/actions/add_target and returning the resulting action.

Inputs

  • Load Balancer (required) — The load balancer to modify. Pick from a searchable list (first 50 load balancers, filtered by name) or enter the numeric ID. Used in the request URL path.
  • Service / Target (JSON) — JSON object sent as the request body. It must contain the target definition the API expects, e.g. a type (such as server, label_selector or ip) plus the matching target field like server: {id: 42}, and optionally use_private_ip. Defaults to {}, which sends no body fields, so the API will likely reject it. Invalid JSON raises a node error.
  • Request Options — Node settings for batching (items per batch, interval in ms), ignoring SSL certificate issues, an HTTP proxy, and a response timeout (default 10000 ms).

Output shape

The action object from the Hetzner API response (unwrapped from the root action property), with fields such as id, command (add_target), status, progress, started and resources. One item per input item.

The call is asynchronous on Hetzner's side. The returned action usually has status running, so use the Action resource's Get operation to check completion. API errors (e.g. invalid target or missing fields) surface as node errors.

Examples

Example 1: Attach a specific server to a load balancer

Load Balancer: choose 'web-lb' from list; Service / Target (JSON): {"type":"server","server":{"id":12345},"use_private_ip":false}

Example 2: Target all servers matching a label

Load Balancer by ID: 42; Service / Target (JSON): {"type":"label_selector","label_selector":{"selector":"env=prod"}}

Links

Discussion