Load Balancers

Create a Load Balancer

Creates a Load Balancer.

Operation specific errors

StatusCodeDescription
412source_port_already_usedThe source port you are trying to add is already in use
412primary_ip_version_mismatchThe specified Primary IP has the wrong IP version
422ip_not_ownedThe IP is not owned by the owner of the project of the Load Balancer
422load_balancer_not_attached_to_networkThe Load Balancer is not attached to a network
422resolve_cloud_private_targets_errorThe server you are trying to add as a target is not attached to the same network as the Load Balancer
422resolve_cloud_public_targets_errorThe server that you are trying to add as a public target does not have a public IPv4 address
422target_already_definedThe Load Balancer target you are trying to define is already defined
422primary_ip_assignedThe specified Primary IP is already assigned to a resource
422primary_ip_blockedThe specified Primary IP is blocked
422primary_ip_location_mismatchThe specified Primary IP is bound to a different Location than the Load Balancer
post/load_balancers

Request

  • Base URL: https://api.hetzner.cloud/v1
  • URL: https://api.hetzner.cloud/v1/load_balancers
  • Auth: HTTP bearer

Request body

namestring required

Name of the Load Balancer.

load_balancer_typestring required

ID or name of the Load Balancer type this Load Balancer should be created with.

labelsobject

User-defined labels (key/value pairs) for the Resource. For more information, see "Labels".

public_interfaceboolean

Enable or disable the public interface of the Load Balancer.

networkinteger

ID of the network the Load Balancer should be attached to on creation.

network_zonestring

Name of network zone.

locationstring

ID or name of Location to create Load Balancer in.

Example request

{
  "name": "Web Frontend",
  "load_balancer_type": "lb11",
  "services": [
    {
      "protocol": "tcp",
      "listen_port": 443,
      "destination_port": 80,
      "health_check": {
        "protocol": "http",
        "port": 4711,
        "interval": 15,
        "timeout": 10,
        "retries": 3,
        "http": {
          "domain": "example.com",
          "path": "/",
          "response": "{\"status\": \"ok\"}",
          "status_codes": [
            "2??",
            "3??"
          ]
        }
      }
    }
  ],
  "targets": [
    {
      "server": {
        "id": 80,
        "ip": "2001:db8::1"
      },
      "label_selector": {
        "selector": "env=prod"
      },
      "ip": {
        "ip": "203.0.113.1"
      },
      "use_private_ip": true
    }
  ],
  "labels": {
    "environment": "prod",
    "example.com/my": "label",
    "just-a-key": ""
  },
  "public_interface": true,
  "public_net": {
    "ipv4": 42,
    "ipv6": 42
  },
  "network": 123,
  "network_zone": "eu-central",
  "location": "fsn1"
}

Response

Request succeeded.

Example response

{
  "load_balancer": {
    "id": 42,
    "name": "my-resource",
    "public_net": {
      "ipv4": {
        "id": 42,
        "ip": "1.2.3.4",
        "dns_ptr": "lb1.example.com"
      },
      "ipv6": {
        "id": 42,
        "ip": "2001:db8::1",
        "dns_ptr": "lb1.example.com"
      }
    },
    "private_net": [
      {
        "network": 4711,
        "ip": "10.0.0.2"
      }
    ],
    "location": {
      "id": 42,
      "name": "fsn1",
      "description": "Falkenstein DC Park 1",
      "country": "DE",
      "city": "Falkenstein",
      "latitude": 50.47612,
      "longitude": 12.370071,
      "network_zone": "eu-central"
    },
    "load_balancer_type": {
      "id": 1,
      "name": "lb11",
      "description": "LB11",
      "max_connections": 20000,
      "max_services": 5,
      "max_targets": 25,
      "max_assigned_certificates": 10,
      "deprecated": "2016-01-30T23:50:00Z",
      "deprecation": {
        "unavailable_after": "2023-09-01T00:00:00Z",
        "announced": "2023-06-01T00:00:00Z"
      },
      "prices": [
        {
          "location": "fsn1",
          "price_hourly": {
            "net": "1.0000",
            "gross": "1.1900"
          },
          "price_monthly": {
            "net": "1.0000",
            "gross": "1.1900"
          },
          "included_traffic": 654321,
          "price_per_tb_traffic": {
            "net": "1.0000",
            "gross": "1.1900"
          }
        }
      ]
    },
    "labels": {
      "environment": "prod",
      "example.com/my": "label",
      "just-a-key": ""
    },
    "created": "2016-01-30T23:55:00Z",
    "services": [
      {
        "protocol": "tcp",
        "listen_port": 443,
        "destination_port": 80,
        "health_check": {
          "protocol": "http",
          "port": 4711,
          "interval": 15,
          "timeout": 10,
          "retries": 3,
          "http": {
            "domain": "example.com",
            "path": "/",
            "response": "{\"status\": \"ok\"}",
            "status_codes": [
              "2??",
              "3??"
            ]
          }
        }
      }
    ],
    "targets": [
      {
        "type": "server",
        "server": {
          "id": 80,
          "ip": "2001:db8::1"
        },
        "health_status": [
          {
            "listen_port": 443,
            "status": "healthy",
            "detail": "unexpected_http_status",
            "http_status_code": 503
          }
        ]
      }
    ],
    "included_traffic": 10000
  },
  "action": {
    "id": 42,
    "command": "start_resource",
    "started": "2016-01-30T23:55:00Z",
    "finished": "2016-01-30T23:55:00Z",
    "progress": 100,
    "resources": [
      {
        "id": 42,
        "type": "server"
      }
    ],
    "error": {
      "code": "action_failed",
      "message": "Action failed"
    }
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.