Hetzner Cloud API
  1. Load Balancers
Hetzner Cloud API
  • Actions
    • Get all Actions
      GET
    • Get an Action
      GET
  • Certificates
    • Get all Certificates
      GET
    • Create a Certificate
      POST
    • Delete a Certificate
      DELETE
    • Get a Certificate
      GET
    • Update a Certificate
      PUT
  • Certificate Actions
    • Get all Actions for a Certificate
      GET
    • Retry Issuance or Renewal
      POST
    • Get an Action for a Certificate
      GET
  • Datacenters
    • Get all Datacenters
      GET
    • Get a Datacenter
      GET
  • Firewalls
    • Get all Firewalls
      GET
    • Create a Firewall
      POST
    • Delete a Firewall
      DELETE
    • Get a Firewall
      GET
    • Update a Firewall
      PUT
  • Firewall Actions
    • Get all Actions for a Firewall
      GET
    • Apply to Resources
      POST
    • Remove from Resources
      POST
    • Set Rules
      POST
    • Get an Action for a Firewall
      GET
  • Floating IPs
    • Get all Floating IPs
    • Create a Floating IP
    • Delete a Floating IP
    • Get a Floating IP
    • Update a Floating IP
  • Floating IP Actions
    • Get all Actions for a Floating IP
    • Assign a Floating IP to a Server
    • Change reverse DNS entry for a Floating IP
    • Change Floating IP Protection
    • Unassign a Floating IP
    • Get an Action for a Floating IP
  • Images
    • Get all Images
    • Delete an Image
    • Get an Image
    • Update an Image
  • Image Actions
    • Get all Actions for an Image
    • Change Image Protection
    • Get an Action for an Image
  • ISOs
    • Get all ISOs
    • Get an ISO
  • Load Balancer Types
    • Get all Load Balancer Types
    • Get a Load Balancer Type
  • Load Balancers
    • Get all Load Balancers
      GET
    • Create a Load Balancer
      POST
    • Delete a Load Balancer
      DELETE
    • Get a Load Balancer
      GET
    • Update a Load Balancer
      PUT
    • Get Metrics for a LoadBalancer
      GET
  • Load Balancer Actions
    • Get all Actions for a Load Balancer
    • Add Service
    • Add Target
    • Attach a Load Balancer to a Network
    • Change Algorithm
    • Change reverse DNS entry for this Load Balancer
    • Change Load Balancer Protection
    • Change the Type of a Load Balancer
    • Delete Service
    • Detach a Load Balancer from a Network
    • Disable the public interface of a Load Balancer
    • Enable the public interface of a Load Balancer
    • Remove Target
    • Update Service
    • Get an Action for a Load Balancer
  • Locations
    • Get all Locations
    • Get a Location
  • Networks
    • Get all Networks
    • Create a Network
    • Delete a Network
    • Get a Network
    • Update a Network
  • Network Actions
    • Get all Actions for a Network
    • Add a route to a Network
    • Add a subnet to a Network
    • Change IP range of a Network
    • Change Network Protection
    • Delete a route from a Network
    • Delete a subnet from a Network
    • Get an Action for a Network
  • Placement Groups
    • Get all PlacementGroups
    • Create a PlacementGroup
    • Delete a PlacementGroup
    • Get a PlacementGroup
    • Update a PlacementGroup
  • Pricing
    • Get all prices
  • Server Types
    • Get all Server Types
    • Get a Server Type
  • Servers
    • Get all Servers
    • Create a Server
    • Delete a Server
    • Get a Server
    • Update a Server
    • Get Metrics for a Server
  • Server Actions
    • Get all Actions for a Server
    • Add a Server to a Placement Group
    • Attach an ISO to a Server
    • Attach a Server to a Network
    • Change alias IPs of a Network
    • Change reverse DNS entry for this Server
    • Change Server Protection
    • Change the Type of a Server
    • Create Image from a Server
    • Detach a Server from a Network
    • Detach an ISO from a Server
    • Disable Backups for a Server
    • Disable Rescue Mode for a Server
    • Enable and Configure Backups for a Server
    • Enable Rescue Mode for a Server
    • Power off a Server
    • Power on a Server
    • Soft-reboot a Server
    • Rebuild a Server from an Image
    • Remove from Placement Group
    • Request Console for a Server
    • Reset a Server
    • Reset root Password of a Server
    • Shutdown a Server
    • Get an Action for a Server
  • SSH Keys
    • Get all SSH keys
    • Create an SSH key
    • Delete an SSH key
    • Get a SSH key
    • Update an SSH key
  • Volumes
    • Get all Volumes
    • Create a Volume
    • Delete a Volume
    • Get a Volume
    • Update a Volume
  • Volume Actions
    • Get all Actions for a Volume
    • Attach Volume to a Server
    • Change Volume Protection
    • Detach Volume
    • Resize Volume
    • Get an Action for a Volume
  • Primary IPs
    • Get all Primary IPs
    • Create a Primary IP
    • Delete a Primary IP
    • Get a Primary IP
    • Update a Primary IP
  • Primary IP Actions
    • Assign a Primary IP to a resource
    • Change reverse DNS entry for a Primary IP
    • Change Primary IP Protection
    • Unassign a Primary IP from a resource
  1. Load Balancers

Create a Load Balancer

POST
/load_balancers
Creates a Load Balancer.

Call specific error codes#

CodeDescription
cloud_resource_ip_not_allowedThe IP you are trying to add as a target belongs to a Hetzner Cloud resource
ip_not_ownedThe IP is not owned by the owner of the project of the Load Balancer
load_balancer_not_attached_to_networkThe Load Balancer is not attached to a network
robot_unavailableRobot was not available. The caller may retry the operation after a short delay.
server_not_attached_to_networkThe server you are trying to add as a target is not attached to the same network as the Load Balancer
source_port_already_usedThe source port you are trying to add is already in use
target_already_definedThe Load Balancer target you are trying to define is already defined

Request

Body Params application/json

Examples

Responses

🟢201The `load_balancer` key contains the Load Balancer that was just created
application/json
Body

Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.hetzner.cloud/v1/load_balancers' \
--header 'Content-Type: application/json' \
--data-raw '{
    "algorithm": {
        "type": "round_robin"
    },
    "labels": {
        "labelkey": "value"
    },
    "load_balancer_type": "lb11",
    "location": "string",
    "name": "Web Frontend",
    "network": 123,
    "network_zone": "eu-central",
    "public_interface": true,
    "services": [
        {
            "destination_port": 80,
            "health_check": {
                "http": {
                    "domain": "example.com",
                    "path": "/",
                    "response": "{\"status\": \"ok\"}",
                    "status_codes": [
                        "2??",
                        "3??"
                    ],
                    "tls": false
                },
                "interval": 15,
                "port": 4711,
                "protocol": "http",
                "retries": 3,
                "timeout": 10
            },
            "http": {
                "certificates": [
                    897
                ],
                "cookie_lifetime": 300,
                "cookie_name": "HCLBSTICKY",
                "redirect_http": true,
                "sticky_sessions": true
            },
            "listen_port": 443,
            "protocol": "https",
            "proxyprotocol": false
        }
    ],
    "targets": [
        {
            "health_status": [
                {
                    "listen_port": 443,
                    "status": "healthy"
                }
            ],
            "ip": {
                "ip": "203.0.113.1"
            },
            "label_selector": {
                "selector": "env=prod"
            },
            "server": {
                "id": 80
            },
            "targets": [
                {
                    "health_status": [
                        {
                            "listen_port": 443,
                            "status": "healthy"
                        }
                    ],
                    "server": {
                        "id": 85
                    },
                    "type": "server",
                    "use_private_ip": false
                }
            ],
            "type": "server",
            "use_private_ip": true
        }
    ]
}'
Response Response Example
{
    "action": {
        "command": "create_load_balancer",
        "error": {
            "code": "action_failed",
            "message": "Action failed"
        },
        "finished": "2016-01-30T23:56:00.000Z",
        "id": 13,
        "progress": 100,
        "resources": [
            {
                "id": 4711,
                "type": "load_balancer"
            }
        ],
        "started": "2016-01-30T23:55:00.000Z",
        "status": "success"
    },
    "load_balancer": {
        "algorithm": {
            "type": "round_robin"
        },
        "created": "2016-01-30T23:50:00.000Z",
        "id": 4711,
        "included_traffic": 654321,
        "ingoing_traffic": 123456,
        "labels": {
            "env": "dev"
        },
        "load_balancer_type": {
            "deprecated": "2016-01-30T23:50:00.000Z",
            "description": "LB11",
            "id": 1,
            "max_assigned_certificates": 10,
            "max_connections": 20000,
            "max_services": 5,
            "max_targets": 25,
            "name": "lb11",
            "prices": [
                {
                    "location": "fsn1",
                    "price_hourly": {
                        "gross": "1.1900000000000000",
                        "net": "1.0000000000"
                    },
                    "price_monthly": {
                        "gross": "1.1900000000000000",
                        "net": "1.0000000000"
                    }
                }
            ]
        },
        "location": {
            "city": "Falkenstein",
            "country": "DE",
            "description": "Falkenstein DC Park 1",
            "id": 1,
            "latitude": 50.47612,
            "longitude": 12.370071,
            "name": "fsn1",
            "network_zone": "eu-central"
        },
        "name": "Web Frontend",
        "outgoing_traffic": 123456,
        "private_net": [
            {
                "ip": "10.0.0.2",
                "network": 4711
            }
        ],
        "protection": {
            "delete": false
        },
        "public_net": {
            "enabled": false,
            "ipv4": {
                "ip": "1.2.3.4"
            },
            "ipv6": {
                "ip": "2001:db8::1"
            }
        },
        "services": [
            {
                "destination_port": 80,
                "health_check": {
                    "http": {
                        "domain": "example.com",
                        "path": "/",
                        "response": "{\"status\": \"ok\"}",
                        "status_codes": [
                            "2??,3??"
                        ],
                        "tls": false
                    },
                    "interval": 15,
                    "port": 4711,
                    "protocol": "http",
                    "retries": 3,
                    "timeout": 10
                },
                "http": {
                    "certificates": [
                        897
                    ],
                    "cookie_lifetime": 300,
                    "cookie_name": "HCLBSTICKY",
                    "redirect_http": true,
                    "sticky_sessions": true
                },
                "listen_port": 443,
                "protocol": "http",
                "proxyprotocol": false
            }
        ],
        "targets": [
            {
                "health_status": [
                    {
                        "listen_port": 443,
                        "status": "healthy"
                    }
                ],
                "server": {
                    "id": 80
                },
                "targets": [
                    {
                        "health_status": [
                            {
                                "listen_port": 443,
                                "status": "healthy"
                            }
                        ],
                        "label_selector": null,
                        "server": {
                            "id": 80
                        },
                        "type": "server",
                        "use_private_ip": true
                    }
                ],
                "type": "server",
                "use_private_ip": true
            }
        ]
    }
}
Modified at 2023-08-16 03:09:21
Previous
Get all Load Balancers
Next
Delete a Load Balancer
Built with