Create a load balancer
Create a load balancer, and optionally its services and targets. Check that traffic reaches your targets before you rely on it.
Bearer $TOKEN
application/json
The ID of the team to create the load balancer in. betterstack team list shows it.
The load balancer's name.
The load balancer's type, such as LB1. Get the types via betterstack load-balancer-type list.
How the load balancer picks a target for each connection.
Valid values:round_robin: Sends each new connection to the next target in turn.least_connections: Sends each new connection to the target with the fewest open connections.source_ip: Sends all connections from one client IP to the same target.
The IDs of your networks to attach. Each network must be in the load balancer's team.
The IDs of the firewalls to attach, at most one. The firewall must be in the load balancer's team.
The billing term.
Valid values:monthly: Billed every month.annual: Paid for a year.
Your own tags as string pairs. Accepts any keys.
Services to create with the load balancer. Each service accepts the same settings as when you add a service later.
Possible values: tcp, http, https, udp.
The port to listen on, 1–65535. Can't be 8402 or 9901, which the load balancer uses itself.
The port on the targets to send traffic to, 1–65535.
The redirect http.
The http timeout seconds.
The sticky sessions.
The sticky cookie name.
The sticky cookie lifetime seconds.
Possible values: disabled, v1, v2.
The IDs of the certificates to present. An https service requires at least one, and a udp service can't have any.
The health check.
How to check the targets. Defaults to http for an HTTP or HTTPS service, and to TCP otherwise. Possible values: tcp, http.
The port to check. Defaults to destination_port.
The interval seconds.
The timeout seconds.
The retries.
The domain.
The path.
The response.
The status codes.
The tls.
Targets to create with the load balancer. Each target accepts the same settings as when you add a target later.
Possible values: server, label_selector.
The ID of the server to send traffic to. A server target requires it, and a label_selector target can't have it.
The tags a server must have to receive traffic, as string pairs. A label_selector target requires at least one tag, and a server target can't have it. Accepts any keys.
The use private ip.
{
"id": "example",
"name": "Example load balancer",
"type": "LB1",
"algorithm": "round_robin",
"status": "provisioning",
"status_message": "example",
"public_ips": [
{
"ip": "example",
"type": "example"
}
],
"private_ips": [
{
"network_id": "123456789",
"ip_address": "example"
}
],
"network_ids": [
"123456789"
],
"firewall_ids": [
"123456789"
],
"services": [
{
"id": 1,
"protocol": "tcp",
"listen_port": 443,
"destination_port": 443,
"redirect_http": false,
"http_timeout_seconds": 180,
"sticky_sessions": false,
"sticky_cookie_name": "Example",
"sticky_cookie_lifetime_seconds": 1,
"proxy_protocol": "disabled",
"certificate_ids": [
"123456789"
],
"target_health": [
{
"service_id": 123456789,
"server_id": "123456789",
"state": "up",
"state_changed_at": "2026-07-01T12:00:00.000Z",
"status_message": "example"
}
],
"health_check": {
"protocol": "tcp",
"port": 443,
"interval_seconds": 180,
"timeout_seconds": 180,
"retries": 1,
"domain": "example",
"path": "example",
"response": "example",
"status_codes": "example",
"tls": false
},
"created_at": "2026-07-01T12:00:00.000Z",
"updated_at": "2026-07-01T12:00:00.000Z"
}
],
"targets": [
{
"id": 1,
"type": "server",
"server_id": "123456789",
"selector": {
"example": "value"
},
"use_private_ip": false,
"created_at": "2026-07-01T12:00:00.000Z",
"updated_at": "2026-07-01T12:00:00.000Z"
}
],
"config_applied_at": "2026-07-01T12:00:00.000Z",
"term": "monthly",
"created_at": "2026-07-01T12:00:00.000Z",
"updated_at": "2026-07-01T12:00:00.000Z",
"team_id": "t123",
"metadata": {
"example": "value"
}
}
{
"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": "The request could not be completed right now. Please try again in a few moments.",
"code": "internal_error"
}
}
Returns the newly created load balancer.
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 organization has reached its quota of load balancers.
The resource's state doesn't allow the request, such as starting a running server or removing a placement group that still has servers.
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 load balancer's ID, a UUID.
The load balancer's name.
The load balancer's type, such as LB1.
How the load balancer picks a target for each connection.
Valid values:round_robin: Sends each new connection to the next target in turn.least_connections: Sends each new connection to the target with the fewest open connections.source_ip: Sends all connections from one client IP to the same target.
The load balancer's state.
Valid values:provisioning: We're starting the load balancer.running: The load balancer is ready. status_message reports any problem. config_applied_at says when we last applied your configuration.rescaling: We're changing the load balancer's type. The load balancer returns to running even when the change didn't finish. The load balancer's events say how the change went.failed: We couldn't create the load balancer. status_message says why.destroyed: The load balancer is deleted.
What went wrong while we created or configured the load balancer, or what's wrong with it now. Is null when there's nothing to report.
The load balancer's public IP addresses, one IPv4 and one IPv6.
The ip.
The type.
The load balancer's private IP in each attached network.
The network id.
The ip address.
The IDs of the networks attached to the load balancer. Order doesn't matter.
The IDs of the firewalls attached to the load balancer, at most one. Order doesn't matter.
The services that listen for traffic, with their settings and the latest health of each target. Add, update or remove them with betterstack load-balancer-service.
The id.
Possible values: tcp, http, https, udp.
The listen port.
The destination port.
The redirect http.
The http timeout seconds.
The sticky sessions.
The sticky cookie name.
The sticky cookie lifetime seconds.
Possible values: disabled, v1, v2.
The certificate ids.
The target health.
The service id.
The server id.
Possible values: up, down, unknown.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The status message.
The health check.
Possible values: tcp, http.
The port.
The interval seconds.
The timeout seconds.
The retries.
The domain.
The path.
The response.
The status codes.
The tls.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The targets you added. A label_selector target shows as one entry, not one per matching server.
The id.
Possible values: server, label_selector.
The server id.
The selector.
The use private ip.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
When we last applied the configuration to the load balancer, or null until we first apply it. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The billing term.
Valid values:monthly: Billed every month.annual: Paid for a year.
When the load balancer was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
When the load balancer was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The ID of the team that owns the load balancer.
Your own tags as string pairs.