mainwp-comments category. All use the mainwp/ namespace on your MainWP Dashboard.
Use these abilities when a script, AI assistant, or MCP client needs to review or moderate comments across your child sites. For example, you can list pending comments on your client sites, approve the legitimate ones, and move spam to Trash. Two abilities read live comments from child sites, one reads the recent comments stored at the last sync, one applies reversible moderation actions, and one previews or permanently deletes trashed comments.
What You’ll Learn
- List comments from your child sites with status, keyword, date, and post filters
- Read one comment from a child site
- Read the recent comments saved at the last sync without contacting child sites
- Approve, unapprove, spam, unspam, trash, and restore comments with status checks
- Preview and confirm the permanent deletion of trashed comments
Prerequisites
- WordPress 6.9 or later on the MainWP Dashboard site
- MainWP Dashboard with Abilities API support; use version 6.2 or later for the
input_jsonexamples below - Comments Add-on 6.1.0 or later, active in MainWP Dashboard
- A current MainWP Child build supporting the Comments v2 contract on target sites for
mainwp/get-comment-v1,mainwp/moderate-comments-v1, andmainwp/delete-comments-permanently-v1. An older or unreadable response fails rather than confirming an action. - An authenticated WordPress user with permission to use MainWP abilities and access to the Comments Add-on
Available Abilities
Discover the abilities and their full input and output schemas:
readonly: true. mainwp/moderate-comments-v1 is marked readonly: false, destructive: false, and idempotent: true. mainwp/delete-comments-permanently-v1 is marked destructive: true and idempotent: false.
Comments returned by these abilities never include the author’s email address, IP address, or URL.
List Comments
Ability:mainwp/list-comments-v1Method: GET The ability asks each selected child site for its comments. All inputs are optional. Without input, it reads up to 50 approved and pending comments from each of the first 100 sites you can access.
comment_dateis a Unix timestamp. An unusable timestamp can fail that site’s read.post_idis0when the comment is not attached to a post.site_resultshas one entry per site on the page. A failed site does not stop the others, andpartialistruewhen some sites succeeded and some failed.paginationpages over sites, not comments. Whenhas_moreistrue, request the nextpage.
end_date. Equal start and end dates return no matches.
When every selected site fails, the ability returns mainwp_comments_child_error with HTTP 502.
Get a Comment
Ability:mainwp/get-comment-v1Method: GET Reads one comment directly from the child site. Both inputs are required positive integers:
site_id and comment_id.
comment_status is approved, pending, spam, trash, or post-trashed (the comment’s post is in Trash). observed_at is the UTC time the Dashboard received the result. Use this ability to check a comment’s current status before you moderate it. A comment without an attached post can appear in list results as post_id: 0, but the current v2 detail reader rejects it.
List Synced Recent Comments
Ability:mainwp/list-synced-recent-comments-v1Method: GET Returns the recent comments the Dashboard stored during the last completed site sync. It does not contact child sites, so it is fast, but the data is only as current as the last sync. Each sync stores at most five approved and five pending comments per site. All inputs are optional.
source (always dashboard_sync_cache), snapshot_limit_per_status (always 5), comments, site_results, total, partial, and pagination. Each comment also carries site_id and last_sync, the UTC time of the sync that stored it.
Each entry in site_results has a status:
When
possibly_truncated is true for a site, a selected status reached the five-comment limit, so the site may have more comments. Use mainwp/list-comments-v1 to read them live.
Moderate Comments
Ability:mainwp/moderate-comments-v1Method: POST Applies one reversible action to up to 100 comments on one site. Each item names a comment and the status you expect it to have. The child site changes a comment only when its current status matches
expected_status, so a comment that someone else moderated in the meantime is not changed by mistake.
results has exactly one entry for every requested comment, with one of these outcomes:
Read each comment again after a failed or unknown result before deciding whether to retry. Repeating an already applied action can return a conflict or not-found result.
Successful changes are recorded in Network Activity.
Permanently Delete Comments
Ability:mainwp/delete-comments-permanently-v1Method: POST Deletes up to 100 comments on one site. Only comments in Trash can be deleted, so every item must use
"expected_status": "trash".
Set exactly one of
dry_run and confirm to true. Sending both as true or both as false returns mainwp_comments_confirmation_required with HTTP 400.
1
Preview the deletion
Send the request with
"dry_run": true and "confirm": false. Comments that would be deleted return the outcome would_delete.2
Confirm the deletion
After the user approves the preview, send the same items with
"dry_run": false and "confirm": true.eligible counts the comments that were in Trash before processing, and deleted counts the comments confirmed gone afterward. Each result has one of these outcomes: would_delete (preview only), deleted, conflict (the comment is not in Trash), not_found, or failed.
Handle Errors
WordPress can reject invalid input against the public schema before the Add-on callback runs. MainWP Dashboard also returns HTTP 401 for unauthenticated requests.
Related Resources
- Comments - Manage comments across your child sites
- Add-on Endpoints - Comments REST API reference
- Abilities API Overview - Authentication and request formats
- MCP Server Overview - Use abilities from AI assistants
