/api/v1/extract/outlineExtract outline API
Headings with level, slug, and line number.
POST /api/v1/extract/outline returns every heading in a markdown document with its level, text, slug id, and line number. The exact data structure you need to render a sidebar table of contents.
Overview
Pull the document's heading hierarchy (h1 through h6). Each item has a level, text, GitHub-style slug `id`, and 1-based line number. The slug ids match the anchors emitted by /api/v1/render.
Request
Authenticate with Authorization: Bearer YOUR_API_KEY and send a JSON body containing the parameters below. Pick your language:
curl -X POST 'https://trymarkdownviewer.com/api/v1/extract/outline' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown":"# Title\n\n## Section"}'Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
| markdown | string | required | Markdown source. |
Response
Success responses are wrapped in a data field. Errors use { error: { code, message } } with an appropriate HTTP status — see the error reference.
{
"data": {
"headings": [
{
"level": 1,
"text": "Title",
"id": "title",
"line": 1
},
{
"level": 2,
"text": "Section",
"id": "section",
"line": 3
}
],
"count": 2
}
}Use cases
Sidebar TOC
Render a sticky right-rail TOC for a long-form article.
Doc indexing
Build a search index keyed by heading text and id.
Related endpoints
Try in browser
Free tools that run the same logic locally — no API key, no upload.
Try it
Send a real request against your account in the API playground. Errors there link straight back to the error reference.