---
title: "Replace a draft's document"
method: PATCH
path: "/posts/{id}"
tags: ["Authoring"]
---

# Replace a draft's document

`PATCH /posts/{id}`

## Request

- Base URL: `https://api.sweetvaluelab.com`
- URL: `https://api.sweetvaluelab.com/posts/{id}`
- Auth: HTTP bearer

Send the WHOLE document again, not a patch of fields. Allowed while the post is `draft` or `rejected`; editing a rejected post makes it a draft again and clears the rejection note. The language is read from the text again on each save (or send `lang` to override it); `slug` may be changed.

## Request body

- object
  - `markdown` string, required: The whole post, frontmatter included.
  - `slug` string

## Other responses

- `400`: `bad_request`: no `markdown`, or a non-integer id.
- `401`: No credential, or a token that is unknown, revoked or expired. The response carries `WWW-Authenticate: Bearer realm="sweetvaluelab"`; `error.code` is `unauthenticated`.
- `404`: `not_found`: no post with that id on this account.
- `409`: `not_editable`: the post is in review or published.
- `413`: `too_large`: the document is over 100 kB.
- `422`: The document has errors. `error.code` is `precheck_failed` and `error.details.issues` lists every finding (see `PrecheckIssue`); fix the `error` ones and send it again.

---

[API](https://skmtc.dev/sweetvaluelab/apis/sweetvaluelab-api.md) · [All operations](https://skmtc.dev/sweetvaluelab/apis/sweetvaluelab-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sweetvaluelab/apis/sweetvaluelab-api/revisions/6990fff94d5e?raw)
