ServersClient
- class ServersClient(client: Client)[source]
- actions: ResourceActionsClient
Servers scoped actions client
- Type:
- add_to_placement_group(server: Server | BoundServer, placement_group: PlacementGroup | BoundPlacementGroup) BoundAction[source]
Adds a server to a placement group.
- Parameters:
server –
BoundServerorServerplacement_group –
BoundPlacementGrouporNetwork
- Returns:
- attach_iso(server: Server | BoundServer, iso: Iso | BoundIso) BoundAction[source]
Attaches an ISO to a server.
- Parameters:
server –
BoundServerorServer
- Returns:
- attach_to_network(server: Server | BoundServer, network: Network | BoundNetwork, ip: str | None = None, alias_ips: list[str] | None = None, ip_range: str | None = None) BoundAction[source]
Attaches a server to a network
- Parameters:
server –
BoundServerorServernetwork –
BoundNetworkorNetworkip – str IP to request to be assigned to this server
alias_ips – List[str] New alias IPs to set for this server.
ip_range – str IP range in CIDR block notation of the subnet to attach to.
- Returns:
- change_alias_ips(server: Server | BoundServer, network: Network | BoundNetwork, alias_ips: list[str]) BoundAction[source]
Changes the alias IPs of an already attached network.
- Parameters:
server –
BoundServerorServernetwork –
BoundNetworkorNetworkalias_ips – List[str] New alias IPs to set for this server.
- Returns:
- change_dns_ptr(server: Server | BoundServer, ip: str, dns_ptr: str | None) BoundAction[source]
Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6) of this server.
- Parameters:
server –
BoundServerorServerip – str The IP address for which to set the reverse DNS entry
dns_ptr – Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(server: Server | BoundServer, delete: bool | None = None, rebuild: bool | None = None) BoundAction[source]
Changes the protection configuration of the server.
- Parameters:
server –
BoundServerorServerdelete – boolean If true, prevents the server from being deleted (currently delete and rebuild attribute needs to have the same value)
rebuild – boolean If true, prevents the server from being rebuilt (currently delete and rebuild attribute needs to have the same value)
- Returns:
- change_type(server: Server | BoundServer, server_type: ServerType | BoundServerType, upgrade_disk: bool) BoundAction[source]
Changes the type (Cores, RAM and disk sizes) of a server.
- Parameters:
server –
BoundServerorServerserver_type –
BoundServerTypeorServerTypeServer type the server should migrate toupgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.
- Returns:
- create(name: str, server_type: ServerType | BoundServerType, image: Image, ssh_keys: list[SSHKey | BoundSSHKey] | None = None, volumes: list[Volume | BoundVolume] | None = None, firewalls: list[Firewall | BoundFirewall] | None = None, networks: list[Network | BoundNetwork] | None = None, user_data: str | None = None, labels: dict[str, str] | None = None, location: Location | BoundLocation | None = None, datacenter: Datacenter | BoundDatacenter | None = None, start_after_create: bool | None = True, automount: bool | None = None, placement_group: PlacementGroup | BoundPlacementGroup | None = None, public_net: ServerCreatePublicNetwork | None = None) CreateServerResponse[source]
Creates a new server. Returns preliminary information about the server as well as an action that covers progress of creation.
- Parameters:
name – str Name of the server to create (must be unique per project and a valid hostname as per RFC 1123)
server_type –
BoundServerTypeorServerTypeServer type this server should be created withimage –
BoundImageorImageImage the server is created fromssh_keys – List[
BoundSSHKeyorSSHKey] (optional) SSH keys which should be injected into the server at creation timevolumes – List[
BoundVolumeorVolume] (optional) Volumes which should be attached to the server at the creation time. Volumes must be in the same location.networks – List[
BoundNetworkorNetwork] (optional) Networks which should be attached to the server at the creation time.user_data – str (optional) Cloud-Init user data to use during server creation. This field is limited to 32KiB.
labels – Dict[str,str] (optional) User-defined labels (key-value pairs)
location –
BoundLocationorLocationdatacenter –
BoundDatacenterorDatacenterstart_after_create – boolean (optional) Start Server right after creation. Defaults to True.
automount – boolean (optional) Auto mount volumes after attach.
placement_group –
BoundPlacementGrouporLocationPlacement Group where server should be added during creationpublic_net –
ServerCreatePublicNetworkOptions to configure the public network of a server on creation
- Returns:
- create_image(server: Server | BoundServer, description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) CreateImageResponse[source]
Creates an image (snapshot) from a server by copying the contents of its disks.
- Parameters:
server –
BoundServerorServerdescription – str (optional) Description of the image. If you do not set this we auto-generate one for you.
type – str (optional) Type of image to create (default: snapshot) Choices: snapshot, backup
labels – Dict[str, str] User-defined labels (key-value pairs)
- Returns:
- delete(server: Server | BoundServer) BoundAction[source]
Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
- Parameters:
server –
BoundServerorServer- Returns:
- detach_from_network(server: Server | BoundServer, network: Network | BoundNetwork) BoundAction[source]
Detaches a server from a network.
- Parameters:
server –
BoundServerorServernetwork –
BoundNetworkorNetwork
- Returns:
- detach_iso(server: Server | BoundServer) BoundAction[source]
Detaches an ISO from a server.
- Parameters:
server –
BoundServerorServer- Returns:
- disable_backup(server: Server | BoundServer) BoundAction[source]
Disables the automatic backup option and deletes all existing Backups for a Server.
- Parameters:
server –
BoundServerorServer- Returns:
- disable_rescue(server: Server | BoundServer) BoundAction[source]
Disables the Hetzner Rescue System for a server.
- Parameters:
server –
BoundServerorServer- Returns:
- enable_backup(server: Server | BoundServer) BoundAction[source]
Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%.
- Parameters:
server –
BoundServerorServer- Returns:
- enable_rescue(server: Server | BoundServer, type: str | None = None, ssh_keys: list[str] | None = None) EnableRescueResponse[source]
Enable the Hetzner Rescue System for this server.
- Parameters:
server –
BoundServerorServertype – str Type of rescue system to boot (default: linux64) Choices: linux64, linux32, freebsd64
ssh_keys – List[str] Array of SSH key IDs which should be injected into the rescue system. Only available for types: linux64 and linux32.
- Returns:
- get_actions(server: Server | BoundServer, status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None) list[BoundAction][source]
Returns all Actions for a Server.
- Parameters:
server – Server to get the Actions for.
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
- get_actions_list(server: Server | BoundServer, status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]
Returns a paginated list of Actions for a Server.
- Parameters:
server – Server to get the Actions for.
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
page – Page number to get.
per_page – Maximum number of Actions returned per page.
- get_all(name: str | None = None, label_selector: str | None = None, status: list[str] | None = None) list[BoundServer][source]
Get all servers from this account
- Parameters:
name – str (optional) Can be used to filter servers by their name.
label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.
status – List[str] (optional) Can be used to filter servers by their status. The response will only contain servers matching the status.
- Returns:
List[
BoundServer]
- get_by_id(id: int) BoundServer[source]
Get a specific server
- Parameters:
id – int
- Returns:
- get_by_name(name: str) BoundServer | None[source]
Get server by name
- Parameters:
name – str Used to get server by name.
- Returns:
- get_list(name: str | None = None, label_selector: str | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None) ServersPageResult[source]
Get a list of servers from this account
- Parameters:
name – str (optional) Can be used to filter servers by their name.
label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.
status – List[str] (optional) Can be used to filter servers by their status. The response will only contain servers matching the status.
page – int (optional) Specifies the page to fetch
per_page – int (optional) Specifies how many results are returned by page
- Returns:
(List[
BoundServer],Meta)
- get_metrics(server: Server | BoundServer, type: Literal['cpu', 'disk', 'network'] | list[Literal['cpu', 'disk', 'network']], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse[source]
Get Metrics for a Server.
- Parameters:
server – The Server to get the metrics for.
type – Type of metrics to get.
start – Start of period to get Metrics for (in ISO-8601 format).
end – End of period to get Metrics for (in ISO-8601 format).
step – Resolution of results in seconds.
- power_off(server: Server | BoundServer) BoundAction[source]
Cuts power to the server. This forcefully stops it without giving the server operating system time to gracefully stop
- Parameters:
server –
BoundServerorServer- Returns:
- power_on(server: Server | BoundServer) BoundAction[source]
Starts a server by turning its power on.
- Parameters:
server –
BoundServerorServer- Returns:
- reboot(server: Server | BoundServer) BoundAction[source]
Reboots a server gracefully by sending an ACPI request.
- Parameters:
server –
BoundServerorServer- Returns:
- rebuild(server: Server | BoundServer, image: Image | BoundImage, user_data: str | None = None, **kwargs: Any) RebuildResponse[source]
Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.
- Parameters:
server – Server to rebuild
image – Image to use for the rebuilt server
user_data – Cloud-Init user data to use during Server rebuild (optional)
- remove_from_placement_group(server: Server | BoundServer) BoundAction[source]
Removes a server from a placement group.
- Parameters:
server –
BoundServerorServer- Returns:
- request_console(server: Server | BoundServer) RequestConsoleResponse[source]
Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server.
- Parameters:
server –
BoundServerorServer- Returns:
- reset(server: Server | BoundServer) BoundAction[source]
Cuts power to a server and starts it again.
- Parameters:
server –
BoundServerorServer- Returns:
- reset_password(server: Server | BoundServer) ResetPasswordResponse[source]
Resets the root password. Only works for Linux systems that are running the qemu guest agent.
- Parameters:
server –
BoundServerorServer- Returns:
- shutdown(server: Server | BoundServer) BoundAction[source]
Shuts down a server gracefully by sending an ACPI shutdown request.
- Parameters:
server –
BoundServerorServer- Returns:
- update(server: Server | BoundServer, name: str | None = None, labels: dict[str, str] | None = None) BoundServer[source]
Updates a server. You can update a server’s name and a server’s labels.
- Parameters:
server –
BoundServerorServername – str (optional) New name to set
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- class BoundServer(client: ServersClient, data: dict[str, Any], complete: bool = True)[source]
- add_to_placement_group(placement_group: PlacementGroup | BoundPlacementGroup) BoundAction[source]
Adds a server to a placement group.
- Parameters:
placement_group –
BoundPlacementGrouporNetwork- Returns:
- attach_iso(iso: Iso | BoundIso) BoundAction[source]
Attaches an ISO to a server.
- Parameters:
- Returns:
- attach_to_network(network: Network | BoundNetwork, ip: str | None = None, alias_ips: list[str] | None = None, ip_range: str | None = None) BoundAction[source]
Attaches a server to a network
- Parameters:
network –
BoundNetworkorNetworkip – str IP to request to be assigned to this server
alias_ips – List[str] New alias IPs to set for this server.
ip_range – str IP range in CIDR block notation of the subnet to attach to.
- Returns:
- change_alias_ips(network: Network | BoundNetwork, alias_ips: list[str]) BoundAction[source]
Changes the alias IPs of an already attached network.
- Parameters:
network –
BoundNetworkorNetworkalias_ips – List[str] New alias IPs to set for this server.
- Returns:
- change_dns_ptr(ip: str, dns_ptr: str | None) BoundAction[source]
Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6) of this server.
- Parameters:
ip – str The IP address for which to set the reverse DNS entry
dns_ptr – Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(delete: bool | None = None, rebuild: bool | None = None) BoundAction[source]
Changes the protection configuration of the server.
- Parameters:
server –
BoundServerorServerdelete – boolean If true, prevents the server from being deleted (currently delete and rebuild attribute needs to have the same value)
rebuild – boolean If true, prevents the server from being rebuilt (currently delete and rebuild attribute needs to have the same value)
- Returns:
- change_type(server_type: ServerType | BoundServerType, upgrade_disk: bool) BoundAction[source]
Changes the type (Cores, RAM and disk sizes) of a server.
- Parameters:
server_type –
BoundServerTypeorServerTypeServer type the server should migrate toupgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.
- Returns:
- create_image(description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) CreateImageResponse[source]
Creates an image (snapshot) from a server by copying the contents of its disks.
- Parameters:
description – str (optional) Description of the image. If you do not set this we auto-generate one for you.
type – str (optional) Type of image to create (default: snapshot) Choices: snapshot, backup
labels – Dict[str, str] User-defined labels (key-value pairs)
- Returns:
- delete() BoundAction[source]
Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
- Returns:
- detach_from_network(network: Network | BoundNetwork) BoundAction[source]
Detaches a server from a network.
- Parameters:
network –
BoundNetworkorNetwork- Returns:
- detach_iso() BoundAction[source]
Detaches an ISO from a server.
- Returns:
- disable_backup() BoundAction[source]
Disables the automatic backup option and deletes all existing Backups for a Server.
- Returns:
- disable_rescue() BoundAction[source]
Disables the Hetzner Rescue System for a server.
- Returns:
- enable_backup() BoundAction[source]
Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%.
- Returns:
- enable_rescue(type: str | None = None, ssh_keys: list[str] | None = None) EnableRescueResponse[source]
Enable the Hetzner Rescue System for this server.
- Parameters:
type – str Type of rescue system to boot (default: linux64) Choices: linux64, linux32, freebsd64
ssh_keys – List[str] Array of SSH key IDs which should be injected into the rescue system. Only available for types: linux64 and linux32.
- Returns:
- get_actions(status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None) list[BoundAction][source]
Returns all Actions for a Server.
- Parameters:
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
- get_actions_list(status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]
Returns a paginated list of Actions for a Server.
- Parameters:
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
page – Page number to get.
per_page – Maximum number of Actions returned per page.
- get_metrics(type: Literal['cpu', 'disk', 'network'] | list[Literal['cpu', 'disk', 'network']], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse[source]
Get Metrics for a Server.
- Parameters:
server – The Server to get the metrics for.
type – Type of metrics to get.
start – Start of period to get Metrics for (in ISO-8601 format).
end – End of period to get Metrics for (in ISO-8601 format).
step – Resolution of results in seconds.
- power_off() BoundAction[source]
Cuts power to the server. This forcefully stops it without giving the server operating system time to gracefully stop
- Returns:
- power_on() BoundAction[source]
Starts a server by turning its power on.
- Returns:
- reboot() BoundAction[source]
Reboots a server gracefully by sending an ACPI request.
- Returns:
- rebuild(image: Image | BoundImage, user_data: str | None = None, **kwargs: Any) RebuildResponse[source]
Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.
- Parameters:
image – Image to use for the rebuilt server
user_data – Cloud-Init user data to use during Server rebuild (optional)
- remove_from_placement_group() BoundAction[source]
Removes a server from a placement group.
- Returns:
- request_console() RequestConsoleResponse[source]
Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server.
- Returns:
- reset() BoundAction[source]
Cuts power to a server and starts it again.
- Returns:
- reset_password() ResetPasswordResponse[source]
Resets the root password. Only works for Linux systems that are running the qemu guest agent.
- Returns:
- shutdown() BoundAction[source]
Shuts down a server gracefully by sending an ACPI shutdown request.
- Returns:
- update(name: str | None = None, labels: dict[str, str] | None = None) BoundServer[source]
Updates a server. You can update a server’s name and a server’s labels.
- Parameters:
name – str (optional) New name to set
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- class Server(id: int, name: str | None = None, status: str | None = None, created: str | None = None, public_net: PublicNetwork | None = None, server_type: BoundServerType | None = None, datacenter: BoundDatacenter | None = None, location: BoundLocation | None = None, image: BoundImage | None = None, iso: BoundIso | None = None, rescue_enabled: bool | None = None, locked: bool | None = None, backup_window: str | None = None, outgoing_traffic: int | None = None, ingoing_traffic: int | None = None, included_traffic: int | None = None, protection: ServerProtection | None = None, labels: dict[str, str] | None = None, volumes: list[BoundVolume] | None = None, private_net: list[PrivateNet] | None = None, primary_disk_size: int | None = None, placement_group: BoundPlacementGroup | None = None)[source]
Server Domain
- Parameters:
id – int ID of the server
name – str Name of the server (must be unique per project and a valid hostname as per RFC 1123)
status – str Status of the server Choices: running, initializing, starting, stopping, off, deleting, migrating, rebuilding, unknown
created – datetime Point in time when the server was created
public_net –
PublicNetworkPublic network information.server_type –
BoundServerTypedatacenter –
This property is deprecated and will be removed after 1 July 2026. Please use the
locationproperty instead.See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
location –
BoundLocationimage –
BoundImage, Noneiso –
BoundIso, Nonerescue_enabled – bool True if rescue mode is enabled: Server will then boot into rescue system on next reboot.
locked – bool True if server has been locked and is not available to user.
backup_window – str, None Time window (UTC) in which the backup will run, or None if the backups are not enabled
outgoing_traffic – int, None Outbound Traffic for the current billing period in bytes
ingoing_traffic – int, None Inbound Traffic for the current billing period in bytes
included_traffic – int Free Traffic for the current billing period in bytes
primary_disk_size – int Size of the primary Disk
protection – dict Protection configuration for the server
labels – dict User-defined labels (key-value pairs)
volumes – List[
BoundVolume] Volumes assigned to this server.private_net – List[
PrivateNet] Private networks information.
- STATUS_DELETING = 'deleting'
Server Status deleting
- STATUS_INIT = 'initializing'
Server Status initializing
- STATUS_MIGRATING = 'migrating'
Server Status migrating
- STATUS_OFF = 'off'
Server Status off
- STATUS_REBUILDING = 'rebuilding'
Server Status rebuilding
- STATUS_RUNNING = 'running'
Server Status running
- STATUS_STARTING = 'starting'
Server Status starting
- STATUS_STOPPING = 'stopping'
Server Status stopping
- STATUS_UNKNOWN = 'unknown'
Server Status unknown
- private_net_for(network: BoundNetwork | Network) PrivateNet | None[source]
Returns the server’s network attachment information in the given Network, and None if no attachment was found.
- class PublicNetwork(ipv4: IPv4Address | None, ipv6: IPv6Network | None, floating_ips: list[BoundFloatingIP], primary_ipv4: BoundPrimaryIP | None, primary_ipv6: BoundPrimaryIP | None, firewalls: list[PublicNetworkFirewall] | None = None)[source]
Public Network Domain
- Parameters:
ipv4 –
IPv4Addressipv6 –
IPv6Networkfloating_ips – List[
BoundFloatingIP]primary_ipv4 –
BoundPrimaryIPprimary_ipv6 –
BoundPrimaryIPfirewalls – List[
PublicNetworkFirewall]
- class IPv4Address(ip: str, blocked: bool, dns_ptr: str)[source]
IPv4 Address Domain
- Parameters:
ip – str The IPv4 Address
blocked – bool Determine if the IP is blocked
dns_ptr – str DNS PTR for the ip
- class IPv6Network(ip: str, blocked: bool, dns_ptr: list[DNSPtr])[source]
IPv6 Network Domain
- Parameters:
ip – str The IPv6 Network as CIDR Notation
blocked – bool Determine if the Network is blocked
dns_ptr – dict DNS PTR Records for the Network as Dict
network – str The network without the network mask
network_mask – str The network mask
- class CreateServerResponse(server: BoundServer, action: BoundAction, next_actions: list[BoundAction], root_password: str | None)[source]
Create Server Response Domain
- Parameters:
server –
BoundServerThe created serveraction –
BoundActionShows the progress of the server creationnext_actions – List[
BoundAction] Additional actions like a start_server action after the server creationroot_password – str, None The root password of the server if no SSH-Key was given on server creation
- class ServerCreatePublicNetwork(ipv4: PrimaryIP | None = None, ipv6: PrimaryIP | None = None, enable_ipv4: bool = True, enable_ipv6: bool = True)[source]
Server Create Public Network Domain
- class ResetPasswordResponse(action: BoundAction, root_password: str)[source]
Reset Password Response Domain
- Parameters:
action –
BoundActionShows the progress of the server passwort reset actionroot_password – str The root password of the server
- class EnableRescueResponse(action: BoundAction, root_password: str)[source]
Enable Rescue Response Domain
- Parameters:
action –
BoundActionShows the progress of the server enable rescue actionroot_password – str The root password of the server in the rescue mode
- class RequestConsoleResponse(action: BoundAction, wss_url: str, password: str)[source]
Request Console Response Domain
- Parameters:
action –
BoundActionShows the progress of the server request console actionwss_url – str URL of websocket proxy to use. This includes a token which is valid for a limited time only.
password – str VNC password to use for this connection. This password only works in combination with a wss_url with valid token.