$ cli-blog docs
Quickstarts by surface

Call the REST API

Create a draft through HTTP and read the published post from any technology.

Use this quickstart when your technology can send HTTP requests and you do not need a language-specific client.

Create a draft

Send a private key in the x-api-key header:

POST=$(curl -sS "https://api.cli-blog.com/v1/posts" \
  --header "x-api-key: $CLI_BLOG_PRIVATE_API_KEY" \
  --header "content-type: application/json" \
  --data '{
    "title": "Shipping an API-first blog",
    "locale": "en-US",
    "body_markdown": "## What shipped\n\nA reviewed product update.",
    "status": "draft"
  }')

The response contains the ID and version required for later updates:

printf '%s' "$POST" | jq '{ id, slug, status, version }'

Publish after review

Use the returned version to prevent publishing an unseen update:

POST_ID=$(printf '%s' "$POST" | jq -r '.id')
POST_VERSION=$(printf '%s' "$POST" | jq -r '.version')

curl -sS "https://api.cli-blog.com/v1/posts/$POST_ID" \
  --header "x-api-key: $CLI_BLOG_PRIVATE_API_KEY" \
  --header "content-type: application/json" \
  --data "$(jq -n --argjson version "$POST_VERSION" \
    '{ status: "published", expected_version: $version }')"

Read published content

Switch to a public key for delivery:

curl -sS "https://api.cli-blog.com/v1/posts?status=published&fields=summary" \
  --header "x-api-key: $CLI_BLOG_PUBLIC_API_KEY"

Continue with API keys and the merged Posts resource and API guide.

On this page