Masked Email client library

class fastmask.masked_email.MaskedMailClient(username: str, token: str)

Bases: object

Client for interfacing with Fastmail’s Masked Email JMAP API

https://www.fastmail.com/developer/maskedemail/

https://jmap.io/

delete(masked_id: str) dict

Delete Masked Email

Address will appear under ‘Review deleted masked address’ and will remain recoverable. Does not permanently delete.

disable(masked_id: str) dict

Set Masked Email to blocked

enable(masked_id: str) dict

Set Masked Email to active

get(ids: list[str] | None = None, filters: Callable | None = None, sort_by: str = 'createdAt', sort_order: str = 'asc', limit: int | None = None) list[dict]

Get Masked Emails associated with account.

ids [optional]: Return Masked Emails matching IDs filters [optional]: Optionally filter list results by field (see https://www.fastmail.com/developer/maskedemail/#object for options) sort_by [optional]: Field to sort results by sort_order [optional]: Whether to sort ascending or descending. Accepted values: ‘asc’ or ‘desc’ limit: Number of results to return

get_account_id() str

Return the accountId for the account matching self.username

Borrowed from Fastmail’s tiny_jmap_library.py: https://github.com/fastmail/JMAP-Samples

get_active() list[dict]

Get all active Masked Emails

get_api_url() str

Get API URL from session

get_deleted() list[dict]

Get all deleted Masked Emails

get_disabled() list[dict]

Get all blocked Masked Emails

get_recent(timeframe: timedelta = datetime.timedelta(days=3)) list[dict]

Get recently created Masked Emails (default is 3 days)

get_session() dict

Return the JMAP Session Resource as a Python dict

Borrowed from Fastmail’s tiny_jmap_library.py: https://github.com/fastmail/JMAP-Samples

get_unused() list[dict]

Get all active Masked Emails that have not received messages

new(url: str | None = None, domain: str = '', description: str = '', state: str = 'enabled')

Created a new Masked Email, optionally setting url, forDomain, description

search(query: str, fields: list[str] = ['email', 'description']) list[dict]

Search for Masked Emails matching query text

Defaults to searching email and description fields only.

update(masked_id: str, changes: dict) dict

Update an existing Masked Email