# Network › DNS › Zone file API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Network product's sections: https://developers.eu.ovhcloud.com/reference/network/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 3 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/network/dns/zone-file/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/network/dns/zone-file.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/network/dns/zone-file.json?format=openapi3

## Operations

- `GET /domain/zone/{zoneName}/export` — Export the zone
- `POST /domain/zone/{zoneName}/import` — Import a zone file
- `POST /domain/zone/{zoneName}/reset` — Reset the zone

## Export the zone

`GET /1.0/domain/zone/{zoneName}/export`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/zone-file/#get-domain-zone-zonename-export

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:export/get`

Returns the zone content as a zone file.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `zoneName` | path | string | yes | Zone name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string | successful operation |

```json
"string"
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/export" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/domain/zone/{zoneName}/export")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/domain/zone/{zoneName}/export");

print_r($result);
?>
```

## Import a zone file

`POST /1.0/domain/zone/{zoneName}/import`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/zone-file/#post-domain-zone-zonename-import

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:import`

Imports a zone file into the zone and returns the task.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `zoneName` | path | string | yes | Zone name |

### Request body (required)

Type: `domain.zone.Import`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `zoneFile` | string | yes | Zone file that will be imported |

```json
{
  "zoneFile": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | domain.zone.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `canAccelerate` | boolean | read-only | Can accelerate the task |
| `canCancel` | boolean | read-only | Can cancel the task |
| `canRelaunch` | boolean | read-only | Can relaunch the task |
| `comment` | string | read-only | Comment about the task |
| `creationDate` | string (date-time) | read-only | Creation date of the task |
| `doneDate` | string (date-time) | read-only | Done date of the task |
| `function` | domain.TaskFunctionEnum | read-only | Function of the task — one of `DnsAnycastActivate`, `DnsAnycastDeactivate`, `DnssecDisable`, `DnssecEnable`, `DnssecResigning`, `DnssecRollKsk`, `DnssecRollZsk`, `ZoneCheck`, `ZoneCreate`, `ZoneCut`, `ZoneDelete`, `ZoneImport`, … |
| `id` | integer | read-only | Id of the task |
| `lastUpdate` | string (date-time) | read-only | Last update date of the task |
| `status` | domain.TaskStatusEnum | read-only | Status of the task — one of `cancelled`, `doing`, `done`, `error`, `problem`, `todo` |
| `todoDate` | string (date-time) | read-only | Todo date of the task |

```json
{
  "canAccelerate": true,
  "canCancel": true,
  "canRelaunch": true,
  "comment": "string",
  "creationDate": "2024-01-01T12:00:00Z",
  "doneDate": "2024-01-01T12:00:00Z",
  "function": "DnsAnycastActivate",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "status": "cancelled",
  "todoDate": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/import" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: domain.zone.Import
result = client.post("/domain/zone/{zoneName}/import",
	zoneFile = None, # Zone file that will be imported (type: string)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: domain.zone.Import
$result = $ovh->post("/domain/zone/{zoneName}/import", array(
	zoneFile => null, // Zone file that will be imported (type: string)
));

print_r($result);
?>
```

## Reset the zone

`POST /1.0/domain/zone/{zoneName}/reset`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/zone-file/#post-domain-zone-zonename-reset

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:reset`

Resets the zone, optionally with the records to set afterward. With `minimized`, only the mandatory records are created.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `zoneName` | path | string | yes | Zone name |

### Request body (required)

Type: `domain.zone.Reset`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `DnsRecords` | domain.zone.ResetRecord[] |  | Records that will be set after reset |
| `DnsRecords[].fieldType` | domain.zone.ResettableNamedResolutionFieldTypeEnum |  | Field type associated to domain zone reset — one of `A`, `MX` |
| `DnsRecords[].target` | string |  | Target associated to domain zone reset |
| `minimized` | boolean |  | Create only mandatory records |

```json
{
  "DnsRecords": [
    {
      "fieldType": "A",
      "target": "string"
    }
  ],
  "minimized": true
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/reset" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: domain.zone.Reset
result = client.post("/domain/zone/{zoneName}/reset",
	DnsRecords = None, # Records that will be set after reset (type: array)
	minimized = None, # Create only mandatory records (type: boolean)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: domain.zone.Reset
$result = $ovh->post("/domain/zone/{zoneName}/reset", array(
	DnsRecords => null, // Records that will be set after reset (type: array)
	minimized => null, // Create only mandatory records (type: boolean)
));

print_r($result);
?>
```
