Update a transport rule
/api/v1/transport-rules/{id}Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | The id identifier. |
Request body
namestringrequiredA name for your team, like
Flag mail from outside.conditionsarray<object>requiredWhat a message must match for the rule to run. At least one.
fieldstringrequiredsender | recipient | subject | header | size | has_attachmentThe part of the message to test.
sizeis in bytes.operatorstringrequiredequals | contains | starts_with | ends_with | regex | greater_than | less_thanHow to compare.
greater_thanandless_thanare forsize.valuestringrequiredWhat to compare with.
actionsarray<object>requiredWhat to do to a matching message. At least one.
typestringrequiredadd_header | modify_subject | redirect | bcc | reject | add_disclaimer | quarantineWhat to do.
redirectandbccare accepted but not carried out yet.add_disclaimeradds a header, not text in the email.paramsobjectSettings for the action.
add_header:{"name": "X-Flag", "value": "yes"}.modify_subject:{"prefix": "[External] "}.reject:{"message": "Not accepted"}.add_disclaimer:{"text": "…"}.
descriptionstringOptional. A note for your team.
directionstringinbound | outbound | bothWhich mail the rule looks at:
inbound(arriving),outbound(leaving) orboth. Defaults toboth.condition_logicstringall | anyHow the conditions combine:
allmust match, oranyone is enough. Defaults toall.priorityintegerLower numbers run first. Defaults to 100.
enabledbooleanWhether it is switched on.
Request
/api/v1/transport-rules/{id}curl -X PUT 'https://app.mailyte.com/api/v1/transport-rules/01JBT8XQ2M9WYC3K4F6R7S8T9V' \
-H 'Authorization: Bearer mk_live_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "Flag mail from outside",
"conditions": [
{
"field": "sender",
"operator": "ends_with",
"value": "@example.com"
}
],
"actions": [
{
"type": "modify_subject",
"params": {
"prefix": "[External] "
}
}
]
}'const response = await fetch('https://app.mailyte.com/api/v1/transport-rules/01JBT8XQ2M9WYC3K4F6R7S8T9V', {
method: 'PUT',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Flag mail from outside",
"conditions": [
{
"field": "sender",
"operator": "ends_with",
"value": "@example.com"
}
],
"actions": [
{
"type": "modify_subject",
"params": {
"prefix": "[External] "
}
}
]
}),
});
const { data } = await response.json();import requests
response = requests.put(
"https://app.mailyte.com/api/v1/transport-rules/01JBT8XQ2M9WYC3K4F6R7S8T9V",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
json={
"name": "Flag mail from outside",
"conditions": [
{
"field": "sender",
"operator": "ends_with",
"value": "@example.com"
}
],
"actions": [
{
"type": "modify_subject",
"params": {
"prefix": "[External] "
}
}
]
},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->put('https://app.mailyte.com/api/v1/transport-rules/01JBT8XQ2M9WYC3K4F6R7S8T9V', [
'name' => 'Flag mail from outside',
'conditions' => [
[
'field' => 'sender',
'operator' => 'ends_with',
'value' => '@example.com',
],
],
'actions' => [
[
'type' => 'modify_subject',
'params' => [
'prefix' => '[External] ',
],
],
],
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/transport-rules/01JBT8XQ2M9WYC3K4F6R7S8T9V")
request = Net::HTTP::Put.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = {
"name": "Flag mail from outside",
"conditions": [
{
"field": "sender",
"operator": "ends_with",
"value": "@example.com"
}
],
"actions": [
{
"type": "modify_subject",
"params": {
"prefix": "[External] "
}
}
]
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectobjectstringtransport_ruleidstringThe rule's ID, a ULID. Rule IDs are uppercase, such as
01M2RV5CEM4MT97RQ00ANRRFCP; compare them exactly.namestringThe rule's name.
descriptionstringYour note about the rule. Null when there is none.
directionstringinbound | outbound | bothWhich mail the rule checks:
inbound,outboundorboth(the default).enabledbooleanA disabled rule keeps its priority and is not evaluated.
priorityintegerThe order rules run in: lower runs first. The default is 100.
PUT /transport-rules/reorderrenumbers rules in steps of 10, so a rule can be put between two others.matchobjectHow a message is matched:
logicand itsconditions.logicstringall | anyallmeans every condition must match (the default);anymeans one is enough.conditionsarray<object>The conditions, each with
field,operatorandvalue.fieldstringsender | recipient | subject | header | size | has_attachmentWhat is checked.
sizeis the message size in bytes;has_attachmentis true or false.operatorstringequals | contains | starts_with | ends_with | regex | greater_than | less_thanHow
valueis compared withfield.valuestringWhat to compare with. Always a string, even for numbers: a size limit reads back as
"1048576". Parse it yourself forgreater_thanandless_than.
actionsarray<object>What happens to a matched message, in order.
typestringadd_header | modify_subject | redirect | bcc | reject | add_disclaimer | quarantineWhat is done to a message that matches.
paramsobjectThe action's settings, keyed by name. Always an object,
{}when there are none.
created_atstringIn ISO 8601 UTC.
updated_atstringIn ISO 8601 UTC.
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait. |
Every status, with what causes it and what to do, is on the error reference.