Update a load balancer service

Update a load balancer's service. A running load balancer applies the change a few moments after the response.

PATCH https://{availability_zone}.betterstackcloud.com/v1/load-balancers/{load_balancer_id}/services/{id}
load_balancer_id string required

The ID of the load balancer.

id string required

The ID of the service to update.

Authorization string required

Bearer $TOKEN

Content-Type string

application/json

protocol string

The protocol the service listens for.
Valid values:
tcp: Forwards TCP connections.
http: Forwards HTTP requests.
https: Ends TLS with the service's certificates and forwards HTTP requests. An https service requires at least one certificate in certificate_ids.
udp: Forwards UDP traffic. A udp service can't use certificates, sticky_sessions, redirect_http or proxy_protocol.

listen_port integer

The port the service listens on, 1–65535. Can't be 8402 or 9901, which the load balancer uses itself. A tcp and a udp service can use the same port.

destination_port integer

The port on the targets that traffic goes to, 1–65535.

redirect_http boolean

Whether HTTP requests are redirected to this HTTPS service. Only https services can redirect.

http_timeout_seconds integer

The HTTP timeout in seconds, 5–600.

sticky_sessions boolean

Whether a cookie sends each client to the same target. Only http and https services can use sticky sessions.

sticky_cookie_name string

The name of the sticky session cookie, 1–64 letters, digits, underscores, dots or hyphens. Defaults to BSLBSTICKY.

sticky_cookie_lifetime_seconds integer

How long the sticky session cookie lasts, 1–86400 seconds.

proxy_protocol string

The PROXY protocol version the targets accept, or disabled. A udp service can't use it. Possible values: disabled, v1, v2.

certificate_ids array of strings

The IDs of the certificates the service presents. Each certificate must be in the load balancer's team. An https service requires at least one certificate. An update replaces the whole list.

health_check object

The health check of the service's targets. An update changes only the health check fields you send.

health_check.protocol string

How we check the targets.
Valid values:
tcp: Checks that the target accepts a TCP connection. The default for tcp and udp services.
http: Sends an HTTP request to the target. The default for http and https services. On a tcp or udp service, an http check needs its own port, different from destination_port.

health_check.port integer or null

The port we check, 1–65535. Without it, we check destination_port.

health_check.interval_seconds integer default: 15

How often we check each target, 2–3600 seconds.

health_check.timeout_seconds integer default: 10

The check timeout in seconds, 1–60.

health_check.retries integer default: 3

How many checks in a row must fail before a target is down, 1–10.

health_check.domain string or null

The hostname we send in the Host header of an HTTP check.

health_check.path string default: /

The path an HTTP check requests, starting with /, with no spaces or quotes.

health_check.response string or null

Text the response must contain, at most 255 characters with no line breaks or quotes.

health_check.status_codes string default: 2??,3??

The status codes that pass, separated by commas. In a pattern, ? matches one digit and * any number of digits.

health_check.tls boolean default: false

Whether checks connect with TLS.

200 OK
{
  "id": 1,
  "protocol": "tcp",
  "listen_port": 80,
  "destination_port": 8080,
  "redirect_http": false,
  "http_timeout_seconds": 50,
  "sticky_sessions": false,
  "sticky_cookie_name": "Example load balancer service",
  "sticky_cookie_lifetime_seconds": 300,
  "proxy_protocol": "disabled",
  "certificate_ids": [
    "123456789"
  ],
  "health_check": {
    "protocol": "tcp",
    "port": 443,
    "interval_seconds": 15,
    "timeout_seconds": 10,
    "retries": 3,
    "domain": "example",
    "path": "/",
    "response": "example",
    "status_codes": "2??,3??",
    "tls": false
  },
  "target_health": [
    {
      "service_id": 123456789,
      "server_id": "123456789",
      "state": "up",
      "state_changed_at": "2026-07-01T12:00:00.000Z",
      "status_message": "example"
    }
  ],
  "created_at": "2026-07-01T12:00:00.000Z",
  "updated_at": "2026-07-01T12:00:00.000Z"
}

Returns the updated load balancer service.

id integer

The service's ID.

protocol string

The protocol the service listens for.
Valid values:
tcp: Forwards TCP connections.
http: Forwards HTTP requests.
https: Ends TLS with the service's certificates and forwards HTTP requests. An https service requires at least one certificate in certificate_ids.
udp: Forwards UDP traffic. A udp service can't use certificates, sticky_sessions, redirect_http or proxy_protocol.

listen_port integer

The port the service listens on, 1–65535. Can't be 8402 or 9901, which the load balancer uses itself. A tcp and a udp service can use the same port.

destination_port integer

The port on the targets that traffic goes to, 1–65535.

redirect_http boolean

Whether HTTP requests are redirected to this HTTPS service. Only https services can redirect.

http_timeout_seconds integer

The HTTP timeout in seconds, 5–600.

sticky_sessions boolean

Whether a cookie sends each client to the same target. Only http and https services can use sticky sessions.

sticky_cookie_name string

The name of the sticky session cookie, 1–64 letters, digits, underscores, dots or hyphens.

sticky_cookie_lifetime_seconds integer

How long the sticky session cookie lasts, 1–86400 seconds.

proxy_protocol string

The PROXY protocol version the targets accept, or disabled. A udp service can't use it. Possible values: disabled, v1, v2.

certificate_ids array of strings

The IDs of the certificates the service presents.

health_check object

The health check of the service's targets.

health_check.protocol string

How we check the targets.
Valid values:
tcp: Checks that the target accepts a TCP connection. The default for tcp and udp services.
http: Sends an HTTP request to the target. The default for http and https services. On a tcp or udp service, an http check needs its own port, different from destination_port.

health_check.port integer or null

The port we check, 1–65535. Without it, we check destination_port.

health_check.interval_seconds integer

How often we check each target, 2–3600 seconds.

health_check.timeout_seconds integer

The check timeout in seconds, 1–60.

health_check.retries integer

How many checks in a row must fail before a target is down, 1–10.

health_check.domain string or null

The hostname we send in the Host header of an HTTP check.

health_check.path string

The path an HTTP check requests, starting with /, with no spaces or quotes.

health_check.response string or null

Text the response must contain, at most 255 characters with no line breaks or quotes.

health_check.status_codes string

The status codes that pass, separated by commas. In a pattern, ? matches one digit and * any number of digits.

health_check.tls boolean

Whether checks connect with TLS.

target_health array of objects

The latest health of each target, updated about every 30 seconds.

target_health[].service_id integer

The ID of the service.

target_health[].server_id string

The ID of the target server.

target_health[].state string

Whether the target is healthy.
Valid values:
up: The target passes its checks.
down: The target fails its checks.
unknown: We have no result for the target yet.

target_health[].state_changed_at datetime or null

When state last changed, or null. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

target_health[].status_message string or null

Why the target is down, or null.

created_at datetime

When the service was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

updated_at datetime

When the service was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.