I’m trying to create an email only post using the Admin API. I’m using Ghost(Pro).
Based on this post and the process described here in the documentation I’m using a two-stage process of creating the post, then updating.
The body for the post update is:
{
"updated_at": post["posts"][0]["updated_at"],
"newsletter": "default-newsletter",
"email_segment": "label:admin",
"email_only": true
}
When I POST this I get an error:
"message"=>"Validation error, cannot edit post.",
"context"=>"Validation failed for email_only.",
"type"=>"ValidationError",
"details"=>[{"keyword"=>"type", "dataPath"=>".posts[0].email_only", "schemaPath"=>"#/properties/email_only/type", "params"=>{"type"=>"boolean"}, "message"=>"should be boolean"}],
"property"=>"email_only",
If I omit the email_only
property, the post is created, but isn’t sent anywhere.
If I add "status": "published"
the post is published without a problem.
I’ve tried "email_only": "true"
and even "email_only": 1
, but neither worked.
I’ve tried moving all combinations of properties between the post creation call and the post update call, but there was no difference.
Also, the values on the post don’t seem to be set to the values I’m providing:
"email_segment"=>"all",
"email_only"=>false,
"newsletter"=>nil
What is the correct process to create an email only post via the Admin API?