Newsletter imports (add-on)
Bringing people in from a CSV file or from the store's own customers, and the history of each run.
Two ways in: a CSV file, uploaded as multipart/form-data, or the store's own customers. Both run as an import with the same counters and the same history. See Subscribers, lists and tags.
List contact imports
/api/v1/kahunacart/newsletters/imports
The recent runs of the CSV importer, newest first, with the file each one read, the list it wrote to, where the run got to and the four counters that say what it did: how many addresses were new, how many were already here, how many were skipped and how many ended in a suppression rather than a subscriber. The four add up to the total, so a merchant asking why twelve thousand addresses became eleven thousand four hundred reads across rather than guessing. Start here when somebody asks where a subscriber came from: every address an import wrote carries the file name.
Get one contact import
/api/v1/kahunacart/newsletters/imports/{id}
One import run with its counters, its status, the reason it failed if it did, and how far through the file it is as a fraction — which is null until it has read its first chunk, because a run that has not started knows nothing and reporting zero would be reporting something. Poll this while a run is going; the counters are written every five hundred rows.
Parameters
| Name | Type | Description |
|---|---|---|
| id required | integer | Import run id |
Preview subscribing the store's customers
/api/v1/kahunacart/newsletters/imports/customers/preview
How many of the store's own customers match a filter and what would happen to each of them, without writing anything. Answers five numbers that add up: how many customers matched, how many of those would be added, how many are already subscribers, how many are suppressed or have bounced, and how many were skipped because they have no usable address. Filters combine with AND and are all optional — bought at least once, bought a given product, bought anything in a category, in a customer group, ordered within so many days or since a date, has an account or is a guest checkout. Use this to answer "how many of my customers are on the mailing list", which needs no write permission at all.
Parameters
| Name | Type | Description |
|---|---|---|
| filter optional | object | Who the run is about. Omit for every customer. Keys: `bought`, `product`, `category`, `group`, `days`, `since`, `account` |
| limit optional | integer | How many matching customers to name, up to 100. Default 20. |
Subscribe the store's customers
/api/v1/kahunacart/newsletters/imports/customers
Put the store's own customers on a list, as one import run with the same counters and the same history as a CSV import. Takes the same filter preview_customer_import takes, and a mode — invite, which writes each customer pending and emails them a confirmation so only the ones who click are subscribed, or subscribed, which writes them subscribed and confirmed straight away. Invite is the default and needs a list to name in the confirmation. Everybody written is tagged, customer unless another tag is given, and is linked to their customer record so purchase segments answer for them immediately. A suppressed address is never written and a bounce or a complaint is never revived, whichever mode is chosen.
Parameters
| Name | Type | Description |
|---|---|---|
| list_id optional | integer | The list everybody joins. Required for the invite mode. |
| mode optional | string |
invite asks each customer to confirm; subscribed writes them in straight away. Default invite.
One of:
invite, subscribed |
| tag optional | string | The tag put on everybody in this batch. Default customer; send an empty string for none. |
| filter optional | object | Who the run is about. Omit for every customer. Keys: `bought`, `product`, `category`, `group`, `days`, `since`, `account` |
Preview a CSV import
/api/v1/kahunacart/newsletters/imports/preview
Upload a CSV file as multipart/form-data in a field named file and read back what is in it: the columns, the first rows, and which column the importer thinks holds the address, the name and the lists. Nothing is written. No tool: a multipart upload is not something the manifest format describes.
Start a CSV import
/api/v1/kahunacart/newsletters/imports
Upload the same file with the column mapping and the list to write to, and start the import as a background run. Follow it with GET /kahunacart/newsletters/imports/{id}. No tool: it is a multipart upload.