Load balancer API

Load balancer API

Manage listeners, health policy, backend membership, and drain operations.

The Load balancer API configures regional listeners and backend selection in a project network. Deployment state and backend health are reported separately.

POST/organizations/{organization_id}/projects/{project_id}/load-balancers
Scope
networks:write
Auth
Bearer API key
Repeat calls
Reuse the creation key after uncertain transport results.

Creates a regional load balancer and its listeners.

Send name, region_id, network_id, exposure, and at least one listener. Exposure is internal by default or public with an eligible public assignment. A listener has protocol, port, backend_port, and a backend selection.

To create an HTTP listener for the selected application backends, send:

JSON
{
  "name": "payments-edge",
  "region_id": "reg_euwest",
  "network_id": "net_production",
  "exposure": "internal",
  "listeners": [
    {
      "protocol": "http",
      "port": 80,
      "backend_port": 8080,
      "backend_selector": { "service": "web" },
      "health_check": { "protocol": "http", "path": "/ready" }
    }
  ]
}

Listener protocols are tcp, http, or https. Ports are integers 1–65535. HTTPS requires certificate_secret_id. A duplicate listener address and port, an invalid health timing, or a foreign-project network returns 422. Accepted creation returns 202 with the service ID and operation.

Health configuration

The health defaults are interval 10 seconds, timeout 3 seconds, unhealthy threshold 3, and healthy threshold 2. Bounds and probe semantics are documented in load balancers.

GET/organizations/{organization_id}/projects/{project_id}/load-balancers/{load_balancer_id}/backends
Scope
networks:read
Auth
Bearer API key

Returns resolved backend IDs, probe result, membership state, and active connection count. Requires networks:read. Selector resolution does not imply healthy membership.

Update listeners

PATCH/organizations/{organization_id}/projects/{project_id}/load-balancers/{load_balancer_id}
Scope
networks:write
Auth
Bearer API key

Replaces the supplied listener configuration.

Requires If-Match. A supplied listeners array replaces the complete listener definition. Omission leaves it unchanged; an empty array is rejected. Accepted changes return 202 and expose desired versus active revision in later reads.

A failed certificate validation leaves the active listener unchanged. A deployment failure after acceptance can leave some instances on their previous revision. Inspect operation adoption before revoking old certificate material.

Drain a backend

POST/organizations/{organization_id}/projects/{project_id}/load-balancers/{load_balancer_id}/backends/{backend_id}/drain
Scope
networks:write
Auth
Bearer API key

Drains a backend after the membership revision applies.

Accepts drain_timeout_seconds, default 300, integer 0–3600. It returns 202 and prevents new selection after the revision applies. Existing connections close on completion or timeout.

POST/organizations/{organization_id}/projects/{project_id}/load-balancers/{load_balancer_id}/backends/{backend_id}/activate
Scope
networks:write
Auth
Bearer API key

Requests return to active membership; the backend still needs to pass its healthy threshold. Reactivation cannot recreate connections already closed by the drain.

Removal

DELETE/organizations/{organization_id}/projects/{project_id}/load-balancers/{load_balancer_id}
Scope
networks:write
Auth
Bearer API key

Deletes the load balancer while retaining independent backend droplets.

Deletion requires If-Match and returns an operation. Backend droplets remain independent. The public assignment's retention is explicit and is not inferred from the backend list. See TLS rotation and connection draining.

Protocol metadata

Each listener can set preserve_host, default true, for HTTP-aware forwarding. Managed X-Forwarded-For and X-Forwarded-Proto values replace incoming client claims at the trusted edge. A backend must trust these values only from the managed balancer path.

TCP listeners can set proxy_protocol to disabled or v2, default disabled. Unsupported protocol combinations return 422 invalid_listener; the option is not ignored. Enable v2 only when the backend expects its binary preamble before its application protocol. See listener protocols.