Skip to main content
Mail rules govern incoming and outgoing email. They attach to the agent identity and are addressed by agent_handle. For a shared policy, set mail_filter_mode and omit rule direction: new rules apply to both sending and receiving. Contact permission edits and standalone exact-email rules change the same choices.
  • whitelist: a matching allow domain permits communication; otherwise it is denied.
  • blacklist: a matching block domain denies communication; otherwise it is permitted.
An active exact-email allow or block takes precedence over domains and defaults in either mode. Evaluate only rules covering the communication’s direction. Inbound is from the external party to the agent; outbound is from the agent to that party. Use mail_inbound_filter_mode and mail_outbound_filter_mode for independent defaults. See Manage identities and the split-mode example. New directional SDK/CLI options require 0.7.3 or later. Receiving permission does not permit a reply. Sending permission does not permit receiving, and does not replace other send requirements. Companion mode can permit a sponsored email conversation without globally allowing every participant. An applicable explicit block anywhere in its exact participant cohort vetoes Companion permission in that direction, after exact-address-over-domain precedence. Separate recipient branches need separate sponsorship. To be eligible to activate a group, the actual sender address needs active exact_email allows covering both inbound and outbound. One both allow and two one-way allows are equivalent. Domain allows and access from blacklist defaults do not make a sender eligible. Their qualifying authenticated message, not the rule alone, activates the scope.
Deprecation. The previous mailbox-addressed routes (/mailboxes/{email_address}/contact-rules) are deprecated. They still work and return the same fields they did before. Migrate to the identity-keyed routes documented here.
Rules match on either a full email address (match_type: "exact_email") or a bare domain (match_type: "domain").

Direction and rule identity

  • Create defaults to direction: "both". PATCH without direction preserves current coverage.
  • List with direction=inbound or outbound includes matching one-way rules and both rules. direction=both selects only bidirectional rules. Omit the filter for all rules without duplicates. Action and match-type filters apply independently, before pagination. A2A direction filters remain exact matches with their existing defaults.
  • One both rule has one action. Opposite actions require separate inbound and outbound rules.
  • Adding compatible coverage for the same target widens the existing rule to both. Matching actions and lifecycle states consolidate even after editing two existing rules. Previously issued IDs remain usable for get, update, and delete of the consolidated logical rule; lists contain it once. An ID does not permanently identify its original direction.
  • Successful POST returns 201, including widening an existing rule. Use the returned ID and direction; success does not guarantee a new ID. PATCH returns 200.
  • Creating coverage that already exists returns 409, with the existing duplicate error and existing_rule_id. Conflicting actions also return 409; create does not overwrite them. Paused coverage is not silently reactivated or combined with active coverage.
These semantics also apply to the deprecated mailbox routes. When a sender is blocked, inbound mail is stored but never delivered to the agent, and no message.received webhook fires. Auth. Claimed agent keys can read their permitted rules. Creating, updating, or deleting rules requires an admin API key or the Inkbox Console. Agent writes return 403. Org-wide listings require administrative access.

List contact rules

List mail contact rules for an agent identity, newest first. An identity-scoped API key may read only its own identity’s agent_handle. Another handle returns 403; agent keys cannot create rules.

Path parameters

Query parameters

Response (200)

JSON

Code examples


Create contact rule

Create an allow or block rule on an agent identity. New rules always start active.

Path parameters

Request body

Request example

JSON

Response (201)

Returns the saved rule, which may be an existing rule widened to both. See Contact rule object.

Error responses

Code examples


Get contact rule

Fetch a single contact rule by ID.

Path parameters

Response (200)

Returns the rule. See Contact rule object.

Error responses

Code examples


Update contact rule

Change a rule’s action or coverage, or atomically edit one covered side. Requires an admin API key, or manage rules from the Inkbox Console. match_type and match_target are immutable — delete the rule and create a new one to change the target.

Path parameters

Request body

Supply action, direction, or both. apply_to requires action and cannot be combined with direction. Supplied values cannot be null.

Request example

JSON

Response (200)

Returns the updated rule.

Change one side without removing the other

For a rule that allows both, this request blocks inbound and retains outbound allow in one operation:
The response contains the addressed inbound rule. Refresh the list to see the preserved outbound rule. Applying the existing action does not split the rule. An uncovered side, apply_to: "both", missing action, null, or a combination with direction returns 422. By contrast, {"direction":"inbound"} on a both rule removes outbound coverage. The outbound mode and remaining applicable rules then determine sending permission. An action-only PATCH changes every direction currently covered by that rule.

Error responses

Code examples


Delete contact rule

Delete a contact rule. Returns 204 No Content on success. Requires an admin API key, or manage rules from the Inkbox Console.

Path parameters

Error responses

Code examples


List org mail contact rules

Org-wide aggregate list of mail contact rules across every identity the caller can see. Intended for admin dashboards that render rules org-wide without fanning out one per-identity request per identity. Requires an admin API key, or browse rules in the Inkbox Console. Results are grouped by matched contact ID, with rules that have no matched contact last. Within each group, rules are ordered by created_at descending and then id ascending. Grouping happens before pagination, and a contact’s rows can span adjacent pages.

Query parameters

Response (200)

Returns an array of contact rule objects — same shape as the per-identity list.

Code examples


Contact rule object

List, get, create, update, and organization-wide list responses include a nullable contact card for an exact target with one resolved owner in the rule’s organization. The card follows the caller’s contact permissions and contains no memories, memory_count, or latest_memory. Domain, unresolved, ambiguous, and inaccessible matches return null. Hidden profile fields and identifiers are not restored by reading a rule. Reads resolve the current contact. An idempotent write replay preserves its original response snapshot. SDK/CLI 0.6.11 supports these cards; CLI tables show contact names and JSON output preserves the card.

Additional resources