Extract document data

Extract text, headings, links, or summary metadata from one document. All routes require a bearer token and use POST with a JSON body.

Routes

Route Required fields Result result_format
/v1/document/extract/text source, input_format Plain extracted text. text
/v1/document/extract/toc source, input_format Heading rows with level, text, and anchor. json_structured
/v1/document/extract/links source, input_format Link rows with href and text. json_structured
/v1/document/extract/meta source, input_format characters, words, headings, links, and first_heading. json_structured

Request fields

Field Required Type Description
source Yes String Non-empty document content. Leading and trailing whitespace is removed before processing.
input_format Yes String Supported input format name or dashed UUID.
bbcode No Object BBCode parsing options. Takes precedence over bbcode_options.
bbcode_options No Object BBCode parsing options if bbcode is absent.
job_ttl No Integer Retention for the extraction job record in seconds. Defaults to 3600 and is constrained to 60 through 86400.
metadata No Object Caller metadata stored with the retained job record; it does not alter extraction.
filename No String Source filename stored with the retained job record.
locale No String Source locale stored with the retained job record.
options No Object Additional data stored with the retained job record; current extraction handlers do not apply this object.

An empty source fails with source is required; an unsupported source format fails with unsupported input_format.

Every successful route returns input_format, result, result_format, warnings, issues, and metadata in data.

Extract a table of contents

curl -sS https://api.document.m7.org/v1/document/extract/toc \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "source": "# Introduction\n\n## Installation",
    "input_format": "markdown"
  }'
{
  "status": 1,
  "comment": "EXTRACT_TOC",
  "data": {
    "input_format": "markdown",
    "result": [
      {
        "level": 1,
        "text": "Introduction",
        "anchor": "introduction"
      },
      {
        "level": 2,
        "text": "Installation",
        "anchor": "installation"
      }
    ],
    "result_format": "json_structured",
    "warnings": [],
    "issues": [],
    "metadata": {
      "result_format": "json_structured"
    }
  }
}