Submit and approve a content draft
Approval records which version of a draft the reviewer accepted. The editor and approver should both read the current revision before changing its state.
Before you start
Use Optimizer and set BRAND_ID and DRAFT_ID to an existing editorial draft. For reads, use optimizations:read. Both keys need analytics:read and current rights to the source content to see the copy. Submission and approval also need optimizations:write. Load the editor, owner or service key for submission into EDITOR_KEY. Use an approver or owner key in APPROVER_KEY for the approval.
1. Read the editor’s copy
curl --fail-with-body "https://api.aeoapi.dev/v2/brands/$BRAND_ID/drafts/$DRAFT_ID" \
-H "Authorization: Bearer $EDITOR_KEY"Check the title and body. You can submit a draft whose data.status is draft or changes_requested. Set REVISION to the integer in data.revision.
2. Submit the revision
curl --fail-with-body -X PATCH "https://api.aeoapi.dev/v2/brands/$BRAND_ID/drafts/$DRAFT_ID" \
-H "Authorization: Bearer $EDITOR_KEY" \
-H 'Content-Type: application/json' \
--data-binary @- <<JSON
{"transition":"submit","expected_revision":$REVISION}
JSONThe draft moves to in_review. Give the reviewer the brand and draft IDs. The reviewer should read the draft with their own key and check the actual content. If it needs changes, send transition: "request_changes" with the current expected_revision and a note for the editor.
3. Approve the copy the reviewer read
Set REVIEW_REVISION and CONTENT_SHA256 to data.revision and data.content_sha256 from the reviewed copy. The checksum identifies its exact content.
curl --fail-with-body -X PATCH "https://api.aeoapi.dev/v2/brands/$BRAND_ID/drafts/$DRAFT_ID" \
-H "Authorization: Bearer $APPROVER_KEY" \
-H 'Content-Type: application/json' \
--data-binary @- <<JSON
{
"transition": "approve",
"expected_revision": $REVIEW_REVISION,
"content_sha256": "$CONTENT_SHA256"
}
JSONCheck for data.status of approved and save data.approved_content_sha256. If another edit causes HTTP 409, read the new revision and review it before trying again. After approval, a publisher or owner can hand off the approved draft with its checksum and destination.