Newsletter methods: import, send
The Newsletter Verbs import, send as typed SDK methods, with inputs, result, refusals and an example.
Reference for Newsletter, one group of Newsletter methods.
Newsletter.import
Import adds subscribers from a CSV File, keeping each one’s consent basis and the date they subscribed. Verb page.
interface NewsletterVerbs {
import(input: NewsletterImportInput, options?: SB.CallOptions): SB.Call<Newsletter>
}Emits Newsletter.imported.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
newsletter | Newsletter | required | The Newsletter. |
file | File | required | The CSV, one subscriber per row. |
basis | string | required | How they consented, as the old tool recorded it. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
newsletter | Newsletter | required | The Newsletter, with its new subscribers counted. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use 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 address | refused | Clear what the check names, then call it again. | None. |
Example
import { $ } from 'startup-builder'
const newsletter = await $.Newsletter.import({ newsletter: 'newsletter_FLjN3aQujc', file: 'file_V1AuhyCTsH', basis: 'Example basis' })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.
interface NewsletterVerbs {
send(input: NewsletterSendInput, options?: SB.CallOptions): SB.Call<Newsletter>
}Emits Newsletter.sent.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
newsletter | Newsletter | required | The Newsletter. |
content | Content | required | The issue to send. |
at | datetime | When to send it. Unset: now. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
newsletter | Newsletter | required | The Newsletter, with the issue in its archive. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
import { $ } from 'startup-builder'
const newsletter = await $.Newsletter.send({ newsletter: 'newsletter_FLjN3aQujc', content: 'content_HYlnoorBdP' })