Suppressions API
Relevant source files
The following files were used as context for generating this wiki page:
The Suppressions API manages email addresses that Resend should not send messages to. This module allows you to add, retrieve, list, and remove addresses from the account-level suppression list to maintain sender reputation and comply with recipient preferences.
The API supports both single-entry operations and batch processing for up to 100 email addresses at a time. It integrates with the broader Resend service architecture via the SuppressionsSvc and emits specific webhook events when the suppression list changes.
Sources: src/suppressions.rs:18-20, CHANGELOG.md:82-83
Service Architecture
The SuppressionsSvc provides the primary interface for suppression operations. It wraps an asynchronous Config object to build and execute HTTP requests against the /suppressions endpoints.
The diagram above shows the relationship between the main service struct and the underlying API endpoints.
Sources: src/suppressions.rs:20-94, src/lib.rs:88
Data Models
Suppression Object
A Suppression represents a specific record in the suppression list. It includes the target email, its origin, and the specific email event that triggered the suppression if applicable.
| Field | Type | Description |
|---|---|---|
id | SuppressionId | Unique identifier for the suppression record. |
email | String | The suppressed email address. |
created_at | String | ISO 8601 timestamp of record creation. |
origin | SuppressionOrigin | The cause: Bounce, Complaint, or Manual. |
source_id | Option<EmailId> | The ID of the email that caused the suppression. |
Sources: src/suppressions.rs:136-152
Suppression Origin
The origin indicates how an email was added to the list.
- Bounce: The recipient's mail server rejected the message.
- Complaint: The recipient marked the message as spam.
- Manual: A user added the email address via the API or dashboard.
Sources: src/suppressions.rs:146-152, src/events.rs:567-573
Core Operations
Single Record Management
You can add or remove individual email addresses. Adding an email requires AddSuppressionOptions, while removal uses the record ID or the email address itself.
Batch Operations
The API processes up to 100 entries in a single call. Batch removal is type-safe, requiring you to specify either a list of IDs or a list of emails, but not both.
- Batch Add: Uses
BatchAddSuppressionOptionscontaining a vector of strings. - Batch Remove: Uses
BatchRemoveSuppressionOptions<M>whereMis aSpecifiedMarker(EmailsSpecifiedorIdsSpecified).
Sources: src/suppressions.rs:77-111, src/suppressions.rs:188-216
Webhook Integration
The Resend system emits SuppressionEvent objects when changes occur. These are integrated into the global Event enum.
| Event Type | Description |
|---|---|
suppression.added | Triggered when a new address is added to the list. |
suppression.removed | Triggered when an address is removed from the list. |
Sources: src/events.rs:434, src/events.rs:518-523, src/events.rs:887-930
Sources: src/events.rs:462-467, src/events.rs:560-565
Usage and Quotas
Resend tracks suppression list activity as part of account-level usage. While suppressions do not count toward daily or monthly email sending limits, they are monitored to provide sender reputation insights.
Sources: src/usage.rs:36-45, CHANGELOG.md:144-145
Implementation Example
use resend_rs::types::{AddSuppressionOptions, BatchRemoveSuppressionOptions};
// Add a single suppression
let opts = AddSuppressionOptions::new()
.with_email("user@example.com");
let res = resend.suppressions.add(opts).await?;
// Batch remove by IDs
let batch_opts = BatchRemoveSuppressionOptions::new()
.add_ids(vec!["id_1", "id_2"]);
let del_res = resend.suppressions.batch_remove(batch_opts).await?;
Sources: src/suppressions.rs:114-131, src/suppressions.rs:253-271