← Markdown to Word
Your token

Markdown to Word API

Reading Markdown, the checks and the Word file all run free in the browser and need no API. The API is for the one metered step: send the document as numbered blocks, and get back, as JSON, a title when there is none, new headings (where each goes, its level and its text, built from the words of its own section) and callouts (which paragraph, which kind). The page builds this input for you and checks every heading before it is added; your own words are never rewritten.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "structure".

taskWhat it doesReply
structureAdds a title, headings that split sections over 300 words, and up to 4 callouts.One JSON object

Input fields

Every field is a string; blocks and facts hold JSON text. All three are required.

FieldMeaning
task"structure"
blocksJSON list of every block in order: {id, kind, words, text}, plus level for headings. id is b1, b2, ...; kind is heading, paragraph, list, table, code, formula, quote, callout or rule; words is the full word count; long text is cut and ends with " ...". 4 to 220 blocks and at least 150 words.
facts{has_title, title, block_count, word_count, headings_max, callouts_max, section_max_words, new_section_min_words, long_sections}, computed from the blocks. headings_max is word_count / 90 (1 to 30); callouts_max is paragraphs / 4 (0 to 4).

The reply

job.output.output is text holding one JSON object: title (a string, empty when the document has one), headings, a list of {before, level, text}, and callouts, a list of {block, kind} with kind note, tip, warning or key. Before using it, check it as the page does: title 2 to 10 words; headings in order, before a non-heading block that does not come straight after an existing heading, level 1 to 3 with no gaps, 1 to 8 words, every word of 4+ letters found in its own section, no repeats; each new section 2+ blocks or 60+ words; afterwards no section of 2+ blocks over 300 words; callouts on paragraphs of 80 words or fewer, not next to each other, warnings only on paragraphs with a warning word. If the balance ran low, truncated is true and the object may stop early; the page keeps every heading that arrived whole.

Worked example

Input (input.json, shortened), notes from a website relaunch meeting with no headings:

{
  "task": "structure",
  "blocks": "[{\"id\": \"b1\", \"kind\": \"paragraph\", \"words\": 4, \"text\": \"Website relaunch - planning notes\"}, {\"id\": \"b2\", \"kind\": \"paragraph\", \"words\": 51, \"text\": \"We met to agree the plan for relaunching the website before the spring campaign. Present: design, content, engineering and the marketing lead. The current site is three years old, slow on phones, and the team cannot update pages without asking engineering for help, which is the main reason for the relaunch.\"}, {\"id\": \"b3\", \"kind\": \"paragraph\", \"words\": 55, \"text\": \"The goal is a faster site that the marketing team can edit on its own. Success means pages load in under two seconds on a mid-range phone, the five most visited pages keep their addresses so search traffic is not lost, and marketing can publish a new landing page in a day without a developer.\"}, ...]",
  "facts": "{\"has_title\":false,\"title\":\"\",\"block_count\":14,\"word_count\":530,\"headings_max\":5,\"callouts_max\":3,\"section_max_words\":300,\"new_section_min_words\":60,\"long_sections\":[{\"from\":\"b1\",\"to\":\"b14\",\"words\":530,\"under\":\"\"}]}"
}

Reply:

{
 "title": "Website relaunch planning notes",
 "headings": [
  {
   "before": "b2",
   "level": 1,
   "text": "Relaunch goal and success"
  },
  {
   "before": "b4",
   "level": 1,
   "text": "Design directions and content review"
  },
  {
   "before": "b7",
   "level": 1,
   "text": "Engineering migration and budget"
  },
  {
   "before": "b10",
   "level": 1,
   "text": "Analytics, timeline and action items"
  }
 ],
 "callouts": [
  {
   "block": "b3",
   "kind": "key"
  },
  {
   "block": "b6",
   "kind": "warning"
  },
  {
   "block": "b9",
   "kind": "warning"
  }
 ]
}

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above, or a required field is missing or empty.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://markdown-to-word.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"markdown-to-word"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "structure", "blocks": "[...]", "facts": "{...}"}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="markdown-to-word:structure:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: title, headings, callouts
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: markdown-to-word:structure:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json