दस्तावेज़ पर जाएँ
PHP

$client->contacts

इस नेमस्पेस का हर मेथड: उसका सिग्नेचर, उसके पैरामीटर, वह क्या लौटाता है और एक उदाहरण।

मेथड

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

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

sourcestring

manual or auto. 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.

लौटाता है

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

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts
TypeScript
contacts.list()
Python
contacts.list()
Ruby
contacts.list
CLI
openemail contacts list

contacts->listAll

Collect the whole address book into one array

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

sourcestring

manual or auto. 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.

लौटाता है

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

उदाहरण

$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;

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts
TypeScript
contacts.listAll()
Python
contacts.list_all()
Ruby
contacts.list_all

contacts->iterate

Stream the address book one contact at a time

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

sourcestring

manual or auto. 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.

लौटाता है

A Generator that yields one contact array per step.

उदाहरण

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

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts
TypeScript
contacts.iterate()
Python
contacts.iterate()
Ruby
contacts.iterate

contacts->get

Read one contact by email address

स्कोपcontacts:read
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

apiKeystring

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

लौटाता है

An array with email, name, source, notes, 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.

उदाहरण

use OpenEmail\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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/{email}
TypeScript
contacts.get()
Python
contacts.get()
Ruby
contacts.get
CLI
openemail contacts get

contacts->create

Save a contact in the workspace address book

स्कोपcontacts:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

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.

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.

लौटाता है

An array with email, name, source as manual, notes 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.

उदाहरण

use OpenEmail\Exception\ConflictException; try {    $contact = $client->contacts->create([        'email' => '[email protected]',        'name' => 'Grace Hopper',        'notes' => 'Met at the compiler workshop.',        '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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
POST /contacts
TypeScript
contacts.create()
Python
contacts.create()
Ruby
contacts.create
CLI
openemail contacts create

contacts->update

Change a contact's name or notes

स्कोपcontacts:write
सिग्नेचर
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.

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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

namestring|null

New display name. Null clears it.

notesstring|null

New notes. Null clears them.

apiKeystring

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

लौटाता है

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

उदाहरण

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

टिप्पणियाँ

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

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

इनमें भी उपलब्ध

API
PATCH /contacts/{email}
TypeScript
contacts.update()
Python
contacts.update()
Ruby
contacts.update
CLI
openemail contacts update

contacts->delete

Delete somebody from the contacts and hide the address

स्कोपcontacts:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

apiKeystring

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

लौटाता है

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

उदाहरण

$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;

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
DELETE /contacts/{email}
TypeScript
contacts.delete()
Python
contacts.delete()
Ruby
contacts.delete
CLI
openemail contacts delete

contacts->setAudiences

Set exactly which audiences a contact is in

स्कोपaudiences:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

audienceIdsstring[]आवश्यक

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.

लौटाता है

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.

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
PUT /contacts/{email}/audiences
TypeScript
contacts.setAudiences()
Python
contacts.set_audiences()
Ruby
contacts.set_audiences
CLI
openemail contacts set-audiences

contacts->listPeople

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

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

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 OpenEmail\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.

लौटाता है

A PeoplePage with items, hasMore, nextCursor and seen. Each person is an array with email, displayEmail, name, saved, source, notes, photoUrl, threads, lastAt, createdAt, updatedAt and blockedBy.

उदाहरण

use OpenEmail\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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/people
TypeScript
contacts.listPeople()
Python
contacts.list_people()
Ruby
contacts.list_people
CLI
openemail contacts list-people

contacts->listAllPeople

Collect everyone on the Contacts page into one array

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

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.

लौटाता है

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

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/people
TypeScript
contacts.listAllPeople()
Python
contacts.list_all_people()
Ruby
contacts.list_all_people

contacts->iteratePeople

Stream everyone on the Contacts page one person at a time

स्कोपcontacts:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

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.

लौटाता है

A Generator that yields one person array per step.

उदाहरण

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

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/people
TypeScript
contacts.iteratePeople()
Python
contacts.iterate_people()
Ruby
contacts.iterate_people

contacts->save

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

स्कोपcontacts:write
सिग्नेचर
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. 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.

पैरामीटर

emailstringआवश्यक

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.

apiKeystring

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

लौटाता है

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

उदाहरण

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

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
PUT /contacts/{email}
TypeScript
contacts.save()
Python
contacts.save()
Ruby
contacts.save
CLI
openemail contacts save

contacts->deleteMany

Delete up to 200 contacts in one call

स्कोपcontacts:write
सिग्नेचर
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.

पैरामीटर

emailsstring[]आवश्यक

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.

लौटाता है

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.

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
POST /contacts/batch-delete
TypeScript
contacts.deleteMany()
Python
contacts.delete_many()
Ruby
contacts.delete_many
CLI
openemail contacts delete-many

contacts->setPhoto

Upload the photo shown for a contact

स्कोपcontacts:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

datastring|resource|SplFileInfo|StreamInterfaceआवश्यक

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.

लौटाता है

An array for the contact with the new photoUrl.

उदाहरण

$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;

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
PUT /contacts/{email}/photo
TypeScript
contacts.setPhoto()
Python
contacts.set_photo()
Ruby
contacts.set_photo
CLI
openemail contacts set-photo

contacts->removePhoto

Remove a contact photo

स्कोपcontacts:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The contact's address, matched case insensitively.

apiKeystring

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

लौटाता है

An array for the contact with photoUrl null.

उदाहरण

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

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
DELETE /contacts/{email}/photo
TypeScript
contacts.removePhoto()
Python
contacts.remove_photo()
Ruby
contacts.remove_photo
CLI
openemail contacts remove-photo

contacts->block

Block an address

स्कोपsettings:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The address to block.

apiKeystring

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

लौटाता है

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

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
POST /contacts/{email}/block
TypeScript
contacts.block()
Python
contacts.block()
Ruby
contacts.block
CLI
openemail contacts block

contacts->unblock

Unblock an address

स्कोपsettings:write
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

The address to unblock.

apiKeystring

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

लौटाता है

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.

उदाहरण

use OpenEmail\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;    }}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
DELETE /contacts/{email}/block
TypeScript
contacts.unblock()
Python
contacts.unblock()
Ruby
contacts.unblock
CLI
openemail contacts unblock

contacts->listThreads

List the conversations with one person

स्कोपthreads:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

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 OpenEmail\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.

लौटाता है

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

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/{email}/threads
TypeScript
contacts.listThreads()
Python
contacts.list_threads()
Ruby
contacts.list_threads
CLI
openemail contacts list-threads

contacts->listAllThreads

Collect every conversation with one person into one array

स्कोपthreads:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

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.

लौटाता है

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

उदाहरण

$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;

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/{email}/threads
TypeScript
contacts.listAllThreads()
Python
contacts.list_all_threads()
Ruby
contacts.list_all_threads

contacts->iterateThreads

Stream the conversations with one person one thread at a time

स्कोपthreads:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

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.

लौटाता है

A Generator that yields one thread summary array per step.

उदाहरण

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

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/{email}/threads
TypeScript
contacts.iterateThreads()
Python
contacts.iterate_threads()
Ruby
contacts.iterate_threads

contacts->activity

Read how mail with one person has gone over a window

स्कोपthreads:read
सिग्नेचर
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.

पैरामीटर

emailstringआवश्यक

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.

लौटाता है

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.

उदाहरण

$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;}

टिप्पणियाँ

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

इनमें भी उपलब्ध

API
GET /contacts/{email}/activity
TypeScript
contacts.activity()
Python
contacts.activity()
Ruby
contacts.activity
CLI
openemail contacts activity