API Quickstart

AAditya Kothadiya4 min readAvg. reading speed: 200 words per minuteLast updated Nov 28, 2026

Create a key, create a book, add a chapter written in Markdown, and publish it.

1. Create an API Key

  1. In the WebBooks app, go to Settings › Developers › API Keys. API keys come with the Professional plan and up.

  2. Name it ("Publishing script"), pick Full Access or the permissions you need, and press Create Key.

  3. The key starts with wb_key_ and is shown once. Keep it in an environment variable or a secret manager, never in code.

export WEBBOOKS_KEY="wb_key_…"

Note: Only want to write from Claude or ChatGPT? You don't need a key: connect the app and sign in, as the Connect AI Apps chapter shows.

The Python samples below assume this setup:

import os, requests

BASE = "https://api.webbooks.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['WEBBOOKS_KEY']}"}

2. Check the Key

curl

curl https://api.webbooks.ai/v1/me -H "Authorization: Bearer $WEBBOOKS_KEY"

JavaScript

const res = await fetch("https://api.webbooks.ai/v1/me", {
  headers: { Authorization: `Bearer ${process.env.WEBBOOKS_KEY}` },
});
console.log(await res.json());

Python

r = requests.get(f"{BASE}/me", headers=HEADERS)
print(r.json())

The answer shows the workspace and plan, what the key may do, the credit balance, the rate limits and what work costs.

3. Create a Book

curl

curl -X POST https://api.webbooks.ai/v1/books \
  -H "Authorization: Bearer $WEBBOOKS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "The First-Time Manager'"'"'s Field Guide",
       "description": "Practical habits for your first year leading a team."}'

JavaScript

const book = await fetch("https://api.webbooks.ai/v1/books", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBBOOKS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: "The First-Time Manager's Field Guide",
    description: "Practical habits for your first year leading a team.",
  }),
}).then((r) => r.json());

Python

book = requests.post(f"{BASE}/books", headers=HEADERS, json={
    "title": "The First-Time Manager's Field Guide",
    "description": "Practical habits for your first year leading a team.",
}).json()

Keep the returned id. A book with a description costs 0.5 credits, what writing a description costs in WebBooks (a title alone is free). The response headers X-Credits-Charged and X-Credits-Remaining show it.

4. Add a Chapter in Markdown

curl

curl -X POST https://api.webbooks.ai/v1/books/$BOOK_ID/chapters \
  -H "Authorization: Bearer $WEBBOOKS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: chapter-1-first-draft" \
  -d '{"title": "Your First One-on-One",
       "content": "## Before the meeting\n\nBlock 30 minutes and ask **one** question."}'

JavaScript

const chapter = await fetch(`https://api.webbooks.ai/v1/books/${book.id}/chapters`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBBOOKS_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "chapter-1-first-draft",
  },
  body: JSON.stringify({
    title: "Your First One-on-One",
    content: "## Before the meeting\n\nBlock 30 minutes and ask **one** question.",
  }),
}).then((r) => r.json());

Python

chapter = requests.post(f"{BASE}/books/{book['id']}/chapters",
    headers={**HEADERS, "Idempotency-Key": "chapter-1-first-draft"},
    json={
        "title": "Your First One-on-One",
        "content": "## Before the meeting\n\nBlock 30 minutes and ask **one** question.",
    }).json()

A chapter with text costs 2.5 credits, like writing one in WebBooks. The Idempotency-Key makes a retry safe: sending the same request again within 24 hours returns the first answer (with Idempotent-Replayed: true) instead of adding, and charging for, a second chapter. Add position to place it (0 is first); by default it goes at the end.

5. Publish

curl

curl -X POST https://api.webbooks.ai/v1/books/$BOOK_ID/publish \
  -H "Authorization: Bearer $WEBBOOKS_KEY"

JavaScript

await fetch(`https://api.webbooks.ai/v1/books/${book.id}/publish`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.WEBBOOKS_KEY}` },
});

Python

requests.post(f"{BASE}/books/{book['id']}/publish", headers=HEADERS)

Publishing is free and publishes every chapter that has text. The answer is the book (with its reader_url), chapters_published and any warnings. Readers see it on the reader site, subscribers are told as usual, and the book shows up in the app with everything else.

Tip: Before publishing, GET /books/{id}/preflight runs the same checks as the Publish dialog. It answers ok, problems (these block publishing, with 422) and warnings (empty chapters, a missing cover or description, broken images).

Every endpoint, with its parameters and a sample response, is in the REST API Reference chapter.