Перейти к документации
Python

openemail.suppressions

Каждый метод этого пространства имён: его сигнатура, параметры, что он возвращает, и пример.

Методы

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

suppressions.list()

List one page of the suppression list

Разрешенияsettings:readПостранично перебирает результаты
Сигнатура
def list(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    reason: SuppressionReason | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Page[SuppressionResource]

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. list_all collects every page into one list and iterate 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 remove 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.

Параметры

limitint

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

cursorstr

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

qstr

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

reasonSuppressionReason

Keeps one kind: bounce, complaint or manual.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

Page[SuppressionResource], a dict with items, hasMore and nextCursor. Each item has id, email, reason, detail, removable and createdAt.

Пример

from openemail import openemail page = openemail.suppressions.list(reason='complaint') for row in page['items']:    print(row['email'], row['createdAt'])

Примечания

  • 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.

Также доступно в

API
GET /suppressions
TypeScript
suppressions.list()
Ruby
suppressions.list
CLI
openemail suppressions list

suppressions.list_all()

Collect every suppressed address into one list

Разрешенияsettings:readПостранично перебирает результаты
Сигнатура
def list_all(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    reason: SuppressionReason | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> builtins.list[SuppressionResource]

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

Параметры

limitint

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

cursorstr

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

qstr

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

reasonSuppressionReason

Keeps one kind: bounce, complaint or manual.

api_keystr

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

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

list[SuppressionResource] holding every suppressed address.

Пример

from openemail import openemail blocked = {row['email'] for row in openemail.suppressions.list_all(limit=100)}recipients = ['[email protected]', '[email protected]', '[email protected]'] print([email for email in recipients if email not in blocked])

Примечания

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

Также доступно в

API
GET /suppressions
TypeScript
suppressions.listAll()
Ruby
suppressions.list_all

suppressions.iterate()

Stream the suppression list one address at a time

Разрешенияsettings:readПостранично перебирает результаты
Сигнатура
def iterate(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    reason: SuppressionReason | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Iterator[SuppressionResource]

Returns a generator that yields one suppressed address at a time, newest first, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and breaking out of it stops the requests.

Параметры

limitint

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

cursorstr

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

qstr

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

reasonSuppressionReason

Keeps one kind: bounce, complaint or manual.

api_keystr

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

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

Iterator[SuppressionResource], a generator yielding one suppressed address per step.

Пример

from openemail import openemail for row in openemail.suppressions.iterate(q='example.com'):    print(row['email'], row['reason'], row['removable'])

Примечания

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

Также доступно в

API
GET /suppressions
TypeScript
suppressions.iterate()
Ruby
suppressions.iterate

suppressions.get()

Read one suppressed address by id

Разрешенияsettings:read
Сигнатура
def get(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SuppressionResource

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.

Параметры

idstrОбязательно

The id from list.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

SuppressionResource with id, email, reason, detail, removable and createdAt.

Пример

from openemail import openemail row = openemail.suppressions.get('7b1e2c3d-4f5a-4b6c-8d7e-9f0a1b2c3d4e') print(row['email'], row['reason'], row['removable'])

Примечания

Также доступно в

API
GET /suppressions/{id}
TypeScript
suppressions.get()
Ruby
suppressions.get
CLI
openemail suppressions get

suppressions.add()

Stop sending to an address

Разрешенияsettings:write
Сигнатура
def add(    body: SuppressionAdd,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SuppressionResource

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.

Параметры

body['email']strОбязательно

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

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

SuppressionResource for the address, new or already there.

Пример

from openemail import openemail row = openemail.suppressions.add({'email': '[email protected]'}) print(row['reason'], row['createdAt'])

Примечания

  • 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.

Также доступно в

API
POST /suppressions
TypeScript
suppressions.add()
Ruby
suppressions.add
CLI
openemail suppressions add

suppressions.remove()

Allow mail to an address again

Разрешенияsettings:write
Сигнатура
def remove(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> RemovedSuppressionResource

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.

Параметры

idstrОбязательно

The id from list.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Возвращает

RemovedSuppressionResource with object set to suppression, the id and email, and deleted set to True.

Пример

from openemail import OpenEmailApiError, openemail try:    removed = openemail.suppressions.remove('7b1e2c3d-4f5a-4b6c-8d7e-9f0a1b2c3d4e')except OpenEmailApiError as error:    if error.code != 'suppression_not_removable':        raise    print('A hard bounce stays on the list. Check the spelling of the address.')else:    print('Mail may go to', removed['email'], 'again')

Примечания

  • 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.

Также доступно в

API
DELETE /suppressions/{id}
TypeScript
suppressions.remove()
Ruby
suppressions.remove
CLI
openemail suppressions remove