Create inbox rule
cooper_create_ruleUse this when mail like X should be labeled, filed, forwarded, or acknowledged on the server with no model call. Requires auth and message_update. Creating a rule with forward_to or auto_reply also needs message_send. HTTP 403 permission_denied with param actions when it does not, and nothing is stored. Inputs: inbox_id (required), name (required, 1–80 characters), conditions (required object; at least one of from, to, subject_contains, body_contains, has_attachment, auth, list), actions (required object; at least one of add_labels, folder, mark_read true, forward_to, auto_reply, or stop_processing), enabled (optional boolean, default true), position (optional integer; lower runs first), stop_processing (optional boolean), client_id (optional idempotency key, at most 128 characters). from is an email, @domain, or a domain. auth is pass or fail and uses DMARC. forward_to is another inbox on this account or a verified owner of this inbox. auto_reply.text is at most 2,000 characters. auto_reply.cooldown_hours is 1–720 and defaults to 24. An inbox stores at most 20 rules (HTTP 409 rule_limit). A bad rule is HTTP 400 invalid_rule. A disallowed forward_to is HTTP 400 forward_target_not_allowed. The same client_id returns the original rule and does not create a second one. Returns the inbox_rule.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Rule name, 1 to 80 characters. | |
| actions | Yes | add_labels, folder (inbox|archive|spam|trash), mark_read, forward_to, auto_reply {text, subject?, cooldown_hours?}. | |
| enabled | No | When false the rule is stored and does not run. Default true. | |
| inbox_id | Yes | Inbox id (inb_…), username, or full email address owned by this key | |
| position | No | Sort key. Lower numbers run first. Ties break by created_at. Omit to append. | |
| client_id | No | Optional idempotency key, 1 to 128 characters. The same key returns the original rule. | |
| conditions | Yes | All set conditions must match. from, to, subject_contains, body_contains (max 256), has_attachment, auth pass|fail, list. | |
| stop_processing | No | When true, later rules do not run after this one matches. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Rule id. Pass it as rule_id. | |
| name | No | Human-readable name. | |
| object | No | Object type name, such as list, message, or thread. | |
| actions | No | What happens to a matching message. | |
| enabled | No | True when the object is active. | |
| inbox_id | No | Inbox id (inb_…) this object belongs to. Null when it applies to every inbox. | |
| position | No | Order the rule runs in. Lower runs first. | |
| client_id | No | Caller idempotency key stored with the object, or null. | |
| conditions | No | What a message must match. | |
| created_at | No | ISO-8601 time the object was created. | |
| last_error | No | Last action error, or null. | |
| updated_at | No | ISO-8601 time the object last changed. | |
| match_count | No | How many messages matched. | |
| last_matched_at | No | ISO-8601 time of the last match, or null. | |
| stop_processing | No | When true, later rules are skipped after a match. |