Skip to the documentation
PHP

$client->contacts

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

Methods

The workspace address book: the contacts somebody saved and the ones the app composer recorded, everyone seen in mail beside them, and for each person their audiences, photo, blocking, conversations and activity.

contacts->list

List the workspace contacts, most recently seen first

Scopescontacts:readPages through results
Signature
list(    ?string $source = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of the workspace address book, ordered by lastSeenAt with the most recent first and contacts that have never been mailed last. source says where a row came from: manual for a contact somebody saved, in the app or through contacts->create, and auto for an address recorded when a member sent mail to it from the app composer. A saved contact stays manual when it is mailed later.

source: narrows the page to one origin, so source: 'manual' is the contacts somebody saved on purpose and source: 'auto' the ones the composer recorded. q: searches the name and the address.

This lists saved contacts only. contacts->listPeople lists everyone the Contacts page in the app shows, the addresses seen in mail included, with thread counts.

Paging is keyset. limit: takes 1 to 200 and defaults to 50, and nextCursor goes back as cursor: while hasMore is true. Never build a cursor yourself.

Contacts belong to the whole workspace rather than to any one address, so a key limited to particular addresses or domains reads and writes the same book as every other key. An app connected by a member who reaches only some addresses is refused with 422 capability_unsupported on addressAllowlist, on every contacts, audiences and broadcasts route.

Parameters

sourcestring

manual, auto or form. Leave it out for the whole book.

qstring

Searches the name and the address, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead, and the pages that follow keep matching the same way.

limitint

Rows per page, a whole number from 1 to 200. The server defaults to 50.

cursorstring

The nextCursor from the previous page. Never build one yourself.

apiKeystring

Overrides the client's API key for this call only.

Returns

A Page of contact arrays, with items, hasMore and nextCursor. Each contact has email, name, source, notes, attributes, photoUrl and lastSeenAt.

Example

$page = $client->contacts->list(source: 'manual', limit: 50); foreach ($page as $contact) {    echo $contact['name'] ?? $contact['email'], ', last mailed ', $contact['lastSeenAt'] ?? 'never', PHP_EOL;} if ($page->hasMore) {    $next = $client->contacts->list(source: 'manual', limit: 50, cursor: $page->nextCursor);     echo count($next), ' more', PHP_EOL;}

Notes

  • Mail sent through this API adds no contacts. Only sends from the app composer record recipients, and contacts->create is the way to add one deliberately.

  • Every member of the workspace reads and writes the same book, so a contact saved by one person is visible to the rest.

  • A contact that has never been mailed has lastSeenAt null and sorts last, after every contact with a date.

  • Addresses are stored lower cased.

Also available in

API
GET /contacts
TypeScript
nextmail.contacts.list()
Python
contacts.list()
Ruby
contacts.list
Go
Contacts.List
Java
contacts().list
C#
Contacts.ListAsync
CLI
openemail contacts list

contacts->listAll

Collect the whole address book into one array

Scopescontacts:readPages through results
Signature
listAll(    ?string $source = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Follows nextCursor from page to page and returns every contact in the workspace, most recently seen first and never-mailed contacts last. It takes the same source: and q: filters as contacts->list.

Everything is held in memory before the call returns, and an address book grows with every recipient the composer records. Prefer contacts->iterate when you can stop early. limit: sets the page size of each request, not the total.

Parameters

sourcestring

manual, auto or form. Leave it out for the whole book.

qstring

Searches the name and the address, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead, and the pages that follow keep matching the same way.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A list of contact arrays holding every contact across all pages.

Example

$saved = $client->contacts->listAll(source: 'manual', limit: 200); echo count($saved), ' contacts saved on purpose', PHP_EOL;echo implode(PHP_EOL, array_column($saved, 'email')), PHP_EOL;

Notes

  • A failure on any page throws out of the whole call, and the contacts already fetched are discarded.

Also available in

API
GET /contacts
TypeScript
nextmail.contacts.listAll()
Python
contacts.list_all()
Ruby
contacts.list_all
Go
Contacts.ListAll
Java
contacts().listAll
C#
Contacts.ListAllAsync

contacts->iterate

Stream the address book one contact at a time

Scopescontacts:readPages through results
Signature
iterate(    ?string $source = null,    ?string $q = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields contacts one at a time, most recently seen 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 the foreach stops the requests.

Parameters

sourcestring

manual, auto or form. Leave it out for the whole book.

qstring

Searches the name and the address, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead, and the pages that follow keep matching the same way.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one contact array per step.

Example

foreach ($client->contacts->iterate(source: 'auto') as $contact) {    if ($contact['lastSeenAt'] === null) {        break;    }     echo $contact['email'], ' ', $contact['lastSeenAt'], PHP_EOL;}

Notes

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

Also available in

API
GET /contacts
TypeScript
nextmail.contacts.iterate()
Python
contacts.iterate()
Ruby
contacts.iterate
Go
Contacts.Iterate
Java
contacts().iterate
C#
Contacts.IterateAsync

contacts->get

Read one contact by email address

Scopescontacts:read
Signature
get(string $email, ?string $apiKey = null): array

Looks up a contact by address in the workspace address book. The address is trimmed and lower cased before the lookup, so [email protected] finds [email protected], and the SDK URL encodes it for the path.

A 404 means only that the address is not in the book. It says nothing about whether mail has been exchanged with it, since received mail never creates contacts.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with email, name, source, notes, attributes, the custom fields as an array of keys and text values, photoUrl and lastSeenAt, plus audiences, every audience the contact is in as an array with id, name and builtin. builtin is default on the audience every contact belongs to and null on one somebody created. A key that also holds forms:read gets signUps, what this address sent through sign-up forms, newest first and at most 20. Each is an array with id, formId, formName, status (pending or added), answers, sourceUrl, createdAt and confirmedAt.

Example

use Nextmail\Exception\NotFoundException; try {    $contact = $client->contacts->get('[email protected]');     echo $contact['name'] ?? $contact['email'], ' is in ', implode(', ', array_column($contact['audiences'], 'name')), PHP_EOL;} catch (NotFoundException) {    echo 'Not in the address book', PHP_EOL;}

Notes

  • name is null for an address recorded automatically without a display name, and notes is free text somebody set in the app or through contacts->update.

  • The address is the contact's identity here and on every other contacts route. There is no id in the public contract.

Also available in

API
GET /contacts/{email}
TypeScript
nextmail.contacts.get()
Python
contacts.get()
Ruby
contacts.get
Go
Contacts.Get
Java
contacts().get
C#
Contacts.GetAsync
CLI
openemail contacts get

contacts->create

Save a contact in the workspace address book

Scopescontacts:write
Signature
create(array $body, ?string $apiKey = null): array

Adds one address to the workspace address book and returns the saved row. email is trimmed and lower cased before it is stored, so [email protected] and [email protected] are the same contact.

The contact is saved with source set to manual, the same value a contact typed into the app carries, and it joins the default audience as it is written. Every contact is in that audience for as long as it exists, so there is nothing to add afterwards. Name audiences of your own in audienceIds to put it in them in the same call, or add it later with audiences->addContact. Sending audienceIds also requires the audiences:write scope, since it writes memberships as well as a contact.

An address can be in the book once. A second create for an address that is already there is refused with 409 contact_exists rather than merged, so a retry cannot quietly overwrite a name somebody edited in the app. Read the existing row with contacts->get and change it with contacts->update.

Parameters

emailstringRequired

The address to save, trimmed and lower cased before it is stored.

namestring|null

Display name. Leave it out to save the contact without one.

notesstring|null

Free text kept with the contact and shown beside it in the app.

attributesarray

Custom fields to set, as an array of keys and text values such as ['plan' => 'team']. A key starts with a letter and holds up to 64 letters, digits and underscores, and a value is text of up to 500 characters, trimmed before it is stored. Null or an empty string removes a field, a field you leave out keeps its value, and a contact holds at most 50.

audienceIdsstring[]

Up to 25 audience ids to put the new contact in. The default audience is joined whether or not it is named. When this is present the key also needs audiences:write, or the call is refused with 403 before anything is saved.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with email, name, source as manual, notes, attributes and lastSeenAt, which is null until mail goes to the address from the app composer, plus audiences, every audience the contact is now in, the default one included.

Example

use Nextmail\Exception\ConflictException; try {    $contact = $client->contacts->create([        'email' => '[email protected]',        'name' => 'Grace Hopper',        'notes' => 'Met at the compiler workshop.',        'attributes' => ['plan' => 'team'],        'audienceIds' => ['aud_9f2c4b7e1a0d63d84c5f2e7b'],    ]);     echo 'Saved ', $contact['email'], ' in ', count($contact['audiences']), ' audiences', PHP_EOL;} catch (ConflictException) {    echo 'Already in the book, so change it with contacts->update', PHP_EOL;}

Notes

  • The SDK does not retry a create after a network failure. If you retry by hand after a lost response, a 409 contact_exists means the first attempt landed.

  • Contacts belong to the workspace, so the contact this creates is the one every member and every other key sees.

  • An id in audienceIds that is not an audience of this workspace fails the whole create. Nothing is saved.

  • A custom field that breaks a rule is 422 invalid_contact, with param set to attributes.<key> for a bad key or a value over 500 characters and to attributes for a 51st field. Nothing is written.

Also available in

API
POST /contacts
TypeScript
nextmail.contacts.create()
Python
contacts.create()
Ruby
contacts.create
Go
Contacts.Create
Java
contacts().create
C#
Contacts.CreateAsync
CLI
openemail contacts create

contacts->update

Change a contact's name, notes or custom fields

Scopescontacts:write
Signature
update(string $email, array $patch, ?string $apiKey = null): array

Changes the fields you send and leaves the rest alone. A key you leave out keeps its stored value, and an explicit null clears it, so ['notes' => null] empties the notes while [] changes nothing. attributes is merged key by key: a string sets a custom field, null removes one and the fields you do not name are kept.

The address cannot be changed. It is the contact's identity, its path segment and the unique key of the book, so moving a contact to a new address is a contacts->delete and a contacts->create, and that new contact starts with no audience membership beyond the default one.

source and lastSeenAt are the server's to set and are not accepted here. A contact recorded automatically stays auto after you give it a name.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

namestring|null

New display name. Null clears it.

notesstring|null

New notes. Null clears them.

attributesarray

Custom fields to set, as an array of keys and text values such as ['plan' => 'team']. A key starts with a letter and holds up to 64 letters, digits and underscores, and a value is text of up to 500 characters, trimmed before it is stored. Null or an empty string removes a field, a field you leave out keeps its value, and a contact holds at most 50.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the contact as it stands after the change, with audiences alongside it.

Example

$contact = $client->contacts->update('[email protected]', [    'name' => 'Grace Hopper',    'notes' => null,    'attributes' => ['plan' => 'team', 'trial' => null],]); echo $contact['name'], ', notes ', $contact['notes'] === null ? 'cleared' : 'kept', ', plan ', $contact['attributes']['plan'] ?? 'none', PHP_EOL;

Notes

  • The SDK retries this call after a network failure, since the same patch sent twice leaves the same contact.

  • An address that is not in the book is a 404, the same as contacts->get.

  • A custom field that breaks a rule is 422 invalid_contact, with param set to attributes.<key> for a bad key or a value over 500 characters and to attributes for a 51st field. Nothing is written.

  • Audience membership is not touched here. Use contacts->setAudiences to set the whole list, or audiences->addContact and audiences->removeContact for one audience.

Also available in

API
PATCH /contacts/{email}
TypeScript
nextmail.contacts.update()
Python
contacts.update()
Ruby
contacts.update
Go
Contacts.Update
Java
contacts().update
C#
Contacts.UpdateAsync
CLI
openemail contacts update

contacts->delete

Delete somebody from the contacts and hide the address

Scopescontacts:write
Signature
delete(string $email, ?string $apiKey = null): array

Does what Delete does on the Contacts page in the app. A saved contact goes with its notes, its photo and every audience it was in, the default one included. The address is then hidden: contacts->listPeople leaves it out, and mail sent to it from the app composer no longer records it as a contact. The address can be one that was only ever seen in mail, which is how you take somebody off the people list, and wasSaved says which it was.

Nothing else moves: the mail exchanged with the address stays in the mailbox, and the address can still be written to. There is no undo. contacts->create or contacts->save afterwards brings the address back as a new contact with no name, no notes and no membership beyond the default audience.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact, email, deleted set to true and wasSaved.

Example

$removed = $client->contacts->delete('[email protected]'); echo $removed['email'], $removed['wasSaved'] ? ' was a saved contact' : ' was only seen in mail', ' and is now hidden', PHP_EOL;

Notes

  • An address that is not in the book is no longer a 404: it is hidden and answers with wasSaved false. Something that is not an address is a 422 invalid_contact.

  • The SDK does not retry a delete, though a second attempt is harmless: it answers with wasSaved false.

  • contacts->deleteMany deletes up to 200 addresses in one call.

Also available in

API
DELETE /contacts/{email}
TypeScript
nextmail.contacts.delete()
Python
contacts.delete()
Ruby
contacts.delete
Go
Contacts.Delete
Java
contacts().delete
C#
Contacts.DeleteAsync
CLI
openemail contacts delete

contacts->setAudiences

Set exactly which audiences a contact is in

Scopesaudiences:write
Signature
setAudiences(string $email, array $body, ?string $apiKey = null): array

Makes the contact's audiences match the list you send, the way the audience picker on a contact does in the app. The contact joins every listed audience it is not in yet and leaves every other one, in one transaction, and memberships it keeps keep their addedAt.

The default audience is always kept, whether or not you name it, so ['audienceIds' => []] leaves the contact in the default audience alone. To add or remove one audience without restating the rest, use audiences->addContact or audiences->removeContact.

The address is trimmed and lower cased, the SDK URL encodes it for the path, and it has to be a contact already: an address that is not in the book is a 404 contact_not_found on email. Create it with contacts->create, which takes audienceIds too. An id that is not an audience of this workspace is a 404 audience_not_found on audienceIds, and nothing is changed.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

audienceIdsstring[]Required

Every audience the contact should be in, up to 100 ids. A repeated id counts once. More than 100 is a 422 invalid_parameter on audienceIds, and an empty id is the same error on that entry, such as audienceIds.0.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the contact as it stands after the change, with audiences, every audience the contact is now in as an array with id, name and builtin, the default one included.

Example

$contact = $client->contacts->setAudiences('[email protected]', [    'audienceIds' => ['aud_9f2c4b7e1a0d63d84c5f2e7b', 'aud_1c4e7a9b2d0f36e85a7c1b4d'],]); foreach ($contact['audiences'] as $audience) {    echo $audience['name'], $audience['builtin'] === 'default' ? ', everyone' : '', PHP_EOL;}

Notes

  • audiences:write is the only scope checked, because this writes memberships rather than the contact.

  • Safe to replay: sending the same list again changes nothing. The SDK retries it after a network failure.

  • Read the current list with contacts->get first when you mean to add one audience to what the contact already has, or use audiences->addContact.

Also available in

API
PUT /contacts/{email}/audiences
TypeScript
nextmail.contacts.setAudiences()
Python
contacts.set_audiences()
Ruby
contacts.set_audiences
Go
Contacts.SetAudiences
Java
contacts().setAudiences
C#
Contacts.SetAudiencesAsync
CLI
openemail contacts set-audiences

contacts->listPeople

List everyone on the Contacts page, saved or seen in mail

Scopescontacts:readPages through results
Signature
listPeople(    ?string $q = null,    ?string $email = null,    ?string $sort = null,    ?bool $blocked = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): PeoplePage

Returns one page of the people the Contacts page in the app lists: the saved contacts, and every address seen in mail as the sender or a recipient of a thread's newest message. Each row says whether it is saved, how many threads it shares with the mailbox and when mail last moved (lastAt). A person seen in mail and saved is one row. contacts->list is the saved contacts alone.

The addresses seen in mail are included only when the key also holds threads:read, because they are read out of the mail. Without it the page holds the saved contacts and seen is false. Deleted addresses and the mailbox's own addresses are never listed.

sort: is recent, newest mail first and saved contacts never seen in mail after them, name, by name or else by address, ignoring case, or threads, most threads first. blockedBy on each row names the workspace blocklist rule that blocks it, and blocked: true narrows the page to those rows.

Paging is keyset. limit: takes 1 to 100 and defaults to 25, and nextCursor goes back as cursor:, with the same sort:, q: and blocked:, while hasMore is true.

Parameters

qstring

Searches names, addresses and notes, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead.

emailstring

One address only, matched case insensitively: the way to read one person's thread count and last mail.

sortstring

recent (the default), name or threads, also in Nextmail\Constants\PeopleSorts.

blockedbool

true for only the people the workspace blocklist blocks, whole-domain rules included.

limitint

Rows per page, 1 to 100. The server defaults to 25.

cursorstring

The nextCursor from the previous page. Never build one yourself.

apiKeystring

Overrides the client's API key for this call only.

Returns

A PeoplePage with items, hasMore, nextCursor and seen. Each person is an array with email, displayEmail, name, saved, source, notes, attributes, which is empty for an address only seen in mail, photoUrl, threads, lastAt, createdAt, updatedAt and blockedBy.

Example

use Nextmail\Constants\PeopleSorts; $people = $client->contacts->listPeople(sort: PeopleSorts::THREADS, limit: 50); if (!$people->seen) {    echo 'Saved contacts only, since this key cannot read the mail', PHP_EOL;} foreach ($people as $person) {    echo $person['name'] ?? $person['displayEmail'], ': ', $person['threads'], ' threads, ', $person['saved'] ? 'saved' : 'seen in mail', PHP_EOL;}

Notes

  • email is lower cased and is what every other contacts method takes. displayEmail keeps the capitals the newest message wrote.

  • A malformed or stale cursor is a 400 invalid_cursor. Start again without one.

  • A key limited to particular addresses or domains gets the saved contacts alone, with seen false, even when it holds threads:read, because the addresses seen in mail would be read from the mail of every address in the workspace.

Also available in

API
GET /contacts/people
TypeScript
nextmail.contacts.listPeople()
Python
contacts.list_people()
Ruby
contacts.list_people
Go
Contacts.ListPeople
Java
contacts().listPeople
C#
Contacts.ListPeopleAsync
CLI
openemail contacts list-people

contacts->listAllPeople

Collect everyone on the Contacts page into one array

Scopescontacts:readPages through results
Signature
listAllPeople(    ?string $q = null,    ?string $email = null,    ?string $sort = null,    ?bool $blocked = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Follows nextCursor from page to page and returns every person contacts->listPeople would list, in the same order and with the same filters. It is how you count the people a blocklist blocks: count($client->contacts->listAllPeople(blocked: true)).

Everything is held in memory before the call returns, and a busy mailbox has seen a great many addresses. Prefer contacts->iteratePeople when you can stop early.

Parameters

qstring

Searches names, addresses and notes, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead.

emailstring

One address only, matched case insensitively: the way to read one person's thread count and last mail.

sortstring

recent (the default), name or threads.

blockedbool

true for only the people the workspace blocklist blocks, whole-domain rules included.

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A list of person arrays holding every person across all pages.

Example

$blocked = $client->contacts->listAllPeople(blocked: true, limit: 100); echo count($blocked), ' people are blocked', PHP_EOL; foreach ($blocked as $person) {    echo $person['email'], ' by ', $person['blockedBy']['rule'], ' in ', $person['blockedBy']['list'], PHP_EOL;}

Notes

  • A failure on any page throws out of the whole call, and the people already fetched are discarded.

  • seen is not reported here. Read one page with contacts->listPeople to learn whether the key reads the people seen in mail.

Also available in

API
GET /contacts/people
TypeScript
nextmail.contacts.listAllPeople()
Python
contacts.list_all_people()
Ruby
contacts.list_all_people
Go
Contacts.ListAllPeople
Java
contacts().listAllPeople
C#
Contacts.ListAllPeopleAsync

contacts->iteratePeople

Stream everyone on the Contacts page one person at a time

Scopescontacts:readPages through results
Signature
iteratePeople(    ?string $q = null,    ?string $email = null,    ?string $sort = null,    ?bool $blocked = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields the people contacts->listPeople lists, one at a time, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and breaking out of the foreach stops the requests.

Parameters

qstring

Searches names, addresses and notes, up to 200 characters. When nothing matches exactly on the first page, close spellings are returned instead.

emailstring

One address only, matched case insensitively: the way to read one person's thread count and last mail.

sortstring

recent (the default), name or threads.

blockedbool

true for only the people the workspace blocklist blocks, whole-domain rules included.

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one person array per step.

Example

foreach ($client->contacts->iteratePeople(sort: 'threads') as $person) {    if ($person['threads'] < 5) {        break;    }     if (!$person['saved']) {        $client->contacts->save($person['email']);    }}

Notes

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

Also available in

API
GET /contacts/people
TypeScript
nextmail.contacts.iteratePeople()
Python
contacts.iterate_people()
Ruby
contacts.iterate_people
Go
Contacts.IteratePeople
Java
contacts().iteratePeople
C#
Contacts.IteratePeopleAsync

contacts->save

Save an address as a contact, or keep one that was recorded

Scopescontacts:write
Signature
save(string $email, ?array $body = null, ?string $apiKey = null): array

Does what Add to contacts and Keep in contacts do in the app, and is safe to call whatever state the address is in. An address that is not a contact yet becomes one with source manual. A contact recorded from a send becomes manual. A contact already saved keeps what it has. A deleted address is brought back.

name in the body replaces the stored name and leaving it out keeps it. notes replaces the stored notes and null clears them. attributes sets the custom fields it names and keeps the rest. Unlike contacts->create, an address already in the book is not an error, and unlike contacts->update, an address not in the book is not one either.

Parameters

emailstringRequired

The address, trimmed and lower cased on the server.

namestring

Up to 200 characters. Left out, the stored name is kept.

notesstring|null

Up to 5,000 characters. Null clears the notes, and left out, they are kept.

attributesarray

Custom fields to set, as an array of keys and text values such as ['plan' => 'team']. A key starts with a letter and holds up to 64 letters, digits and underscores, and a value is text of up to 500 characters, trimmed before it is stored. Null or an empty string removes a field, a field you leave out keeps its value, and a contact holds at most 50.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the contact as it stands after the save, with audiences.

Example

$contact = $client->contacts->save('[email protected]', ['name' => 'Grace Hopper']); echo $contact['email'], ' is ', $contact['source'], $contact['createdAt'] === $contact['updatedAt'] ? ', just added' : '', PHP_EOL;

Notes

  • The server answers 201 for a new contact and 200 for one that was there. The SDK returns the same array for both, so compare createdAt with updatedAt if you need to tell them apart.

  • Safe to replay, so the SDK retries it after a network failure.

  • A new contact joins the default audience, as it does from contacts->create.

Also available in

API
PUT /contacts/{email}
TypeScript
nextmail.contacts.save()
Python
contacts.save()
Ruby
contacts.save
Go
Contacts.Save
Java
contacts().save
C#
Contacts.SaveAsync
CLI
openemail contacts save

contacts->deleteMany

Delete up to 200 contacts in one call

Scopescontacts:write
Signature
deleteMany(array $emails, ?string $apiKey = null): array

Deletes every address in emails the way contacts->delete deletes one: a saved contact goes with its notes, its photo and every audience membership, and every address is hidden, so mail sent to it from the app composer does not record it again. Addresses that were only seen in mail are hidden too.

An entry that is not an address comes back in invalid and the rest still go through. A repeated address counts once. There is no undo.

Parameters

emailsstring[]Required

1 to 200 addresses, matched case insensitively. More than 200, or none, is a 422 on emails.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_batch_delete, deleted, saved and invalid. deleted counts the addresses deleted and hidden, saved how many of them were saved contacts.

Example

$result = $client->contacts->deleteMany(['[email protected]', '[email protected]', 'not an address']); echo $result['deleted'], ' deleted, ', $result['saved'], ' of them saved contacts', PHP_EOL; if ($result['invalid'] !== []) {    echo 'Skipped: ', implode(', ', $result['invalid']), PHP_EOL;}

Notes

  • Safe to replay: deleting an address twice leaves it deleted and hidden, so the SDK retries it after a network failure.

  • No mail is deleted, and nobody is unsubscribed from anything.

Also available in

API
POST /contacts/batch-delete
TypeScript
nextmail.contacts.deleteMany()
Python
contacts.delete_many()
Ruby
contacts.delete_many
Go
Contacts.DeleteMany
Java
contacts().deleteMany
C#
Contacts.DeleteManyAsync
CLI
openemail contacts delete-many

contacts->setPhoto

Upload the photo shown for a contact

Scopescontacts:write
Signature
setPhoto(string $email, mixed $data, ?string $contentType = null, ?string $apiKey = null): array

Sends the image bytes as the request body, replacing any photo the contact had. PNG, JPEG, WebP and GIF are accepted, up to 5 MB. The server fits the image into a 512 pixel square, stores it as WebP, keeps the first frame of an animation, and answers with the contact and its new photoUrl.

data is a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file. The type is read from contentType:, or when that is left out from the media type a PSR-7 uploaded file declares, or from the extension of the file an SplFileInfo or a stream points at. Without any of these the bytes go as application/octet-stream and the server refuses them with 422 invalid_image.

The address has to be a saved contact already: contacts->save it first.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

datastring|resource|SplFileInfo|StreamInterfaceRequired

The image: a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file.

contentTypestring

image/png, image/jpeg, image/webp or image/gif. Required for a string of bytes, and for a file or stream whose name does not end in .png, .jpg, .jpeg, .webp or .gif.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the contact with the new photoUrl.

Example

$client->contacts->save('[email protected]'); $contact = $client->contacts->setPhoto('[email protected]', file_get_contents('photo.jpg'), contentType: 'image/jpeg'); echo 'Photo at ', $contact['photoUrl'], PHP_EOL;

Notes

  • An address that is not a saved contact is a 404 contact_not_found.

  • A busy image service answers 503 image_busy, which the SDK retries like any other 503.

  • Every upload gets a new URL, so a cached old photo never shows under the new one.

Also available in

API
PUT /contacts/{email}/photo
TypeScript
nextmail.contacts.setPhoto()
Python
contacts.set_photo()
Ruby
contacts.set_photo
Go
Contacts.SetPhoto
Java
contacts().setPhoto
C#
Contacts.SetPhotoAsync
CLI
openemail contacts set-photo

contacts->removePhoto

Remove a contact photo

Scopescontacts:write
Signature
removePhoto(string $email, ?string $apiKey = null): array

Takes the photo off the contact and deletes the stored image, the way Remove does on a contact in the app. The contact answers with photoUrl null. Removing a photo from a contact that has none changes nothing.

Parameters

emailstringRequired

The contact's address, matched case insensitively.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the contact with photoUrl null.

Example

$contact = $client->contacts->removePhoto('[email protected]'); echo $contact['email'], ' now shows ', $contact['photoUrl'] ?? 'initials', PHP_EOL;

Notes

  • An address that is not a saved contact is a 404 contact_not_found.

  • Safe to replay, so the SDK retries it after a network failure.

Also available in

API
DELETE /contacts/{email}/photo
TypeScript
nextmail.contacts.removePhoto()
Python
contacts.remove_photo()
Ruby
contacts.remove_photo
Go
Contacts.RemovePhoto
Java
contacts().removePhoto
C#
Contacts.RemovePhotoAsync
CLI
openemail contacts remove-photo

contacts->block

Block an address

Scopessettings:write
Signature
block(string $email, ?string $apiKey = null): array

Puts the address on the workspace blocklist, the same list settings->update edits as blockedSenders, so mail from it is refused from then on. This is Block on a contact in the app. A plus tag is dropped: blocking [email protected] blocks [email protected], and every tag of it.

When a rule already blocks the address, a whole-domain rule included, nothing is added: created is false and blockedBy names that rule. The address does not have to be a contact.

Parameters

emailstringRequired

The address to block.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_block, email, blocked set to true, blockedBy and created.

Example

$block = $client->contacts->block('[email protected]'); if ($block['created']) {    echo 'Blocked ', $block['email'], PHP_EOL;} else {    echo 'Already blocked by ', $block['blockedBy']['rule'], ' in ', $block['blockedBy']['list'], PHP_EOL;}

Notes

  • It needs settings:write rather than contacts:write, because it writes the blocklist rather than the contact.

  • Safe to replay, so the SDK retries it after a network failure.

  • An address with fewer than two letters or numbers is refused with 422 blocklist_entry_too_broad.

  • A key limited to particular addresses or domains gets 422 capability_unsupported on addressAllowlist, because the blocklist belongs to the whole workspace and filters the mail of every address in it.

Also available in

API
POST /contacts/{email}/block
TypeScript
nextmail.contacts.block()
Python
contacts.block()
Ruby
contacts.block
Go
Contacts.Block
Java
contacts().block
C#
Contacts.BlockAsync
CLI
openemail contacts block

contacts->unblock

Unblock an address

Scopessettings:write
Signature
unblock(string $email, ?string $apiKey = null): array

Takes every workspace blocklist rule that blocks the address off the list and lists them in removed. This is Unblock on a contact in the app.

When one of them is a whole-domain rule, in blockedDomains, everybody at that domain is unblocked with it, so check removed when that matters. Rules set for one address or one domain in the settings are not touched. An address that no rule blocks answers with removed empty.

Parameters

emailstringRequired

The address to unblock.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_block, email, blocked set to false and removed, each entry of which is an array with rule and list.

Example

use Nextmail\Constants\ContactBlockLists; $unblock = $client->contacts->unblock('[email protected]'); foreach ($unblock['removed'] as $removed) {    if ($removed['list'] === ContactBlockLists::BLOCKED_DOMAINS) {        echo 'Everybody at ', $removed['rule'], ' is unblocked too', PHP_EOL;    }}

Notes

  • Safe to replay, so the SDK retries it after a network failure.

  • A key limited to particular addresses or domains gets 422 capability_unsupported on addressAllowlist, because the blocklist belongs to the whole workspace and filters the mail of every address in it.

Also available in

API
DELETE /contacts/{email}/block
TypeScript
nextmail.contacts.unblock()
Python
contacts.unblock()
Ruby
contacts.unblock
Go
Contacts.Unblock
Java
contacts().unblock
C#
Contacts.UnblockAsync
CLI
openemail contacts unblock

contacts->listThreads

List the conversations with one person

Scopesthreads:readPages through results
Signature
listThreads(    string $email,    ?string $q = null,    ?string $sort = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of the threads the address wrote or was written to, in every folder: the Mail tab on a contact in the app. Each row is a summary, subject, from, receivedAt, messageCount, hasUnread and labels, and threads->get reads the messages behind its id.

limit: takes 1 to 100 and defaults to 25. Pass nextCursor back as cursor:, with the same q: and sort:, while hasMore is true.

Parameters

emailstringRequired

The address. It does not have to be a saved contact.

qstring

Searches inside those threads, with the mailbox search syntax, up to 200 characters.

sortstring

newest (the default), oldest, sender or subject, also in Nextmail\Constants\ContactThreadSorts.

limitint

Threads per page, 1 to 100. The server defaults to 25.

cursorstring

The nextCursor from the previous page. Never build one yourself.

apiKeystring

Overrides the client's API key for this call only.

Returns

A Page of thread summary arrays, with items, hasMore and nextCursor.

Example

$threads = $client->contacts->listThreads('[email protected]', q: 'invoice', limit: 10); foreach ($threads as $thread) {    echo $thread['receivedAt'], ' ', $thread['subject'], ' (', $thread['messageCount'], ')', $thread['hasUnread'] ? ', unread' : '', PHP_EOL;}

Notes

  • It needs threads:read, because it reads mail rather than the contact.

  • A key limited to particular addresses or domains gets 422 capability_unsupported on addressAllowlist, because a contact's threads and activity are read from the mail of every address in the workspace.

Also available in

API
GET /contacts/{email}/threads
TypeScript
nextmail.contacts.listThreads()
Python
contacts.list_threads()
Ruby
contacts.list_threads
Go
Contacts.ListThreads
Java
contacts().listThreads
C#
Contacts.ListThreadsAsync
CLI
openemail contacts list-threads

contacts->listAllThreads

Collect every conversation with one person into one array

Scopesthreads:readPages through results
Signature
listAllThreads(    string $email,    ?string $q = null,    ?string $sort = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Follows nextCursor from page to page and returns every thread contacts->listThreads would list for the address, in the same order.

Everything is held in memory before the call returns. Prefer contacts->iterateThreads when you can stop early.

Parameters

emailstringRequired

The address. It does not have to be a saved contact.

qstring

Searches inside those threads, with the mailbox search syntax, up to 200 characters.

sortstring

newest (the default), oldest, sender or subject.

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A list of thread summary arrays holding every thread across all pages.

Example

$threads = $client->contacts->listAllThreads('[email protected]', sort: 'oldest', limit: 100); $unread = array_filter($threads, static fn(array $thread): bool => $thread['hasUnread']); echo count($threads), ' conversations, ', count($unread), ' with unread mail', PHP_EOL;

Notes

  • A failure on any page throws out of the whole call, and the threads already fetched are discarded.

Also available in

API
GET /contacts/{email}/threads
TypeScript
nextmail.contacts.listAllThreads()
Python
contacts.list_all_threads()
Ruby
contacts.list_all_threads
Go
Contacts.ListAllThreads
Java
contacts().listAllThreads
C#
Contacts.ListAllThreadsAsync

contacts->iterateThreads

Stream the conversations with one person one thread at a time

Scopesthreads:readPages through results
Signature
iterateThreads(    string $email,    ?string $q = null,    ?string $sort = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields the threads contacts->listThreads lists for the address, one at a time, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and breaking out of the foreach stops the requests.

Parameters

emailstringRequired

The address. It does not have to be a saved contact.

qstring

Searches inside those threads, with the mailbox search syntax, up to 200 characters.

sortstring

newest (the default), oldest, sender or subject.

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one thread summary array per step.

Example

foreach ($client->contacts->iterateThreads('[email protected]') as $thread) {    if ($thread['hasUnread']) {        echo 'Newest unread: ', $thread['subject'], ' from ', $thread['from']['email'], PHP_EOL;         break;    }}

Notes

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

Also available in

API
GET /contacts/{email}/threads
TypeScript
nextmail.contacts.iterateThreads()
Python
contacts.iterate_threads()
Ruby
contacts.iterate_threads
Go
Contacts.IterateThreads
Java
contacts().iterateThreads
C#
Contacts.IterateThreadsAsync

contacts->activity

Read how mail with one person has gone over a window

Scopesthreads:read
Signature
activity(    string $email,    ?int $minutes = null,    ?string $grain = null,    ?int $offsetMinutes = null,    ?string $apiKey = null,): array

Returns the numbers behind the Activity tab on a contact in the app, over a window that ends now: messages received from the address and sent to it per bucket, the threads that moved, the threads whose newest message is theirs and so waits on a reply from the mailbox, when each side last wrote, and the median time each side takes to answer, in milliseconds.

minutes: sets how far back the window reaches, 90 days by default. grain: sets the bucket width and the key shape, YYYY-MM-DD, YYYY-MM-DDTHH or YYYY-MM-DDTHH:MM, and offsetMinutes: shifts the boundaries so days break where the reader's day does. buckets is sparse and oldest first. Mail in the bin or in spam is left out.

Parameters

emailstringRequired

The address. It does not have to be a saved contact.

minutesint

Window length in minutes, from 1 to about 20 years. The server defaults to 90 days.

grainstring

Bucket width: minute, hour or day, defaulting to day.

offsetMinutesint

Minutes east of UTC to cut the buckets in, from -840 to 840, defaulting to 0. Pass intdiv((new DateTimeImmutable())->getOffset(), 60) for the local zone.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_activity, email, since, until, grain, buckets, totals and replyTime. totals has received, sent, threads, waiting, lastReceivedAt and lastSentAt, and replyTime has yours and theirs, each null when there is no reply to measure.

Example

$activity = $client->contacts->activity(    '[email protected]',    minutes: 30 * 24 * 60,    offsetMinutes: intdiv((new \DateTimeImmutable())->getOffset(), 60),); $totals = $activity['totals']; echo $totals['received'], ' received, ', $totals['sent'], ' sent, ', $totals['waiting'], ' waiting on a reply', PHP_EOL; if ($activity['replyTime']['yours'] !== null) {    echo 'You answer in ', round($activity['replyTime']['yours'] / 3600000, 1), ' hours', PHP_EOL;}

Notes

  • It needs threads:read, because it reads mail rather than the contact.

  • Read only, so the SDK retries it after a network failure like any other read.

  • A key limited to particular addresses or domains gets 422 capability_unsupported on addressAllowlist, because a contact's threads and activity are read from the mail of every address in the workspace.

Also available in

API
GET /contacts/{email}/activity
TypeScript
nextmail.contacts.activity()
Python
contacts.activity()
Ruby
contacts.activity
Go
Contacts.Activity
Java
contacts().activity
C#
Contacts.ActivityAsync
CLI
openemail contacts activity

contacts->listEvents

List the events recorded for one contact

Scopescontacts:readPages through results
Signature
listEvents(    string $email,    ?string $name = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of the events events->send recorded for a contact in the last 90 days, the most recent first by when they happened. Each has its name, properties, occurredAt and mode, which is test for an event a test key sent.

limit: takes 1 to 200 and defaults to 50. Pass nextCursor back as cursor:, with the same name:, while hasMore is true. listAllEvents and iterateEvents do that walk for you.

Parameters

emailstringRequired

The contact, by email address, compared without case. The contactId an event or an enrollment carries works here too.

namestring

Only events with exactly this name.

limitint

Events per page, a whole number from 1 to 200. The server defaults to 50.

cursorstring

The nextCursor from the previous page, passed back exactly as it came. One that names no event of this contact is a 400 invalid_cursor.

apiKeystring

Overrides the client's API key for this call only.

Returns

A Page of arrays with items, hasMore and nextCursor. Each item has id, contactId, email, name, properties, occurredAt, mode and createdAt.

Example

$page = $client->contacts->listEvents('[email protected]', name: 'order.placed'); foreach ($page as $event) {    echo $event['occurredAt'], ' ', $event['name'], PHP_EOL;}

Notes

  • An address or id nobody you can reach has is 404 contact_not_found. An app a member connected reads only the contacts that member added.

  • Read only, so the SDK retries it after a network failure like any other read.

Also available in

API
GET /contacts/{email}/events
TypeScript
nextmail.contacts.listEvents()
Python
contacts.list_events()
Ruby
contacts.list_events
Go
Contacts.ListEvents
Java
contacts().listEvents
C#
Contacts.ListEventsAsync
CLI
openemail contacts list-events

contacts->listAllEvents

Collect every event of one contact into one array

Scopescontacts:readPages through results
Signature
listAllEvents(    string $email,    ?string $name = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Follows nextCursor from page to page and returns every event recorded for the contact in the last 90 days, the most recent first, in the shape listEvents returns. limit: sets the page size of each request, not the total.

Parameters

emailstringRequired

The contact, by email address, compared without case. The contactId an event or an enrollment carries works here too.

namestring

Only events with exactly this name.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A nextCursor from an earlier page to start after.

apiKeystring

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

Returns

A list of arrays holding every matching event across all pages, each shaped like an item of listEvents.

Example

$events = $client->contacts->listAllEvents('[email protected]'); $names = array_unique(array_column($events, 'name')); echo count($events), ' events: ', implode(', ', $names), PHP_EOL;

Notes

  • A failure on any page throws out of the whole call, and the events already fetched are discarded.

Also available in

API
GET /contacts/{email}/events
TypeScript
nextmail.contacts.listAllEvents()
Python
contacts.list_all_events()
Ruby
contacts.list_all_events
Go
Contacts.ListAllEvents
Java
contacts().listAllEvents
C#
Contacts.ListAllEventsAsync

contacts->iterateEvents

Stream the events of one contact one at a time

Scopescontacts:readPages through results
Signature
iterateEvents(    string $email,    ?string $name = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields the events of a contact one by one, the most recent first, and requests the next page only once the current one is drained. Breaking out of the loop stops the requests.

Parameters

emailstringRequired

The contact, by email address, compared without case. The contactId an event or an enrollment carries works here too.

namestring

Only events with exactly this name.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A nextCursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one event array per step.

Example

foreach ($client->contacts->iterateEvents('[email protected]') as $event) {    if ($event['name'] === 'plan.cancelled') {        echo 'Cancelled on ', $event['occurredAt'], PHP_EOL;         break;    }}

Notes

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

Also available in

API
GET /contacts/{email}/events
TypeScript
nextmail.contacts.iterateEvents()
Python
contacts.iterate_events()
Ruby
contacts.iterate_events
Go
Contacts.IterateEvents
Java
contacts().iterateEvents
C#
Contacts.IterateEventsAsync

contacts->listCards

List the address book as contact cards

Scopescontacts:readPages through results
Signature
listCards(    ?string $email = null,    ?bool $withoutEmail = null,    ?string $kind = null,    ?string $groupId = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Page

Returns one page of contact cards, newest first. A card is a saved contact with everything an address book keeps for it: phone numbers, other email addresses, postal addresses, websites, organisation, department, job title, birthday, nickname and the name in parts. Cards with no email address, such as a plumber saved on a phone, are listed too. It is the address book phones and computers sync over CardDAV.

email: finds the card of one saved contact, and withoutEmail: true lists only the cards with no address. An address that was only ever mailed, and never saved, has no card.

Paging is keyset. limit: takes 1 to 200 and defaults to 50, and nextCursor goes back as cursor: while hasMore is true. Never build a cursor yourself.

Parameters

emailstring

Only the card of the saved contact with this address.

withoutEmailbool

True lists only the cards that have no email address.

kindstring

group lists only the groups, individual only the people and companies, as in ContactCardKinds.

groupIdstring

Only the cards in the group with this id.

limitint

Cards per page, a whole number from 1 to 200. The server defaults to 50.

cursorstring

The nextCursor from the previous page. Never build one yourself.

apiKeystring

Overrides the client's API key for this call only.

Returns

A Page of card arrays, with items, hasMore and nextCursor. Each card has id, uid, email, name, nameParts, nickname, organization, department, title, birthday, notes, the lists emails, phones, addresses and urls, photoUrl, createdAt and updatedAt.

Example

$page = $client->contacts->listCards(withoutEmail: true); foreach ($page as $card) {    echo $card['name'] ?? 'No name', ': ', implode(', ', array_column($card['phones'], 'value')), PHP_EOL;} if ($page->hasMore) {    $next = $client->contacts->listCards(withoutEmail: true, cursor: $page->nextCursor);     echo count($next), ' more', PHP_EOL;}

Notes

  • Every member reads the same address book through a key, since a key acts for the workspace owner.

  • A cursor that names no card is a 400 invalid_cursor. Start again without one.

Also available in

API
GET /contacts/cards
TypeScript
nextmail.contacts.listCards()
Python
contacts.list_cards()
Ruby
contacts.list_cards
Go
Contacts.ListCards
Java
contacts().listCards
C#
Contacts.ListCardsAsync
CLI
openemail contacts list-cards

contacts->listAllCards

Collect every contact card into one array

Scopescontacts:readPages through results
Signature
listAllCards(    ?string $email = null,    ?bool $withoutEmail = null,    ?string $kind = null,    ?string $groupId = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): array

Follows nextCursor from page to page and returns every card in the address book, newest first. It takes the same email: and withoutEmail: filters as contacts->listCards.

Everything is held in memory before the call returns. Prefer contacts->iterateCards when you can stop early. limit: sets the page size of each request, not the total.

Parameters

emailstring

Only the card of the saved contact with this address.

withoutEmailbool

True lists only the cards that have no email address.

kindstring

group lists only the groups, individual only the people and companies, as in ContactCardKinds.

groupIdstring

Only the cards in the group with this id.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A list of card arrays holding every card across all pages.

Example

$cards = $client->contacts->listAllCards(); echo count($cards), ' cards in the address book', PHP_EOL;

Notes

  • A failure on any page throws out of the whole call, and the cards already fetched are discarded.

Also available in

API
GET /contacts/cards
TypeScript
nextmail.contacts.listAllCards()
Python
contacts.list_all_cards()
Ruby
contacts.list_all_cards
Go
Contacts.ListAllCards
Java
contacts().listAllCards
C#
Contacts.ListAllCardsAsync

contacts->iterateCards

Stream the address book one card at a time

Scopescontacts:readPages through results
Signature
iterateCards(    ?string $email = null,    ?bool $withoutEmail = null,    ?string $kind = null,    ?string $groupId = null,    ?int $limit = null,    ?string $cursor = null,    ?string $apiKey = null,): Generator

Returns a Generator that yields cards one 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 the foreach stops the requests. It takes the same email: and withoutEmail: filters as contacts->listCards.

Parameters

emailstring

Only the card of the saved contact with this address.

withoutEmailbool

True lists only the cards that have no email address.

kindstring

group lists only the groups, individual only the people and companies, as in ContactCardKinds.

groupIdstring

Only the cards in the group with this id.

limitint

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one card array per step.

Example

foreach ($client->contacts->iterateCards() as $card) {    if ($card['birthday'] !== null) {        echo $card['name'], ': ', $card['birthday'], PHP_EOL;    }}

Notes

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

Also available in

API
GET /contacts/cards
TypeScript
nextmail.contacts.iterateCards()
Python
contacts.iterate_cards()
Ruby
contacts.iterate_cards
Go
Contacts.IterateCards
Java
contacts().iterateCards
C#
Contacts.IterateCardsAsync

contacts->getCard

Get one contact card

Scopescontacts:read
Signature
getCard(string $id, ?string $apiKey = null): array

Returns one card with everything it holds. To find the card of a saved contact by its address, pass email: to contacts->listCards.

Parameters

idstringRequired

The card id, ccd_ followed by 24 characters, from contacts->listCards or contacts->getCard.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with id, uid, the vCard UID that phones and computers know the card by, email, null on a card with no address, name, nameParts, nickname, organization, department, title, birthday, notes, photoUrl, createdAt and updatedAt. emails, phones and urls are lists of arrays with value, label and customLabel, and addresses is a list of arrays with label, customLabel, street, locality, region, postalCode and country.

Example

use Nextmail\Exception\NotFoundException; try {    $card = $client->contacts->getCard('ccd_0123456789abcdef01234567');     echo $card['name'], ', ', $card['organization'] ?? 'no organisation', PHP_EOL;} catch (NotFoundException) {    echo 'No card has that id', PHP_EOL;}

Notes

Also available in

API
GET /contacts/cards/{id}
TypeScript
nextmail.contacts.getCard()
Python
contacts.get_card()
Ruby
contacts.get_card
Go
Contacts.GetCard
Java
contacts().getCard
C#
Contacts.GetCardAsync
CLI
openemail contacts get-card

contacts->createCard

Add a card to the address book

Scopescontacts:write
Signature
createCard(array $body, ?string $apiKey = null): array

Adds a contact card. With email the card is a saved contact as well, the same one contacts->create makes, and an address the workspace already knows from mail becomes saved. Without one it is a card on its own, kept for its name, phone numbers and the rest. A card needs at least a name, an email address, a phone number or an organisation.

Each entry in emails, phones and urls is an array with value, and optionally label, one of Nextmail\Constants\ContactCardLabels, and customLabel, a label of your own.

Phones and computers that sync the address book over CardDAV get the new card on their next sync.

Parameters

emailstring|null

The address Nextmail knows the contact by. With it the card is a saved contact as well. A saved contact keeps its address, so put any other address in emails.

namestring|null

The full name the address book shows, up to 200 characters.

namePartsarray|null

The name in parts, an array with prefix, given, middle, family and suffix, the way phones keep it.

nicknamestring|null

A nickname.

organizationstring|null

The company or organisation.

departmentstring|null

The department within the organisation.

titlestring|null

The job title.

birthdaystring|null

YYYY-MM-DD, or --MM-DD when the year is not known.

notesstring|null

Free-form notes. On a saved contact these are the notes the contact page shows.

emailsarray

Other email addresses besides email, each an array with value, and optionally label and customLabel.

phonesarray

Phone numbers, each an array with value, and optionally label and customLabel.

addressesarray

Postal addresses, each an array with any of label, customLabel, street, locality, region, postalCode and country.

urlsarray

Websites and profile links, each an array with value, and optionally label and customLabel.

kindstring

group makes a group, the kind phones keep, which needs name and takes members instead of an address. individual when left out.

membersarray

For a group, the ids of the cards in it, up to 2,000. Groups cannot hold other groups.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the new card, with the fields contacts->getCard returns.

Example

use Nextmail\Constants\ContactCardLabels; $card = $client->contacts->createCard([    'email' => '[email protected]',    'name' => 'Ada Lovelace',    'organization' => 'Analytical Engines',    'phones' => [['value' => '+44 20 7946 0000', 'label' => ContactCardLabels::WORK]],    'birthday' => '1815-12-10',]); echo $card['id'], ' ', $card['email'], PHP_EOL;

Notes

  • The SDK does not retry it after a network failure, because a second call would make a second card.

  • An address that already belongs to another card is a 409 contact_card_email_taken, and a card with nothing to keep a 422 invalid_contact_card.

  • A workspace that already keeps as many cards as it may gets a 409 contact_card_limit. Delete some before you add more.

Also available in

API
POST /contacts/cards
TypeScript
nextmail.contacts.createCard()
Python
contacts.create_card()
Ruby
contacts.create_card
Go
Contacts.CreateCard
Java
contacts().createCard
C#
Contacts.CreateCardAsync
CLI
openemail contacts create-card

contacts->updateCard

Change a contact card

Scopescontacts:write
Signature
updateCard(string $id, array $patch, ?string $apiKey = null): array

Changes the fields you send and leaves the rest alone. Null clears a field, and a list you send (emails, phones, addresses or urls) replaces the whole list, so read the card first when you mean to add one entry.

On a saved contact, name and notes are the contact's own, so the contact page shows the change. email can only be given to a card that has none, which makes it a saved contact. A saved contact keeps its address: add another address to emails instead.

Phones and computers that sync the address book over CardDAV get the change on their next sync.

Parameters

idstringRequired

The card id, ccd_ followed by 24 characters, from contacts->listCards or contacts->getCard.

emailstring|null

The address Nextmail knows the contact by. Given to a card that has none, it makes the card a saved contact. A saved contact keeps its address, so put any other address in emails.

namestring|null

The full name the address book shows, up to 200 characters.

namePartsarray|null

The name in parts, an array with prefix, given, middle, family and suffix, the way phones keep it.

nicknamestring|null

A nickname.

organizationstring|null

The company or organisation.

departmentstring|null

The department within the organisation.

titlestring|null

The job title.

birthdaystring|null

YYYY-MM-DD, or --MM-DD when the year is not known.

notesstring|null

Free-form notes. On a saved contact these are the notes the contact page shows.

emailsarray

Other email addresses besides email, each an array with value, and optionally label and customLabel. The list replaces the one the card has.

phonesarray

Phone numbers, each an array with value, and optionally label and customLabel. The list replaces the one the card has.

addressesarray

Postal addresses, each an array with any of label, customLabel, street, locality, region, postalCode and country. The list replaces the one the card has.

urlsarray

Websites and profile links, each an array with value, and optionally label and customLabel. The list replaces the one the card has.

kindstring

What the card already is. A person cannot become a group or a group a person, so any other value is a 422 invalid_contact_card.

membersarray

For a group, the ids of the cards in it. Given, it replaces the whole list, so send the ids already in it with the ones you add.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the card as it stands after the change.

Example

use Nextmail\Constants\ContactCardLabels; $card = $client->contacts->getCard('ccd_0123456789abcdef01234567'); $updated = $client->contacts->updateCard($card['id'], [    'phones' => [...$card['phones'], ['value' => '+1 555 0100', 'label' => ContactCardLabels::MOBILE]],]); echo count($updated['phones']), ' phone numbers', PHP_EOL;

Notes

Also available in

API
PATCH /contacts/cards/{id}
TypeScript
nextmail.contacts.updateCard()
Python
contacts.update_card()
Ruby
contacts.update_card
Go
Contacts.UpdateCard
Java
contacts().updateCard
C#
Contacts.UpdateCardAsync
CLI
openemail contacts update-card

contacts->deleteCard

Delete a contact card

Scopescontacts:write
Signature
deleteCard(string $id, ?string $apiKey = null): array

Removes the card from the address book and from every phone and computer that syncs it. On a saved contact it is the same as contacts->delete: the contact goes with its notes, photo and audiences, and the address is hidden from the people list and the suggestions.

Parameters

idstringRequired

The card id, ccd_ followed by 24 characters, from contacts->listCards or contacts->getCard.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_card, id and deleted set to true.

Example

$removed = $client->contacts->deleteCard('ccd_0123456789abcdef01234567'); echo $removed['id'], ' deleted', PHP_EOL;

Notes

  • There is no undo, and the SDK does not retry it after a network failure.

  • An id that names no card is a 404 contact_card_not_found.

Also available in

API
DELETE /contacts/cards/{id}
TypeScript
nextmail.contacts.deleteCard()
Python
contacts.delete_card()
Ruby
contacts.delete_card
Go
Contacts.DeleteCard
Java
contacts().deleteCard
C#
Contacts.DeleteCardAsync
CLI
openemail contacts delete-card

contacts->findDuplicateCards

Find duplicate contact cards

Scopescontacts:read
Signature
findDuplicateCards(?string $apiKey = null): array

Finds the cards in the address book that look like the same person, as Find duplicates on the Contacts page of the app does: cards that share an email address or a phone number, or that have the same full name. Each group in data lists its cards with the most complete one first, which is the card to keep when you pass the rest to contacts->mergeCards.

Groups found by a shared address come first, then by phone number, then by name. Phone numbers match on their last nine digits, so +44 20 7946 0000 and 020 7946 0000 are the same number. Group cards are never compared.

Parameters

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with data, each group an array with object set to contact_card_duplicates, reason, as in ContactCardDuplicateReasons, and cards, and hasMore, true when more than 100 groups were found.

Example

$found = $client->contacts->findDuplicateCards(); foreach ($found['data'] as $group) {    $keep = $group['cards'][0];     echo $group['reason'], ': keep ', $keep['name'] ?? $keep['id'], ', merge ', count($group['cards']) - 1, PHP_EOL;}

Notes

  • It reads every card, so call it when somebody asks rather than on every page load.

  • With hasMore, merge the groups you have and call it again for the rest.

Also available in

API
GET /contacts/cards/duplicates
TypeScript
nextmail.contacts.findDuplicateCards()
Python
contacts.find_duplicate_cards()
Ruby
contacts.find_duplicate_cards
Go
Contacts.FindDuplicateCards
Java
contacts().findDuplicateCards
C#
Contacts.FindDuplicateCardsAsync
CLI
openemail contacts find-duplicate-cards

contacts->mergeCards

Merge contact cards

Scopescontacts:write
Signature
mergeCards(string $id, array $body, ?string $apiKey = null): array

Folds other cards into the card id names and deletes them, as Merge does in Find duplicates on the Contacts page of the app. Fields the kept card leaves empty are filled from the others, notes are joined, and every email address, phone number, postal address and website is kept. Groups that held the other cards hold the kept one instead.

A saved contact among the others stays known by its address, in the people list and in its audiences, but it leaves the address book. When the kept card has no address of its own, it becomes the saved contact of the first address the others had. Phones and computers that sync the address book over CardDAV get the change on their next sync.

Parameters

idstringRequired

The card to keep, from contacts->listCards, contacts->getCard or contacts->findDuplicateCards.

cardIdsarrayRequired

The cards to fold into it, 1 to 10 of them. They are deleted once their details are kept.

apiKeystring

Overrides the client's API key for this call only.

Returns

The card that kept everything, as an array.

Example

$card = $client->contacts->mergeCards('ccd_0123456789abcdef01234567', ['cardIds' => ['ccd_89abcdef0123456789abcdef']]); echo $card['name'] ?? $card['id'], ' keeps ', count($card['emails']), ' other addresses', PHP_EOL;

Notes

  • There is no undo, and the SDK does not retry it after a network failure.

  • Naming the kept card among cardIds, or a group anywhere, is a 422 invalid_contact_card, and an id that names no card a 404 contact_card_not_found.

Also available in

API
POST /contacts/cards/{id}/merge
TypeScript
nextmail.contacts.mergeCards()
Python
contacts.merge_cards()
Ruby
contacts.merge_cards
Go
Contacts.MergeCards
Java
contacts().mergeCards
C#
Contacts.MergeCardsAsync
CLI
openemail contacts merge-cards

contacts->listBirthdays

List birthdays

Scopescontacts:read
Signature
listBirthdays(    DateTimeInterface|string $from,    DateTimeInterface|string $to,    ?string $timezone = null,    ?string $apiKey = null,): array

Returns the birthdays of the people in the address book that fall between from: and to:, the birthdays calendar the Calendar page of the app can show. There is one entry for each date, so a window of a whole year can hold somebody twice, and age is how old they turn that day when the card holds the year of birth. Somebody born on 29 February has their birthday on 28 February in other years.

from: and to: take a DateTimeInterface or an ISO 8601 string and may be at most 366 days apart. timezone:, UTC unless you say, decides which day the window starts and ends on.

Parameters

fromstring|DateTimeInterfaceRequired

The start of the window.

tostring|DateTimeInterfaceRequired

The end of the window, after from: and at most 366 days later.

timezonestring

IANA zone such as Europe/London, at most 64 characters. Defaults to UTC.

apiKeystring

Overrides the client's API key for this call only.

Returns

A list of arrays sorted by date and then by name, each with cardId, contactId, email, name, birthday, date, age and photoUrl.

Example

$from = new \DateTimeImmutable();$birthdays = $client->contacts->listBirthdays(from: $from, to: $from->modify('+30 days'), timezone: 'Europe/London'); foreach ($birthdays as $birthday) {    echo $birthday['date'], ' ', $birthday['name'] ?? $birthday['cardId'], ' ', $birthday['age'] ?? 'age not known', PHP_EOL;}

Notes

  • A value that does not parse, a reversed or overlong window, or an unknown zone is a 400 invalid_parameter naming the field.

Also available in

API
GET /contacts/birthdays
TypeScript
nextmail.contacts.listBirthdays()
Python
contacts.list_birthdays()
Ruby
contacts.list_birthdays
Go
Contacts.ListBirthdays
Java
contacts().listBirthdays
C#
Contacts.ListBirthdaysAsync
CLI
openemail contacts list-birthdays

contacts->importVcf

Import a contacts file

Scopescontacts:write
Signature
importVcf(mixed $data, ?string $filename = null, ?string $apiKey = null): array

Sends a vCard (.vcf) file as the request body and queues it. Every card in it becomes a contact card, with its phone numbers, addresses and the rest. Poll contacts->getImport until status is completed.

The file may be 20 MB. Imported contacts join no audience, so a broadcast never reaches them because of an import. A card whose address or UID is already in the address book is counted under merged and left as it is, and a card with no address is matched on its phone number. A workspace keeps 20,000 cards, and the cards past that are counted under skipped.

data is a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file, and it goes out as text/vcard whatever the file is called.

Parameters

datastring|resource|SplFileInfo|StreamInterfaceRequired

The .vcf file: a string of bytes, a stream resource, an SplFileInfo or a PSR-7 stream or uploaded file.

filenamestring

The name to show for the file in the list of imports, at most 255 characters. It is not read from the file, so left out the import has fileName null.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the import with object set to contact_import and status set to queued, shaped like the one contacts->getImport returns.

Example

use Nextmail\Constants\ItemImportStatuses; $import = $client->contacts->importVcf(new \SplFileInfo('contacts.vcf'), filename: 'contacts.vcf'); while (in_array($import['status'], [ItemImportStatuses::QUEUED, ItemImportStatuses::RUNNING], true)) {    sleep(2);     $import = $client->contacts->getImport($import['id']);} echo $import['status'], ': ', $import['counts']['imported'], ' cards added, ', $import['counts']['merged'], ' already here', PHP_EOL;

Notes

  • A body that holds no vCard is a 400 not_a_contacts_file, and an empty one a 400 item_import_empty.

  • A file over 20 MB is a 413 item_import_too_large.

  • Text you already hold goes in as it is, since a PHP string is already bytes.

  • An upload that outlasts the client's timeout fails as a NetworkException, so raise it on the client for a large file on a slow connection.

  • Not retried automatically.

Also available in

API
POST /contacts/imports
TypeScript
nextmail.contacts.importVcf()
Python
contacts.import_vcf()
Ruby
contacts.import_vcf
Go
Contacts.ImportVcf
Java
contacts().importVcf
C#
Contacts.ImportVcfAsync
CLI
openemail contacts import-vcf

contacts->listImports

List contacts imports

Scopescontacts:readPages through results
Signature
listImports(?int $limit = null, ?string $cursor = null, ?string $apiKey = null): Page

Returns one page of the contacts files and address books brought in, newest first, each with what it added and what it left out. Beside the files sent with contacts->importVcf it lists the address books that came with a mailbox import, and those carry the id of that import in parentImportId.

Paging is keyset. limit: takes 1 to 100 and defaults to 25, and nextCursor goes back as cursor: while hasMore is true. contacts->listAllImports and contacts->iterateImports do that walk for you.

Parameters

limitint

Imports per page, a whole number from 1 to 100. The server defaults to 25.

cursorstring

The nextCursor from the previous page. Never build one yourself.

apiKeystring

Overrides the client's API key for this call only.

Returns

A Page of import arrays, with items, hasMore and nextCursor. Each import is shaped like the one contacts->getImport returns.

Example

$page = $client->contacts->listImports(limit: 50); foreach ($page as $import) {    echo $import['fileName'] ?? 'From a mailbox import', ': ', $import['status'], ', ', $import['counts']['imported'], ' added, ', $import['counts']['merged'], ' already here', PHP_EOL;} if ($page->hasMore) {    $next = $client->contacts->listImports(limit: 50, cursor: $page->nextCursor);     echo count($next), ' more', PHP_EOL;}

Notes

  • source is file for an upload. takeout, carddav and microsoft came with a mailbox import.

  • A cursor that names no import is a 400 invalid_cursor.

  • A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's maxRetries, and on a 429 only when it carries a Retry-After of a minute or less.

Also available in

API
GET /contacts/imports
TypeScript
nextmail.contacts.listImports()
Python
contacts.list_imports()
Ruby
contacts.list_imports
Go
Contacts.ListImports
Java
contacts().listImports
C#
Contacts.ListImportsAsync
CLI
openemail contacts list-imports

contacts->listAllImports

Collect every contacts import into one array

Scopescontacts:readPages through results
Signature
listAllImports(?int $limit = null, ?string $cursor = null, ?string $apiKey = null): array

Follows nextCursor from page to page and returns every contacts import, newest first.

Everything is held in memory before the call returns. Prefer contacts->iterateImports when you can stop early. limit: sets the page size of each request, not the total.

Parameters

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A list of import arrays holding every import across all pages.

Example

$imports = $client->contacts->listAllImports(); $added = array_sum(array_map(static fn(array $import): int => (int) $import['counts']['imported'], $imports)); echo $added, ' cards came from ', count($imports), ' imports', PHP_EOL;

Notes

  • A failure on any page throws out of the whole call, and the imports already fetched are discarded.

Also available in

API
GET /contacts/imports
TypeScript
nextmail.contacts.listAllImports()
Python
contacts.list_all_imports()
Ruby
contacts.list_all_imports
Go
Contacts.ListAllImports
Java
contacts().listAllImports
C#
Contacts.ListAllImportsAsync

contacts->iterateImports

Stream contacts imports one at a time

Scopescontacts:readPages through results
Signature
iterateImports(?int $limit = null, ?string $cursor = null, ?string $apiKey = null): Generator

Returns a Generator that yields contacts imports one 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 the foreach stops the requests.

Parameters

limitint

Page size per request, from 1 to 100, defaulting to 25 on the server.

cursorstring

A cursor from an earlier page to start after.

apiKeystring

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

Returns

A Generator that yields one import array per step.

Example

use Nextmail\Constants\ItemImportStatuses; foreach ($client->contacts->iterateImports() as $import) {    if ($import['status'] === ItemImportStatuses::RUNNING) {        echo 'Still running: ', $import['id'], ' with ', $import['counts']['total'], ' cards', PHP_EOL;         break;    }}

Notes

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

Also available in

API
GET /contacts/imports
TypeScript
nextmail.contacts.iterateImports()
Python
contacts.iterate_imports()
Ruby
contacts.iterate_imports
Go
Contacts.IterateImports
Java
contacts().iterateImports
C#
Contacts.IterateImportsAsync

contacts->getImport

Get a contacts import

Scopescontacts:read
Signature
getImport(string $id, ?string $apiKey = null): array

Returns one contacts import with its counts and its report: the files it read, how many cards it left out and why, and up to 20 of the cards it left out. Poll it after contacts->importVcf until status is completed or failed.

counts.imported is what was added, counts.merged the cards left as they were because they were already in the address book, and counts.skipped what was left out, which report.skipped breaks down by reason: limit for a card past the 20,000 a workspace keeps, invalid for one that could not be read and empty for one that held nothing.

Parameters

idstringRequired

Contacts import id, iimp_ followed by 24 hex characters.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array with object set to contact_import, id, kind, source, status, fileName, fileBytes, parentImportId, counts, report, lastError, undoable, createdAt, startedAt, finishedAt and undoneAt. counts holds total, imported, merged, skipped and failed. report holds collections, a list of arrays with name and items, skipped, a count for each reason, and samples, a list of arrays with name and reason. status is one of Nextmail\Constants\ItemImportStatuses and each reason one of Nextmail\Constants\ItemImportSkipReasons.

Example

$import = $client->contacts->getImport('iimp_7b1e4d8f60a5c7b92d3f9c2a'); echo $import['status'], ': ', $import['counts']['imported'], ' added, ', $import['counts']['merged'], ' already here, ', $import['counts']['skipped'], ' left out', PHP_EOL; foreach ($import['report']['samples'] as $sample) {    echo $sample['name'], ' was left out: ', $sample['reason'], PHP_EOL;}

Notes

  • An id that names no contacts import is a 404 item_import_not_found, thrown as a NotFoundException.

  • A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's maxRetries, and on a 429 only when it carries a Retry-After of a minute or less.

Also available in

API
GET /contacts/imports/{id}
TypeScript
nextmail.contacts.getImport()
Python
contacts.get_import()
Ruby
contacts.get_import
Go
Contacts.GetImport
Java
contacts().getImport
C#
Contacts.GetImportAsync
CLI
openemail contacts get-import

contacts->undoImport

Remove what a contacts import added

Scopescontacts:write
Signature
undoImport(string $id, ?string $apiKey = null): array

Deletes every contact and card the import added, changed since or not, and marks the import undone. Contacts that were already in the address book are not touched.

Parameters

idstringRequired

Contacts import id, iimp_ followed by 24 hex characters.

apiKeystring

Overrides the client's API key for this call only.

Returns

An array for the import with status set to undone and undoneAt set.

Example

use Nextmail\Exception\ConflictException; try {    $undone = $client->contacts->undoImport('iimp_7b1e4d8f60a5c7b92d3f9c2a');     echo $undone['counts']['imported'], ' cards removed at ', $undone['undoneAt'], PHP_EOL;} catch (ConflictException) {    echo 'That import is still running or was already removed', PHP_EOL;}

Notes

  • An import that is still running, or was already removed, is a 409 item_import_not_undoable, thrown as a ConflictException. undoable on the import says whether the call would remove anything.

  • An id that names no contacts import is a 404 item_import_not_found.

  • Not retried automatically.

Also available in

API
POST /contacts/imports/{id}/undo
TypeScript
nextmail.contacts.undoImport()
Python
contacts.undo_import()
Ruby
contacts.undo_import
Go
Contacts.UndoImport
Java
contacts().undoImport
C#
Contacts.UndoImportAsync
CLI
openemail contacts undo-import