{ "openapi": "3.0.1", "info": { "title": "Hetzner DNS Public API", "description": "This is the public documentation Hetzner's DNS API.", "contact": { "name": "Hetzner Online GmbH", "email": "support@hetzner.com" }, "version": "1.1.1", "x-logo": { "url": "https://www.hetzner.com/themes/hetzner/images/logo/hetzner-logo.svg", "altText": "Hetzner" } }, "servers": [ { "url": "https://dns.hetzner.com/api/v1" } ], "tags": [ { "name": "Zones", "description": "A secondary zone can be created, by adding a primary server before adding any records." }, { "name": "Records", "description": "" }, { "name": "Primary Servers", "description": "Primary servers can only be added to a zone, if no records were added to it, yet. By adding a primary server to a newly created zone, it automatically becomes a secondary zone." } ], "security": [{"Auth-API-Token": []}], "paths": { "/zones": { "get": { "tags": [ "Zones" ], "summary": "Get All Zones", "description": "Returns paginated zones associated with the user. Limited to 100 zones per request.", "operationId": "GetZones", "parameters": [ { "name": "name", "in": "query", "description": "Full name of a zone. Will return an array with one or no results", "required": false, "style": "form", "explode": true, "schema": { "type": "string", "example": "example.com" } }, { "name": "search_name", "in": "query", "description": "Partial name of a zone. Will return a maximum of 100 zones that contain the searched string", "required": false, "style": "form", "explode": true, "schema": { "type": "string", "example": "example" } }, { "name": "per_page", "in": "query", "description": "Number of zones to be shown per page. Returns 100 by default", "required": false, "style": "form", "explode": true, "schema": { "type": "number", "default": 100.0, "maximum": 100.0 } }, { "name": "page", "in": "query", "description": "A page parameter specifies the page to fetch.
The number of the first page is 1", "required": false, "style": "form", "explode": true, "schema": { "type": "integer", "minimum": 1, "default": 1 } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "zones": { "type": "array", "items": { "$ref": "#/components/schemas/ZoneResponse" } }, "meta": { "$ref": "#/components/schemas/Meta" } } } } } }, "400": { "description": "Pagination selectors are mutually exclusive" }, "401": { "description": "Unauthorized" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Get Zones\n# Returns all zones associated with the user.\ncurl \"https://dns.hetzner.com/api/v1/zones\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendGetZones() {\n\t// Get Zones (GET https://dns.hetzner.com/api/v1/zones)\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"GET\", \"https://dns.hetzner.com/api/v1/zones\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " 'example.com',\n 'ttl' => 86400\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Create Zone\n # POST https://dns.hetzner.com/api/v1/zones\n\n try:\n response = requests.post(\n url=\"https://dns.hetzner.com/api/v1/zones\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"name\": \"example.com\",\n \"ttl\": 86400\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" } }, "/zones/{ZoneID}": { "get": { "tags": [ "Zones" ], "summary": "Get Zone", "description": "Returns an object containing all information about a zone. Zone to get is identified by 'ZoneID'.", "operationId": "GetZone", "parameters": [ { "name": "ZoneID", "in": "path", "description": "ID of zone to get", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "zone": { "$ref": "#/components/schemas/ZoneResponse" } } } } } }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Get Zone\n# Returns an object containing all information about a zone. Zone to get is identified by 'ZoneID'.\ncurl \"https://dns.hetzner.com/api/v1/zones/{ZoneID}\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj' \\\n -H 'Content-Type: application/json; charset=utf-8'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendGetZone() {\n\t// Get Zone (GET https://dns.hetzner.com/api/v1/zones/{ZoneID})\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"GET\", \"https://dns.hetzner.com/api/v1/zones/{ZoneID}\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\treq.Header.Add(\"Content-Type\", \"application/json; charset=utf-8\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " 'example.com',\n 'ttl' => 86400\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Update Zone\n # PUT https://dns.hetzner.com/api/v1/zones/{ZoneID}\n\n try:\n response = requests.put(\n url=\"https://dns.hetzner.com/api/v1/zones/{ZoneID}\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"name\": \"example.com\",\n \"ttl\": 86400\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" }, "delete": { "tags": [ "Zones" ], "summary": "Delete Zone", "description": "Deletes a zone.", "operationId": "DeleteZone", "parameters": [ { "name": "ZoneID", "in": "path", "description": "ID of zone to be deleted", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response" }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Delete Zone\n# Deletes a zone.\ncurl -X \"DELETE\" \"https://dns.hetzner.com/api/v1/zones/{ZoneID}\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendDeleteZone() {\n\t// Delete Zone (DELETE https://dns.hetzner.com/api/v1/zones/{ZoneID})\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"DELETE\", \"https://dns.hetzner.com/api/v1/zones/{ZoneID}\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": "The number of the first page is 1", "required": false, "style": "form", "explode": true, "schema": { "type": "number", "minimum": 1, "default": 1 } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "records": { "type": "array", "items": { "$ref": "#/components/schemas/RecordResponse" } } } } } } }, "401": { "description": "Unauthorized" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Get Records\n# Returns all records associated with user.\ncurl \"https://dns.hetzner.com/api/v1/records?zone_id={ZoneID}\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj'" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendGetRecords() {\n\t// Get Records (GET https://dns.hetzner.com/api/v1/records?zone_id={ZoneID})\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"GET\", \"https://dns.hetzner.com/api/v1/records?zone_id={ZoneID}\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\tparseFormErr := req.ParseForm()\n\tif parseFormErr != nil {\n\t fmt.Println(parseFormErr) \n\t}\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " '1.1.1.1',\n 'ttl' => 86400,\n 'type' => 'A',\n 'name' => 'www',\n 'zone_id' => '1'\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Create Record\n # POST https://dns.hetzner.com/api/v1/records\n\n try:\n response = requests.post(\n url=\"https://dns.hetzner.com/api/v1/records\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"value\": \"1.1.1.1\",\n \"ttl\": 86400,\n \"type\": \"A\",\n \"name\": \"www\",\n \"zone_id\": \"1\"\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" } }, "/records/{RecordID}": { "get": { "tags": [ "Records" ], "summary": "Get Record", "description": "Returns information about a single record.", "operationId": "GetRecord", "parameters": [ { "name": "RecordID", "in": "path", "description": "ID of record to get", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "record": { "$ref": "#/components/schemas/RecordResponse" } } } } } }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Get Record\n# Returns information about a single record.\ncurl \"https://dns.hetzner.com/api/v1/records/{RecordID}\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendGetRecord() {\n\t// Get Record (GET https://dns.hetzner.com/api/v1/records/{RecordID})\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"GET\", \"https://dns.hetzner.com/api/v1/records/{RecordID}\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " '1.1.1.2',\n 'ttl' => 0,\n 'type' => 'A',\n 'name' => 'www',\n 'zone_id' => 'oH7shFebR6nLPgTnmvNjM8'\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Update Record\n # PUT https://dns.hetzner.com/api/v1/records/{RecordID}\n\n try:\n response = requests.put(\n url=\"https://dns.hetzner.com/api/v1/records/{RecordID}\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"value\": \"1.1.1.2\",\n \"ttl\": 0,\n \"type\": \"A\",\n \"name\": \"www\",\n \"zone_id\": \"oH7shFebR6nLPgTnmvNjM8\"\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" }, "delete": { "tags": [ "Records" ], "summary": "Delete Record", "description": "Deletes a record.", "operationId": "DeleteRecord", "parameters": [ { "name": "RecordID", "in": "path", "description": "ID of record to delete", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response" }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Delete Record\n# Deletes a record.\ncurl -X \"DELETE\" \"https://dns.hetzner.com/api/v1/records/{RecordID}\" \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n)\n\nfunc sendDeleteRecord() {\n\t// Delete Record (DELETE https://dns.hetzner.com/api/v1/records/{RecordID})\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"DELETE\", \"https://dns.hetzner.com/api/v1/records/{RecordID}\", nil)\n\n\t// Headers\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " [\n [\n 'value' => '81.169.145.141',\n 'type' => 'A',\n 'name' => 'autoconfig',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:202:5800::1141',\n 'type' => 'AAAA',\n 'name' => 'autoconfig',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '81.169.145.105',\n 'type' => 'A',\n 'name' => 'www',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:202:1105::',\n 'type' => 'AAAA',\n 'name' => 'www',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '81.169.145.105',\n 'type' => 'A',\n 'name' => 'cloud',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:202:1105::',\n 'type' => 'AAAA',\n 'name' => 'cloud',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '81.169.145.105',\n 'type' => 'A',\n 'name' => '@',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:202:1105::',\n 'type' => 'AAAA',\n 'name' => '@',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '81.169.145.97',\n 'type' => 'A',\n 'name' => 'smtpin',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:202:50f0::1097',\n 'type' => 'AAAA',\n 'name' => 'smtpin',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20b:43:6653::506',\n 'type' => 'AAAA',\n 'name' => 'shades06',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '85.214.0.236',\n 'type' => 'A',\n 'name' => 'shades06',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '10 smtpin',\n 'type' => 'MX',\n 'name' => '@',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '81.169.146.21',\n 'type' => 'A',\n 'name' => 'docks11',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ],\n [\n 'value' => '2a01:238:20a:930:6653::d11',\n 'type' => 'AAAA',\n 'name' => 'docks11',\n 'zone_id' => 'LXmSv4RsTcmYtugtyVWExG'\n ]\n ]\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Bulk Create Records\n # POST https://dns.hetzner.com/api/v1/records/bulk\n\n try:\n response = requests.post(\n url=\"https://dns.hetzner.com/api/v1/records/bulk\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"records\": [\n {\n \"value\": \"81.169.145.141\",\n \"type\": \"A\",\n \"name\": \"autoconfig\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:202:5800::1141\",\n \"type\": \"AAAA\",\n \"name\": \"autoconfig\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"81.169.145.105\",\n \"type\": \"A\",\n \"name\": \"www\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:202:1105::\",\n \"type\": \"AAAA\",\n \"name\": \"www\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"81.169.145.105\",\n \"type\": \"A\",\n \"name\": \"cloud\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:202:1105::\",\n \"type\": \"AAAA\",\n \"name\": \"cloud\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"81.169.145.105\",\n \"type\": \"A\",\n \"name\": \"@\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:202:1105::\",\n \"type\": \"AAAA\",\n \"name\": \"@\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"81.169.145.97\",\n \"type\": \"A\",\n \"name\": \"smtpin\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:202:50f0::1097\",\n \"type\": \"AAAA\",\n \"name\": \"smtpin\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20b:43:6653::506\",\n \"type\": \"AAAA\",\n \"name\": \"shades06\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"85.214.0.236\",\n \"type\": \"A\",\n \"name\": \"shades06\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"10 smtpin\",\n \"type\": \"MX\",\n \"name\": \"@\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"81.169.146.21\",\n \"type\": \"A\",\n \"name\": \"docks11\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n },\n {\n \"value\": \"2a01:238:20a:930:6653::d11\",\n \"type\": \"AAAA\",\n \"name\": \"docks11\",\n \"zone_id\": \"LXmSv4RsTcmYtugtyVWExG\"\n }\n ]\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" }, "put": { "tags": [ "Records" ], "summary": "Bulk Update Records", "description": "Update several records at once.", "operationId": "BulkUpdateRecords", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "records": { "type": "array", "items": { "$ref": "#/components/schemas/RecordBulk" } } } } } }, "required": false }, "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "records": { "type": "array", "items": { "$ref": "#/components/schemas/RecordResponse" } }, "failed_records": { "type": "array", "items": { "$ref": "#/components/schemas/BaseRecord" } } } } } } }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" }, "409": { "description": "Conflict" }, "422": { "description": "Unprocessable entity" } }, "x-code-samples": [ { "lang": "cURL", "source": "## Bulk Update Records\n# Update several records at once.\ncurl -X \"PUT\" \"https://dns.hetzner.com/api/v1/records/bulk\" \\\n -H 'Content-Type: application/json' \\\n -H 'Auth-API-Token: LlGoDUQ39S6akqoav5meAsv5OIpeywhj' \\\n -d $'{\n \"records\": [\n {\n \"id\": \"mnsQmZmXXmWh5MpFeT67ZZ\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"type\": \"AAAA\",\n \"name\": \"www\",\n \"zone_id\": \"oH7shFebR6nLPgTnmvNjM8\"\n },\n {\n \"id\": \"uuK5PKsmfvi7853g5wXfRa\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"mail\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n },\n {\n \"id\": \"L5RawAt6pJrdhFacynLrVg\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"cloud\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n },\n {\n \"id\": \"HD3FZLUoxZQ2GpDCxPGEjY\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"@\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n }\n ]\n}'\n" }, { "lang": "Go", "source": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"bytes\"\n)\n\nfunc sendBulkUpdateRecords() {\n\t// Bulk Update Records (PUT https://dns.hetzner.com/api/v1/records/bulk)\n\n\tjson := []byte(`{\"records\": [{\"id\": \"mnsQmZmXXmWh5MpFeT67ZZ\",\"value\": \"2a01:4f8:d0a:11f5::2\",\"type\": \"AAAA\",\"name\": \"www\",\"zone_id\": \"oH7shFebR6nLPgTnmvNjM8\"},{\"id\": \"uuK5PKsmfvi7853g5wXfRa\",\"value\": \"2a01:4f8:d0a:11f5::2\",\"ttl\": 60,\"type\": \"AAAA\",\"name\": \"mail\",\"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"},{\"id\": \"L5RawAt6pJrdhFacynLrVg\",\"value\": \"2a01:4f8:d0a:11f5::2\",\"ttl\": 60,\"type\": \"AAAA\",\"name\": \"cloud\",\"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"},{\"id\": \"HD3FZLUoxZQ2GpDCxPGEjY\",\"value\": \"2a01:4f8:d0a:11f5::2\",\"ttl\": 60,\"type\": \"AAAA\",\"name\": \"@\",\"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"}]}`)\n\tbody := bytes.NewBuffer(json)\n\n\t// Create client\n\tclient := &http.Client{}\n\n\t// Create request\n\treq, err := http.NewRequest(\"PUT\", \"https://dns.hetzner.com/api/v1/records/bulk\", body)\n\n\t// Headers\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Auth-API-Token\", \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\")\n\n\t// Fetch Request\n\tresp, err := client.Do(req)\n\t\n\tif err != nil {\n\t\tfmt.Println(\"Failure : \", err)\n\t}\n\n\t// Read Response Body\n\trespBody, _ := ioutil.ReadAll(resp.Body)\n\n\t// Display Results\n\tfmt.Println(\"response Status : \", resp.Status)\n\tfmt.Println(\"response Headers : \", resp.Header)\n\tfmt.Println(\"response Body : \", string(respBody))\n}\n\n\n" }, { "lang": "PHP (cURL)", "source": " [\n [\n 'id' => 'mnsQmZmXXmWh5MpFeT67ZZ',\n 'value' => '2a01:4f8:d0a:11f5::2',\n 'type' => 'AAAA',\n 'name' => 'www',\n 'zone_id' => 'oH7shFebR6nLPgTnmvNjM8'\n ],\n [\n 'id' => 'uuK5PKsmfvi7853g5wXfRa',\n 'value' => '2a01:4f8:d0a:11f5::2',\n 'ttl' => 60,\n 'type' => 'AAAA',\n 'name' => 'mail',\n 'zone_id' => '6hYQBACMFjqWg6VKPfnvgD'\n ],\n [\n 'id' => 'L5RawAt6pJrdhFacynLrVg',\n 'value' => '2a01:4f8:d0a:11f5::2',\n 'ttl' => 60,\n 'type' => 'AAAA',\n 'name' => 'cloud',\n 'zone_id' => '6hYQBACMFjqWg6VKPfnvgD'\n ],\n [\n 'id' => 'HD3FZLUoxZQ2GpDCxPGEjY',\n 'value' => '2a01:4f8:d0a:11f5::2',\n 'ttl' => 60,\n 'type' => 'AAAA',\n 'name' => '@',\n 'zone_id' => '6hYQBACMFjqWg6VKPfnvgD'\n ]\n ]\n]; \n$body = json_encode($json_array);\n\n// set body\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $body);\n\n// send the request and save response to $response\n$response = curl_exec($ch);\n\n// stop if fails\nif (!$response) {\n die('Error: \"' . curl_error($ch) . '\" - Code: ' . curl_errno($ch));\n}\n\necho 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;\necho 'Response Body: ' . $response . PHP_EOL;\n\n// close curl resource to free up system resources \ncurl_close($ch);\n\n\n" }, { "lang": "Python", "source": "# Install the Python Requests library:\n# `pip install requests`\n\nimport requests\nimport json\n\n\ndef send_request():\n # Bulk Update Records\n # PUT https://dns.hetzner.com/api/v1/records/bulk\n\n try:\n response = requests.put(\n url=\"https://dns.hetzner.com/api/v1/records/bulk\",\n headers={\n \"Content-Type\": \"application/json\",\n \"Auth-API-Token\": \"LlGoDUQ39S6akqoav5meAsv5OIpeywhj\",\n },\n data=json.dumps({\n \"records\": [\n {\n \"id\": \"mnsQmZmXXmWh5MpFeT67ZZ\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"type\": \"AAAA\",\n \"name\": \"www\",\n \"zone_id\": \"oH7shFebR6nLPgTnmvNjM8\"\n },\n {\n \"id\": \"uuK5PKsmfvi7853g5wXfRa\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"mail\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n },\n {\n \"id\": \"L5RawAt6pJrdhFacynLrVg\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"cloud\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n },\n {\n \"id\": \"HD3FZLUoxZQ2GpDCxPGEjY\",\n \"value\": \"2a01:4f8:d0a:11f5::2\",\n \"ttl\": 60,\n \"type\": \"AAAA\",\n \"name\": \"@\",\n \"zone_id\": \"6hYQBACMFjqWg6VKPfnvgD\"\n }\n ]\n })\n )\n print('Response HTTP Status Code: {status_code}'.format(\n status_code=response.status_code))\n print('Response HTTP Response Body: {content}'.format(\n content=response.content))\n except requests.exceptions.RequestException:\n print('HTTP Request failed')\n\n\n" } ], "x-codegen-request-body-name": "body" } }, "/primary_servers": { "get": { "tags": [ "Primary Servers" ], "summary": "Get All Primary Servers", "description": "Returns all primary servers associated with user. Primary servers can also be filtered by zone_id.", "operationId": "GetPrimaryServers", "parameters": [ { "name": "zone_id", "in": "query", "description": "ID of zone", "required": false, "style": "form", "explode": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "primary_servers": { "type": "array", "items": { "$ref": "#/components/schemas/PrimaryServerResponse" } } } } } } }, "401": { "description": "Unauthorized" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } } }, "post": { "tags": [ "Primary Servers" ], "summary": "Create Primary Server", "description": "Creates a new primary server.", "operationId": "CreatePrimaryServer", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrimaryServer" } } }, "required": false }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "type": "object", "properties": { "primary_server": { "$ref": "#/components/schemas/PrimaryServerResponse" } } } } } }, "401": { "description": "Unauthorized" }, "406": { "description": "Not acceptable" }, "422": { "description": "Unprocessable entity" } }, "x-codegen-request-body-name": "body" } }, "/primary_servers/{PrimaryServerID}": { "get": { "tags": [ "Primary Servers" ], "summary": "Get Primary Server", "description": "Returns an object containing all information of a primary server. Primary Server to get is identified by 'PrimaryServerID'.", "operationId": "GetPrimaryServer", "parameters": [ { "name": "PrimaryServerID", "in": "path", "description": "ID of primary server to get", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "primary_server": { "$ref": "#/components/schemas/PrimaryServerResponse" } } } } } }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } } }, "put": { "tags": [ "Primary Servers" ], "summary": "Update Primary Server", "description": "Updates a primary server.", "operationId": "UpdatePrimaryServer", "parameters": [ { "name": "PrimaryServerID", "in": "path", "description": "ID of primaryServer to update", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PrimaryServer" } } } }, "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "primary_server": { "$ref": "#/components/schemas/PrimaryServerResponse" } } } } } }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" }, "409": { "description": "Conflict" }, "422": { "description": "Unprocessable entity" } }, "x-codegen-request-body-name": "body" }, "delete": { "tags": [ "Primary Servers" ], "summary": "Delete Primary Server", "description": "Deletes a primary server.", "operationId": "DeletePrimaryServer", "parameters": [ { "name": "PrimaryServerID", "in": "path", "description": "ID of primary server to be deleted", "required": true, "style": "simple", "explode": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Successful response" }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" }, "404": { "description": "Not found" }, "406": { "description": "Not acceptable" } } } } }, "components": { "securitySchemes": { "Auth-API-Token": { "description": "You can create an API token in the DNS console.", "type": "apiKey", "name": "Auth-API-Token", "in": "header" } }, "schemas": { "BaseRecord": { "properties": { "zone_id": { "type": "string", "description": "ID of zone this record is associated with" }, "type": { "$ref": "#/components/schemas/RecordTypeCreatable" }, "name": { "type": "string", "description": "Name of record" }, "value": { "type": "string", "description": "Value of record (e.g. 127.0.0.1, 1.1.1.1)" }, "ttl": { "type": "integer", "description": "TTL of record", "format": "uint64" } } }, "ExistingRecord": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/BaseRecord" } ], "properties": { "id": { "type": "string", "description": "ID of record", "readOnly": true }, "created": { "type": "string", "description": "Time record was created", "readOnly": true, "format": "date-time" }, "modified": { "type": "string", "description": "Time record was last updated", "readOnly": true, "format": "date-time" } } }, "Record": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/ExistingRecord" } ], "required": [ "name", "type", "value", "zone_id" ] }, "BaseRecordBulk": { "properties": { "id": { "type": "string", "description": "ID of record" }, "zone_id": { "type": "string", "description": "ID of zone this record is associated with" }, "type": { "$ref": "#/components/schemas/RecordTypeCreatable" }, "name": { "type": "string", "description": "Name of record" }, "value": { "type": "string", "description": "Value of record (e.g. 127.0.0.1, 1.1.1.1)" }, "ttl": { "type": "integer", "description": "TTL of record", "format": "uint64" } } }, "ExistingRecordBulk": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/BaseRecordBulk" } ], "properties": { "id": { "type": "string", "description": "ID of record", "readOnly": false }, "created": { "type": "string", "description": "Time record was created", "readOnly": true, "format": "date-time" }, "modified": { "type": "string", "description": "Time record was last updated", "readOnly": true, "format": "date-time" } } }, "RecordBulk": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/ExistingRecordBulk" } ], "required": [ "id", "name", "type", "value", "zone_id" ] }, "RecordResponse": { "type": "object", "properties": { "type": { "$ref": "#/components/schemas/RecordType" } }, "allOf": [ { "$ref": "#/components/schemas/ExistingRecord" } ] }, "BasePrimaryServer": { "properties": { "zone_id": { "type": "string", "description": "ID of zone this record is associated with" }, "address": { "type": "string", "description": "IPv4 or IPv6 address of the primary server" }, "port": { "type": "integer", "description": "Port number of the primary server", "minimum": 1, "maximum": 65535 } } }, "ExistingPrimaryServer": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/BasePrimaryServer" } ], "properties": { "id": { "type": "string", "description": "ID of primary server", "readOnly": true }, "created": { "type": "string", "description": "Time primary server was created", "readOnly": true, "format": "date-time" }, "modified": { "type": "string", "description": "Time primary server was last updated", "readOnly": true, "format": "date-time" } } }, "PrimaryServer": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/ExistingPrimaryServer" } ], "required": [ "id", "address", "port", "zone_id" ] }, "PrimaryServerResponse": { "type": "object", "properties": { "port": { "type": "integer", "minimum": 1, "maximum": 65535 } }, "allOf": [ { "$ref": "#/components/schemas/ExistingPrimaryServer" } ] }, "BaseZone": { "type": "object", "properties": { "id": { "type": "string", "description": "ID of zone", "readOnly": true }, "created": { "type": "string", "description": "Time zone was created", "readOnly": true, "format": "date-time" }, "modified": { "type": "string", "description": "Time zone was last updated", "readOnly": true, "format": "date-time" }, "legacy_dns_host": { "type": "string", "readOnly": true }, "legacy_ns": { "type": "array", "readOnly": true, "items": { "type": "string" } }, "name": { "type": "string", "description": "Name of zone" }, "ns": { "type": "array", "items": { "type": "string" }, "readOnly": true }, "owner": { "type": "string", "description": "Owner of zone", "readOnly": true }, "paused": { "type": "boolean", "readOnly": true }, "permission": { "type": "string", "description": "Zone's permissions", "readOnly": true }, "project": { "type": "string", "readOnly": true }, "registrar": { "type": "string", "readOnly": true }, "status": { "type": "string", "description": "Status of zone", "enum": [ "verified", "failed", "pending" ], "readOnly": true }, "ttl": { "type": "integer", "description": "TTL of zone", "format": "uint64" }, "verified": { "type": "string", "description": "Verification of zone", "readOnly": true, "format": "date-time" }, "records_count": { "type": "integer", "description": "Amount of records associated to this zone", "readOnly": true, "format": "uint64" }, "is_secondary_dns": { "type": "boolean", "description": "Indicates if a zone is a secondary DNS zone", "readOnly": true }, "txt_verification": { "type": "object", "description": "Shape of the TXT record that has to be set to verify a zone. If name and token are empty, no TXT record needs to be set", "readOnly": true, "properties": { "name": { "type": "string", "description": "Name of the TXT record", "readOnly": true }, "token": { "type": "string", "description": "Value of the TXT record", "readOnly": true } } } } }, "Zone": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/BaseZone" } ], "required": [ "name" ] }, "ZoneResponse": { "type": "object", "allOf": [ { "$ref": "#/components/schemas/BaseZone" } ] }, "RecordTypeCreatable": { "type": "string", "enum": [ "A", "AAAA", "NS", "MX", "CNAME", "RP", "TXT", "SOA", "HINFO", "SRV", "DANE", "TLSA", "DS", "CAA" ], "description": "Type of the record" }, "RecordType": { "type": "string", "enum": [ "A", "AAAA", "PTR", "NS", "MX", "CNAME", "RP", "TXT", "SOA", "HINFO", "SRV", "DANE", "TLSA", "DS", "CAA" ], "description": "Type of the record" }, "Meta": { "type": "object", "description": "", "properties": { "pagination": { "$ref": "#/components/schemas/Pagination" } } }, "Pagination": { "type": "object", "description": "", "properties": { "page": { "type": "number", "description": "This value represents the current page", "minimum": 1 }, "per_page": { "type": "number", "description": "This value represents the number of entries that are returned per page", "minimum": 1 }, "last_page": { "type": "number", "description": "This value represents the last page", "minimum": 1 }, "total_entries": { "type": "number", "description": "This value represents the total number of entries" } } } } } }