---
title: "Python SDK: Security"
description: "The methods of the Python client under Security. Risk assessment and sender trust: the policy that warns, holds and guards sending, the senders an inbox knows, held mail and the audit log."
url: https://doorman.fyi/docs/python/reference/security
markdown: https://doorman.fyi/docs/python/reference/security.md
area: "SDKs and tools"
section: "Python SDK"
---

# Python SDK: Security

The methods of the Python client under Security. Risk assessment and sender trust: the policy that warns, holds and guards sending, the senders an inbox knows, held mail and the audit log.

Source: https://doorman.fyi/docs/python/reference/security

## client.held_sends.approve

Python:
```python
client.held_sends.approve(held_send_id: str) -> models.SentMessage
```

Operation [`heldSends.approve`](https://doorman.fyi/docs/reference/security.md#heldSends-approve): `POST /v1/held-sends/{heldSendId}/approve`

Send a held send.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.held_sends.discard

Python:
```python
client.held_sends.discard(held_send_id: str) -> None
```

Operation [`heldSends.discard`](https://doorman.fyi/docs/reference/security.md#heldSends-discard): `POST /v1/held-sends/{heldSendId}/discard`

Discard a held send.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.held_sends.get

Python:
```python
client.held_sends.get(held_send_id: str) -> models.HeldSend
```

Operation [`heldSends.get`](https://doorman.fyi/docs/reference/security.md#heldSends-get): `GET /v1/held-sends/{heldSendId}`

Read a held send.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.inboxes.held.list

Python:
```python
client.inboxes.held.list(inbox_id: str, *, limit: int | None = None, offset: int | None = None) -> models.HeldMessagePage
```

Operation [`inboxes.held.list`](https://doorman.fyi/docs/reference/security.md#inboxes-held-list): `GET /v1/inboxes/{inboxId}/held`

List held messages.

Access `any`: any API key, or a console session. An app token needs `mail:read`.

## client.inboxes.held.iterate

Python:
```python
client.inboxes.held.iterate(inbox_id: str, *, limit: int | None = None, offset: int | None = None) -> Iterator[models.HeldMessage]
```

Every item of [`client.inboxes.held.list`](https://doorman.fyi/docs/python/reference/security.md#inboxes-held-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.inboxes.held_sends.list

Python:
```python
client.inboxes.held_sends.list(inbox_id: str, *, status: Literal['held', 'sent', 'discarded', 'expired'] | None = None, kind: Literal['held', 'draft'] | None = None, limit: int | None = None, offset: int | None = None) -> models.HeldSendPage
```

Operation [`inboxes.heldSends.list`](https://doorman.fyi/docs/reference/security.md#inboxes-heldSends-list): `GET /v1/inboxes/{inboxId}/held-sends`

List held sends.

Access `any`: any API key, or a console session. App tokens are refused.

## client.inboxes.held_sends.iterate

Python:
```python
client.inboxes.held_sends.iterate(inbox_id: str, *, status: Literal['held', 'sent', 'discarded', 'expired'] | None = None, kind: Literal['held', 'draft'] | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.HeldSend]
```

Every item of [`client.inboxes.held_sends.list`](https://doorman.fyi/docs/python/reference/security.md#inboxes-heldSends-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.inboxes.security.get

Python:
```python
client.inboxes.security.get(inbox_id: str) -> models.SecuritySettings
```

Operation [`inboxes.security.get`](https://doorman.fyi/docs/reference/security.md#inboxes-security-get): `GET /v1/inboxes/{inboxId}/security`

Read an inbox's security policy.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.inboxes.security.reset

Python:
```python
client.inboxes.security.reset(inbox_id: str) -> None
```

Operation [`inboxes.security.reset`](https://doorman.fyi/docs/reference/security.md#inboxes-security-reset): `DELETE /v1/inboxes/{inboxId}/security`

Return an inbox to the account's security policy.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.inboxes.security.update

Python:
```python
client.inboxes.security.update(inbox_id: str, body: models.UpdateSecurityPolicy) -> models.SecuritySettings
```

Operation [`inboxes.security.update`](https://doorman.fyi/docs/reference/security.md#inboxes-security-update): `PATCH /v1/inboxes/{inboxId}/security`

Give an inbox its own security policy.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.inboxes.senders.list

Python:
```python
client.inboxes.senders.list(inbox_id: str, *, standing: Literal['trusted', 'known', 'new', 'blocked'] | None = None, q: str | None = None, limit: int | None = None, offset: int | None = None) -> models.SenderPage
```

Operation [`inboxes.senders.list`](https://doorman.fyi/docs/reference/security.md#inboxes-senders-list): `GET /v1/inboxes/{inboxId}/senders`

List an inbox's senders.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.inboxes.senders.iterate

Python:
```python
client.inboxes.senders.iterate(inbox_id: str, *, standing: Literal['trusted', 'known', 'new', 'blocked'] | None = None, q: str | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.Sender]
```

Every item of [`client.inboxes.senders.list`](https://doorman.fyi/docs/python/reference/security.md#inboxes-senders-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.messages.discard

Python:
```python
client.messages.discard(message_id: str) -> None
```

Operation [`messages.discard`](https://doorman.fyi/docs/reference/security.md#messages-discard): `POST /v1/messages/{messageId}/discard`

Discard a held message.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.messages.feedback

Python:
```python
client.messages.feedback(message_id: str, body: models.RiskFeedback) -> models.Message
```

Operation [`messages.feedback`](https://doorman.fyi/docs/reference/security.md#messages-feedback): `POST /v1/messages/{messageId}/feedback`

Mark a message safe or unsafe.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.messages.release

Python:
```python
client.messages.release(message_id: str) -> models.Message
```

Operation [`messages.release`](https://doorman.fyi/docs/reference/security.md#messages-release): `POST /v1/messages/{messageId}/release`

Release a held message.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.security.audit

Python:
```python
client.security.audit(*, inbox_id: str | None = None, limit: int | None = None, offset: int | None = None) -> models.SecurityAuditPage
```

Operation [`security.audit`](https://doorman.fyi/docs/reference/security.md#security-audit): `GET /v1/security/audit`

Read the security audit log.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.security.iterate_audit

Python:
```python
client.security.iterate_audit(*, inbox_id: str | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.SecurityAuditEntry]
```

Every item of [`client.security.audit`](https://doorman.fyi/docs/python/reference/security.md#security-audit), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.

## client.security.get

Python:
```python
client.security.get() -> models.SecuritySettings
```

Operation [`security.get`](https://doorman.fyi/docs/reference/security.md#security-get): `GET /v1/security`

Read the security policy.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.security.preview

Python:
```python
client.security.preview(body: models.SecurityPreviewRequest) -> models.SecurityPreview
```

Operation [`security.preview`](https://doorman.fyi/docs/reference/security.md#security-preview): `POST /v1/security/preview`

Preview what a policy does to a message.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.security.update

Python:
```python
client.security.update(body: models.UpdateSecurityPolicy) -> models.SecuritySettings
```

Operation [`security.update`](https://doorman.fyi/docs/reference/security.md#security-update): `PATCH /v1/security`

Change the security policy.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.sender_rules.create

Python:
```python
client.sender_rules.create(body: models.CreateSenderRule) -> models.SenderRule
```

Operation [`senderRules.create`](https://doorman.fyi/docs/reference/security.md#senderRules-create): `POST /v1/sender-rules`

Trust or block a sender.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.sender_rules.delete

Python:
```python
client.sender_rules.delete(sender_rule_id: str) -> None
```

Operation [`senderRules.delete`](https://doorman.fyi/docs/reference/security.md#senderRules-delete): `DELETE /v1/sender-rules/{senderRuleId}`

Remove a sender rule.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.sender_rules.list

Python:
```python
client.sender_rules.list(*, inbox_id: str | None = None, standing: Literal['trusted', 'blocked'] | None = None, q: str | None = None, limit: int | None = None, offset: int | None = None) -> models.SenderRulePage
```

Operation [`senderRules.list`](https://doorman.fyi/docs/reference/security.md#senderRules-list): `GET /v1/sender-rules`

List sender rules.

Access `account`: an account-scoped key or a console session; an inbox-scoped key gets 403 `forbidden`. App tokens are refused.

## client.sender_rules.iterate

Python:
```python
client.sender_rules.iterate(*, inbox_id: str | None = None, standing: Literal['trusted', 'blocked'] | None = None, q: str | None = None, limit: int | None = None, offset: int | None = None) -> Iterator[models.SenderRule]
```

Every item of [`client.sender_rules.list`](https://doorman.fyi/docs/python/reference/security.md#senderRules-list), one page at a time: the next page is asked for when the loop reaches it. A page that does not advance raises `ApiError`.
