# Web Cloud › Email and Collaborative Solutions › MX Plan › Roundcube platform › Redirections API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Web Cloud product's sections: https://developers.eu.ovhcloud.com/reference/web-cloud/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/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections.json?format=openapi3

## Operations

- `GET /email/domain/{domain}/redirection` — List redirections
- `GET /email/domain/{domain}/redirection/{id}` — Get a redirection
- `POST /email/domain/{domain}/redirection` — Create a redirection
- `DELETE /email/domain/{domain}/redirection/{id}` — Delete a redirection
- `POST /email/domain/{domain}/redirection/{id}/changeRedirection` — Change a redirection target

## List redirections

`GET /1.0/email/domain/{domain}/redirection`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/#get-email-domain-domain-redirection

**Status:** Alpha version  
**IAM actions:** `emailDomain:apiovh:redirection/get`

Returns the IDs of the redirections of the domain. Filter them by `from` or `to` address.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Name of your domain name |
| `from` | query | string |  | Name of redirection |
| `to` | query | string |  | Email of redirection target |

### Responses

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

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

### Example

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

print_r($result);
?>
```

## Get a redirection

`GET /1.0/email/domain/{domain}/redirection/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/#get-email-domain-domain-redirection-id

**Status:** Alpha version  
**IAM actions:** `emailDomain:apiovh:redirection/get`

Returns the ID, the source address (`from`) and the target address (`to`) of the redirection.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Name of your domain name |
| `id` | path | string | yes | Id |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.RedirectionGlobal | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `from` | string | read-only | Name of redirection |
| `id` | string | read-only | Id of redirection |
| `to` | string | read-only | Target of redirection |

```json
{
  "from": "string",
  "id": "string",
  "to": "string"
}
```

### Example

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

print_r($result);
?>
```

## Create a redirection

`POST /1.0/email/domain/{domain}/redirection`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/#post-email-domain-domain-redirection

**Status:** Alpha version  
**IAM actions:** `emailDomain:apiovh:redirection/create`

Creates a redirection from the `from` address to the `to` address, and returns the task. Set `localCopy` to true to keep a local copy.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Name of your domain name |

### Request body (required)

Type: `email.domain.RedirectionCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `from` | string | yes | Name of redirection |
| `localCopy` | boolean | yes | If true keep a local copy |
| `to` | string | yes | Target of account |

```json
{
  "from": "string",
  "localCopy": true,
  "to": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.TaskSpecialAccount | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | domain.DomainSpecialAccountActionEnum | read-only | Action of task — one of `add`, `change`, `delete` |
| `date` | string (date-time) | read-only | Creation date of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `type` | domain.DomainSpecialAccountTypeEnum | read-only | Type of action filter — one of `25g`, `alias`, `delete`, `filter`, `forward`, `responder` |

```json
{
  "account": "string",
  "action": "add",
  "date": "2024-01-01T12:00:00Z",
  "domain": "string",
  "id": 0,
  "type": "25g"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/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: email.domain.RedirectionCreation
result = client.post("/email/domain/{domain}/redirection",
	from = None, # Name of redirection (type: string)
	localCopy = None, # If true keep a local copy (type: boolean)
	to = None, # Target of account (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: email.domain.RedirectionCreation
$result = $ovh->post("/email/domain/{domain}/redirection", array(
	from => null, // Name of redirection (type: string)
	localCopy => null, // If true keep a local copy (type: boolean)
	to => null, // Target of account (type: string)
));

print_r($result);
?>
```

## Delete a redirection

`DELETE /1.0/email/domain/{domain}/redirection/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/#delete-email-domain-domain-redirection-id

**Status:** Alpha version  
**IAM actions:** `emailDomain:apiovh:redirection/delete`

Deletes the redirection and returns the task.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Name of your domain name |
| `id` | path | string | yes | Id |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.TaskSpecialAccount | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | domain.DomainSpecialAccountActionEnum | read-only | Action of task — one of `add`, `change`, `delete` |
| `date` | string (date-time) | read-only | Creation date of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `type` | domain.DomainSpecialAccountTypeEnum | read-only | Type of action filter — one of `25g`, `alias`, `delete`, `filter`, `forward`, `responder` |

```json
{
  "account": "string",
  "action": "add",
  "date": "2024-01-01T12:00:00Z",
  "domain": "string",
  "id": 0,
  "type": "25g"
}
```

### Example

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

print_r($result);
?>
```

## Change a redirection target

`POST /1.0/email/domain/{domain}/redirection/{id}/changeRedirection`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/redirections/#post-email-domain-domain-redirection-id-changeredirection

**Status:** Alpha version  
**IAM actions:** `emailDomain:apiovh:redirection/changeRedirection`

Sets the new target address (`to`) of the redirection and returns the task.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domain` | path | string | yes | Name of your domain name |
| `id` | path | string | yes | Id |

### Request body (required)

Type: `email.domain.RedirectionChangeRedirectionCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `to` | string | yes | Target of account |

```json
{
  "to": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.TaskSpecialAccount | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | domain.DomainSpecialAccountActionEnum | read-only | Action of task — one of `add`, `change`, `delete` |
| `date` | string (date-time) | read-only | Creation date of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `type` | domain.DomainSpecialAccountTypeEnum | read-only | Type of action filter — one of `25g`, `alias`, `delete`, `filter`, `forward`, `responder` |

```json
{
  "account": "string",
  "action": "add",
  "date": "2024-01-01T12:00:00Z",
  "domain": "string",
  "id": 0,
  "type": "25g"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/redirection/{id}/changeRedirection" \
  -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: email.domain.RedirectionChangeRedirectionCreation
result = client.post("/email/domain/{domain}/redirection/{id}/changeRedirection",
	to = None, # Target of account (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: email.domain.RedirectionChangeRedirectionCreation
$result = $ovh->post("/email/domain/{domain}/redirection/{id}/changeRedirection", array(
	to => null, // Target of account (type: string)
));

print_r($result);
?>
```
