Skip to Content
APIEndpointsApply content edits

Apply content edits

Changes a draft’s body now with block edits, all of them or none. When teammates have the draft open in the editor, the change appears there too. The live page changes only when the draft is published.

  • Refused with 409 conflict while the draft has suggestions waiting for review.
  • Every apply returns an edit_id; Undo content edit reverses it while the edited blocks are unchanged.
  • A 500 means the outcome could not be confirmed: read the outline before sending the edits again. The hashes refuse a set that already landed.

Requires the write:content scope, and the workspace must be enabled for API writes.

POST /v1/brands/{brand_id}/content/{draft_id}/edits

Authorization

HeaderTypeRequired
AuthorizationBearer asky_sk_…required
Idempotency-Keystringrequired

Path parameters

ParameterTypeRequiredDescription
brand_iduuidrequiredFrom List brands
draft_iduuidrequiredFrom List content drafts

Query parameters

None.

Body

application/json, up to 1 MB.

FieldTypeRequiredDescription
editsarray, 1 to 40requiredBlock edits, below

Block edits

Body edits address the numbered blocks Get content outline returns. Each edit is one object:

FieldTypeRequiredDescription
op"replace" | "insert" | "delete"requiredreplace swaps block N, insert places new html before block N (N equal to the block count appends), delete removes block N
indexintegerrequiredBlock index from the outline
htmlstring, up to 20,000 charsfor replace and insertThe new html
base_hashstringrequired while the body has blocksThe outline’s hash for block N; for an append, the last block’s
  • Indexes are fixed: every index addresses the outline as you read it, never as changed by your other edits. To add several blocks in one place, send one insert per block, all with the same index, in reading order.
  • An edit whose base_hash no longer matches its block is refused with 409 conflict, and so is the whole set: read the outline again and rebuild the edits. Nothing is written.
  • Allowed tags: p, h1 to h5, ul, ol, li, blockquote, pre, code, strong, em, s, u, a, img, hr, br, table, tr, th, td. Anything else is removed before the edit is checked, as the editor would store it.
  • An img may only use an image already in the draft.
  • At most 40 edits per call, one per block.

Request

curl --request POST \ --url 'https://api.askylabs.com/v1/brands/242546de-4cee-4a7d-952e-f6aa60c63ef8/content/7c1e2b90-3f4d-4a8e-9b21-5d6f7a8b9c0d/edits' \ --header 'Authorization: Bearer <api-key>' \ --header 'Idempotency-Key: <unique-per-attempt>' \ --header 'Content-Type: application/json' \ --data '{"edits":[{"op":"insert","index":2,"html":"<h2>What a CRM costs</h2>","base_hash":"c41d9e07"},{"op":"insert","index":2,"html":"<p>Most small-team plans cost less than one hour of sales time a month.</p>","base_hash":"c41d9e07"}]}'

Response

{ "data": { "edit_id": "5e6f7a8b-9c0d-4e1f-a2b3-c4d5e6f7a8b9", "draft_id": "7c1e2b90-3f4d-4a8e-9b21-5d6f7a8b9c0d", "applied": 2, "undo_available": true, "review_url": "https://app.askylabs.com/content/7c1e2b90-3f4d-4a8e-9b21-5d6f7a8b9c0d", "live_page_updated": false, "translations_unchanged": [] }, "request_id": "req_7d21b0af59c34e18b6ac" }

Response fields

FieldTypeDescription
data.edit_iduuid | nullrequired. For undo; null when the edit could not be logged, and then it cannot be undone here
data.draft_iduuidrequired
data.appliedintegerrequired. Edits applied
data.undo_availablebooleanrequired
data.review_urlstringrequired
data.live_page_updatedbooleanrequired. Always false
data.translations_unchangedarrayrequired. The draft’s translations, which this edit does not touch
request_idstringrequired
Last updated on