Replace filter rules
PUT
/api/v1/mailbox/rulesReplaces the whole list (up to 50 rules), in the order given. Send every rule you want to keep.
Errors
| Status | When |
|---|---|
401 |
No token, or the session expired or was signed out. Sign in again with POST /mailbox-auth/login. |
403 |
The account has a temporary password: until POST /security/password succeeds, every other call answers this with error_code: password_change_required. |
422 |
More than 50 rules, or a rule with an unknown field, operator or action. |
Request body
rulesarray<object>The whole list, in order. Each rule:
name,match(allorany),enabled,conditionsandactions, as in the response.
Request
PUT
/api/v1/mailbox/rulescurl -X PUT 'https://courier.mailyte.com/api/v1/mailbox/rules' \
-H 'Authorization: Bearer MAILBOX_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"rules": [
{
"name": "Invoices to Finance",
"match": "any",
"enabled": true,
"conditions": [
{
"field": "subject",
"operator": "contains",
"value": "invoice"
}
],
"actions": [
{
"type": "move",
"value": "Finance"
}
]
}
]
}'const response = await fetch('https://courier.mailyte.com/api/v1/mailbox/rules', {
method: 'PUT',
headers: {
Authorization: 'Bearer MAILBOX_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"rules": [
{
"name": "Invoices to Finance",
"match": "any",
"enabled": true,
"conditions": [
{
"field": "subject",
"operator": "contains",
"value": "invoice"
}
],
"actions": [
{
"type": "move",
"value": "Finance"
}
]
}
]
}),
});
const { data } = await response.json();import requests
response = requests.put(
"https://courier.mailyte.com/api/v1/mailbox/rules",
headers={"Authorization": "Bearer MAILBOX_TOKEN"},
json={
"rules": [
{
"name": "Invoices to Finance",
"match": "any",
"enabled": true,
"conditions": [
{
"field": "subject",
"operator": "contains",
"value": "invoice"
}
],
"actions": [
{
"type": "move",
"value": "Finance"
}
]
}
]
},
)
data = response.json()["data"]<?php
$response = Http::withToken('MAILBOX_TOKEN')
->put('https://courier.mailyte.com/api/v1/mailbox/rules', [
'rules' => [
[
'name' => 'Invoices to Finance',
'match' => 'any',
'enabled' => true,
'conditions' => [
[
'field' => 'subject',
'operator' => 'contains',
'value' => 'invoice',
],
],
'actions' => [
[
'type' => 'move',
'value' => 'Finance',
],
],
],
],
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://courier.mailyte.com/api/v1/mailbox/rules")
request = Net::HTTP::Put.new(uri)
request["Authorization"] = "Bearer MAILBOX_TOKEN"
request["Content-Type"] = "application/json"
request.body = {
"rules": [
{
"name": "Invoices to Finance",
"match": "any",
"enabled": true,
"conditions": [
{
"field": "subject",
"operator": "contains",
"value": "invoice"
}
],
"actions": [
{
"type": "move",
"value": "Finance"
}
]
}
]
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Successful Response
dataobjectrulesarray<object>idstringnamestringmatchstringall | anyenabledbooleanconditionsarray<object>fieldstringfrom, to, cc, subject or body.
operatorstringcontains (the default), is, or matches (with * and ? wildcards).
valuestring
actionsarray<object>typestringmove (value: a folder), label (value: a label), flag, mark_read, forward (value: an address) or discard.
valuestring
200
application/json{
"type": "success",
"msg": "Rules saved",
"data": {
"rules": [
{
"id": "r1",
"name": "Invoices to Finance",
"match": "any",
"enabled": true,
"conditions": [
{
"field": "subject",
"operator": "contains",
"value": "invoice"
}
],
"actions": [
{
"type": "move",
"value": "Finance"
}
]
}
]
}
}Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | No token, or the session expired or was signed out. Sign in again with `POST /mailbox-auth/login`. |
403 | The account has a temporary password: until `POST /security/password` succeeds, every other call answers this with `error_code: password_change_required`. |
422 | More than 50 rules, or a rule with an unknown field, operator or action. |
Every status, with what causes it and what to do, is on the error reference.