pydo.load_balancers.create()
Generated on 8 May 2026
from pydo version
v0.34.0
Usage
client.load_balancers.create(
body={
"droplet_ids": [...],
"region": "nyc3",
"name": "example-lb-01",
...,
},
)Description
To create a new load balancer instance, send a POST request to
/v2/load_balancers.
You can specify the Droplets that will sit behind the load balancer using one of two methods:
- Set
droplet_idsto a list of specific Droplet IDs. - Set
tagto the name of a tag. All Droplets with this tag applied will be assigned to the load balancer. Additional Droplets will be automatically assigned as they are tagged.
These methods are mutually exclusive.
Parameters
droplet_idsarray of integers optionalExample:
[3164444, 3164445]An array containing the IDs of the Droplets assigned to the load balancer.
regionstring requiredThe slug identifier for the region where the resource will initially be available.
idstring optional read-onlyExample:
4de7ac8b-495b-4884-9a69-1050c6793cd6A unique ID that can be used to identify and reference a load balancer.
namestring optionalExample:
example-lb-01A human-readable name for a load balancer instance.
project_idstring optionalExample:
4de7ac8b-495b-4884-9a69-1050c6793cd6The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created.
ipstring optional read-onlyExample:
104.131.186.241An attribute containing the public-facing IP address of the load balancer.
ipv6string optional read-onlyExample:
2604:a880:800:14::85f5:c000An attribute containing the public-facing IPv6 address of the load balancer.
size_unitinteger optionalExample:
3How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the
sizefield to scale load balancers that reside in these regions.sizestring optional deprecatedThis field has been replaced by the
size_unitfield for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes.
*lb-small= 1 node
*lb-medium= 3 nodes
*lb-large= 6 nodes
You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation.algorithmstring optional deprecatedThis field has been deprecated. You can no longer specify an algorithm for load balancers.
statusstring optional read-onlyA status string indicating the current state of the load balancer. This can be
new,active, orerrored.created_atstring optional read-onlyExample:
2017-02-01T22:22:58ZA time value given in ISO8601 combined date and time format that represents when the load balancer was created.
forwarding_rulesarray of objects requiredAn array of objects specifying the forwarding rules for a load balancer.
Show child properties
entry_protocolstring requiredThe protocol used for traffic to the load balancer. The possible values are:
http,https,http2,http3,tcp, orudp. If you set theentry_protocoltoudp, thetarget_protocolmust be set toudp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.entry_portinteger requiredExample:
443An integer representing the port on which the load balancer instance will listen.
target_protocolstring requiredThe protocol used for traffic from the load balancer to the backend Droplets. The possible values are:
http,https,http2,tcp, orudp. If you set thetarget_protocoltoudp, theentry_protocolmust be set toudp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.target_portinteger requiredExample:
80An integer representing the port on the backend Droplets to which the load balancer will send traffic.
certificate_idstring optionalExample:
892071a0-bb95-49bc-8021-3afd67a210bfThe ID of the TLS certificate used for SSL termination if enabled.
tls_passthroughboolean optionalExample:
FalseA boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets.
health_checkobject optionalAn object specifying health check settings for the load balancer.
Show child properties
protocolstring optionalThe protocol used for health checks sent to the backend Droplets. The possible values are
http,https, ortcp.portinteger optionalExample:
80An integer representing the port on the backend Droplets on which the health check will attempt a connection.
pathstring optionalExample:
/The path on the backend Droplets to which the load balancer instance will send a request.
check_interval_secondsinteger optionalExample:
10The number of seconds between between two consecutive health checks.
response_timeout_secondsinteger optionalExample:
5The number of seconds the load balancer instance will wait for a response until marking a health check as failed.
unhealthy_thresholdinteger optionalExample:
5The number of times a health check must fail for a backend Droplet to be marked "unhealthy" and be removed from the pool.
healthy_thresholdinteger optionalExample:
3The number of times a health check must pass for a backend Droplet to be marked "healthy" and be re-added to the pool.
sticky_sessionsobject optionalAn object specifying sticky sessions settings for the load balancer.
Show child properties
typestring optionalAn attribute indicating how and if requests from a client will be persistently served by the same backend Droplet. The possible values are
cookiesornone.cookie_namestring optionalExample:
DO-LBThe name of the cookie sent to the client. This attribute is only returned when using
cookiesfor the sticky sessions type.cookie_ttl_secondsinteger optionalExample:
300The number of seconds until the cookie set by the load balancer expires. This attribute is only returned when using
cookiesfor the sticky sessions type.
redirect_http_to_httpsboolean optionalExample:
TrueA boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443.
enable_proxy_protocolboolean optionalExample:
TrueA boolean value indicating whether PROXY Protocol is in use.
enable_backend_keepaliveboolean optionalExample:
TrueA boolean value indicating whether HTTP keepalive connections are maintained to target Droplets.
http_idle_timeout_secondsinteger optionalExample:
90An integer value which configures the idle timeout for HTTP requests to the target droplets.
vpc_uuidstring optionalExample:
c33931f2-a26a-4e61-b85c-4e95a2ec431bA string specifying the UUID of the VPC to which the load balancer is assigned.
disable_lets_encrypt_dns_recordsboolean optionalExample:
TrueA boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer.
firewallobject optionalAn object specifying allow and deny rules to control traffic to the load balancer.
Show child properties
denyarray of strings optionalExample:
['ip:1.2.3.4', 'cidr:2.3.0.0/16']the rules for denying traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')
allowarray of strings optionalExample:
['ip:1.2.3.4', 'cidr:2.3.0.0/16']the rules for allowing traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16')
networkstring optionalA string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer.
network_stackstring optionalA string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer.
typestring optionalA string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer.
domainsarray of objects optionalAn array of objects specifying the domain configurations for a Global load balancer.
Show child properties
namestring optionalExample:
example.comFQDN to associate with a Global load balancer.
is_managedboolean optionalExample:
TrueA boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added.
certificate_idstring optionalExample:
892071a0-bb95-49bc-8021-3afd67a210bfThe ID of the TLS certificate used for SSL termination.
glb_settingsobject optionalAn object specifying forwarding configurations for a Global load balancer.
Show child properties
target_protocolstring optionalThe protocol used for forwarding traffic from the load balancer to the target backends. The possible values are
http,httpsandhttp2.target_portinteger optionalExample:
80An integer representing the port on the target backends which the load balancer will forward traffic to.
cdnobject optionalAn object specifying CDN configurations for a Global load balancer.
Show child properties
is_enabledboolean optionalExample:
TrueA boolean flag to enable CDN caching.
region_prioritiesobject optionalExample:
{'nyc1': 1, 'fra1': 2, 'sgp1': 3}A map of region string to an integer priority value indicating preference for which regional target a Global load balancer will forward traffic to. A lower value indicates a higher priority.
failover_thresholdinteger optionalExample:
50An integer value as a percentage to indicate failure threshold to decide how the regional priorities will take effect. A value of
50would indicate that the Global load balancer will choose a lower priority region to forward traffic to once this failure threshold has been reached for the higher priority region.
target_load_balancer_idsarray of strings optionalExample:
['7dbf91fe-cbdb-48dc-8290-c3a181554905', '996fa239-fac3-42a2-b9a1-9fa822268b7a']An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer.
tls_cipher_policystring optionalA string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are
DEFAULTorSTRONG. The default value isDEFAULT.tagstring optionalExample:
prod:webThe name of a Droplet tag corresponding to Droplets assigned to the load balancer.
Request Sample
Response Example
More Information
See /v2/load_balancers in the API reference for additional detail on responses, headers, parameters, and more.