Skip to content

Newsletter routes: import, send

The Newsletter Verbs import, send as api.sb routes, with inputs, result, refusals and an example.

Reference for Newsletter, one group of Newsletter routes.

Newsletter.import

Import adds subscribers from a CSV File, keeping each one’s consent basis and the date they subscribed. Verb page.

Text
POST /{namespace}/newsletters/{newsletter}/import

Path: newsletter. Body, as JSON: the other inputs. Emits Newsletter.imported.

Inputs

InputTypeRequiredDescription
newsletterNewsletterrequiredThe Newsletter.
fileFilerequiredThe CSV, one subscriber per row.
basisstringrequiredHow they consented, as the old tool recorded it.

Returns

OutputTypeRequiredDescription
newsletterNewsletterrequiredThe Newsletter, with its new subscribers counted.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
A row with no email, and skips a suppressed addressrefusedClear what the check names, then call it again.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/newsletters/newsletter_FLjN3aQujc/import \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file":"file_V1AuhyCTsH","basis":"Example basis"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "newsletter": {
    "$id": "https://api.sb/leaseline.app/newsletters/newsletter_FLjN3aQujc",
    "$type": "Newsletter",
    "name": "Leaseline notes",
    "from": "mailbox_93HvOnR17L"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Newsletter.import",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Newsletter.send

Send emails one issue, a piece of Content, to every subscribed Contact, and a paid issue only to those whose Offer covers it. Verb page.

Text
POST /{namespace}/newsletters/{newsletter}/send

Path: newsletter. Body, as JSON: the other inputs. Emits Newsletter.sent.

Inputs

InputTypeRequiredDescription
newsletterNewsletterrequiredThe Newsletter.
contentContentrequiredThe issue to send.
atdatetimeWhen to send it. Unset: now.

Returns

OutputTypeRequiredDescription
newsletterNewsletterrequiredThe Newsletter, with the issue in its archive.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/newsletters/newsletter_FLjN3aQujc/send \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"content_HYlnoorBdP"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "newsletter": {
    "$id": "https://api.sb/leaseline.app/newsletters/newsletter_FLjN3aQujc",
    "$type": "Newsletter",
    "name": "Leaseline notes",
    "from": "mailbox_93HvOnR17L"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Newsletter.send",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}