Ghost Posts API & Newsletters

Running Ghost 5.2.2 and using the Admin API to publish posts.

Alongside publishing the post via the API, I want it to send it out to a specified newsletter.

As far as I can tell from the Ghost documentation (Ghost Admin API Documentation) all I need to do is add ?newsletter={{newsletter-slug}} to the query string when I create the post. However it schedules the post, but doesn’t schedule/send the email.

Everything appears to be working well (in terms of scheduling and publishing posts), just not sending out the emails.

What am I missing?

Sample HTTPS request:

URL: {{website-url}}/ghost/api/admin/posts/?newsletter=default-newsletter&source=html

Method: POST

Body: {“posts”: [{“title”: “Title”,“status”: “scheduled”,“html”: “Content”,“published_at”: “2022-06-15T20:07:00.000Z”}]}

Headers:

  • Content-Type: application/json
  • Authorization: Ghost {{token}}
1 Like

Did you succeed at this? I have the same problem…

Months later, but is there any updates on this? Similar problem.

I just got it to work. Steps:

  1. Send the post as a draft;
  2. Update the post status to published with a PUT call to /posts/{postId}/?newsletter={newsletter}

The POST call which creates a new post does not work to send the e-mail, even if status is already set to published.

Hi!
I think I have the same problem but am confused by where exactly you are inserting the PUT call to /posts/{postId}/?newsletter={newsletter} ?

My problem:
• I sent (only) a newsletter to members, but ‘View in Browser’ turns up 404 error.
• In the console, the post shows as a draft meaning no analytics are available.
• I don’t want the post published on site but do need it viewable in browsers. And that is the only available option in the console — which has never happened before today.

No idea why this occurred, does this seem like the issue you experienced?

Thanks in advance, this is embarrassing!

PS: Here are console views if it helps.
1 — Publish pane, showing it has been sent
2 — Editor view, showing 'draft saved and Publish option
3 — Admin console Draft status

So frustrating, hopeful for some wisdom…



Hi, @EOBSL . Not embarrassing at all! But I don’t think we are dealing with the same issue. If I understand correctly, you are working from the console only; I am creating the text outside Ghost, and using the API with a Python script to send the post to Ghost and to the newsletter; the PUT request is made by the script.

Anyway, in my case, my script works as follows:

  1. send the post as a draft first (POST request to /posts/);
  2. update the post to published and send the newsletter (PUT request to /posts/{postId}/?newsletter={newsletter})

In your case, while the post is a draft, it will indeed show a 404 error to the users. If you are using API calls, perhaps this above may help. Cheers!