rules.set
Save and activate filter rules.
Replaces the JSON filter rules for this mailbox, compiles them into a Sieve script, and activates them for incoming mail delivery.
openemail.rules.set(
mailboxId: string,
body: RulesDocument,
options?: CallOptions,
): ApiPromise<FilterRulesPutResult>It calls PUT /mailboxes/{mailboxId}/rules: Save and activate filter rules in the API reference.
Example
const filterRulesPutResult = await openemail.rules.set(mailboxId, { rules: [{ conditions: [], actions: [] }] })Arguments
| Argument | Type | Description |
|---|---|---|
mailboxId | string | Mailbox ULID identifier. The path's {mailboxId}. |
body | RulesDocument | The request's body. |
Options
It takes no options of its own. Every call also takes signal, timeout, retry and headers, which say how that one call is sent (call options).
Answer
Awaited, it is the API's JSON, FilterRulesPutResult. It is an ApiPromise: .withResponse() gives the same with the Response it came in, for its headers.
Errors
| Status | What it means |
|---|---|
400 | validation_failed — malformed rules document; or destination_is_self / destination_loops / destination_chain_too_long when a redirect target routes back to this mailbox; or destination_unverified when a redirect target this save introduces has not been confirmed as a forwarding destination |
401 | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a WWW-Authenticate: Bearer challenge |
404 | Mailbox not found or not accessible to this principal |
409 | too_many_scripts; or mailbox_is_group_persona — a group persona's archive runs no rules |
413 | too_large — rules document exceeds size limit (48 KiB) |
422 | invalid_script — rules compile to an oversized or invalid Sieve script |
503 | temporary_failure: the mailbox or account is in transition while its store is being adopted; retry after Retry-After |
A failed call rejects with a RequestError: its status, and its code, the API's error. Decide on the code: one status covers several.
Types
It names these types of the API, each on a page of its own: FilterRulesPutResult, RulesDocument.