Check a post before sending
const url = 'https://digize.com/api/v1/newsletter/posts/example/checks';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"audience":{"tags":[],"excludeTags":[],"stages":[],"lists":["example"],"excludeLists":["example"],"tier":"example"},"abTest":{"metric":"opens","share":1,"waitHours":1,"variants":[{"subject":"example","preview":""}]},"at":null}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://digize.com/api/v1/newsletter/posts/example/checks \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "audience": { "tags": [], "excludeTags": [], "stages": [], "lists": [ "example" ], "excludeLists": [ "example" ], "tier": "example" }, "abTest": { "metric": "opens", "share": 1, "waitHours": 1, "variants": [ { "subject": "example", "preview": "" } ] }, "at": null }'Every check before a post goes, at once: errors stop it (no subject, no content, no service or sending domain ready, no postal address, nobody in the audience, a link that isn’t http(s), mailto:, tel: or a merge tag, a resend too soon), warnings are to judge (images without alt text, a paywall going only to free readers, an email over Gmail’s 102 KB clip, an A/B test too small to pick a winner). With audience, abTest and at, it checks those in place of the saved post’s, as the send dialog does. Also how many it would go to now.
Needs the newsletter:read permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.
Example
5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Any of these tags; empty for everyone subscribed.
Leaves out contacts with any of these tags.
Leads (no orders), customers (1–2) or repeat customers (3 or more); empty for all.
In any of these CRM lists (crm.lists.list), smart or static; empty for no list.
Leaves out anyone in any of these segments (CRM lists, newsletter.segments.list); empty to leave nobody out.
Readers by tier: all (or left out), free readers only, paid readers of any tier, or one tier’s id (newsletter.tiers.list). A paid-only post goes to paid readers whatever this says.
object
What picks the winner: the share of people who opened it (a person’s open, never a mail app’s own fetch) or who clicked a link.
The share of the audience the test goes to, 0.1 to 0.5, split evenly between the variants.
Hours after the test’s last batch went before the winner is picked and goes to the rest.
The other subjects (B, C, D). Variant A is the post’s own subject and preview text.
object
Its preview text; empty for the post’s own.
Responses
Section titled “Responses”Done
object
object
Example
{ "checks": [ { "code": "subject", "level": "error" } ]}What was sent isn’t valid (invalid).
object
object
object
Example
{ "error": { "code": "invalid" }}No key, or one that’s unknown, off or expired.
object
object
object
Example
{ "error": { "code": "invalid" }}The key doesn’t have the permission this needs.
object
object
object
Example
{ "error": { "code": "invalid" }}Nothing has that id (not_found).
object
object
object
Example
{ "error": { "code": "invalid" }}A request with the same Idempotency-Key is still running (conflict).
object
object
object
Example
{ "error": { "code": "invalid" }}The Idempotency-Key was used with a different request.
object
object
object
Example
{ "error": { "code": "invalid" }}Over the rate limit; see retry-after.
object
object
object
Example
{ "error": { "code": "invalid" }}