Create a load balancer service
Add a service to a load balancer. A running load balancer starts serving it a few moments after the response.
The ID of the load balancer.
Bearer $TOKEN
application/json
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.
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.
The port on the targets that traffic goes to, 1–65535.
Whether HTTP requests are redirected to this HTTPS service. Only https services can redirect.
The HTTP timeout in seconds, 5–600.
Whether a cookie sends each client to the same target. Only http and https services can use sticky sessions.
The name of the sticky session cookie, 1–64 letters, digits, underscores, dots or hyphens. Defaults to BSLBSTICKY.
How long the sticky session cookie lasts, 1–86400 seconds.
The PROXY protocol version the targets accept, or disabled. A udp service can't use it. Possible values: disabled, v1, v2.
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.
The health check of the service's targets. An update changes only the health check fields you send.
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.
The port we check, 1–65535. Without it, we check destination_port.
How often we check each target, 2–3600 seconds.
The check timeout in seconds, 1–60.
How many checks in a row must fail before a target is down, 1–10.
The hostname we send in the Host header of an HTTP check.
The path an HTTP check requests, starting with /, with no spaces or quotes.
Text the response must contain, at most 255 characters with no line breaks or quotes.
The status codes that pass, separated by commas. In a pattern, ? matches one digit and * any number of digits.
Whether checks connect with TLS.
{
"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"
}
{
"error": {
"message": "Malformed JSON body.",
"code": "bad_request"
}
}
{
"error": {
"message": "Missing or invalid token.",
"code": "unauthorized"
}
}
{
"error": {
"message": "We require at least one successful credit card transaction before allowing billable actions via the API. This significantly helps us to prevent fraud. Once your first transaction is processed, you will be able to use the API unrestricted. Please add credit to your account at https://betterstack.com/settings/billing/card/new?credits=10&activate_api=true. Need help? We're here for you at hello@betterstack.com.",
"code": "payment_required"
}
}
{
"error": {
"message": "This token is read-only and cannot be used for write operations.",
"code": "read_only_token"
}
}
{
"error": {
"message": "Resource not found.",
"code": "not_found"
}
}
{
"error": {
"message": "The request could not be completed right now. Please try again in a few moments.",
"code": "internal_error"
}
}
Returns the newly created load balancer service.
The body isn't valid JSON.
The API token is missing or invalid.
The organization hasn't made its first payment yet, and the request creates a resource we charge for. The code is payment_required. A request that creates a server, load balancer, object cache, database, reserved IP or volume can also return first_purchase. The url in first_purchase opens a page where you make the payment. The resource is created after the payment. The page works until expires_at, 24 hours after the response.
The request would go over a quota, with the code quota_exceeded. Or a read-only token tried to make a change, with the code read_only_token. Or a rule of the resource forbids it.
The resource doesn't exist, it's in another zone, or your token can't access it.
The load balancer has as many services as its type allows.
The load balancer would present more certificates than its type allows.
A Kubernetes cluster manages the load balancer.
A value isn't valid, with the code validation_failed. The error's details list the messages for each field. A create or rescale that names a deprecated type with a replacement returns the code type_deprecated. The error's details then name the field, the deprecated type and its replacement.
We've locked the resource, with the code locked. Every change to a locked resource is refused, and so is a change that involves one.
Too many requests, with the code rate_limited. We limit requests per client IP and per organization, and some costly endpoints have a stricter limit. Wait as long as the Retry-After header says.
An unexpected, temporary error on our side, with the code internal_error. Try again.
The zone has no capacity, with the code no_capacity. Or we couldn't set up or change the resource, with the code orchestration_failed. Or the organization is creating too many resources at the same time, with the code concurrent_create_limit. Try again after a short wait.
The service's ID.
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.
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.
The port on the targets that traffic goes to, 1–65535.
Whether HTTP requests are redirected to this HTTPS service. Only https services can redirect.
The HTTP timeout in seconds, 5–600.
Whether a cookie sends each client to the same target. Only http and https services can use sticky sessions.
The name of the sticky session cookie, 1–64 letters, digits, underscores, dots or hyphens.
How long the sticky session cookie lasts, 1–86400 seconds.
The PROXY protocol version the targets accept, or disabled. A udp service can't use it. Possible values: disabled, v1, v2.
The IDs of the certificates the service presents.
The health check of the service's targets.
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.
The port we check, 1–65535. Without it, we check destination_port.
How often we check each target, 2–3600 seconds.
The check timeout in seconds, 1–60.
How many checks in a row must fail before a target is down, 1–10.
The hostname we send in the Host header of an HTTP check.
The path an HTTP check requests, starting with /, with no spaces or quotes.
Text the response must contain, at most 255 characters with no line breaks or quotes.
The status codes that pass, separated by commas. In a pattern, ? matches one digit and * any number of digits.
Whether checks connect with TLS.
The latest health of each target, updated about every 30 seconds.
The ID of the service.
The ID of the target server.
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.
When state last changed, or null. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
Why the target is down, or null.
When the service was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
When the service was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.