Approvals API
Request and record approvals on merge requests and publications.
Approval methods let you request sign-off from reviewers and record their approve or reject decisions on a merge request or a direct publication. They live at cms.api.<collection>.<method> and mirror on the client at client.<collection>.<method> with identical types. Examples below use pages as the sample collection. An approval targets either a merge request or a direct publication (a branch's head commit); the targetType field reflects which.
These methods record approvals against an existing commit, they don't produce content commits, so none returns the commit: { id, message, createdAt, createdBy } envelope that commit-producing mutations elsewhere in the API return.
Request Approval
Ask one or more reviewers to sign off on a merge request or a branch's head commit (a direct publication). Each reviewer gets their own pending approval and a notification. Provide exactly one of mergeRequestId or branchId.
approval:create/{collection}/requestApprovalconst data = await cms.api.pages.requestApproval({
body: {
branchId: 'br_9f2a1c', // required (or mergeRequestId, exactly one)
requestedReviewers: ['user_editor', 'user_legal'], // required
message: 'Ready for review before publishing.',
},
});const { data, error } = await client.pages.requestApproval({
body: {
branchId: 'br_9f2a1c', // required (or mergeRequestId, exactly one)
requestedReviewers: ['user_editor', 'user_legal'], // required
message: 'Ready for review before publishing.',
},
});requestedReviewersstring[]requiredUser IDs to request approval from (non-empty, unique).
mergeRequestIdstringMerge request to request approval on. Provide exactly one of `mergeRequestId` or `branchId`.
branchIdstringBranch whose head commit to request approval on (direct publication). Provide exactly one of `mergeRequestId` or `branchId`.
messagestringMessage sent to reviewers with the request.
approvalsApproval[]One newly created pending approval per requested reviewer. Each carries `id`, `status` (`pending`), `mergeRequestId`, `branchId`, `commitId`, `requestedBy`, `requestedReviewer`, `targetType`, and timestamps.
List Approvals
Page through approvals, filtered by status, target, requester, or reviewer, so you can build a review queue or an audit trail. Approvals on archived entries are left out, and every query field is optional.
approval:read/{collection}/listApprovalsconst data = await cms.api.pages.listApprovals({
query: { status: 'pending', requestedReviewer: 'user_editor', limit: 20 },
});const { data, error } = await client.pages.listApprovals({
query: { status: 'pending', requestedReviewer: 'user_editor', limit: 20 },
});limitnumber= 20Page size, 1 to 100.
offsetnumber= 0Rows to skip.
status'pending' | 'approved' | 'rejected'Filter by approval status.
mergeRequestIdstringFilter by merge request.
branchIdstringFilter by branch.
commitIdstringFilter by commit.
requestedBystringFilter by the user who requested the approval.
requestedReviewerstringFilter by the requested reviewer.
reviewedBystringFilter by the user who reviewed the approval.
targetType'mergeRequest' | 'publication'Filter by target: merge-request approvals or direct-publication approvals.
approvalsApproval[]The approvals on this page, newest first. Each carries the full approval record, plus enriched `requestedByUser` / `requestedReviewerUser` / `reviewedByUser` (`ExposedUser`) when user enrichment is enabled.
totalnumberTotal approvals matching the filters across all pages, ignoring limit/offset.
hasMorebooleanWhether more approvals exist after this page.
Get an Approval
Fetch a single approval by id, with its requester, requested reviewer, and reviewer enriched as full user profiles (when user enrichment is enabled), so you can render who asked and who signed off.
approval:read/{collection}/getApprovalconst data = await cms.api.pages.getApproval({
query: { approvalId: 'apr_1a2b3c' }, // required
});const { data, error } = await client.pages.getApproval({
query: { approvalId: 'apr_1a2b3c' }, // required
});approvalIdstringrequiredApproval id to fetch.
approvalApprovalThe approval record: `id`, `status`, `mergeRequestId`, `branchId`, `commitId`, `requestedBy`, `requestedReviewer`, `reviewedBy`, `message`, `rejectionReason`, `reviewedAt`, `createdAt`, `updatedAt`, `targetType`. When user enrichment is enabled it also carries `requestedByUser`, `requestedReviewerUser`, and (once reviewed) `reviewedByUser` as `ExposedUser` profiles.
Approve a Request
Approve a pending approval as its requested reviewer. Only that reviewer may approve it, and for a direct-publication approval it fails if the branch head has moved since the request went out.
approval:update/{collection}/submitApprovalconst data = await cms.api.pages.submitApproval({
body: { approvalId: 'apr_1a2b3c' }, // required
});const { data, error } = await client.pages.submitApproval({
body: { approvalId: 'apr_1a2b3c' }, // required
});approvalIdstringrequiredApproval to approve (must be pending).
approvalApprovalThe now-approved record, with `status` set to `approved`, `reviewedBy` set to you, and `reviewedAt` timestamped.
Reject a Request
Reject a pending approval, optionally recording why. The same requested-reviewer and staleness rules as submitApproval apply.
approval:update/{collection}/submitRejectionconst data = await cms.api.pages.submitRejection({
body: {
approvalId: 'apr_1a2b3c', // required
rejectionReason: 'Needs revision before publishing.',
},
});const { data, error } = await client.pages.submitRejection({
body: {
approvalId: 'apr_1a2b3c', // required
rejectionReason: 'Needs revision before publishing.',
},
});approvalIdstringrequiredApproval to reject (must be pending).
rejectionReasonstringReason recorded on the rejection.
approvalApprovalThe now-rejected record, with `status` set to `rejected`, your `rejectionReason` recorded, `reviewedBy` set to you, and `reviewedAt` timestamped.
Cancel a Request
Cancel a pending approval, deleting the request outright. Only pending approvals can be canceled; an already-approved or rejected one can't be undone this way.
approval:delete/{collection}/cancelApprovalconst data = await cms.api.pages.cancelApproval({
body: { approvalId: 'apr_1a2b3c' }, // required
});const { data, error } = await client.pages.cancelApproval({
body: { approvalId: 'apr_1a2b3c' }, // required
});approvalIdstringrequiredPending approval to cancel.
approvalIdstringThe id of the canceled (deleted) approval, echoed back.