/api/v1/generate/slugsGenerate slugs API
Slugify a list of heading titles.
POST /api/v1/generate/slugs slugifies a batch of heading titles using the GitHub-compatible algorithm. Duplicates get `-1`, `-2` suffixes so links remain stable across a single document.
Overview
Apply the same slugify algorithm that powers `/api/v1/render` heading anchors and GitHub's heading ids. Duplicate inputs get `-1`, `-2` suffixes so the slugs stay stable.
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/generate/slugs' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"headings":["Hello world","Hello world"]}'Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
| headings | string[] | required | Heading titles. Max 1000 entries. |
Response
Success responses are wrapped in a data field. Errors use { error: { code, message } } with an appropriate HTTP status — see the error reference.
{
"data": {
"slugs": [
{
"input": "Hello world",
"slug": "hello-world"
},
{
"input": "Hello world",
"slug": "hello-world-1"
}
]
}
}Use cases
Anchor links
Pre-compute anchors when generating TOCs outside the renderer.
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.