WordPress REST API publishing for SEO comes down to one authenticated HTTP request to the endpoint /wp-json/wp/v2/posts. That call carries the title, the content and a meta object holding your SEO title and description. Here it is:
{"title": "Heat Pump Sizing", "content": "<p>...</p>", "status": "draft", "meta": {"_yoast_wpseo_title": "Heat Pump Sizing Guide", "_yoast_wpseo_metadesc": "How to size a heat pump for your home."}}
The meta part saves only after one small setup step. Each piece is explained below.
How the WordPress REST API publishes an article
Endpoints, namespaces and the core content route
WordPress exposes its data as JSON under /wp-json/. The segment after it is the namespace: wp/v2 belongs to core, while plugins register their own, such as yoast/v1. A route plus an HTTP method makes an endpoint. The posts route handles blog posts: GET lists them, POST creates one.
What a publish request looks like (HTTP method and JSON)
A publish call is an HTTP POST with a JSON body and the header Content-Type: application/json. WordPress answers with the new post as JSON, including its id, link and status, so your script knows exactly what it created.
Set up authentication with application passwords
Create an application password for a dedicated user
Create a separate user, for example api-publisher. Log in as that user, open Users > Profile, scroll to Application Passwords, name the password after your script and click Add New. Copy it right away, because WordPress shows it only once.
Send the credentials with Basic Auth over HTTPS
Encode username:password in Base64 and send it as Authorization: Basic <encoded> on every call. With curl, -u api-publisher:"xxxx xxxx xxxx" does the encoding. Use HTTPS only, since Basic Auth over plain HTTP can be read by anyone on the network.
Pick a role with the fewest permissions that can still publish
Author can publish its own articles, which covers new ones. Editing those written by other users requires Editor. Skip Administrator: a leaked key would then control plugins and users too.
Create your first article with the REST API
The minimum fields: title, content, slug and status
Four fields are enough: title, content (HTML), slug and status. Use draft while testing and switch to publish once you trust the output. Set the slug yourself. Otherwise WordPress builds it from the title, stop words included.
Categories, tags and featured image
Categories and tags take arrays of term IDs, not names: "categories": [4], "tags": [12, 15]. For a featured image, upload the file to the media endpoint first, then pass the returned id as featured_media.
Schedule WordPress content with the date and future status
To schedule content, send "status": "future" together with "date": "2026-10-20T09:00:00", which is read in the site’s timezone. If your script works in UTC, use date_gmt instead. A past date with future status publishes immediately.
Add SEO meta fields in the same request
Why SEO plugin fields are not writable by default
SEO plugins store their fields as custom post meta, and the API exposes only meta registered with show_in_rest. Yoast’s keys also start with an underscore, which marks them as protected. Unregistered keys are dropped without any error message.
Registering the meta keys so the API accepts them
Add this to a small plugin or to functions.php:
register_post_meta( 'post', '_yoast_wpseo_title', array( 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'auth_callback' => function() { return current_user_can( 'edit_posts' ); } ) );
Repeat it for _yoast_wpseo_metadesc and _yoast_wpseo_focuskw. The auth_callback is what lets protected keys through.
A full request with SEO title, meta description and focus keyword
These are the steps for WordPress REST API publishing for SEO, with meta fields included:
- Register each SEO meta key with
show_in_restand anauth_callback. - Add a
metaobject to the JSON body with the SEO title, meta description and focus keyword ("_yoast_wpseo_focuskw": "heat pump sizing"). - Send it as a POST to the posts endpoint with your application password.
- Check that the
metaobject in the response returns the values you sent.
Plugin meta keys change by version: how to verify yours
Treat these keys as examples, not constants. Fill in the SEO fields for one post in the editor, then look in the wp_postmeta table for the keys your installed version actually writes. Rank Math usually uses rank_math_title, rank_math_description and rank_math_focus_keyword.

Update existing posts with SEO data
Find the post ID by slug
GET /wp-json/wp/v2/posts?slug=heat-pump-sizing returns an array; take id from the first item. Drafts appear only when the call is authenticated and includes status=draft.
Send a partial update without overwriting content
POST to the single-post route, /wp-json/wp/v2/posts/123, with only the fields you change. Fields you leave out keep their values, so you can refresh descriptions across older blog posts without touching their content: {"meta": {"_yoast_wpseo_metadesc": "New description"}}.
Fix common errors: 401, 403 and meta that does not save
401 and 403 responses
A 401 means WordPress didn’t accept who you are: a mistyped password, the wrong username, or a host that strips the Authorization header (a rewrite rule in .htaccess passes it through). A 403 means you’re recognized but not allowed, often rest_cannot_create or a weak role.
Meta fields ignored or returned empty
Empty meta has three likely causes. The key isn’t registered, it’s registered for the wrong post type, or its name differs from what your plugin version writes. A security plugin can also block write calls on your blog.
How to confirm the result in the response and on the page
Read the JSON output first: the meta object should echo your values. Then view the source of the live page and check the <title> tag and meta description. If the response is right but the page isn’t, a cache is serving old output.
Does REST API publishing affect search rankings?
What Google sees: the rendered page, not the publishing method
WordPress REST API publishing for SEO has no ranking effect of its own. Google crawls the rendered HTML, and nothing in that page reveals whether the post came from the editor, an import or an API call.
What actually causes problems: thin content, missing metadata and broken canonicals
Automation scales mistakes. Hundreds of thin pages, empty descriptions after a silent meta failure, or canonicals pointing at a staging domain all hurt. Check the first batch before running the whole queue.
When API publishing beats the editor
A decision rule by publishing volume and number of sites
Stay in the editor if you publish a few articles a week on one site and each needs hand formatting. Switch to WordPress REST API publishing for SEO work when you publish blog posts in batches, run several sites, or draft elsewhere. Headless WordPress setups need it regardless.
Security checklist for write access
- One user and one application password per script.
- Author or Editor role, never Administrator.
- HTTPS only.
- Password stored in an environment variable, not in code.
- Unused passwords revoked in the profile screen.
If you’d rather not maintain the script yourself, RankFlow publishes to WordPress from the same workspace where articles are planned and written.
Frequently asked questions
How do I publish a WordPress post with the REST API?
How do I publish a WordPress post with the REST API?
Create an application password for a dedicated user. Then send a POST to /wp-json/wp/v2/posts over HTTPS with Basic Auth and a JSON body containing title, content and "status": "publish". The response returns the new post’s id and URL.
How do I add Yoast SEO meta title and description using the REST API?
How do I add Yoast SEO meta title and description using the REST API?
Register _yoast_wpseo_title and _yoast_wpseo_metadesc with register_post_meta, show_in_rest and an auth_callback. Then include them in a meta object in your create or update call. Confirm the key names against your installed Yoast version first.
Is the WordPress REST API secure for publishing?
Is the WordPress REST API secure for publishing?
Yes, when you limit what a leaked credential can do. Use HTTPS, a dedicated user with the Author or Editor role, and one revocable application password per script. Reading public posts is open by default, but writing always requires authentication.
Can I fetch WordPress posts with the REST API?
Can I fetch WordPress posts with the REST API?
Yes. A plain GET to /wp-json/wp/v2/posts returns published posts as JSON, ten per page by default. Add ?per_page=50, ?search=term or ?slug=name to filter. Drafts and private posts require authentication.
Can I use Rank Math instead of Yoast with the same approach?
Can I use Rank Math instead of Yoast with the same approach?
Yes. The process is identical; only the meta keys change. Register Rank Math’s keys, usually rank_math_title, rank_math_description and rank_math_focus_keyword, and send them in the meta object. Check the keys in wp_postmeta on your own site first.
