Audiences
Named lists the contacts are grouped into.
Audiences tools
| Tool | What it does |
|---|---|
| listAudiences | The lists this mailbox groups its contacts into, the default one first, a page at a time. |
| getAudience | One audience in full: its name, what it is for, how many contacts are in it and whether it is the default one. |
| createAudience | Create a named list. It is created empty, and nothing stops two audiences sharing a name, so read the list first. |
| updateAudience | Rename an audience or change what it says it is for. The default audience can be renamed like any other and stays the default whatever it is called. |
| deleteAudience | Delete an audience. The membership goes, every contact that was in it stays. The default audience cannot be deleted. |
| listAudienceContacts | Who is in one audience and when each person joined it, a page at a time. Search by name or address, separate the ones added by hand from the ones recorded from a send, and sort by when somebody was last heard from, by when they joined or by name. Asking for the default audience lists every contact on the mailbox. |
| addContactToAudience | Put an existing contact in an audience. It never creates a contact, because a mistyped address would become a permanent row nobody asked for. |
| removeContactFromAudience | Take a contact out of an audience. It stays a contact, with its notes and its other audiences. |
| addContactsToAudience | Put up to 200 existing contacts in one audience in one call. Like the single add it never creates a contact, and the addresses that are not contacts yet are listed back. |
| removeContactsFromAudience | Take up to 200 contacts out of one audience in one call. Every one of them stays a contact, with its notes and its other audiences. |
| importContactsToAudience | Bring up to 500 people into an audience in one call, with any custom fields, creating the contacts that do not exist yet, the way a CSV import on the audience page does. |
| emptyAudience | Take everyone out of one audience at once. The audience and every contact stay. It cannot be undone, and the default audience cannot be emptied. |
| setContactAudiences | Say exactly which audiences one contact is in: it joins the ones listed and leaves the rest. The default audience is always kept. |
| getAudienceGrowth | How many contacts joined each audience over a window, by day, hour or minute: the chart on the audiences page. |
Every mailbox has a default audience holding every contact, and it is the one thing here that cannot be deleted or thinned. Taking somebody out of it would mean a contact that listContacts shows and listAudienceContacts cannot, which is a book that disagrees with itself. deleteContact is what removes somebody from the mailbox entirely.
Putting somebody in an audience mails them nothing. Sending one email to everybody in an audience is a separate set of tools, under Sending to audiences.
Adding a contact to a list is a write to the LIST rather than to the contact, so it is gated on audiences:write and not on contacts:write. importContactsToAudience is the exception: it creates contacts, so it needs both. Reading the addresses in an audience needs only audiences:read.
Somebody whose access is limited to some addresses sees the default audience and the audiences they created, and only the contacts they added. Every tool here works inside that view: emptyAudience takes out only their own contacts, an import skips a contact another member added, and setContactAudiences leaves the audiences they cannot see as they are. Counts are the one exception: the contact count on an audience and the figures from getAudienceGrowth include everybody in a list they can see. The workspace owner is never limited this way, even through a client limited to some addresses.
emptyAudience cannot be undone and nothing records who was in the list, so read listAudienceContacts first when the list matters. getAudienceGrowth counts joins only: an audience records when somebody joined and never when they left, so every figure is the people still in the list by the date they joined, and a line never falls.
Some tools on this server make a change the REST API guards with a verification code, and ask for the same code. Until the client has verified a code in the last 60 minutes, or the person has chosen Allow changes for 60 minutes on it in Account → Connected apps, such a tool answers with a result that starts Refused (step_up_required): and changes nothing. emptyAudience never asks for a code. The API Authentication page lists every tool that asks, and shows how to ask for a code and verify it.
Reference
listAudiences
The lists this mailbox groups its contacts into. Every mailbox has a default audience holding every contact, and may define more: a newsletter list, the people at one customer, whoever came in from a form. Listing them sends nothing; sendToAudience sends one email to everybody in one. One page at a time: when more follow, the last line gives a cursor to pass back for the next page. Anybody but the workspace owner sees the default audience and the audiences they created, and only the contacts they added.
Inputs
limitinteger- At least 1At most 100Default
50 cursorstring
Also available in
- API
GET /audiences- TypeScript
nextmail.audiences.list()nextmail.audiences.listAll()nextmail.audiences.iterate()- Python
audiences.list()audiences.list_all()audiences.iterate()- Ruby
audiences.listaudiences.list_allaudiences.iterate- PHP
audiences->listaudiences->listAllaudiences->iterate- Go
Audiences.ListAudiences.ListAllAudiences.Iterate- Java
audiences().listaudiences().listAllaudiences().iterate- C#
Audiences.ListAsyncAudiences.ListAllAsyncAudiences.IterateAsync
getAudience
One audience in full: its name, what it is for, how many contacts are in it and whether it is the default one. listAudienceContacts is what lists who is actually in it.
Inputs
audienceIdstringRequired
Also available in
- API
GET /audiences/{id}- TypeScript
nextmail.audiences.get()- Python
audiences.get()- Ruby
audiences.get- PHP
audiences->get- Go
Audiences.Get- Java
audiences().get- C#
Audiences.GetAsync
createAudience
Create an audience: a named list this mailbox’s contacts can be put in. It is created empty, and addContactToAudience fills it. Nothing stops two audiences sharing a name, so read listAudiences first rather than making a second “Newsletter” beside the one that is already there. Creating one sends nothing; sendToAudience is how an email goes to everybody in it.
Inputs
namestringRequired- 1 to 120 characters
descriptionstring- Up to 1000 characters
showOnPreferencesbooleantrue lists the audience by name on the email preferences page the unsubscribe link opens, where its members can leave or rejoin it. false keeps it private.
Also available in
updateAudience
Rename an audience or change what it says it is for. Passing null clears the description. The default audience can be renamed like any other, because the name is just this mailbox’s word for “everyone”, but it stays the default whatever it is called.
Inputs
audienceIdstringRequirednamestring- 1 to 120 characters
descriptionstring- Can be nullUp to 1000 characters
showOnPreferencesbooleantrue lists the audience by name on the email preferences page the unsubscribe link opens, where its members can leave or rejoin it. false keeps it private.
Also available in
deleteAudience
Delete an audience. The audience and its membership go; every contact that was in it stays, and keeps its notes. This is permanent and nothing here recreates the membership. The default audience cannot be deleted.
- Asks for a verification codeOnly when it deletes an audience you created
DELETE /audiences/{id}
Inputs
audienceIdstringRequired
Also available in
listAudienceContacts
Who is in one audience, with the date each person joined it. Same shape as listContacts, narrowed to one list, and paged the same way: pass the cursor from the last line back, with the same sort and filters, for the next page. q searches the name and the address, source separates the ones added by hand from the ones recorded from a send, and sort orders the list the way the audience page can: last-heard-newest (the default), last-heard-oldest, added-newest, added-oldest or name. statuses keeps only subscribed or only unsubscribed members; leave it out, or name both, for everyone. Asking for the default audience lists every contact on the mailbox. Walking every page is how to export a list.
Inputs
audienceIdstringRequiredqstring- Up to 200 characters
sourcestring- One of
"manual""auto""form" sortstring- One of
"last-heard-newest""last-heard-oldest""added-newest""added-oldest""name" statusesstring[]- Up to 2 itemsOne of
"subscribed""unsubscribed" limitinteger- At least 1At most 200Default
50 cursorstring
Also available in
- API
GET /audiences/{id}/contacts- TypeScript
nextmail.audiences.listContacts()nextmail.audiences.listAllContacts()nextmail.audiences.iterateContacts()- Python
audiences.list_contacts()audiences.list_all_contacts()audiences.iterate_contacts()- Ruby
audiences.list_contactsaudiences.list_all_contactsaudiences.iterate_contacts- PHP
audiences->listContactsaudiences->listAllContactsaudiences->iterateContacts- Go
Audiences.ListContactsAudiences.ListAllContactsAudiences.IterateContacts- Java
audiences().listContactsaudiences().listAllContactsaudiences().iterateContacts- C#
Audiences.ListContactsAsyncAudiences.ListAllContactsAsyncAudiences.IterateContactsAsync
addContactToAudience
Put an existing contact in an audience. The contact has to exist already: this never creates one, because a mistyped address would become a permanent row nobody asked for. createContact adds it first. Adding somebody to a list sends nothing to them.
Inputs
audienceIdstringRequiredemailstringRequired- Format
email
Also available in
removeContactFromAudience
Take a contact out of an audience. The contact stays a contact on this mailbox, with its notes and its other audiences. Nobody can be taken out of the default audience, which holds every contact there is; deleteContact is what removes somebody from the mailbox entirely.
Inputs
audienceIdstringRequiredemailstringRequired- Format
email
Also available in
addContactsToAudience
Put up to 200 existing contacts in one audience in one call, by address. Like addContactToAudience it never creates a contact: an address that is not a contact yet is listed back as not added, and importContactsToAudience is the call that creates them. Somebody already in the audience is left as they are. Adding people to a list sends nothing to them.
Inputs
audienceIdstringRequiredemailsstring[]Required- 1 to 200 items
Also available in
removeContactsFromAudience
Take up to 200 contacts out of one audience in one call, by address. Every one of them stays a contact on this mailbox, with its notes and its other audiences. Addresses that are not in the audience, or are not contacts at all, are listed back and nothing happens to them. Nobody can be taken out of the default audience; deleteContact removes somebody from the mailbox entirely.
Inputs
audienceIdstringRequiredemailsstring[]Required- 1 to 200 items
Also available in
importContactsToAudience
Bring a list of people into an audience, creating the contacts that do not exist yet, the way importing a CSV on the audience page does. Up to 500 rows per call; send a longer list in further calls. An address that is already a contact is reused, never duplicated, and keeps the name it has; a name given here only fills one that was empty. Every new contact also joins the default audience. Malformed addresses are skipped and listed back. Nothing is sent and nobody is subscribed to anything. A row can carry custom fields as attributes, such as the other columns of a spreadsheet: each value replaces the field of that name and the fields a row leaves out keep their values. Anybody but the workspace owner cannot touch a contact another member added, and those rows are skipped.
Inputs
audienceIdstringRequiredcontactsobject[]Required- 1 to 500 items
emailstringRequired- 1 to 320 characters
namestring- Up to 200 characters
attributesRecord<string, string>Custom fields for the contact, as an object of keys and text values, such as the other columns of a CSV file. A key starts with a letter and holds up to 64 letters, digits and underscores, and a value is text of at most 500 characters. A value replaces the field of that name on a new or existing contact, an empty value is ignored, and the fields a row leaves out keep their values. A contact that would pass 50 fields keeps the ones it has.
Also available in
emptyAudience
Take every contact out of one audience at once. The audience stays, empty, with its name and description, and every contact stays a contact with its notes and its other audiences. This cannot be undone and nothing records who was in it, so read listAudienceContacts first if the list matters. The default audience cannot be emptied, because it holds every contact for as long as it is a contact. Anybody but the workspace owner only takes out the contacts they added.
Inputs
audienceIdstringRequired
Also available in
setContactAudiences
Say exactly which audiences one contact is in, in one call: it joins every audience listed and leaves every other one. The default audience is kept whatever is passed, because every contact is in it, so an empty list takes the contact out of every audience but that one. The contact has to exist already; createContact makes it. An audience id that does not exist is refused and nothing changes. Moving somebody between lists sends nothing to them. Anybody but the workspace owner can only move the contacts they added, and audiences they cannot see are left as they are.
Inputs
emailstringRequired- Format
email audienceIdsstring[]Required- Up to 100 items
Also available in
getAudienceGrowth
How audiences have grown: how many contacts joined each list over a window that ends now, bucketed by day, hour or minute, the chart on the audiences page. Pass audienceIds for some lists or leave it out for every audience; days reaches back from 1 to 1095 (30 by default), and minutes sets a shorter window, such as the last hour by minute, and wins over days. offsetMinutes is the reader's UTC offset, so days break at their midnight. An audience only records when somebody joined, never when they left, so every figure counts the people still in the list today by the date they joined, and it never falls. Contacts counts each person once however many lists they are in, while Memberships adds the lists up. Anybody but the workspace owner reads the default audience and the audiences they created, and the figures count everybody in those lists.
Inputs
audienceIdsstring[]- Up to 50 items
daysinteger- At least 1At most 1095
minutesinteger- At least 1At most 1576800
grainstring- One of
"minute""hour""day" offsetMinutesinteger- At least -840At most 840