# Network › DNS › Records 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

> 6 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/records/

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

## Operations

- `GET /domain/zone/{zoneName}/record` — List records
- `GET /domain/zone/{zoneName}/record/{id}` — Get a record
- `POST /domain/zone/{zoneName}/record` — Create a record
- `PUT /domain/zone/{zoneName}/record/{id}` — Update a record
- `DELETE /domain/zone/{zoneName}/record/{id}` — Delete a record
- `POST /domain/zone/{zoneName}/refresh` — Refresh the zone

## List records

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#getRecords

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

Returns the identifiers of the zone records. Can be filtered by subdomain and record type.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `fieldType` | query | domain.zone.RecordTypeEnum |  | Filter the value of fieldType property (like) — one of `A`, `AAAA`, `CAA`, `CNAME`, `DKIM`, `DMARC`, `DNAME`, `HTTPS`, `LOC`, `MX`, `NAPTR`, `NS`, … |
| `subDomain` | query | string |  | Filter the value of subDomain property (ilike) |
| `zoneName` | path | string | yes | Zone name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | integer[] | successful operation |

```json
[
  0
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/record" \
  -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}/record")

# 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}/record");

print_r($result);
?>
```

## Get a record

`GET /1.0/domain/zone/{zoneName}/record/{id}`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#getRecord

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

Returns a record: type, subdomain, target and TTL.

### Parameters

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

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fieldType` | domain.zone.RecordTypeEnum | read-only | Resource record name — one of `A`, `AAAA`, `CAA`, `CNAME`, `DKIM`, `DMARC`, `DNAME`, `HTTPS`, `LOC`, `MX`, `NAPTR`, `NS`, … |
| `id` | integer | read-only | Id of the record |
| `subDomain` | string | read-only | Record subDomain |
| `target` | string | read-only | Target of the record |
| `ttl` | integer | read-only | TTL of the record |
| `zone` | string | read-only | Resource record zone |

```json
{
  "fieldType": "A",
  "id": 0,
  "subDomain": "string",
  "target": "string",
  "ttl": 0,
  "zone": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/record/{id}" \
  -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}/record/{id}")

# 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}/record/{id}");

print_r($result);
?>
```

## Create a record

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#createRecord

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:record/create`

Creates a record in the zone. The change applies after the zone is refreshed.

### Parameters

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

### Request body (required)

Type: `domain.zone.RecordCreate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fieldType` | domain.zone.RecordTypeEnum | yes | Resource record name — one of `A`, `AAAA`, `CAA`, `CNAME`, `DKIM`, `DMARC`, `DNAME`, `HTTPS`, `LOC`, `MX`, `NAPTR`, `NS`, … |
| `id` | integer | read-only | Id of the record |
| `subDomain` | string |  | Record subDomain |
| `target` | string | yes | Target of the record |
| `ttl` | integer |  | TTL of the record |
| `zone` | string | read-only | Resource record zone |

```json
{
  "fieldType": "A",
  "subDomain": "string",
  "target": "string",
  "ttl": 0
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fieldType` | domain.zone.RecordTypeEnum | read-only | Resource record name — one of `A`, `AAAA`, `CAA`, `CNAME`, `DKIM`, `DMARC`, `DNAME`, `HTTPS`, `LOC`, `MX`, `NAPTR`, `NS`, … |
| `id` | integer | read-only | Id of the record |
| `subDomain` | string | read-only | Record subDomain |
| `target` | string | read-only | Target of the record |
| `ttl` | integer | read-only | TTL of the record |
| `zone` | string | read-only | Resource record zone |

```json
{
  "fieldType": "A",
  "id": 0,
  "subDomain": "string",
  "target": "string",
  "ttl": 0,
  "zone": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/record" \
  -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.RecordCreate
result = client.post("/domain/zone/{zoneName}/record",
	fieldType = None, #  (type: )
	subDomain = None, # Record subDomain (type: string, nullable)
	target = None, # Target of the record (type: string)
	ttl = None, # TTL of the record (type: integer)
)

# 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.RecordCreate
$result = $ovh->post("/domain/zone/{zoneName}/record", array(
	fieldType => null, //  (type: )
	subDomain => null, // Record subDomain (type: string, nullable)
	target => null, // Target of the record (type: string)
	ttl => null, // TTL of the record (type: integer)
));

print_r($result);
?>
```

## Update a record

`PUT /1.0/domain/zone/{zoneName}/record/{id}`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#editRecord

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:record/edit`

Updates the subdomain, target and TTL of a record. The change applies after the zone is refreshed.

### Parameters

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

### Request body (required)

Type: `domain.zone.RecordUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `subDomain` | string |  | Record subdomain |
| `target` | string |  | Target of the record |
| `ttl` | integer |  | TTL of the record |

```json
{
  "subDomain": "string",
  "target": "string",
  "ttl": 0
}
```

### Responses

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

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/record/{id}" \
  -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.RecordUpdate
result = client.put("/domain/zone/{zoneName}/record/{id}",
	subDomain = None, # Record subdomain (type: string, nullable)
	target = None, # Target of the record (type: string)
	ttl = None, # TTL of the record (type: integer, nullable)
)

# 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.RecordUpdate
$result = $ovh->put("/domain/zone/{zoneName}/record/{id}", array(
	subDomain => null, // Record subdomain (type: string, nullable)
	target => null, // Target of the record (type: string)
	ttl => null, // TTL of the record (type: integer, nullable)
));

print_r($result);
?>
```

## Delete a record

`DELETE /1.0/domain/zone/{zoneName}/record/{id}`

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#deleteRecord

**Status:** Stable production version  
**IAM actions:** `dnsZone:apiovh:record/delete`

Deletes a record from the zone. The change applies after the zone is refreshed.

### Parameters

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

### Responses

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

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/record/{id}" \
  -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.delete("/domain/zone/{zoneName}/record/{id}")

# 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->delete("/domain/zone/{zoneName}/record/{id}");

print_r($result);
?>
```

## Refresh the zone

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/records/#refreshZone

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

Applies the pending record changes to the zone.

### Parameters

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

### Responses

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

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/refresh" \
  -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.post("/domain/zone/{zoneName}/refresh")

# 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->post("/domain/zone/{zoneName}/refresh");

print_r($result);
?>
```
