Receive Emails: Rules
Create Rule
Create a filter that runs on every new email: match by sender, domain, provider, subject, body, attachments, time and more, then move, label, flag, snooze or reply.
https://g.sendcorex.com/v1command: create_ruleThe new rule goes to the end of the list. Rules run in order; stop: true skips the rules below it when it matches.
A rule cannot take an email out of Spam, trust or block the sender, or reply automatically unless the From domain passed SPF or DKIM aligned (or DMARC). Anyone can write From: boss@yourcompany.com; without this check that email would skip your filters or block your boss.
Arguments
namestringrequiredUp to 80 characters.
conditionsobject[]required[{ field, op, value, header? }]. 1 to 20 (counting exceptions).matchstringoptionalall(default) oranyof the conditions.exceptobject[]optionalIf any of these match, the rule does not run.
actionsobject[]required[{ type, value? }]. 1 to 12. Only onemove.stopbooleanoptionalDo not run the rules below when this one matches.
enabledbooleanoptionalDefaults to
true.timezonestringoptionalIANA name used by
received_hour,received_weekdayandnext_morning. Defaults to UTC.presetstringoptionalYour own tag for rules created from a template.
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "create_rule",
args: {
name: "Clients always in Inbox",
match: "all",
conditions: [
{
field: "from_domain",
op: "in_list",
value: "acme.com, globex.com"
},
{
field: "provider",
op: "is_any_of",
value: [
"microsoft_365",
"google_workspace"
]
}
],
except: [
{
field: "subject",
op: "contains",
value: "newsletter"
}
],
actions: [
{
type: "keep_inbox"
},
{
type: "label",
value: "Clients"
},
{
type: "star"
}
],
stop: false,
timezone: "Asia/Kuala_Lumpur"
}
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);
const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);Response
{
"type": "SUCCESS",
"results": [
{
"command": "create_rule",
"id": "0",
"type": "SUCCESS",
"data": {
"id": "Vj0xUlVMRTAx",
"rule_id": "Vj0xUlVMRTAx",
"name": "Clients always in Inbox",
"match": "all",
"conditions": [
{
"field": "from_domain",
"op": "in_list",
"value": "acme.com, globex.com"
},
{
"field": "provider",
"op": "is_any_of",
"value": [
"microsoft_365",
"google_workspace"
]
}
],
"except": [
{
"field": "subject",
"op": "contains",
"value": "newsletter"
}
],
"actions": [
{
"type": "keep_inbox"
},
{
"type": "label",
"value": "Clients"
},
{
"type": "star"
}
],
"stop": false,
"timezone": "Asia/Kuala_Lumpur",
"enabled": true,
"position": 0,
"hits": 128,
"last_hit_at": "2026-10-25T09:12:44Z",
"created_at": "2026-10-01T02:00:00Z",
"updated_at": "2026-10-20T08:30:00Z"
}
}
]
}Fields and operators
from / from_name / reply_totext: contains, not_contains, is, is_not, starts_with, ends_with, regex, not_regex, in_list, not_in_list, is_empty, not_empty
from_domaindomain: is (also matches subdomains), is_not, in_list, not_in_list, contains, not_contains, ends_with, regex, not_regex
to / cc / recipientlist of addresses (recipient = to + cc). Same operators as text; matches when any address matches
subject / body / subject_or_bodytext. The body is read up to the first 20,000 characters
attachment_name / attachment_typelist. attachment_type is the extension: pdf, xlsx…
list_idtext. The List-Id of a mailing list
headertext, with the header name in
header(e.g. x-mailer). Only checked when the email arrivesprovideris_any_of / is_none_of: google_workspace, gmail, microsoft_365, outlook, yahoo, icloud, zoho, proton, amazon_ses, sendgrid, mailgun, other
received_weekdayis_any_of / is_none_of: sun, mon, tue, wed, thu, fri, sat (in the rule timezone)
received_hourgt, lt, between, not_between.
22-6crosses midnightsize_kbgt, lt, between, not_between
has_attachment, is_mailing_list, is_reply, is_auto_reply, is_calendar_invite, authenticated, trusted_sender, first_time_sender, only_to_meis_true / is_false
Actions
movevalue: inbox, archive, spam, trash, promotions or custom:<folder-id>. The first rule that moves wins
keep_inboxAlways Inbox: never Spam, triage (Agents / NotSubscribing) or Promotions
mark_read / star / importantFlags. They add up across rules
labelvalue: the label name (1–50 characters). Labels add up across rules
trust_sender / block_senderSaves the sender as trusted or blocked for the next emails. block_sender also moves to Spam
snoozevalue: hours (1 to 8760) or next_morning (next 8:00 in the rule timezone). Only for emails that stay in Inbox
auto_replyvalue: a template id. One reply per sender every 24 hours
When several rules match: the first move wins, labels and flags add up, and block_sender overrides trust_sender.
What a rule cannot override
A rule cannot take an email out of Spam, trust or block the sender, or reply automatically unless the From domain passed SPF or DKIM aligned (or DMARC). Anyone can write From: boss@yourcompany.com; without this check that email would skip your filters or block your boss.
Labels, read, star and moving to Spam or Trash always apply. Phishing reports, DMARC quarantine, a sender you blocked by hand and a list you unsubscribed from keep the email in Spam whatever the rule says.
provider comes from the delivery path that we verify: the server that connected to us (reverse DNS confirmed forward) and SPF passing through the provider's own range. The MX record is never used: anyone can point MX to Google and send from their own server.
Values
in_list takes a list separated by comma, semicolon or new line. In address lists, @acme.com matches anyone at that domain. regex uses RE2: no lookahead, lookbehind or backreferences, up to 300 characters. Text comparisons ignore case.
Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
TOKEN_EXPIREDThe access token has expired. Call Refresh Token and repeat the request.
- 401
INVALID_TOKENThe token is malformed, unknown or revoked.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD
INVALID_ARGSA required argument is missing or invalid.
- CMD
INVALID_RULEThe rule is not valid. The message says which condition or action and why.
- CMD
LIMITThe mailbox reached the limit (100 rules, 200 templates or 100 labels).
- CMD
INTERNALServer error. The detail is only written to the server log.