REST API reference

The plugin exposes 94 routes under /wp-json/wpcb/v1. The MCP server uses them, Xaflo Desktop uses them, and so can your own scripts: it is plain HTTPS and JSON, nothing AI-specific.

On this page

Base URL and authentication

Every route lives under your site’s REST base. Send a token in the Authorization header:

curl
curl -H "Authorization: Bearer YOUR_TOKEN" 
  https://your-site.example/wp-json/wpcb/v1/whoami
  • If your host strips Authorization, send the same value in X-WPCB-Authorization.
  • Requests must use HTTPS; plain HTTP is answered with 426.
  • /health, /install/info and the two installer scripts are public. Token and plugin administration routes accept only a logged-in WordPress administrator, not a token.
  • The live list of routes is always at GET /wp-json/wpcb/v1, the standard WordPress namespace index.

Errors

Errors use the WordPress REST format, with a code that starts with wpcb_:

JSON
{
  "code": "wpcb_rate_limited",
  "message": "…",
  "data": { "status": 429, "retry_after": 12, "limit": 60, "scope_limited": "__global__" }
}
StatusCodeMeaning
400wpcb_validationA parameter is missing or invalid.
401wpcb_unauthorizedNo valid token.
403wpcb_forbiddenMissing scope or WordPress capability.
426wpcb_upgrade_requiredThe request was not over HTTPS.
428wpcb_confirmation_requiredDestructive operation: repeat it with the confirmation_token returned.
428wpcb_confirmation_invalidThe confirmation token is expired, used or for another operation.
429wpcb_rate_limitedToo many requests; wait for Retry-After seconds.
400wpcb_hash_mismatch, wpcb_invalid_packageAn uploaded zip does not match its SHA-256, or is not exactly one plugin.
403xaflo_fs_outside_uploadsA file change outside the uploads folder without fs:admin.
409wpcb_login_link_2fa and database refusalsSomething on the site stops the request: a two-factor sign-in plugin for quick login, or tables or MySQL settings /db/query cannot work with.
413wpcb_too_largeAn uploaded zip over 20 MB or over the server’s upload limit.

Two-step confirmation

Destructive operations answer the first call with 428 and a confirmation token instead of acting:

JSON · first response
{
  "error": {
    "code": "wpcb_confirmation_required",
    "message": "Provide confirmation_token to restore.",
    "confirmation_token": "ct_…",
    "expires_at": "…",
    "operation_summary": "…"
  }
}

Repeat the same call with confirmation_token set to that value within five minutes. The token works once, for that operation, user and resource only; for writes it is also bound to the exact content, and for a plugin upload to the slug and the hash. MCP server 1.3 and Xaflo Desktop 2.0 never send it by themselves: they show the summary and wait for the person.

/db/query refusals carry their own codes, such as unsupported_placeholder, unknown_qualifier, cross_database, secret_column, protected_option or protected_table.

Health check

GET /health needs no token and returns status, version, plugin_version, wp_version, php_version, site_url, rest_base, time and multilingual. Sent with a valid token, it also returns that token’s scopes (plugin 1.7.0). It is not written to the audit log.

New and changed in 1.7.0

  • POST /admin/login-link (scope admin:login, administrator) returns {url, expires_in: 60}, a one-time sign-in link; an optional redirect_to must be a path under wp-admin. GET /admin/login-link/redeem is public and works once.
  • POST /plugins/install-zip also accepts zip_base64, filename and sha256 instead of zip_url; activation only with activate: true.
  • /fs/* writes: site:write inside uploads only, fs:admin elsewhere; confirmation_token accepted on write, upload, rename and delete; fs/write returns a backup id.
  • /media and /media/unused need media:read; /db/query needs an administrator; every token route checks a WordPress capability.
  • GET /plugins reports available updates and descriptions; WP-CLI values go in args.

All routes

“Needs” lists the scopes for each method, in order. “admin” means the user behind the token must also be able to manage options; “admin session” means a logged-in administrator in the WordPress admin, with no token.

Identity, health and stats

RouteMethodsNeedsDoes
/healthGETpublicPlugin version, WordPress and PHP versions, site URL, time, multilingual adapter; with a valid token, also that token’s scopes.
/whoamiGETauth:readThe user and scopes behind the token.
/auditGETaudit:read · adminThe audit log.
/stats/dashboardGETdashboard:readDashboard statistics.
/stats/timeseriesGETdashboard:readRequest counts over time.

Posts, pages, terms and search

RouteMethodsNeedsDoes
/postsGET · POSTcontent:read · content:writeList or create posts. New posts are drafts unless the token has content:publish.
/posts/{id}GET · PATCH · DELETEcontent:read · content:writeRead, update (a revision is saved first) or delete. Permanent delete asks for confirmation.
/posts/{id}/publishPOSTcontent:publishPublish a post.
/pagesGET · POSTcontent:read · content:writeList or create pages.
/pages/{id}PATCH · DELETEcontent:writeUpdate or delete a page. Permanent delete asks for confirmation.
/termsGET · POSTcontent:read · content:writeList or create terms of a taxonomy.
/searchGETcontent:readSearch across content.

Media

RouteMethodsNeedsDoes
/mediaGETmedia:readList the media library.
/media/from-urlPOSTmedia:writeSideload a file from a URL (SSRF-guarded).
/media/from-base64POSTmedia:writeUpload a base64-encoded file.
/media/{id}PATCH · DELETEmedia:writeEdit alt text, caption and description; delete with confirmation.
/media/{id}/optimizePOSTmedia:writeOptimise an image.
/media/unusedGETmedia:readMedia that no content uses.

SEO

RouteMethodsNeedsDoes
/seo/{post_id}GET · PATCHseo:read · seo:writeRead or write SEO meta for a post.
/seo/{post_id}/analyzeGETseo:readAnalyse one post.
/seo/auditGETseo:readAudit many posts.
/seo/sitemapGETseo:readSitemap status.
/seo/broken-linksGETseo:readBroken links in recent content or all of it.

Analytics

RouteMethodsNeedsDoes
/analytics/detectGETanalytics:readWhich analytics source the site has.
/analytics/overviewGETanalytics:readTraffic overview.
/analytics/top-postsGETanalytics:readMost visited content.
/analytics/top-referrersGETanalytics:readTop referrers.
/analytics/top-keywordsGETanalytics:readTop search keywords.
/analytics/post/{post_id}GETanalytics:readTraffic for one post.
/analytics/compareGETanalytics:readCompare two periods.
/analytics/trend-by-categoryGETanalytics:readTrends per category.
/analytics/no-traffic-pagesGETanalytics:readPublished content without visits.

Multilingual

RouteMethodsNeedsDoes
/multilingual/detectGETcontent:readWhich multilingual plugin is active.
/multilingual/languagesGETcontent:readSite languages.
/multilingual/post/{post_id}/translationsGET · POSTcontent:read · content:writeRead or link translations.
/multilingual/post/{post_id}/languagePATCHcontent:writeSet the language of a post.
/multilingual/media/{attachment_id}/translationsGETcontent:readMedia translations.
/multilingual/media/{attachment_id}/translations/{language_code}PATCHmedia:writeTranslate media metadata.
/multilingual/media/auditGETcontent:readMedia translation coverage.
/multilingual/stringsGETcontent:readString translations.
/multilingual/strings/auditGETcontent:readString translation coverage.

Theme

RouteMethodsNeedsDoes
/themeGETtheme:readThe active theme.
/theme/filesGET · PUTtheme:read · theme:writeList files, or write one (the previous version is kept).
/theme/files/readGETtheme:readRead a theme file.
/theme/custom-cssPOSTtheme:writeAdd custom CSS.
/theme/switchPOSTtheme:writeSwitch theme, with confirmation.

Plugins

RouteMethodsNeedsDoes
/pluginsGETplugin:readInstalled plugins.
/plugins/{slug}/files/readGETplugin:readRead a plugin file.
/plugins/{slug}/filesPUTplugin:writeWrite a plugin file.
/plugins/scaffoldPOSTplugin:installCreate a new plugin skeleton.
/plugins/install-zipPOSTplugin:installInstall from a zip URL, or from a zip in the request (zip_base64, filename, sha256; at most 20 MB). Replacing an installed plugin asks for confirmation.
/plugins/install-repoPOSTplugin:installInstall from the WordPress.org directory, with confirmation.
/plugins/{slug}/activatePOSTplugin:installActivate a plugin.
/plugins/{slug}/deactivatePOSTplugin:installDeactivate a plugin.

Settings, menus, widgets

RouteMethodsNeedsDoes
/settingsGET · POSTsite:read · site:writeRead or change settings. Changing siteurl, home or admin_email asks for confirmation.
/menusGET · POSTsite:read · site:writeList or create menus.
/menus/{id}PATCHsite:writeUpdate a menu.
/widgetsGET · POSTsite:read · site:writeRead or set widgets.
/customizerGET · POSTsite:read · site:writeRead or set Customizer values.
/performanceGETsite:readSystem, database, cache and disk information.

Backups

RouteMethodsNeedsDoes
/backupGET · POSTsystem:backup · adminList backups, or create one (database, files or both).
/backup/{id}/restorePOSTsystem:backup · adminRestore a backup, with confirmation.

Maintenance mode and debug log

RouteMethodsNeedsDoes
/maintenanceGET · POST · DELETEsite:read · site:write · adminStatus, turn on, turn off.
/maintenance/previewGETsite:read · adminRender the 503 page without enabling it.
/debug/logGET · DELETEaudit:read · site:write · adminTail or clear debug.log.
/debug/log/statusGETaudit:read · adminSize and state of debug.log.

Files

RouteMethodsNeedsDoes
/fs/listGETsite:read · adminList a directory.
/fs/readGETsite:read · adminRead a file.
/fs/downloadGETsite:read · adminDownload a file.
/fs/searchGETsite:read · adminFind files by name.
/fs/writePUTsite:write · fs:admin · adminWrite a file: inside uploads with site:write, elsewhere with fs:admin (overwrites confirmed).
/fs/mkdirPOSTsite:write · fs:admin · adminCreate a directory.
/fs/renamePOSTsite:write · fs:admin · adminRename or move, with confirmation under fs:admin.
/fs/uploadPOSTsite:write · fs:admin · adminUpload a file.
/fs/deleteDELETE · POSTsite:write · fs:admin · adminDelete, with confirmation; recursive for folders.

Database and WP-CLI

RouteMethodsNeedsDoes
/db/queryPOSTdb:read · db:write · adminSQL through the guard. Writes need mode write, db:write, InnoDB tables and confirmation.
/cliPOSTcli:exec · adminAllowlisted WP-CLI commands. Off until the site owner enables it.

Quick login

RouteMethodsNeedsDoes
/admin/login-linkPOSTadmin:login · adminA one-time link, valid 60 seconds, that signs the token’s own user in to wp-admin.
/admin/login-link/redeemGETpublicUses a sign-in link once. Every refusal redirects to wp-login.php.

Plugin administration

RouteMethodsNeedsDoes
/tokensGET · POSTadmin sessionList or create tokens.
/tokens/{jti}DELETEadmin sessionRevoke a token.
/scopesGETadmin sessionAll scopes with descriptions.
/jwt-secret-suggestGETadmin sessionA fresh secret value.
/admin/settingsGET · POSTadmin sessionPlugin settings.
/admin/cleanup-nowPOSTadmin sessionRun the daily cleanup now.
/admin/jwt-secret/statusGETadmin sessionWhether the secret is set.
/admin/jwt-secret/installPOSTadmin sessionWrite a new secret into wp-config.php.
/admin/jwt-secret/rotatePOSTadmin sessionReplace the secret, which invalidates every token.
/admin/jwt-secret/removePOSTadmin sessionRemove the secret.
/admin/routesGETadmin sessionThe live route list.
/install/infoGETpublicMCP package version and installer URLs.
/install/script.shGETpublicInstaller script for bash.
/install/script.ps1GETpublicInstaller script for PowerShell.
/install/bundlePOSTadmin sessionInstaller bundle.