xtract.bot
POST /api/markdown-toc

Build a Markdown table of contents from your document's headings. Configurable depth, optional anchor links matching popular renderers (GitHub, etc.).

Scans a Markdown document for `#` / `##` / etc. headings and returns a table of contents — both as a nested JSON structure and as a Markdown-formatted bullet list ready to drop into your README. Options: - `maxDepth` (default 3): include headings down to this level (`1` = top-level only, `6` = everything). - `anchorStyle`: how to slugify each heading. `github` (default) matches GitHub's scheme so the links work in rendered READMEs.

Inputs

NameTypeDefaultDescription
markdown*stringMarkdown source to scan.
maxDepthnumber (1…6)3Deepest heading level to include.
minDepthnumber (1…6)1Shallowest heading level to include.
slugenum (github | hugo)"github"Slug algorithm. `github` matches GitHub anchors; `hugo` matches Hugo's default rules.
skipFirstH1booleanfalseWhen true, drop the first H1 (commonly the document title).

Response

Modes: json. Cache: yes (24h TTL).

Code samples

Built from the default-depth-3 example.


curl -X POST https://api.xtract.bot/api/markdown-toc \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "markdown": "# Title\n\n## Setup\n\n### Install\n\n### Configure\n\n## Usage\n\n#### Edge cases (skipped)\n"
}'