# Network › CDN › Domains 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

> 5 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/cdn/domains/

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

## Operations

- `GET /cdn/dedicated/{serviceName}/domains` — List domains
- `POST /cdn/dedicated/{serviceName}/domains` — Create a domain
- `GET /cdn/dedicated/{serviceName}/domains/{domain}` — Get a domain
- `DELETE /cdn/dedicated/{serviceName}/domains/{domain}` — Delete a domain
- `PUT /cdn/dedicated/{serviceName}/domains/{domain}` — Update a domain

## List domains

`GET /1.0/cdn/dedicated/{serviceName}/domains`

Link: https://developers.eu.ovhcloud.com/reference/network/cdn/domains/#get-cdn-dedicated-servicename-domains

**Status:** Stable production version  
**IAM actions:** `cdn:apiovh:domains/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | The internal name of your CDN offer |

### Responses

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

```json
[
  "string"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/cdn/dedicated/{serviceName}/domains" \
  -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("/cdn/dedicated/{serviceName}/domains")

# 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("/cdn/dedicated/{serviceName}/domains");

print_r($result);
?>
```

## Create a domain

`POST /1.0/cdn/dedicated/{serviceName}/domains`

Link: https://developers.eu.ovhcloud.com/reference/network/cdn/domains/#post-cdn-dedicated-servicename-domains

**Status:** Stable production version  
**IAM actions:** `cdn:apiovh:domains/create`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | The internal name of your CDN offer |

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | string | yes | domain name to add on CDN |

```json
{
  "domain": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | cdnanycast.Domain | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `cacheRuleUse` | integer | read-only |  |
| `cname` | string | read-only |  |
| `domain` | string | read-only | Domain of this object |
| `status` | cdnanycast.DomainStatusEnum |  | All states a status can be in — one of `error`, `off`, `on`, `removing` |
| `type` | cdnanycast.DomainTypeEnum | read-only | All type of Domain — one of `plain`, `ssl` |

```json
{
  "cacheRuleUse": 0,
  "cname": "string",
  "domain": "string",
  "status": "error",
  "type": "plain"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/cdn/dedicated/{serviceName}/domains" \
  -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: string
result = client.post("/cdn/dedicated/{serviceName}/domains",
	domain = None, # domain name to add on CDN (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: string
$result = $ovh->post("/cdn/dedicated/{serviceName}/domains", array(
	domain => null, // domain name to add on CDN (type: string)
));

print_r($result);
?>
```

## Get a domain

`GET /1.0/cdn/dedicated/{serviceName}/domains/{domain}`

Link: https://developers.eu.ovhcloud.com/reference/network/cdn/domains/#get-cdn-dedicated-servicename-domains-domain

**Status:** Stable production version  
**IAM actions:** `cdn:apiovh:domains/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Domain of this object |
| `serviceName` | path | string | yes | The internal name of your CDN offer |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | cdnanycast.Domain | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `cacheRuleUse` | integer | read-only |  |
| `cname` | string | read-only |  |
| `domain` | string | read-only | Domain of this object |
| `status` | cdnanycast.DomainStatusEnum |  | All states a status can be in — one of `error`, `off`, `on`, `removing` |
| `type` | cdnanycast.DomainTypeEnum | read-only | All type of Domain — one of `plain`, `ssl` |

```json
{
  "cacheRuleUse": 0,
  "cname": "string",
  "domain": "string",
  "status": "error",
  "type": "plain"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/cdn/dedicated/{serviceName}/domains/{domain}" \
  -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("/cdn/dedicated/{serviceName}/domains/{domain}")

# 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("/cdn/dedicated/{serviceName}/domains/{domain}");

print_r($result);
?>
```

## Delete a domain

`DELETE /1.0/cdn/dedicated/{serviceName}/domains/{domain}`

Link: https://developers.eu.ovhcloud.com/reference/network/cdn/domains/#delete-cdn-dedicated-servicename-domains-domain

**Status:** Stable production version  
**IAM actions:** `cdn:apiovh:domains/delete`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Domain of this object |
| `serviceName` | path | string | yes | The internal name of your CDN offer |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | cdnanycast.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `comment` | string | read-only |  |
| `function` | cdnanycast.TaskFunctionEnum | read-only | All function CDN task can be — one of `flush`, `flushAll`, `generateSsl`, `installSsl`, `reinstallSsl`, `removeDomain`, `uninstallSsl`, `updateCacheRule` |
| `status` | cdnanycast.TaskStateEnum | read-only | All states a CDN task can be in — one of `cancelled`, `doing`, `done`, `error`, `todo` |
| `taskId` | integer | read-only |  |

```json
{
  "comment": "string",
  "function": "flush",
  "status": "cancelled",
  "taskId": 0
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/cdn/dedicated/{serviceName}/domains/{domain}" \
  -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("/cdn/dedicated/{serviceName}/domains/{domain}")

# 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("/cdn/dedicated/{serviceName}/domains/{domain}");

print_r($result);
?>
```

## Update a domain

`PUT /1.0/cdn/dedicated/{serviceName}/domains/{domain}`

Link: https://developers.eu.ovhcloud.com/reference/network/cdn/domains/#put-cdn-dedicated-servicename-domains-domain

**Status:** Stable production version  
**IAM actions:** `cdn:apiovh:domains/edit`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Domain of this object |
| `serviceName` | path | string | yes | The internal name of your CDN offer |

### Request body (required)

Type: `cdnanycast.Domain`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `cacheRuleUse` | integer | read-only |  |
| `cname` | string | read-only |  |
| `domain` | string | read-only | Domain of this object |
| `status` | cdnanycast.DomainStatusEnum |  | All states a status can be in — one of `error`, `off`, `on`, `removing` |
| `type` | cdnanycast.DomainTypeEnum | read-only | All type of Domain — one of `plain`, `ssl` |

```json
{
  "status": "error"
}
```

### Responses

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

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/cdn/dedicated/{serviceName}/domains/{domain}" \
  -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: cdnanycast.Domain
result = client.put("/cdn/dedicated/{serviceName}/domains/{domain}",
	status = None, #  (type: )
)

# 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: cdnanycast.Domain
$result = $ovh->put("/cdn/dedicated/{serviceName}/domains/{domain}", array(
	status => null, //  (type: )
));

print_r($result);
?>
```
