Primary IPs

Create a Primary IP

Create a new Primary IP.

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 this Primary IP shall be created in.

A Primary IP can only be assigned to resource in the same Location later on.

Operation specific errors

StatusCodeDescription
422server_not_stoppedThe specified Server is running, but needs to be powered off
422server_has_ipv4The Server already has an ipv4 address
422server_has_ipv6The Server already has an ipv6 address
post/primary_ips

Request

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

Request body

namestring required

Name of the Resource. Must be unique per Project.

labelsobject

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

type'ipv4' | 'ipv6' required

Primary IP type.

assignee_type'server' | 'unassigned'

Type of resource to assign the Primary IP to.

Omitted if the Primary IP should not get assigned.

assignee_idinteger nullable

ID of resource to assign the Primary IP to.

Omitted if the Primary IP should not get assigned.

auto_deleteboolean

Auto deletion state.

If enabled the Primary IP will be deleted once the assigned resource gets deleted.

Example request

{
  "name": "my-resource",
  "labels": {
    "environment": "prod",
    "example.com/my": "label",
    "just-a-key": ""
  },
  "type": "ipv6",
  "location": "fsn1",
  "assignee_type": "server",
  "assignee_id": 17
}

Response

Request succeeded.

Example response

{
  "primary_ip": {
    "id": 42,
    "name": "my-resource",
    "labels": {
      "environment": "prod",
      "example.com/my": "label",
      "just-a-key": ""
    },
    "created": "2016-01-30T23:55:00Z",
    "location": {
      "id": 42,
      "name": "fsn1",
      "description": "Falkenstein DC Park 1",
      "country": "DE",
      "city": "Falkenstein",
      "latitude": 50.47612,
      "longitude": 12.370071,
      "network_zone": "eu-central"
    },
    "ip": "2001:db8::/64",
    "dns_ptr": [
      {
        "ip": "2001:db8::1",
        "dns_ptr": "server.example.com"
      }
    ],
    "type": "ipv6",
    "auto_delete": true,
    "assignee_type": "server",
    "assignee_id": 17
  },
  "action": {
    "id": 42,
    "command": "start_resource",
    "started": "2016-01-30T23:55:00Z",
    "finished": "2016-01-30T23:55:00Z",
    "progress": 100,
    "resources": [
      {
        "id": 42,
        "type": "server"
      }
    ],
    "error": {
      "code": "action_failed",
      "message": "Action failed"
    }
  }
}

Changes

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