Skip to the documentation
C#

client.Addresses

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

Methods

Which addresses and domains the key may send from.

Addresses.ListAsync

List the addresses and domains this key may send as

Scopesemails:readPages through results
Signature
Task<AddressBookPage> ListAsync(    int? limit = null,    string? cursor = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Answers the question behind an unexplained 403 from_address_forbidden: which addresses this key may put in from. It returns one page of the addresses the key reaches, alphabetically, as the address list of the app shows them, each with a canSend verdict for this key and the role the key reaches it with, plus the domains themselves. ListAllAsync collects every page into one book and IterateAsync 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, and every address created on them is listed. A key can be narrowed by whole domains, by individual addresses, or by both, and any of those makes unrestricted false. A narrowed key lists only what it covers: the addresses on the whole domains it holds and the addresses on its address list, and domains holds only those whole domains and the domains of the addresses on its list. An address it does not cover is left out, not listed with canSend false.

role is owner on every address when the key acts for the workspace owner, as an API key always does. An app a member connected reads member where the member may read the address and send from it, through the address itself, its whole domain or a role that reaches every address, and viewer where they may only read it, so canSend is false there.

The SDK reshapes the wire envelope: the server's data object arrives as addresses, so the result is a single AddressBookPage rather than a list.

Parameters

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?

Reports on this key instead of the one the client was built with.

cancellationTokenCancellationToken

Cancels the request.

Returns

An AddressBookPage with unrestricted, hasMore, nextCursor, addresses (objects with address, enabled, canSend and role) and domains (objects with domain, receivingVerified, sendingVerified and catchAll). Looping over it or counting it goes through addresses.

Example

using Nextmail.Constants; var page = await client.Addresses.ListAsync(); Console.WriteLine($"{(page.Unrestricted == true ? "Any address on these domains" : "Only the addresses marked")}"); foreach (var entry in page){    if ((bool?)entry["canSend"] == true)    {        Console.WriteLine($"{entry["address"]}");    }    else if ((string?)entry["role"] == AddressRoles.Viewer)    {        Console.WriteLine($"{entry["address"]} (read only)");    }} foreach (var domain in page.Domains){    Console.WriteLine($"{domain["domain"]}{((bool?)domain["sendingVerified"] == true ? "" : " (cannot sign yet)")}");}

Notes

  • It needs emails:read, or emails:send in its place: the app lists the same addresses to anyone who may read sent mail, and emails:send includes reading it, so a key that only sends can call it too.

  • An app a member connected always reports unrestricted: false, 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 holds addresses:all. That is worked out again on every call, so a domain added later appears on the next one.

  • canSend is false when the address is disabled, when the caller may only read it (role viewer), or when its domain cannot sign yet. sendingVerified on each domain is that last fact on its own, so a domain that is verified for receiving and not yet for sending shows receivingVerified: true, sendingVerified: false.

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

Also available in

API
GET /addresses
TypeScript
addresses.list()
Python
addresses.list()
Ruby
addresses.list
PHP
addresses->list
Go
Addresses.List
Java
addresses().list
CLI
nextmail addresses list

Addresses.ListAllAsync

Collect every address this key may see into one book

Scopesemails:readPages through results
Signature
Task<AddressBook> ListAllAsync(    int? limit = null,    string? cursor = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Walks every page of ListAsync and returns one AddressBook holding every address the key reaches, alphabetically, each with its canSend verdict and its role, with unrestricted and domains as the last page reported them. A key narrowed to particular addresses or domains gets only the addresses and domains it covers. One request per page.

Parameters

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?

Reports on this key instead of the one the client was built with.

cancellationTokenCancellationToken

Cancels the request.

Returns

An AddressBook with unrestricted, every address the key reaches in addresses, each with address, enabled, canSend and role, and domains. Looping over it or counting it goes through addresses.

Example

var book = await client.Addresses.ListAllAsync(limit: 100); Console.WriteLine(book.Count);

Notes

  • It needs emails:read, or emails:send in its place, as ListAsync does.

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

Also available in

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

Addresses.IterateAsync

Stream the addresses one at a time

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

Returns an IAsyncEnumerable<JsonObject> that yields the addresses the key reaches one at a time, alphabetically, each with its canSend verdict for this key and its role, and requests the next page only once the current one is drained. A key narrowed to particular addresses or domains yields only the addresses it covers. It yields addresses only. Read ListAsync for unrestricted and domains.

Parameters

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?

Reports on this key instead of the one the client was built with.

cancellationTokenCancellationToken

Cancels the request.

Returns

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

Example

await foreach (var entry in client.Addresses.IterateAsync(limit: 50)){    if ((bool?)entry["canSend"] == true)    {        Console.WriteLine($"{entry["address"]} as {entry["role"]}");    }}

Notes

  • It needs emails:read, or emails:send in its place, as ListAsync does.

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

Also available in

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