Preview a post
const url = 'https://digize.com/api/v1/newsletter/posts/preview';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"subject":"example","preview":"example","body":"","format":"plain","blocks":[],"access":"all","visibility":"email_web","web":{"title":"","subtitle":"","seoTitle":"","seoDescription":"","thumbnail":null,"tags":[],"authors":[]},"slug":"example","id":"example","contactId":null,"medium":"email","tier":"free"}'};
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/preview \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "subject": "example", "preview": "example", "body": "", "format": "plain", "blocks": [], "access": "all", "visibility": "email_web", "web": { "title": "", "subtitle": "", "seoTitle": "", "seoDescription": "", "thumbnail": null, "tags": [], "authors": [] }, "slug": "example", "id": "example", "contactId": null, "medium": "email", "tier": "free" }'A post’s subject, HTML and text as a contact would get them, or with a sample reader’s (Alex Rivera, alex@example.com) without one, before it’s saved or sent; or its web page (medium: web). As a free reader by default, or a paid one, who reads past the paywall.
Needs the newsletter:read permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “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
The line inboxes show after the subject, hidden in an html post; a plain one shows its first line.
Text for plain, a whole HTML document for html; a blocks post keeps none. Variables such as {{first_name}} and {{contact.
blocks for a post written in the editor (its blocks), plain for text, html for your own HTML.
A blocks post’s content, each block with type and show (where it shows: on both, email or web; tiers all, free or paid). {{view_online}} is the link to read it in a browser, or on the site.
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
Who it’s for: all, free readers only or paid readers only. A paid post with no paywall block shows free readers nothing.
email_web goes by email and on the site once sent, email by email only, web only on the site (newsletter.posts.publish).
object
The headline on the site; the subject when empty.
For search results and link previews; the title when empty.
Workspace members (members.list), with their names.
object
The saved post’s id, for its links.
Responses
Section titled “Responses”Done
object
Example generated
{ "subject": "example", "html": "example", "text": "example"}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" }}