save REST endpoint
Save an atomic draft or publish content and related metadata after permission, validation, and conflict checks.
Endpoint#
Save an atomic draft or publish content and related metadata after permission, validation, and conflict checks.
/wp-json/cantata-edit/v1/save
Named regular-expression groups in this registered route are path parameters. Replace them with an actual matching value when constructing a request.
POST#
This operation uses a server permission callback. Browser clients need an authenticated WordPress session and REST nonce. The server checks the relevant caller capability and feature gates.
Permission expression in this release:
'permission_callback' => static fn( $req ) => current_user_can( 'edit_post', (int) $req['post_id'] ),
Registered argument schema#
{
"post_id": {
"type": "integer",
"required": true
},
"title": {
"type": "string"
},
"content": {
"type": "string"
},
"parts": {
"type": "object"
},
"publish": {
"type": "boolean",
"default": false
},
"base": {
"type": "object"
},
"force": {
"type": "boolean",
"default": false
},
"blocks": {
"type": "array"
},
"seo": {
"type": "object"
}
}
WordPress applies these registered field rules before the callback. Feature-specific validation can add further constraints.
Callback input keys#
base, blocks, content, force, parts, post_id, publish, scope, seo, title. This literal-key inventory supplements the registered schema; nested objects and downstream validators can define additional structure.
Implementation#
- cantata_edit_rest_save
- cantata_edit_already_saved
- cantata_edit_atomic
- cantata_edit_blocks_mode
- cantata_edit_has_draft
- cantata_edit_history_url
- cantata_edit_page_rev
- cantata_edit_part_already_saved
- cantata_edit_part_draft
- cantata_edit_part_post
- cantata_edit_part_published
- cantata_edit_part_rev
- cantata_edit_revs
- cantata_edit_sanitize_saved_content
- cantata_edit_save_blocks
- cantata_edit_save_writes
- cantata_edit_validate_part
- cantata_edit_without_kses
Client handling#
Use HTTPS on production sites. Treat authentication failures, validation errors, missing records, and stale-revision conflicts as different outcomes. Read the returned WordPress error code and message. Before retrying a timed-out mutation, determine whether the first request succeeded. Prefer the documented higher-level editor or Ability workflow when an endpoint coordinates several metadata owners.