# Network › DNS › Redirections 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/dns/redirections/

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

## Operations

- `GET /domain/zone/{zoneName}/redirection` — List redirections
- `GET /domain/zone/{zoneName}/redirection/{id}` — Get a redirection
- `POST /domain/zone/{zoneName}/redirection` — Create a redirection
- `PUT /domain/zone/{zoneName}/redirection/{id}` — Update a redirection
- `DELETE /domain/zone/{zoneName}/redirection/{id}` — Delete a redirection

## List redirections

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/redirections/#getRedirections

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

Returns the identifiers of the zone redirections. Can be filtered by subdomain.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `subDomain` | query | string |  | Filter the value of subDomain property |
| `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}/redirection" \
  -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}/redirection")

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

print_r($result);
?>
```

## Get a redirection

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/redirections/#getRedirection

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

Returns a redirection: subdomain, target, type and, for an invisible one, title, description and keywords.

### Parameters

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

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | read-only | Description for the invisible redirection |
| `id` | integer | read-only | Id of the redirection |
| `keywords` | string | read-only | Keywords for the invisible redirection |
| `subDomain` | string | read-only | Subdomain to redirect |
| `target` | string | read-only | Target of the redirection |
| `title` | string | read-only | Title for the invisible redirection |
| `type` | domain.zone.RedirectionTypeEnum | read-only | Redirection type: - visible -> Redirection by http code 302 - visiblePermanent -> Redirection by http code 301 - invisible -> Redirection by html frame — one of `invisible`, `visible`, `visiblePermanent` |
| `zone` | string | read-only | Redirection zone |

```json
{
  "description": "string",
  "id": 0,
  "keywords": "string",
  "subDomain": "string",
  "target": "string",
  "title": "string",
  "type": "invisible",
  "zone": "string"
}
```

### Example

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

print_r($result);
?>
```

## Create a redirection

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/redirections/#createRedirection

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

Creates a redirection of type `visible` (HTTP 302), `visiblePermanent` (HTTP 301) or `invisible` (HTML frame). 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.RedirectionCreate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  | Description for the invisible redirection |
| `keywords` | string |  | Keywords for the invisible redirection |
| `subDomain` | string |  | Subdomain to redirect |
| `target` | string | yes | Target of the redirection |
| `title` | string |  | Title for the invisible redirection |
| `type` | domain.zone.RedirectionTypeEnum | yes | Redirection type: - visible -> Redirection by http code 302 - visiblePermanent -> Redirection by http code 301 - invisible -> Redirection by html frame — one of `invisible`, `visible`, `visiblePermanent` |

```json
{
  "description": "string",
  "keywords": "string",
  "subDomain": "string",
  "target": "string",
  "title": "string",
  "type": "invisible"
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | read-only | Description for the invisible redirection |
| `id` | integer | read-only | Id of the redirection |
| `keywords` | string | read-only | Keywords for the invisible redirection |
| `subDomain` | string | read-only | Subdomain to redirect |
| `target` | string | read-only | Target of the redirection |
| `title` | string | read-only | Title for the invisible redirection |
| `type` | domain.zone.RedirectionTypeEnum | read-only | Redirection type: - visible -> Redirection by http code 302 - visiblePermanent -> Redirection by http code 301 - invisible -> Redirection by html frame — one of `invisible`, `visible`, `visiblePermanent` |
| `zone` | string | read-only | Redirection zone |

```json
{
  "description": "string",
  "id": 0,
  "keywords": "string",
  "subDomain": "string",
  "target": "string",
  "title": "string",
  "type": "invisible",
  "zone": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/redirection" \
  -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.RedirectionCreate
result = client.post("/domain/zone/{zoneName}/redirection",
	description = None, # Description for the invisible redirection (type: string, nullable)
	keywords = None, # Keywords for the invisible redirection (type: string, nullable)
	subDomain = None, # Subdomain to redirect (type: string)
	target = None, # Target of the redirection (type: string)
	title = None, # Title for the invisible redirection (type: string, nullable)
	type = 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: domain.zone.RedirectionCreate
$result = $ovh->post("/domain/zone/{zoneName}/redirection", array(
	description => null, // Description for the invisible redirection (type: string, nullable)
	keywords => null, // Keywords for the invisible redirection (type: string, nullable)
	subDomain => null, // Subdomain to redirect (type: string)
	target => null, // Target of the redirection (type: string)
	title => null, // Title for the invisible redirection (type: string, nullable)
	type => null, //  (type: )
));

print_r($result);
?>
```

## Update a redirection

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/redirections/#editRedirection

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

Updates the target, type, title, description and keywords of a redirection.

### Parameters

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

### Request body (required)

Type: `domain.zone.RedirectionUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  | Description for the invisible redirection |
| `keywords` | string |  | Keywords for the invisible redirection |
| `target` | string |  | Target of the redirection |
| `title` | string |  | Title for the invisible redirection |
| `type` | domain.zone.RedirectionTypeEnum |  | Redirection type: - visible -> Redirection by http code 302 - visiblePermanent -> Redirection by http code 301 - invisible -> Redirection by html frame — one of `invisible`, `visible`, `visiblePermanent` |

```json
{
  "description": "string",
  "keywords": "string",
  "target": "string",
  "title": "string",
  "type": "invisible"
}
```

### Responses

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

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/domain/zone/{zoneName}/redirection/{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.RedirectionUpdate
result = client.put("/domain/zone/{zoneName}/redirection/{id}",
	description = None, # Description for the invisible redirection (type: string, nullable)
	keywords = None, # Keywords for the invisible redirection (type: string, nullable)
	target = None, # Target of the redirection (type: string)
	title = None, # Title for the invisible redirection (type: string, nullable)
	type = 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: domain.zone.RedirectionUpdate
$result = $ovh->put("/domain/zone/{zoneName}/redirection/{id}", array(
	description => null, // Description for the invisible redirection (type: string, nullable)
	keywords => null, // Keywords for the invisible redirection (type: string, nullable)
	target => null, // Target of the redirection (type: string)
	title => null, // Title for the invisible redirection (type: string, nullable)
	type => null, //  (type: )
));

print_r($result);
?>
```

## Delete a redirection

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

Link: https://developers.eu.ovhcloud.com/reference/network/dns/redirections/#deleteRedirection

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

Deletes a redirection. 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}/redirection/{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}/redirection/{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}/redirection/{id}");

print_r($result);
?>
```
