Skip to the documentation
C#

client.Suppressions

Every method in this namespace: its signature, its parameters, what it returns and an example.

Methods

The addresses this workspace will not send to: hard bounces, complaints and the ones you block by hand.

Suppressions.ListAsync

List one page of the suppression list

Scopessettings:readPages through results
Signature
Task<Page> ListAsync(    string? q = null,    string? reason = null,    int? limit = null,    string? cursor = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns one page of the addresses this workspace will not send to, newest first: every address that bounced hard, complained, or was added by hand. ListAllAsync collects every page and IterateAsync walks them lazily.

A send to a suppressed address is refused for that recipient before anything leaves, and a message whose recipients are all suppressed fails outright. The list belongs to the whole workspace, so a key limited to some addresses reads all of it, and a row names the recipient, never which of your addresses sent to it.

removable says whether RemoveAsync will take the address off. A hard bounce is permanent here, because the address could not take mail. A complaint or a manual entry can be removed.

Parameters

qstring?

Searches the address, the reason and the detail. Words match loosely, and a close spelling is tried when nothing matches exactly.

reasonstring?

Keeps one kind: bounce, complaint or manual, as in OpenEmail\Constants\SuppressionReasons.

limitint?

Page size, from 1 to 100. The server defaults to 25.

cursorstring?

The nextCursor of the previous page. Leave it out for the first page.

apiKeystring?

Overrides the client API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

Returns

A Page with items, hasMore and nextCursor. Each item has id, email, reason, detail, removable and createdAt.

Example

using OpenEmail.Constants; var page = await client.Suppressions.ListAsync(reason: SuppressionReasons.Complaint); foreach (var row in page){    Console.WriteLine($"{row["email"]} since {row["createdAt"]}");}

Notes

  • Needs settings:read, the scope the Blocked addresses screen in Settings is gated on.

  • The cursor is opaque and holds where the last row sat, so an address removed between pages never breaks the walk. A cursor this list did not hand out is a 400 invalid_cursor.

Also available in

API
GET /suppressions
TypeScript
suppressions.list()
Python
suppressions.list()
Ruby
suppressions.list
PHP
suppressions->list
Go
Suppressions.List
Java
suppressions().list
CLI
openemail suppressions list

Suppressions.ListAllAsync

Collect the whole suppression list into one object

Scopessettings:readPages through results
Signature
Task<IReadOnlyList<JsonObject>> ListAllAsync(    string? q = null,    string? reason = null,    int? limit = null,    string? cursor = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Walks every page of ListAsync and returns every suppressed address, newest first. One request per page, with the same filters on each.

Parameters

qstring?

Searches the address, the reason and the detail. Words match loosely, and a close spelling is tried when nothing matches exactly.

reasonstring?

Keeps one kind: bounce, complaint or manual, as in OpenEmail\Constants\SuppressionReasons.

limitint?

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstring?

Starts the walk after this cursor instead of the first page.

apiKeystring?

Overrides the client API key for every page of this walk.

cancellationTokenCancellationToken

Cancels the request.

Returns

A list of JsonObject items holding every suppressed address, each with the fields ListAsync returns.

Example

var rows = await client.Suppressions.ListAllAsync(limit: 100); Console.WriteLine(rows.Count);

Notes

  • If any page fails the call throws and the rows already fetched are discarded.

Also available in

API
GET /suppressions
TypeScript
suppressions.listAll()
Python
suppressions.list_all()
Ruby
suppressions.list_all
PHP
suppressions->listAll
Go
Suppressions.ListAll
Java
suppressions().listAll

Suppressions.IterateAsync

Stream the suppression list one address at a time

Scopessettings:readPages through results
Signature
IAsyncEnumerable<JsonObject> IterateAsync(    string? q = null,    string? reason = null,    int? limit = null,    string? cursor = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns an IAsyncEnumerable<JsonObject> that yields one suppressed address at a time, newest first, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.

Parameters

qstring?

Searches the address, the reason and the detail. Words match loosely, and a close spelling is tried when nothing matches exactly.

reasonstring?

Keeps one kind: bounce, complaint or manual, as in OpenEmail\Constants\SuppressionReasons.

limitint?

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstring?

Starts the walk after this cursor instead of the first page.

apiKeystring?

Overrides the client API key for every page of this walk.

cancellationTokenCancellationToken

Cancels the request.

Returns

An IAsyncEnumerable<JsonObject> that yields one suppressed address per step.

Example

await foreach (var row in client.Suppressions.IterateAsync(q: "example.com")){    Console.WriteLine($"{row["email"]} {row["reason"]}");}

Notes

  • The generator is lazy, so an abandoned loop costs only the pages you consumed.

Also available in

API
GET /suppressions
TypeScript
suppressions.iterate()
Python
suppressions.iterate()
Ruby
suppressions.iterate
PHP
suppressions->iterate
Go
Suppressions.Iterate
Java
suppressions().iterate

Suppressions.GetAsync

Read one suppressed address by id

Scopessettings:read
Signature
Task<JsonObject> GetAsync(    string id,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns one row of the suppression list: the address, why it is there, the detail the bounce or complaint carried, whether it can be removed and when it was added.

Parameters

idstringRequired

The id from ListAsync.

apiKeystring?

Overrides the client API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

Returns

A JsonObject with id, email, reason, detail, removable and createdAt.

Example

var row = await client.Suppressions.GetAsync("7b1e2c3d-4f5a-4b6c-8d7e-9f0a1b2c3d4e"); Console.WriteLine($"{row["email"]}{((bool?)row["removable"] == true ? " can be removed" : " stays on the list")}");

Notes

Also available in

API
GET /suppressions/{id}
TypeScript
suppressions.get()
Python
suppressions.get()
Ruby
suppressions.get
PHP
suppressions->get
Go
Suppressions.Get
Java
suppressions().get
CLI
openemail suppressions get

Suppressions.AddAsync

Stop sending to an address

Scopessettings:write
Signature
Task<JsonObject> AddAsync(    IReadOnlyDictionary<string, object?> body,    string? apiKey = null,    CancellationToken cancellationToken = default)

Puts an address on the suppression list by hand, with reason set to manual, so no address in the workspace sends to it again until it is removed. It is the Block an address control on the Blocked addresses screen.

Adding an address that is already there changes nothing: the server answers 200 with the row it already holds, whatever its reason, where a new entry answers 201. Either way you get the row back. A new entry fires suppression.added to the webhooks that asked for it.

Parameters

emailstringRequired

The address to stop sending to. It is trimmed and lower cased.

apiKeystring?

Overrides the client API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

Returns

A JsonObject for the address, new or already there, with the fields GetAsync returns.

Example

var row = await client.Suppressions.AddAsync(new Body { ["email"] = "[email protected]" }); Console.WriteLine($"{row["reason"]} since {row["createdAt"]}");

Notes

  • Safe to repeat: a second add finds the first entry, so the SDK retries it after a network failure.

  • A key limited to particular addresses or domains is refused with 422 capability_unsupported, because the list stops mail from every address in the workspace. So is an app connected by anybody but the owner.

Also available in

API
POST /suppressions
TypeScript
suppressions.add()
Python
suppressions.add()
Ruby
suppressions.add
PHP
suppressions->add
Go
Suppressions.Add
Java
suppressions().add
CLI
openemail suppressions add

Suppressions.RemoveAsync

Allow mail to an address again

Scopessettings:write
Signature
Task<JsonObject> RemoveAsync(    string id,    string? apiKey = null,    CancellationToken cancellationToken = default)

Takes an address off the suppression list, so mail may go to it again. It is Allow again on the Blocked addresses screen, and it fires suppression.removed.

Only a complaint or a manual entry can be removed. A hard bounce answers 409 suppression_not_removable and stays, because the address could not take mail: check it is spelled right and send to the corrected one instead.

Parameters

idstringRequired

The id from ListAsync.

apiKeystring?

Overrides the client API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

Returns

A JsonObject with object set to suppression, the id, the email, and deleted set to true.

Example

var page = await client.Suppressions.ListAsync(q: "[email protected]"); if (page.Count > 0){    try    {        await client.Suppressions.RemoveAsync(page[0]["id"]!.GetValue<string>());    }    catch (OpenEmailApiException error) when (error.IsConflict)    {        Console.WriteLine($"{page[0]["email"]} bounced hard, so it stays on the list");    }}

Notes

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

  • A key limited to particular addresses or domains is refused with 422 capability_unsupported.

Also available in

API
DELETE /suppressions/{id}
TypeScript
suppressions.remove()
Python
suppressions.remove()
Ruby
suppressions.remove
PHP
suppressions->remove
Go
Suppressions.Remove
Java
suppressions().remove
CLI
openemail suppressions remove