openemail.addresses
Каждый метод этого пространства имён: его сигнатура, параметры, что он возвращает, и пример.
Методы
Which addresses and domains the key may send from.
addresses.list()
List the addresses and domains this key may send as
def list( *, limit: int | None = None, cursor: str | None = None, api_key: str | None = None, timeout: float | None = None,) -> AddressBookPageAnswers the question behind an unexplained 403 from_address_forbidden: which addresses this key may put in from. It returns one page of the addresses created on the workspace's domains, alphabetically, each with a canSend verdict for this key, plus the domains themselves. list_all collects every page into one book and iterate walks the addresses lazily.
unrestricted is True when the key is narrowed by nothing, in which case the API accepts any local-part on the workspace's domains, including ones nobody has created. A key can be narrowed by whole domains, by individual addresses, or by both, and any of those makes unrestricted False. canSend is then True only for an enabled address the key covers, either because its domain is one of the whole domains the key holds or because the address itself is on its address list. A disabled address always reports canSend as False.
The SDK reshapes the wire envelope: the server's data list arrives as addresses, so the result is one dict holding the page, the domains and the paging fields rather than a bare list.
Параметры
limitintPage size, from 1 to 100. The server defaults to 25.
cursorstrThe
nextCursorof the previous page. Leave it out for the first page.api_keystrReports on this key instead of the one the client was built with.
timeoutfloatSeconds this call may take, the response included, before it raises
OpenEmailNetworkErrorwithis_timeout. It overrides the client'stimeoutfor this call, and0turns the limit off.
Возвращает
AddressBookPage, a dict with unrestricted, hasMore, nextCursor, addresses (each with address, enabled and canSend) and domains (each with domain, receivingVerified, sendingVerified and catchAll).
Пример
from openemail import openemail page = openemail.addresses.list(limit=100)sendable = [entry['address'] for entry in page['addresses'] if entry['canSend']]signing = [domain['domain'] for domain in page['domains'] if domain['sendingVerified']] print(page['unrestricted'], sendable, signing)Примечания
It needs
emails:send, not a read scope, because it describes what a send would accept.An app a member connected always reports
unrestrictedasFalse, because its access token is held to what that member reaches: the addresses and domains they were granted, or every domain of the workspace when their role holdsaddresses:all. That is worked out again on every call, so a domain added later appears on the next one.canSendisFalsewhen the address is disabled, when the key's allowlists leave it out, or when the domain cannot sign yet.sendingVerifiedon each domain is that last fact on its own, so a domain that is verified for receiving and not yet for sending showsreceivingVerifiedasTrueandsendingVerifiedasFalse.Only created addresses appear in
addresses. An allowlisted address with no mailbox behind it can still be sent from without ever showing up here, and a key that holds a whole domain can send as any local-part on it, including ones created after the key was.The cursor is opaque and holds where the last row sat in this order, so a row deleted or edited between pages never breaks the walk: the next page starts at the first row that sorts after it. A cursor this list did not hand out is a 400
invalid_cursor.
Также доступно в
- API
GET /addresses- TypeScript
addresses.list()- Ruby
addresses.list- CLI
openemail addresses list
addresses.list_all()
Collect every address this key may see into one book
def list_all( *, limit: int | None = None, cursor: str | None = None, api_key: str | None = None, timeout: float | None = None,) -> AddressBookResourceWalks every page of list and returns one AddressBookResource holding all addresses, alphabetically, with unrestricted and domains as the last page reported them. One request per page.
Параметры
limitintPage size for each request, from 1 to 100. The server defaults to 25.
cursorstrStarts the walk after this cursor instead of the first page.
api_keystrReports on this key instead of the one the client was built with.
timeoutfloatSeconds this call may take, the response included, before it raises
OpenEmailNetworkErrorwithis_timeout. It overrides the client'stimeoutfor this call, and0turns the limit off.
Возвращает
AddressBookResource, a dict with unrestricted, every address in addresses, and domains.
Пример
from openemail import openemail book = openemail.addresses.list_all()sendable = [entry['address'] for entry in book['addresses'] if entry['canSend']] print(book['unrestricted'], len(sendable), sendable[:10])Примечания
If any page fails, the call raises and the addresses already fetched are discarded.
Также доступно в
- API
GET /addresses- TypeScript
addresses.listAll()- Ruby
addresses.list_all
addresses.iterate()
Stream the addresses one at a time
def iterate( *, limit: int | None = None, cursor: str | None = None, api_key: str | None = None, timeout: float | None = None,) -> Iterator[AddressResource]Returns a generator that yields addresses one at a time, alphabetically, each with its canSend verdict for this key, and requests the next page only once the current one is drained. It yields addresses only, so call list for unrestricted and domains.
Параметры
limitintPage size for each request, from 1 to 100. The server defaults to 25.
cursorstrStarts the walk after this cursor instead of the first page.
api_keystrReports on this key instead of the one the client was built with.
timeoutfloatSeconds this call may take, the response included, before it raises
OpenEmailNetworkErrorwithis_timeout. It overrides the client'stimeoutfor this call, and0turns the limit off.
Возвращает
Iterator[AddressResource], a generator that yields one address per step.
Пример
from openemail import openemail for entry in openemail.addresses.iterate(): if entry['canSend']: print(entry['address'])Примечания
The generator is lazy, so an abandoned loop costs only the pages you consumed.
Также доступно в
- API
GET /addresses- TypeScript
addresses.iterate()- Ruby
addresses.iterate