openapi: 3.0.3 info: title: Hetzner Cloud Actions Primary IPs API version: 1.0.0 x-summary: 'Manage Hetzner Cloud services and resources linked to them, such as Floating IPs, Volumes and Load Balancers. ' description: "# Overview\n\nThis is the official documentation for the Hetzner Cloud API.\n\n## Introduction\n\nThe Hetzner Cloud API operates over HTTPS and uses JSON as its data format. The API is a RESTful API and utilizes HTTP methods and HTTP status codes to specify requests and responses.\n\nAs an alternative to working directly with our API you may also consider to use:\n\n- Our CLI program [hcloud](https://github.com/hetznercloud/cli)\n- Our [library for Go](https://github.com/hetznercloud/hcloud-go)\n- Our [library for Python](https://github.com/hetznercloud/hcloud-python)\n\nYou can find even more libraries, tools and integrations on our [Awesome List on GitHub](https://github.com/hetznercloud/awesome-hcloud).\n\n### Open source credits\n\nIf you are developing an open-source project that supports or intends to add support for Hetzner APIs, you may be eligible for a free one-time credit of up to € 50 / $ 50 on your account. Please contact us via the support page on your [Hetzner Console](https://console.hetzner.cloud/support) and let us know the following:\n\n- The name of the project you are working on\n- A short description of the project\n- Link to the project website or repo where the project is hosted\n- Affiliation with / role in the project (e.g. project maintainer)\n- Link to some other open-source work you have already done (if you have done so)\n\n**Note:** We only consider rewards for projects that provide Hetzner-specific functionality or integrations. For example, our Object Storage exposes a standard S3 API without any Hetzner-specific extensions. Projects that focus solely on generic S3 capabilities (e.g., general S3 clients or SDKs) are not Hetzner-specific and are therefore not eligible for Hetzner Rewards.\n\n## Getting Started\n\nTo get started using the API you first need an API token. Sign in into the [Hetzner Console](https://console.hetzner.com/) choose a Project, go to `Security` → `API Tokens`, and generate a new token. Make sure to copy the token because it won’t be shown to you again. A token is bound to a Project, to interact with the API of another Project you have to create a new token inside the Project. Let’s say your new token is `LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj`.\n\nYou’re now ready to do your first request against the API. To get a list of all Servers in your Project, issue the example request on the right side using [curl](https://curl.se/).\n\nMake sure to replace the token in the example command with the token you have just created. Since your Project probably does not contain any Servers yet, the example response will look like the response on the right side. We will almost always provide a resource root like `servers` inside the example response. A response can also contain a `meta` object with information like [Pagination](#description/pagination).\n\n**Example Request**\n\n```shell\ncurl -H \"Authorization: Bearer LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj\" \\\n https://api.hetzner.cloud/v1/servers\n```\n\n**Example Response**\n\n```json\n{\n \"servers\": [],\n \"meta\": {\n \"pagination\": {\n \"page\": 1,\n \"per_page\": 25,\n \"previous_page\": null,\n \"next_page\": null,\n \"last_page\": 1,\n \"total_entries\": 0\n }\n }\n}\n```\n\n## Authentication\n\nAll requests to the Hetzner Cloud API must be authenticated via a API token. Include your secret API token in every request you send to the API with the `Authorization` HTTP header.\n\nTo create a new API token for your Project, switch into the [Hetzner Console](https://console.hetzner.com/) choose a Project, go to `Security` → `API Tokens`, and generate a new token.\n\n**Example Authorization header**\n\n```http\nAuthorization: Bearer LRK9DAWQ1ZAEFSrCNEEzLCUwhYX1U3g7wMg4dTlkkDC96fyDuyJ39nVbVjCKSDfj\n```\n\n## Query Parameters\n\nThe API makes use of query parameters to sort and filter responses. The parameter names and values must be URI encoded according to [RFC2396](https://datatracker.ietf.org/doc/html/rfc2396). Query parameters of type `array` can be used multiple times:\n\n**Example query parameters for pagination**\n\n```\nhttps://api.hetzner.cloud/v1/certificates?page=1&page_size=12\n```\n\n**Example use of multiple values for a parameter**\n\n```\nhttps://api.hetzner.cloud/v1/certificates?type=uploaded&type=managed\n```\n\n**Example use of an encoded parameter**\n\n```\nhttps://api.hetzner.cloud/v1/certificates?label_selector=key%3Dvalue\n```\n\n## Errors\n\nErrors are indicated by HTTP status codes. Further, the response of the request which generated the error contains an error code, an error message, and, optionally, error details. The schema of the error details object depends on the error code.\n\nThe error response contains the following keys:\n\n| Keys | Meaning |\n| --------- | --------------------------------------------------------------------- |\n| `code` | Short string indicating the type of error (machine-parsable) |\n| `message` | Textual description on what has gone wrong |\n| `details` | An object providing for details on the error (schema depends on code) |\n\n**Example response**\n\n```json\n{\n \"error\": {\n \"code\": \"invalid_input\",\n \"message\": \"invalid input in field 'broken_field': is too long\",\n \"details\": {\n \"fields\": [\n {\n \"name\": \"broken_field\",\n \"messages\": [\"is too long\"]\n }\n ]\n }\n }\n}\n```\n\n### Error Codes\n\n| Status | Code | Description |\n| --- | --- | --- |\n| `400` | `json_error` | Invalid JSON input in your request. |\n| `401` | `unauthorized` | Request was made with an invalid or unknown token. |\n| `401` | `token_readonly` | The token is only allowed to perform GET requests. |\n| `403` | `forbidden` | Insufficient permissions for this request. |\n| `403` | `maintenance` | Cannot perform operation due to maintenance. |\n| `403` | `resource_limit_exceeded` | Error when exceeding the maximum quantity of a resource for an account. |\n| `404` | `not_found` | Entity not found. |\n| `405` | `method_not_allowed` | The request method is not allowed |\n| `409` | `uniqueness_error` | One or more of the objects fields must be unique. |\n| `409` | `conflict` | The resource has changed during the request, please retry. |\n| `410` | `deprecated_api_endpoint` | The API endpoint functionality was removed. |\n| `412` | `resource_unavailable` | The requested resource is currently unavailable (e.g. not available for order). |\n| `422` | `invalid_input` | Error while parsing or processing the input. |\n| `422` | `service_error` | Error within a service. |\n| `422` | `unsupported_error` | The corresponding resource does not support the Action. |\n| `423` | `locked` | The item you are trying to access is locked (there is already an Action running). |\n| `423` | `protected` | The Action you are trying to start is protected for this resource. |\n| `429` | `rate_limit_exceeded` | Error when sending too many requests. |\n| `500` | `server_error` | Error within the API backend. |\n| `503` | `unavailable` | A service or product is currently not available. |\n| `504` | `timeout` | The request could not be answered in time, please retry. |\n\n**invalid_input**\n\n```json\n{\n \"error\": {\n \"code\": \"invalid_input\",\n \"message\": \"invalid input in field 'broken_field': is too long\",\n \"details\": {\n \"fields\": [\n {\n \"name\": \"broken_field\",\n \"messages\": [\"is too long\"]\n }\n ]\n }\n }\n}\n```\n\n**uniqueness_error**\n\n```json\n{\n \"error\": {\n \"code\": \"uniqueness_error\",\n \"message\": \"SSH key with the same fingerprint already exists\",\n \"details\": {\n \"fields\": [\n {\n \"name\": \"public_key\"\n }\n ]\n }\n }\n}\n```\n\n**resource_limit_exceeded**\n\n```json\n{\n \"error\": {\n \"code\": \"resource_limit_exceeded\",\n \"message\": \"project limit exceeded\",\n \"details\": {\n \"limits\": [\n {\n \"name\": \"project_limit\"\n }\n ]\n }\n }\n}\n```\n\n**deprecated_api_endpoint**\n\n```json\n{\n \"error\": {\n \"code\": \"deprecated_api_endpoint\",\n \"message\": \"API functionality was removed\",\n \"details\": {\n \"announcement\": \"https://docs.hetzner.cloud/changelog#2023-07-20-foo-endpoint-is-deprecated\"\n }\n }\n}\n```\n\n## Actions\n\nActions represent asynchronous tasks within the API, targeting one or more resources. Triggering changes in the API may return a `running` action.\n\nAn action should be waited upon, until it reaches either the `success` or `error` state. Avoid polling the action's state too frequently to reduce the risk of exhausting your API requests and hitting the [rate limit](#description/rate-limiting).\n\nIf an action fails, it will contain details about the underlying error.\n\nOnce the asynchronous tasks have completed and the targeted resources are in a consistent state, the action is marked as succeeded.\n\nIn some cases, you may trigger multiple changes at once, and only wait for the returned actions at a later stage.\n\n## Labels\n\nLabels are `key/value` pairs that can be attached to all resources.\n\nValid label keys have two segments: an optional prefix and name, separated by a slash (`/`). The name segment is required and must be a string of 63 characters or less, beginning and ending with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots (`.`), not longer than 253 characters in total, followed by a slash (`/`).\n\nValid label values must be a string of 63 characters or less and must be empty or begin and end with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between.\n\nThe `hetzner.cloud/` prefix is reserved and cannot be used.\n\n**Example Labels**\n\n```json\n{\n \"labels\": {\n \"environment\": \"development\",\n \"service\": \"backend\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\"\n }\n}\n```\n\n## Label Selector\n\nFor resources with labels, you can filter resources by their labels using the label selector query language.\n\n| Expression | Meaning |\n| -------------------- | ---------------------------------------------------- |\n| `k==v` / `k=v` | Value of key `k` does equal value `v` |\n| `k!=v` | Value of key `k` does not equal value `v` |\n| `k` | Key `k` is present |\n| `!k` | Key `k` is not present |\n| `k in (v1,v2,v3)` | Value of key `k` is `v1`, `v2`, or `v3` |\n| `k notin (v1,v2,v3)` | Value of key `k` is neither `v1`, nor `v2`, nor `v3` |\n| `k1==v,!k2` | Value of key `k1` is `v` and key `k2` is not present |\n\n### Examples\n\n- Returns all resources that have a `env=production` label and that don't have a `type=database` label:\n\n `env=production,type!=database`\n\n- Returns all resources that have a `env=testing` or `env=staging` label:\n\n `env in (testing,staging)`\n\n- Returns all resources that don't have a `type` label:\n\n `!type`\n\n## Pagination\n\nResponses which return multiple items support pagination. If they do support pagination, it can be controlled with following query string parameters:\n\n- A `page` parameter specifies the page to fetch. The number of the first page is 1.\n- A `per_page` parameter specifies the number of items returned per page. The default value is 25, the maximum value is 50 except otherwise specified in the documentation.\n\nResponses contain a `Link` header with pagination information.\n\nAdditionally, if the response body is JSON and the root object is an object, that object has a `pagination` object inside the `meta` object with pagination information:\n\n**Example Pagination**\n\n```json\n{\n \"servers\": [...],\n \"meta\": {\n \"pagination\": {\n \"page\": 2,\n \"per_page\": 25,\n \"previous_page\": 1,\n \"next_page\": 3,\n \"last_page\": 4,\n \"total_entries\": 100\n }\n }\n}\n```\n\nThe keys `previous_page`, `next_page`, `last_page`, and `total_entries` may be `null` when on the first page, last page, or when the total number of entries is unknown.\n\n**Example Pagination Link header**\n\n```http\nLink: ; rel=\"prev\",\n ; rel=\"next\",\n ; rel=\"last\"\n```\n\nLine breaks have been added for display purposes only and responses may only contain some of the above `rel` values.\n\n## Rate Limiting\n\nAll requests, whether they are authenticated or not, are subject to rate limiting. If you have reached your limit, your requests will be handled with a `429 Too Many Requests` error. Burst requests are allowed. Responses contain several headers which provide information about your current rate limit status.\n\n- The `RateLimit-Limit` header contains the total number of requests you can perform per hour.\n- The `RateLimit-Remaining` header contains the number of requests remaining in the current rate limit time frame.\n- The `RateLimit-Reset` header contains a UNIX timestamp of the point in time when your rate limit will have recovered, and you will have the full number of requests available again.\n\nThe default limit is 3600 requests per hour and per Project. The number of remaining requests increases gradually. For example, when your limit is 3600 requests per hour, the number of remaining requests will increase by 1 every second.\n\n## Server Metadata\n\nYour Server can discover metadata about itself by doing a HTTP request to specific URLs. The following data is available:\n\n| Data | Format | Contents |\n| ----------------- | ------ | ------------------------------------------------------------ |\n| hostname | text | Name of the Server as set in the api |\n| instance-id | number | ID of the server |\n| public-ipv4 | text | Primary public IPv4 address |\n| private-networks | yaml | Details about the private networks the Server is attached to |\n| availability-zone | text | Name of the availability zone that Server runs in |\n| region | text | Network zone, e.g. eu-central |\n\n**Example: Summary**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata\n```\n\n```yaml\navailability-zone: hel1-dc2\nhostname: my-server\ninstance-id: 42\npublic-ipv4: 1.2.3.4\nregion: eu-central\n```\n\n**Example: Hostname**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/hostname\nmy-server\n```\n\n**Example: Instance ID**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/instance-id\n42\n```\n\n**Example: Public IPv4**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/public-ipv4\n1.2.3.4\n```\n\n**Example: Private Networks**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/private-networks\n```\n\n```yaml\n- ip: 10.0.0.2\n alias_ips: [10.0.0.3, 10.0.0.4]\n interface_num: 1\n mac_address: 86:00:00:2a:7d:e0\n network_id: 1234\n network_name: nw-test1\n network: 10.0.0.0/8\n subnet: 10.0.0.0/24\n gateway: 10.0.0.1\n- ip: 192.168.0.2\n alias_ips: []\n interface_num: 2\n mac_address: 86:00:00:2a:7d:e1\n network_id: 4321\n network_name: nw-test2\n network: 192.168.0.0/16\n subnet: 192.168.0.0/24\n gateway: 192.168.0.1\n```\n\n**Example: Availability Zone**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/availability-zone\nhel1-dc2\n```\n\n**Example: Region**\n\n```shell\n$ curl http://169.254.169.254/hetzner/v1/metadata/region\neu-central\n```\n\n## Sorting\n\nSome responses which return multiple items support sorting. If they do support sorting the documentation states which fields can be used for sorting. You specify sorting with the `sort` query string parameter. You can sort by multiple fields. You can set the sort direction by appending `:asc` or `:desc` to the field name. By default, ascending sorting is used.\n\n**Example: Sorting**\n\n```\nhttps://api.hetzner.cloud/v1/actions?sort=status\nhttps://api.hetzner.cloud/v1/actions?sort=status:asc\nhttps://api.hetzner.cloud/v1/actions?sort=status:desc\nhttps://api.hetzner.cloud/v1/actions?sort=status:asc&sort=command:desc\n```\n\n## Deprecation Notices\n\nYou can find all announced deprecations in our [Changelog](/changelog).\n" servers: - url: https://api.hetzner.cloud/v1 security: - APIToken: [] tags: - name: Primary IPs description: 'Primary IPs help you to create more flexible networking setups. You can assign at most one Primary IP of type `ipv4` and one of type `ipv6` per Server. This Server then uses these IPs. You can only unassign a Primary IP from a Server when it''s powered off. This Primary IP can then be assigned to a different powered off Server, or you can keep it around for later use. Primary IPs are bound to a specific Location. You can not assign a Primary IP from one Location to a Server in a different Location. If you need this capability use Floating IPs instead. If your Server''s operating system supports cloud-init there is no further configuration needed to make Primary IPs work. Primary IPs of type `ipv4` use a single IPv4 address as their `ip` property. Primary IPs of type `ipv6` use a /64 network such as `fc00::/64` as their `ip` property. Any IP address within that network can be used on your host. Primary IPs are billed on an hourly basis. ' paths: /primary_ips: get: operationId: list_primary_ips summary: List Primary IPs description: 'List multiple [Primary IPs](#tag/primary-ips). Use the provided URI parameters to modify the result. ' tags: - Primary IPs parameters: - description: 'Filter resources by their name. The response will only contain the resources matching exactly the specified name. ' name: name in: query required: false schema: type: string - description: 'Filter resources by labels. The response will only contain resources matching the label selector. For more information, see "[Label Selector](#description/label-selector)". ' name: label_selector in: query required: false schema: type: string - description: Filter results by IP address. name: ip in: query required: false schema: type: string example: 127.0.0.1 - description: Page number to return. For more information, see "[Pagination](#description/pagination)". name: page in: query required: false schema: type: integer format: int64 default: 1 example: 1 - description: Maximum number of entries returned per page. For more information, see "[Pagination](#description/pagination)". name: per_page in: query required: false schema: type: integer format: int64 default: 25 example: 25 - description: 'Sort resources by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". ' name: sort in: query required: false schema: type: array items: type: string enum: - id - id:asc - id:desc - created - created:asc - created:desc responses: '200': description: Request succeeded. content: application/json: schema: title: PrimaryIPsResponse type: object properties: primary_ips: type: array items: title: PrimaryIP type: object properties: id: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' created: description: Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). type: string format: date-time example: '2016-01-30T23:55:00Z' blocked: description: Blocked state of the [Primary IP](#tag/primary-ips). type: boolean example: false datacenter: deprecated: true description: '**Deprecated**: This property is deprecated and will be removed after the 1 July 2026. Use the `location` property instead. [Data Center](#tag/data-centers) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Data Center](#tag/data-centers). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: 'Unique name for the [Data Center](#tag/data-centers). May be used as a more descriptive identifier. ' type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1-dc8 description: description: 'Descriptive name for the [Data Center](#tag/data-centers). Desired to be easy to understand for humans. May change for cosmetic reasons. Must not be used as an identifier. ' type: string example: Falkenstein DC Park 8 location: description: '[Location](#tag/locations) the [Data Center](#tag/data-centers) is located at. ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone server_types: deprecated: true description: 'This field is deprecated, as all of it''s properties are deprecated. [Server Types](#tag/server-types) supported and available in this [Data Center](#tag/data-centers). ' type: object properties: supported: deprecated: true description: 'This field is deprecated. Use the [Server Type](#tag/server-types) `locations` field instead. List of [Server Types](#tag/server-types) supported in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) are generally available in this Data Center, but may be temporarily out of stock. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) currently available in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) can currently be purchased. Types that are temporarily unavailable but are supported in this [Data Center](#tag/data-centers) are listed as `supported`. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available_for_migration: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) available to migrate to in this [Data Center](#tag/data-centers). Existing [Servers](#tag/servers) can be migrated to these [Server Types](#tag/server-types). ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 required: - supported - available - available_for_migration required: - id - name - description - location - server_types location: description: '[Location](#tag/locations) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone ip: description: IP address. type: string example: 2001:db8::/64 dns_ptr: description: List of reverse DNS records. type: array items: type: object properties: ip: description: 'Single IPv4 or IPv6 address of the record. ' type: string example: 2001:db8::1 dns_ptr: description: 'Domain Name to point to. PTR record content used for reverse DNS. ' type: string example: server.example.com required: - ip - dns_ptr protection: description: Protection configuration for the Resource. type: object properties: delete: description: Prevent the Resource from being deleted. type: boolean example: false required: - delete type: description: '[Primary IP](#tag/primary-ips) type.' type: string enum: - ipv4 - ipv6 example: ipv6 auto_delete: description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false example: true assignee_type: description: 'Type of resource the [Primary IP](#tag/primary-ips) can get assigned to. ' type: string enum: - server example: server assignee_id: description: 'ID of resource the [Primary IP](#tag/primary-ips) is assigned to. `null` if the [Primary IP](#tag/primary-ips) is not assigned. ' type: integer format: int64 nullable: true example: 17 required: - id - name - labels - created - blocked - location - datacenter - ip - dns_ptr - protection - type - auto_delete - assignee_type - assignee_id meta: title: ListMeta type: object properties: pagination: description: See "[Pagination](#description/pagination)" for more information. type: object properties: page: description: Current page number. type: integer format: int64 example: 3 per_page: description: Maximum number of entries returned per page. type: integer format: int64 example: 25 previous_page: description: Page number of the previous page. Can be null if the current page is the first one. type: integer format: int64 nullable: true example: 2 next_page: description: Page number of the next page. Can be null if the current page is the last one. type: integer format: int64 nullable: true example: 4 last_page: description: Page number of the last page available. Can be null if the current page is the last one. type: integer format: int64 nullable: true example: 4 total_entries: description: Total number of entries that exist for this query. Can be null if unknown. type: integer format: int64 nullable: true example: 100 required: - page - per_page - previous_page - next_page - last_page - total_entries required: - pagination required: - primary_ips - meta 4xx: description: Request failed with a user error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: unauthorized message: unable to authenticate details: null 5xx: description: Request failed with a server error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: timeout message: request timeout details: null security: - APIToken: [] x-codeSamples: - lang: Go label: Go source: "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIPs, err := client.PrimaryIP.All(ctx)\n}" - lang: Python label: Python source: 'from __future__ import annotations from os import environ from hcloud import Client token = environ["HCLOUD_TOKEN"] client = Client(token=token) primary_ips = client.primary_ips.get_all()' - lang: Shell label: CLI source: hcloud primary-ip list post: operationId: create_primary_ip summary: Create a Primary IP description: 'Create a new [Primary IP](#tag/primary-ips). Can optionally be assigned to a resource by providing an `assignee_id` and `assignee_type`. If not assigned to a resource the `location` key needs to be provided. This can be either the ID or the name of the [Location](#tag/locations) this [Primary IP](#tag/primary-ips) shall be created in. A [Primary IP](#tag/primary-ips) can only be assigned to resource in the same [Location](#tag/locations) later on. The `datacenter` key is deprecated in favor of `location` and will be removed after 01 July 2026. #### Operation specific errors | Status | Code | Description | | --- | --- | --- | | `422` | `server_not_stopped` | The specified [Server](#tag/servers) is running, but needs to be powered off | | `422` | `server_has_ipv4` | The [Server](#tag/servers) already has an ipv4 address | | `422` | `server_has_ipv6` | The [Server](#tag/servers) already has an ipv6 address | ' tags: - Primary IPs requestBody: description: 'Request Body for creating a new [Primary IP](#tag/primary-ips). The `location`, `datacenter` and `assignee_id`/`assignee_type` attributes are mutually exclusive. ' required: true content: application/json: schema: title: PrimaryIPCreateRequest type: object properties: name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' type: description: '[Primary IP](#tag/primary-ips) type.' type: string enum: - ipv4 - ipv6 example: ipv6 datacenter: deprecated: true description: '**Deprecated**: This property is deprecated and will be removed after 1 July 2026. Use the `location` key instead. [Data Center](#tag/data-centers) ID or name. The [Primary IP](#tag/primary-ips) will be bound to this [Data Center](#tag/data-centers). Omit if `assignee_id`/`assignee_type` or `location` are provided. ' oneOf: - description: '**Deprecated**: This property is deprecated and will be removed after 1 July 2026. Use the `location` key instead. [Data Center](#tag/data-centers) ID or name. The [Primary IP](#tag/primary-ips) will be bound to this [Data Center](#tag/data-centers). Omit if `assignee_id`/`assignee_type` or `location` are provided. ' type: string example: fsn1-dc8 - description: '**Deprecated**: This property is deprecated and will be removed after 1 July 2026. Use the `location` key instead. [Data Center](#tag/data-centers) ID or name. The [Primary IP](#tag/primary-ips) will be bound to this [Data Center](#tag/data-centers). Omit if `assignee_id`/`assignee_type` or `location` are provided. ' type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 location: description: '[Location](#tag/locations) ID or name the [Primary IP](#tag/primary-ips) will be bound to. Omit if `assignee_id`/`assignee_type` or `datacenter` are provided. ' oneOf: - description: '[Location](#tag/locations) ID or name the [Primary IP](#tag/primary-ips) will be bound to. Omit if `assignee_id`/`assignee_type` or `datacenter` are provided. ' type: string example: fsn1 - description: '[Location](#tag/locations) ID or name the [Primary IP](#tag/primary-ips) will be bound to. Omit if `assignee_id`/`assignee_type` or `datacenter` are provided. ' type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 assignee_type: description: 'Type of resource the [Primary IP](#tag/primary-ips) can get assigned to. Currently [Primary IPs](#tag/primary-ips) can only be assigned to [Servers](#tag/servers), therefore this field must be set to `server`. ' type: string enum: - server example: server assignee_id: description: 'ID of resource to assign the [Primary IP](#tag/primary-ips) to. Omitted if the [Primary IP](#tag/primary-ips) should not get assigned. ' type: integer format: int64 nullable: true example: 17 auto_delete: example: false description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false required: - name - type - assignee_type responses: '201': description: Request succeeded. content: application/json: schema: title: CreatePrimaryIPResponse type: object properties: primary_ip: title: PrimaryIP type: object properties: id: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' created: description: Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). type: string format: date-time example: '2016-01-30T23:55:00Z' blocked: description: Blocked state of the [Primary IP](#tag/primary-ips). type: boolean example: false datacenter: deprecated: true description: '**Deprecated**: This property is deprecated and will be removed after the 1 July 2026. Use the `location` property instead. [Data Center](#tag/data-centers) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Data Center](#tag/data-centers). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: 'Unique name for the [Data Center](#tag/data-centers). May be used as a more descriptive identifier. ' type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1-dc8 description: description: 'Descriptive name for the [Data Center](#tag/data-centers). Desired to be easy to understand for humans. May change for cosmetic reasons. Must not be used as an identifier. ' type: string example: Falkenstein DC Park 8 location: description: '[Location](#tag/locations) the [Data Center](#tag/data-centers) is located at. ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone server_types: deprecated: true description: 'This field is deprecated, as all of it''s properties are deprecated. [Server Types](#tag/server-types) supported and available in this [Data Center](#tag/data-centers). ' type: object properties: supported: deprecated: true description: 'This field is deprecated. Use the [Server Type](#tag/server-types) `locations` field instead. List of [Server Types](#tag/server-types) supported in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) are generally available in this Data Center, but may be temporarily out of stock. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) currently available in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) can currently be purchased. Types that are temporarily unavailable but are supported in this [Data Center](#tag/data-centers) are listed as `supported`. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available_for_migration: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) available to migrate to in this [Data Center](#tag/data-centers). Existing [Servers](#tag/servers) can be migrated to these [Server Types](#tag/server-types). ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 required: - supported - available - available_for_migration required: - id - name - description - location - server_types location: description: '[Location](#tag/locations) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone ip: description: IP address. type: string example: 2001:db8::/64 dns_ptr: description: List of reverse DNS records. type: array items: type: object properties: ip: description: 'Single IPv4 or IPv6 address of the record. ' type: string example: 2001:db8::1 dns_ptr: description: 'Domain Name to point to. PTR record content used for reverse DNS. ' type: string example: server.example.com required: - ip - dns_ptr protection: description: Protection configuration for the Resource. type: object properties: delete: description: Prevent the Resource from being deleted. type: boolean example: false required: - delete type: description: '[Primary IP](#tag/primary-ips) type.' type: string enum: - ipv4 - ipv6 example: ipv6 auto_delete: description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false example: true assignee_type: description: 'Type of resource the [Primary IP](#tag/primary-ips) can get assigned to. ' type: string enum: - server example: server assignee_id: description: 'ID of resource the [Primary IP](#tag/primary-ips) is assigned to. `null` if the [Primary IP](#tag/primary-ips) is not assigned. ' type: integer format: int64 nullable: true example: 17 required: - id - name - labels - created - blocked - location - datacenter - ip - dns_ptr - protection - type - auto_delete - assignee_type - assignee_id action: title: Action type: object properties: id: description: ID of the [Action](#description/actions). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 command: description: Command executed in the Action. type: string example: start_resource status: description: Status of the Action. type: string enum: - running - success - error started: description: Point in time when the Action was started (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). type: string format: date-time example: '2016-01-30T23:55:00Z' finished: description: Point in time when the Action was finished (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). Only set if the Action is finished otherwise null. type: string format: date-time example: '2016-01-30T23:55:00Z' nullable: true progress: description: Progress of the Action in percent. type: integer format: int32 example: 100 resources: description: Resources the Action relates to. type: array items: type: object properties: id: description: ID of the Resource. type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 type: description: Type of the Resource. type: string example: server required: - id - type error: description: Error message for the Action if an error occurred, otherwise null. type: object nullable: true properties: code: description: Fixed error code for machines. type: string example: action_failed message: description: Error message for humans. type: string example: Action failed required: - code - message required: - id - command - status - progress - started - finished - resources - error required: - primary_ip examples: default: value: primary_ip: id: 42 name: my-ip labels: key: value created: '2016-01-30T23:50:00Z' blocked: false location: id: 1 name: fsn1 description: Falkenstein DC Park 1 country: DE city: Falkenstein latitude: 50.47612 longitude: 12.370071 network_zone: eu-central datacenter: id: 42 name: fsn1-dc8 description: Falkenstein DC Park 8 location: id: 1 name: fsn1 description: Falkenstein DC Park 1 country: DE city: Falkenstein latitude: 50.47612 longitude: 12.370071 network_zone: eu-central server_types: supported: - 1 - 2 - 3 available: - 1 - 2 - 3 available_for_migration: - 1 - 2 - 3 ip: 2001:db8::/64 dns_ptr: - ip: 2001:db8::1 dns_ptr: server.example.com protection: delete: false type: ipv6 auto_delete: true assignee_type: server assignee_id: 17 action: id: 13 command: assign_primary_ip status: running progress: 0 started: '2016-01-30T23:50:00Z' finished: null resources: - id: 17 type: server error: code: action_failed message: Action failed 4xx: description: Request failed with a user error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: unauthorized message: unable to authenticate details: null 5xx: description: Request failed with a server error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: timeout message: request timeout details: null security: - APIToken: [] x-codeSamples: - lang: Go label: Go source: "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tresult, _, err := client.PrimaryIP.Create(ctx, hcloud.PrimaryIPCreateOpts{\n\t\tAssigneeID: hcloud.Ptr(int64(17)),\n\t\tAssigneeType: \"server\",\n\t\tAutoDelete: hcloud.Ptr(false),\n\t\tLocation: \"hel1\",\n\t\tLabels: map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t},\n\t\tName: \"my-ip\",\n\t\tType: \"ipv4\",\n\t})\n\n\terr = client.Action.WaitFor(ctx, result.Action)\n\n\tprimaryIP := result.PrimaryIP\n}" - lang: Python label: Python source: "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nresponse = client.primary_ips.create(\n assignee_id=17,\n assignee_type=\"server\",\n auto_delete=False,\n location=\"hel1\",\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n type=\"ipv4\",\n)\n\nresponse.action.wait_until_finished()\n\nprimary_ip = response.primary_ip" - lang: Shell label: CLI source: "hcloud primary-ip create \\\n --assignee-id 17 \\\n --auto-delete=false \\\n --location hel1 \\\n --label \"environment=prod\" \\\n --label \"example.com/my=label\" \\\n --label \"just-a-key=\" \\\n --name my-ip \\\n --type ipv4" /primary_ips/{id}: get: operationId: get_primary_ip summary: Get a Primary IP description: 'Returns a [Primary IP](#tag/primary-ips). ' tags: - Primary IPs parameters: - description: ID of the Primary IP. name: id in: path required: true schema: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 responses: '200': description: Request succeeded. content: application/json: schema: title: PrimaryIPResponse type: object properties: primary_ip: title: PrimaryIP type: object properties: id: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' created: description: Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). type: string format: date-time example: '2016-01-30T23:55:00Z' blocked: description: Blocked state of the [Primary IP](#tag/primary-ips). type: boolean example: false datacenter: deprecated: true description: '**Deprecated**: This property is deprecated and will be removed after the 1 July 2026. Use the `location` property instead. [Data Center](#tag/data-centers) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Data Center](#tag/data-centers). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: 'Unique name for the [Data Center](#tag/data-centers). May be used as a more descriptive identifier. ' type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1-dc8 description: description: 'Descriptive name for the [Data Center](#tag/data-centers). Desired to be easy to understand for humans. May change for cosmetic reasons. Must not be used as an identifier. ' type: string example: Falkenstein DC Park 8 location: description: '[Location](#tag/locations) the [Data Center](#tag/data-centers) is located at. ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone server_types: deprecated: true description: 'This field is deprecated, as all of it''s properties are deprecated. [Server Types](#tag/server-types) supported and available in this [Data Center](#tag/data-centers). ' type: object properties: supported: deprecated: true description: 'This field is deprecated. Use the [Server Type](#tag/server-types) `locations` field instead. List of [Server Types](#tag/server-types) supported in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) are generally available in this Data Center, but may be temporarily out of stock. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) currently available in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) can currently be purchased. Types that are temporarily unavailable but are supported in this [Data Center](#tag/data-centers) are listed as `supported`. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available_for_migration: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) available to migrate to in this [Data Center](#tag/data-centers). Existing [Servers](#tag/servers) can be migrated to these [Server Types](#tag/server-types). ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 required: - supported - available - available_for_migration required: - id - name - description - location - server_types location: description: '[Location](#tag/locations) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone ip: description: IP address. type: string example: 2001:db8::/64 dns_ptr: description: List of reverse DNS records. type: array items: type: object properties: ip: description: 'Single IPv4 or IPv6 address of the record. ' type: string example: 2001:db8::1 dns_ptr: description: 'Domain Name to point to. PTR record content used for reverse DNS. ' type: string example: server.example.com required: - ip - dns_ptr protection: description: Protection configuration for the Resource. type: object properties: delete: description: Prevent the Resource from being deleted. type: boolean example: false required: - delete type: description: '[Primary IP](#tag/primary-ips) type.' type: string enum: - ipv4 - ipv6 example: ipv6 auto_delete: description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false example: true assignee_type: description: 'Type of resource the [Primary IP](#tag/primary-ips) can get assigned to. ' type: string enum: - server example: server assignee_id: description: 'ID of resource the [Primary IP](#tag/primary-ips) is assigned to. `null` if the [Primary IP](#tag/primary-ips) is not assigned. ' type: integer format: int64 nullable: true example: 17 required: - id - name - labels - created - blocked - location - datacenter - ip - dns_ptr - protection - type - auto_delete - assignee_type - assignee_id required: - primary_ip 4xx: description: Request failed with a user error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: unauthorized message: unable to authenticate details: null 5xx: description: Request failed with a server error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: timeout message: request timeout details: null security: - APIToken: [] x-codeSamples: - lang: Go label: Go source: "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.GetByID(ctx, 123)\n}" - lang: Python label: Python source: 'from __future__ import annotations from os import environ from hcloud import Client token = environ["HCLOUD_TOKEN"] client = Client(token=token) primary_ip = client.primary_ips.get_by_id(123)' - lang: Shell label: CLI source: hcloud primary-ip describe $PRIMARYIP put: operationId: update_primary_ip summary: Update a Primary IP description: 'Update a [Primary IP](#tag/primary-ips). If another change is concurrently performed on this [Primary IP](#tag/primary-ips), a error response with code `conflict` will be returned. ' tags: - Primary IPs parameters: - description: ID of the Primary IP. name: id in: path required: true schema: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 requestBody: required: true content: application/json: schema: title: PrimaryIPUpdateRequest type: object properties: name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. Note that the set of [Labels](#description/labels) provided in the request will overwrite the existing one. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' auto_delete: description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false example: true responses: '200': description: Request succeeded. content: application/json: schema: title: PrimaryIPResponse type: object properties: primary_ip: title: PrimaryIP type: object properties: id: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Name of the Resource. Must be unique per Project. type: string example: my-resource labels: description: 'User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". ' type: object additionalProperties: type: string example: environment: prod example.com/my: label just-a-key: '' created: description: Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). type: string format: date-time example: '2016-01-30T23:55:00Z' blocked: description: Blocked state of the [Primary IP](#tag/primary-ips). type: boolean example: false datacenter: deprecated: true description: '**Deprecated**: This property is deprecated and will be removed after the 1 July 2026. Use the `location` property instead. [Data Center](#tag/data-centers) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Data Center](#tag/data-centers). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: 'Unique name for the [Data Center](#tag/data-centers). May be used as a more descriptive identifier. ' type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1-dc8 description: description: 'Descriptive name for the [Data Center](#tag/data-centers). Desired to be easy to understand for humans. May change for cosmetic reasons. Must not be used as an identifier. ' type: string example: Falkenstein DC Park 8 location: description: '[Location](#tag/locations) the [Data Center](#tag/data-centers) is located at. ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone server_types: deprecated: true description: 'This field is deprecated, as all of it''s properties are deprecated. [Server Types](#tag/server-types) supported and available in this [Data Center](#tag/data-centers). ' type: object properties: supported: deprecated: true description: 'This field is deprecated. Use the [Server Type](#tag/server-types) `locations` field instead. List of [Server Types](#tag/server-types) supported in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) are generally available in this Data Center, but may be temporarily out of stock. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) currently available in this [Data Center](#tag/data-centers). These [Server Types](#tag/server-types) can currently be purchased. Types that are temporarily unavailable but are supported in this [Data Center](#tag/data-centers) are listed as `supported`. ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 available_for_migration: deprecated: true description: 'This field is deprecated. Use the `available` flag in the [Server Type](#tag/server-types) `locations` field instead (`server_type.locations[].available`). [Server Types](#tag/server-types) available to migrate to in this [Data Center](#tag/data-centers). Existing [Servers](#tag/servers) can be migrated to these [Server Types](#tag/server-types). ' type: array items: type: integer format: int64 example: - 1 - 2 - 3 required: - supported - available - available_for_migration required: - id - name - description - location - server_types location: description: '[Location](#tag/locations) of the [Primary IP](#tag/primary-ips). ' type: object properties: id: description: ID of the [Location](#tag/locations). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 name: description: Unique identifier of the [Location](#tag/locations). type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: fsn1 description: description: Human readable description of the [Location](#tag/locations). type: string example: Falkenstein DC Park 1 country: description: 'Country the [Location](#tag/locations) resides in. ISO 3166-1 alpha-2 code of the country. ' type: string example: DE city: description: 'Name of the closest city to the [Location](#tag/locations). City name or city name and state in short form. E.g. `Falkenstein` or `Ashburn, VA`. ' type: string example: Falkenstein latitude: description: Latitude of the city closest to the [Location](#tag/locations). type: number format: double example: 50.47612 longitude: description: Longitude of the city closest to the [Location](#tag/locations). type: number format: double example: 12.370071 network_zone: description: Name of the Network Zone this [Location](#tag/locations) resides in. type: string pattern: ^[a-z0-9]+(-?[a-z0-9]*)*$ example: eu-central required: - id - name - description - country - city - latitude - longitude - network_zone ip: description: IP address. type: string example: 2001:db8::/64 dns_ptr: description: List of reverse DNS records. type: array items: type: object properties: ip: description: 'Single IPv4 or IPv6 address of the record. ' type: string example: 2001:db8::1 dns_ptr: description: 'Domain Name to point to. PTR record content used for reverse DNS. ' type: string example: server.example.com required: - ip - dns_ptr protection: description: Protection configuration for the Resource. type: object properties: delete: description: Prevent the Resource from being deleted. type: boolean example: false required: - delete type: description: '[Primary IP](#tag/primary-ips) type.' type: string enum: - ipv4 - ipv6 example: ipv6 auto_delete: description: 'Auto deletion state. If enabled the [Primary IP](#tag/primary-ips) will be deleted once the assigned resource gets deleted. ' type: boolean default: false example: true assignee_type: description: 'Type of resource the [Primary IP](#tag/primary-ips) can get assigned to. ' type: string enum: - server example: server assignee_id: description: 'ID of resource the [Primary IP](#tag/primary-ips) is assigned to. `null` if the [Primary IP](#tag/primary-ips) is not assigned. ' type: integer format: int64 nullable: true example: 17 required: - id - name - labels - created - blocked - location - datacenter - ip - dns_ptr - protection - type - auto_delete - assignee_type - assignee_id required: - primary_ip 4xx: description: Request failed with a user error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: unauthorized message: unable to authenticate details: null 5xx: description: Request failed with a server error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: timeout message: request timeout details: null security: - APIToken: [] x-codeSamples: - lang: Go label: Go source: "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\tprimaryIP, _, err := client.PrimaryIP.Update(ctx, &hcloud.PrimaryIP{ID: 123}, hcloud.PrimaryIPUpdateOpts{\n\t\tAutoDelete: hcloud.Ptr(true),\n\t\tLabels: hcloud.Ptr(map[string]string{\n\t\t\t\"environment\": \"prod\",\n\t\t\t\"example.com/my\": \"label\",\n\t\t\t\"just-a-key\": \"\",\n\t\t}),\n\t\tName: \"my-ip\",\n\t})\n}" - lang: Python label: Python source: "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nprimary_ip = client.primary_ips.update(\n primary_ip=PrimaryIP(id=123),\n auto_delete=True,\n labels={\n \"environment\": \"prod\",\n \"example.com/my\": \"label\",\n \"just-a-key\": \"\",\n },\n name=\"my-resource\",\n)" - lang: Shell label: CLI source: "hcloud primary-ip update $PRIMARYIP \\\n --auto-delete=false \\\n --name \"new-name\"\nhcloud primary-ip add-label --overwrite $PRIMARYIP \\\n \"environment=prod\" \"example.com/my=label\" \"just-a-key=\"\nhcloud primary-ip remove-label $PRIMARYIP \\\n \"environment\" \"example.com\" \"just-a-key\"" delete: operationId: delete_primary_ip summary: Delete a Primary IP description: 'Deletes a [Primary IP](#tag/primary-ips). The [Server](#tag/servers) must be powered off (status `off`) in order for this operation to succeed. If assigned to a [Server](#tag/servers) the [Primary IP](#tag/primary-ips) will be unassigned automatically until 1 May 2026. After this date, the [Primary IP](#tag/primary-ips) needs to be unassigned before it can be deleted. #### Operation specific errors | Status | Code | Description | | --- | --- | --- | | `422` | `must_be_unassigned` | Error when IP is still assigned to a Resource. This error will appear as of 1 May 2026. | ' tags: - Primary IPs parameters: - description: ID of the Primary IP. name: id in: path required: true schema: description: ID of the [Primary IP](#tag/primary-ips). type: integer format: int64 minimum: 1 maximum: 9007199254740991 example: 42 responses: '204': description: Request succeeded. 4xx: description: Request failed with a user error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: unauthorized message: unable to authenticate details: null 5xx: description: Request failed with a server error. content: application/json: schema: type: object properties: error: type: object properties: code: description: Error code for machines. type: string message: description: Error message for humans. type: string details: description: Details about the error. type: object nullable: true required: - code - message required: - error example: error: code: timeout message: request timeout details: null security: - APIToken: [] x-codeSamples: - lang: Go label: Go source: "package examples\n\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/hetznercloud/hcloud-go/v2/hcloud\"\n)\n\nfunc main() {\n\ttoken := os.Getenv(\"HCLOUD_TOKEN\")\n\n\tclient := hcloud.NewClient(hcloud.WithToken(token))\n\tctx := context.TODO()\n\n\t_, err := client.PrimaryIP.Delete(ctx, &hcloud.PrimaryIP{ID: 123})\n}" - lang: Python label: Python source: "from __future__ import annotations\n\nfrom os import environ\n\nfrom hcloud import Client\nfrom hcloud.primary_ips import PrimaryIP\n\ntoken = environ[\"HCLOUD_TOKEN\"]\nclient = Client(token=token)\n\nclient.primary_ips.delete(\n primary_ip=PrimaryIP(id=123),\n)" - lang: Shell label: CLI source: hcloud primary-ip delete $PRIMARYIP components: securitySchemes: APIToken: type: http scheme: bearer x-tagGroups: - name: Actions tags: - Actions - name: Servers tags: - Servers - Server Actions - Server Types - Images - Image Actions - ISOs - Placement Groups - Primary IPs - Primary IP Actions - name: Volumes tags: - Volumes - Volume Actions - name: Floating IPs tags: - Floating IPs - Floating IP Actions - name: Firewalls tags: - Firewalls - Firewall Actions - name: Load Balancers tags: - Load Balancers - Load Balancer Actions - Load Balancer Types - name: Networks tags: - Networks - Network Actions - name: DNS tags: - Zones - Zone Actions - Zone RRSets - Zone RRSet Actions - name: Security tags: - Certificates - Certificate Actions - SSH Keys - name: Locations tags: - Locations - Data Centers - name: Billing tags: - Pricing