How to automate WordPress content deployment with WP-CLI and the REST API
Clicking "Push" in wp-admin is fine for a one-off. It stops being fine the moment content deployment needs to be part of something else — a release script that pushes a batch of pages as the last step of a deploy, a nightly job that pulls a specific set of posts from staging, a CI pipeline that needs to know, programmatically, whether a deployment actually succeeded before it moves on. None of that works if the only interface is a button in a browser.
Two different APIs, because they're two different trust problems
PostDeploy already has a REST API — it's how one site's PostDeploy install talks to another's when you click Push or Pull. That API authenticates with a pre-shared secret between the two sites' connection records; the caller is another PostDeploy installation, not a person or a script. Reusing that same namespace for "let an external tool trigger a deployment" would mean teaching it a second, unrelated identity to authenticate — awkward at best.
So automation gets its own namespace instead, authenticated the way WordPress's REST API is normally meant to be used: as a real WordPress user, via an Application Password (core since WP 5.6) for an external script, or the ordinary logged-in session for a browser-based tool. No custom auth scheme, no separate credential to manage — a script authenticates exactly the way a human admin does, just without a browser in the loop, and every route is still gated on the same WordPress capabilities the Admin UI checks.
WP-CLI, for anything already on the server
If your deploy process already runs on the server — an SSH-triggered script, a Bash step in a self-hosted CI runner — WP-CLI is the more direct path:
wp postdeploy status
wp postdeploy connections
wp postdeploy push 1234 --to=production
wp postdeploy pull 3f9e2b1a-...-uuid --from=production
wp postdeploy dry-run 3f9e2b1a-...-uuid --from=production
wp postdeploy deployments --limit=20
wp postdeploy retry 1042
wp postdeploy rollback 1042
Nothing here is a parallel, CLI-only implementation of push and pull — every command calls the exact same service classes the Admin UI's buttons call. That matters more than it sounds: a script and a human clicking around in wp-admin should never get subtly different behavior for "the same" action, and the only way to guarantee that is for there to be exactly one place that behavior lives.
The REST API, for everything else
Not every automated trigger has shell access to the server — a CI pipeline on a separate runner, an external scheduler, a release tool that only speaks HTTP. For those, a dedicated REST namespace exposes the same operations:
POST /wp-json/postdeploy-pro/v1/deployments
{ "connection": "production", "post_id": 1234 }
POST /wp-json/postdeploy-pro/v1/deployments
{ "connection": "production", "uuid": "3f9e2b1a-...-uuid" }
Which one of those two a given request means — push a local post, or pull a remote object — is decided by which parameter you actually sent: post_id pushes, uuid pulls. That sounds obvious, but it's a deliberate fix for a real bug class: an earlier version decided the direction from the connection's own stored default instead, which meant a script correctly sending post_id to push a post through a connection whose stored default happened to be "pull" got rejected with a pull-shaped error for no reason a caller could see. Branching on what the request itself asked for, not on a setting elsewhere, is what makes the endpoint behave the way its own request body says it will.
Checking before you commit
A scheduled or bulk pull running unattended is exactly the situation where you want to know it'll succeed before it runs, not after a cron job silently fails at 3am. A dry run validates authentication, package integrity, post type support, destination permissions, conflicts, and media reachability without deploying anything — available the same way as every other operation, both as wp postdeploy dry-run and as POST /deployments/dry-run, so a CI step can gate on it before the real deployment request goes out.
When something goes wrong
Deployments and their history are listable and inspectable from either surface — wp postdeploy deployments or GET /deployments — and a failed one can be retried, or a completed one rolled back to its state from before that deployment ran, through the matching command or endpoint. A /diagnostics route (and its CLI equivalent) runs the identical health checks the Admin UI's own Diagnostics page shows, so a monitoring script and a person looking at wp-admin are never looking at two different answers to "is this actually healthy."
Try it
PostDeploy Free moves Posts, Pages, and custom post types through the Dashboard UI. PostDeploy Pro adds the WP-CLI commands and the dedicated REST automation API described here, alongside ACF, Elementor, and WPML reference resolution.