# Web Cloud › Email and Collaborative Solutions › MX Plan › Roundcube platform › Filters 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

> 10 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/filters/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters.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/filters.json?format=openapi3

## Operations

- `GET /email/domain/{domain}/account/{accountName}/filter` — List filters
- `GET /email/domain/{domain}/account/{accountName}/filter/{name}` — Get a filter
- `POST /email/domain/{domain}/account/{accountName}/filter` — Create a filter
- `DELETE /email/domain/{domain}/account/{accountName}/filter/{name}` — Delete a filter
- `POST /email/domain/{domain}/account/{accountName}/filter/{name}/changeActivity` — Enable or disable a filter
- `POST /email/domain/{domain}/account/{accountName}/filter/{name}/changePriority` — Change filter priority
- `GET /email/domain/{domain}/account/{accountName}/filter/{name}/rule` — List filter rules
- `GET /email/domain/{domain}/account/{accountName}/filter/{name}/rule/{id}` — Get a filter rule
- `POST /email/domain/{domain}/account/{accountName}/filter/{name}/rule` — Create a filter rule
- `DELETE /email/domain/{domain}/account/{accountName}/filter/{name}/rule/{id}` — Delete a filter rule

## List filters

`GET /1.0/email/domain/{domain}/account/{accountName}/filter`

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

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/get`

List filters. Returns the names of the filters of the email account. Get one to read its action, its priority and whether it is active.

### Parameters

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

### 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}/account/{accountName}/filter" \
  -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}/account/{accountName}/filter")

# 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}/account/{accountName}/filter");

print_r($result);
?>
```

## Get a filter

`GET /1.0/email/domain/{domain}/account/{accountName}/filter/{name}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#get-email-domain-domain-account-accountname-filter-name

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/get`

Get a filter. Returns the account, priority, active state, action (accept, account, delete or redirect) and action parameter of the filter.

### Parameters

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

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | domain.DomainFilterActionEnum | read-only | Action of filter — one of `accept`, `account`, `delete`, `redirect` |
| `actionParam` | string | read-only | Action parameter of filter |
| `active` | boolean | read-only | If true filter is active |
| `domain` | string | read-only | Domain name of filter |
| `name` | string | read-only | Filter name |
| `pop` | string | read-only | Account name of filter |
| `priority` | integer | read-only | Priority of filter |

```json
{
  "action": "accept",
  "actionParam": "string",
  "active": true,
  "domain": "string",
  "name": "string",
  "pop": "string",
  "priority": 0
}
```

### Example

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

# 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}/account/{accountName}/filter/{name}");

print_r($result);
?>
```

## Create a filter

`POST /1.0/email/domain/{domain}/account/{accountName}/filter`

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

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/create`

Create a filter. Creates a filter with a rule on a `header` (`operand` and `value`), an `action`, a `priority` and an `active` state, and returns the task.

### Parameters

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

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | domain.DomainFilterActionEnum | yes | Action of filter — one of `accept`, `account`, `delete`, `redirect` |
| `actionParam` | string |  | Action parameter of filter |
| `active` | boolean | yes | If true filter is active |
| `header` | string | yes | Header to be filtered |
| `name` | string | yes | Filter name |
| `operand` | domain.DomainFilterOperandEnum | yes | Rule of filter — one of `checkspf`, `contains`, `noContains` |
| `priority` | integer | yes | Priority of filter |
| `value` | string | yes | Rule parameter of filter |

```json
{
  "action": "accept",
  "actionParam": "string",
  "active": true,
  "header": "string",
  "name": "string",
  "operand": "checkspf",
  "priority": 0,
  "value": "string"
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
{
  "account": "string",
  "action": "string",
  "domain": "string",
  "id": 0,
  "timestamp": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter" \
  -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
)

result = client.post("/email/domain/{domain}/account/{accountName}/filter",
	action = None, # Action of filter (type: domain.DomainFilterActionEnum)
	actionParam = None, # Action parameter of filter (type: string, nullable)
	active = None, # If true filter is active (type: boolean)
	header = None, # Header to be filtered (type: string)
	name = None, # Filter name (type: string)
	operand = None, # Rule of filter (type: domain.DomainFilterOperandEnum)
	priority = None, # Priority of filter (type: long)
	value = None, # Rule parameter of filter (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

$result = $ovh->post("/email/domain/{domain}/account/{accountName}/filter", array(
	action => null, // Action of filter (type: domain.DomainFilterActionEnum)
	actionParam => null, // Action parameter of filter (type: string, nullable)
	active => null, // If true filter is active (type: boolean)
	header => null, // Header to be filtered (type: string)
	name => null, // Filter name (type: string)
	operand => null, // Rule of filter (type: domain.DomainFilterOperandEnum)
	priority => null, // Priority of filter (type: long)
	value => null, // Rule parameter of filter (type: string)
));

print_r($result);
?>
```

## Delete a filter

`DELETE /1.0/email/domain/{domain}/account/{accountName}/filter/{name}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#delete-email-domain-domain-account-accountname-filter-name

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/delete`

Delete a filter. Removes the filter and its rules from the email account, and returns the tasks. Incoming emails are no longer filtered by it.

### Parameters

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

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.TaskFilter[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
[
  {
    "account": "string",
    "action": "string",
    "domain": "string",
    "id": 0,
    "timestamp": "2024-01-01T12:00:00Z"
  }
]
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter/{name}" \
  -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}/account/{accountName}/filter/{name}")

# 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}/account/{accountName}/filter/{name}");

print_r($result);
?>
```

## Enable or disable a filter

`POST /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/changeActivity`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#post-email-domain-domain-account-accountname-filter-name-changeactivity

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/changeActivity`

Enable or disable a filter. Set `activity` to true to apply the filter to incoming emails, or to false to suspend it.

### Parameters

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

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `activity` | boolean | yes | New activity |

```json
{
  "activity": true
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
{
  "account": "string",
  "action": "string",
  "domain": "string",
  "id": 0,
  "timestamp": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter/{name}/changeActivity" \
  -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: boolean
result = client.post("/email/domain/{domain}/account/{accountName}/filter/{name}/changeActivity",
	activity = None, # New activity (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: boolean
$result = $ovh->post("/email/domain/{domain}/account/{accountName}/filter/{name}/changeActivity", array(
	activity => null, // New activity (type: boolean)
));

print_r($result);
?>
```

## Change filter priority

`POST /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/changePriority`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#post-email-domain-domain-account-accountname-filter-name-changepriority

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/changePriority`

Change filter priority. Sets the `priority` of the filter, which gives the order the filters of the account are applied in.

### Parameters

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

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `priority` | integer | yes | New priority |

```json
{
  "priority": 0
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
{
  "account": "string",
  "action": "string",
  "domain": "string",
  "id": 0,
  "timestamp": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter/{name}/changePriority" \
  -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: long
result = client.post("/email/domain/{domain}/account/{accountName}/filter/{name}/changePriority",
	priority = None, # New priority (type: long)
)

# 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: long
$result = $ovh->post("/email/domain/{domain}/account/{accountName}/filter/{name}/changePriority", array(
	priority => null, // New priority (type: long)
));

print_r($result);
?>
```

## List filter rules

`GET /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#get-email-domain-domain-account-accountname-filter-name-rule

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/rule/get`

List filter rules. Returns the IDs of the rules of the filter. Get one to read the header it checks, its operand and its value.

### Parameters

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

### Responses

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

```json
[
  0
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule" \
  -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}/account/{accountName}/filter/{name}/rule")

# 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}/account/{accountName}/filter/{name}/rule");

print_r($result);
?>
```

## Get a filter rule

`GET /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#get-email-domain-domain-account-accountname-filter-name-rule-id

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/rule/get`

Get a filter rule. Returns the header, the operand (checkspf, contains or noContains) and the value of the rule.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `accountName` | path | string | yes | Name of account |
| `domain` | path | string | yes | Name of your domain name |
| `id` | path | integer | yes |  |
| `name` | path | string | yes | Filter name |

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `header` | string | read-only | Header to be filtered |
| `id` | integer | read-only |  |
| `operand` | domain.DomainFilterOperandEnum | read-only | Rule of filter — one of `checkspf`, `contains`, `noContains` |
| `value` | string | read-only | Rule parameter of filter |

```json
{
  "header": "string",
  "id": 0,
  "operand": "checkspf",
  "value": "string"
}
```

### Example

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

print_r($result);
?>
```

## Create a filter rule

`POST /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#post-email-domain-domain-account-accountname-filter-name-rule

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/rule/create`

Create a filter rule. Adds a rule to the filter on a `header`, with an `operand` (checkspf, contains or noContains) and a `value`, and returns the task.

### Parameters

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

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `header` | string | yes | Header to be filtered |
| `operand` | domain.DomainFilterOperandEnum | yes | Rule of filter — one of `checkspf`, `contains`, `noContains` |
| `value` | string | yes | Rule parameter of filter |

```json
{
  "header": "string",
  "operand": "checkspf",
  "value": "string"
}
```

### Responses

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
{
  "account": "string",
  "action": "string",
  "domain": "string",
  "id": 0,
  "timestamp": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule" \
  -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("/email/domain/{domain}/account/{accountName}/filter/{name}/rule",
	header = None, # Header to be filtered (type: string)
	operand = None, # Rule of filter (type: domain.DomainFilterOperandEnum)
	value = None, # Rule parameter of filter (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("/email/domain/{domain}/account/{accountName}/filter/{name}/rule", array(
	header => null, // Header to be filtered (type: string)
	operand => null, // Rule of filter (type: domain.DomainFilterOperandEnum)
	value => null, // Rule parameter of filter (type: string)
));

print_r($result);
?>
```

## Delete a filter rule

`DELETE /1.0/email/domain/{domain}/account/{accountName}/filter/{name}/rule/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/email-and-collaborative-solutions/mx-plan/roundcube-platform/filters/#delete-email-domain-domain-account-accountname-filter-name-rule-id

**Status:** Stable production version  
**IAM actions:** `emailDomain:apiovh:account/filter/rule/delete`

Delete a filter rule. Removes the rule from the filter and returns the tasks. The filter keeps applying its other rules.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `accountName` | path | string | yes | Name of account |
| `domain` | path | string | yes | Name of your domain name |
| `id` | path | integer | yes |  |
| `name` | path | string | yes | Filter name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | email.domain.TaskFilter[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | read-only | Account name of task |
| `action` | string | read-only | Action of task |
| `domain` | string | read-only | Domain name of task |
| `id` | integer | read-only | Id of task |
| `timestamp` | string (date-time) | read-only | Creation date of task |

```json
[
  {
    "account": "string",
    "action": "string",
    "domain": "string",
    "id": 0,
    "timestamp": "2024-01-01T12:00:00Z"
  }
]
```

### Example

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

print_r($result);
?>
```
