---
title: "Check a post, or save it as a draft"
method: POST
path: "/posts"
tags: ["Authoring"]
---

# Check a post, or save it as a draft

`POST /posts`

## Request

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

With `?dryRun=1`: run every check and save nothing; `data` is `{ dryRun: true, precheck }`. This costs no quota and is the call to repeat while revising.

Without it: save a draft and return `{ post, precheck }`. A draft is saved even when its check still has errors (so it can be fixed in place with PATCH); what cannot be saved is a document with no frontmatter, no title, no description, an empty body or an invalid slug, which answers 422.

Figures in the body must be images uploaded to this post, so a figure always fails the check until the draft exists and the image is uploaded — create first, upload, then PATCH.

## Query parameters

- `dryRun` '1'

## Request body

- PostDocument: A post as one Markdown document. The frontmatter keys are `title`, `description`, `date` (required) and `updated`, `tags`, `stocks`, `hero`, `heroAlt` (optional); any other key is an error, and `author` is ignored because the byline is the credential. See https://sweetvaluelab.com/write-for-us.md for every limit.
  - `markdown` string, required: The whole post: a `---` frontmatter block, then the body. At most 100 kB.
  - `lang` 'en' | 'zh': Optional, and normally left out: the edition is detected from the text on every save (Chinese when Han characters outnumber 1.5 × the Latin words, otherwise English), and an editor corrects a wrong guess in review. Send it only to override the detection.
  - `slug` string: The URL's last segment. Derived from the title when omitted.

## Other responses

- `400`: `bad_request`: no `markdown` string, or `lang` is not `en` / `zh`.
- `401`: No credential, or a token that is unknown, revoked or expired. The response carries `WWW-Authenticate: Bearer realm="sweetvaluelab"`; `error.code` is `unauthenticated`.
- `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.
- `429`: `quota_exceeded`: 10 drafts in the last 24 hours on this account. Dry runs do not count.

---

[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)
