POST/api/v1/projects/{project_id}/lists/{list_id}/subscribers/import
import_subscribers
Adds a batch of up to 1 000 subscribers to a list in one call and reports record by record.
- Call it
- to load many addresses at once; for more than 1 000, call it again or use the API (10 000 a request). Each record is
emailand optionalattributes, added asadd_subscriberadds one, in order: a new address is created (active, orpendingon a list with double opt-in), an address already on the list keeps its status and gets its attributes merged, two records of one address merge into one subscriber. An invalid record (bad email, attributes over their limits) is reported ininvalidby its index and fails nothing else. - Needs
- an admin key with
project_id, or a project key with scopewrite(its own project; the argument is ignored), and a list that is not deleted; more than 1 000 records isvalidation_failedand nothing is written. - Returns
created,updated,invalidandpending_confirmation, the same asPOST /api/v1/projects/{project_id}/lists/{list_id}/subscribers/import. There is noIdempotency-Key: a repeat adds nothing twice and changes no status (it reports the records asupdated).
Arguments
- object
-
list_idstring · uuidrequiredThe list to add the subscribers to.
-
The records, up to 1 000, in order; the result names an invalid one by its index here.
≤ 1000 items
2 fields
- ImportRecordArgument object
-
emailstringrequiredThe address; any case and surrounding whitespace are normalized.
example
ann@example.com -
attributesmap of string → string | number | boolean | nullAttributes to set: a map of string, number or boolean values;
nullfor a key removes it. Up to 64 keys, up to 4 KB of JSON.default
{}
-
project_idstring · uuid | nullThe subscribers’ project. An admin key must pass it; a project key’s own project is used and this is ignored.
No other arguments are accepted.
Result
The result comes back as structuredContent, with the same JSON as a text block.
- object · all fields required
-
createdinteger · uintRecords whose address was not on the list: new subscribers.
≥ 0
-
invalidarray of InvalidImportRecordRecords not added, by index.
5 fields
- InvalidImportRecord object · all fields required
-
codestringinvalidorinvalid_type, as in avalidation_failederror. -
emailstringThe email as the record had it.
-
fieldstringThe record’s field:
email,attributesorattributes.<key>. -
indexinteger · uintThe record’s index in
subscribers, from 0.≥ 0
-
messagestring
-
pending_confirmationinteger · uintOf the created subscribers, those
pending(the list has double opt-in).≥ 0
-
updatedinteger · uintValid records whose address was already on the list or came earlier in the batch: merged into that subscriber, its status kept.
≥ 0
Definitions
ImportRecordArgument
One record of import_subscribers: the arguments of add_subscriber
without the list.
- object
-
emailstringrequiredThe address; any case and surrounding whitespace are normalized.
example
ann@example.com -
attributesmap of string → string | number | boolean | nullAttributes to set: a map of string, number or boolean values;
nullfor a key removes it. Up to 64 keys, up to 4 KB of JSON.default
{}
InvalidImportRecord
A record the import did not add, with the first problem of its values.
- object · all fields required
-
codestringinvalidorinvalid_type, as in avalidation_failederror. -
emailstringThe email as the record had it.
-
fieldstringThe record’s field:
email,attributesorattributes.<key>. -
indexinteger · uintThe record’s index in
subscribers, from 0.≥ 0
-
messagestring
Errors
A failed call answers isError: true with a code from the same table as the HTTP API, and detail. How tools report errors
HTTP API
The same operation over HTTP: POST /api/v1/projects/{project_id}/lists/{list_id}/subscribers/import