apyhub
Back
▣ INGESTION KIT · DOCUMENT INTELLIGENCE KIT

Convert Document to Markdown API

What it does

Document to Markdown converts a single office document, spreadsheet, slide deck, e-book, PDF or text file into Markdown. You send the file's name and its bytes as base64, and get back clean Markdown — tables for spreadsheets and CSVs, text with line breaks for PDFs — plus the detected format and the input and output sizes. It reads 28 formats including docx, xlsx, pptx, odt, epub, rtf, pdf, csv, html and json; it does not run OCR and does not send documents to an external AI model.

It has one endpoint, Convert a document to Markdown. Its filename picks the format by extension and contentBase64 carries the file, up to 3 MiB. Errors are specific — UNSUPPORTED_FORMAT, EMPTY_DOCUMENT, OCR_REQUIRED for scanned PDFs, CORRUPT_FILE — so a pipeline can tell a bad file from a bad request. Capacity is shared across buyers: 30 requests per minute and 10,000 per day.

Document to Markdown is a good fit when you need to feed office files and PDFs into search indexing, a RAG or language-model pipeline, or a content workflow that expects plain Markdown — without running your own document converters.

POST
Convert a document to Markdown
https://api.eu.apyhub.com/chensichengmalu/convert-document-to-markdown

QUICKSTART

GUIDE

Quickstart

curl -X POST "https://api.eu.apyhub.com/chensichengmalu/convert-document-to-markdown" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"filename":"document.csv","contentBase64":"bmFtZSxzY29yZQpBZGEsNDIK"}'

What you'll get back

The sample file is a two-line CSV (name,score / Ada,42); it comes back as a Markdown table:

{
  "markdown": "| name | score |\n| --- | --- |\n| Ada | 42 |\n",
  "format": "csv",
  "filename": "document.csv",
  "inputBytes": 18,
  "outputBytes": 44,
  "ocrUsed": false
}
TRY ITLIVE · 120 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
The file to convert: its name (for the format) and its bytes as base64.
The file's name, 1–255 characters, ending in a supported extension (it decides the format). Paths and control characters are stripped; HTML markup is rejected.
The file's bytes as standard padded base64 (ASCII spaces, tabs and line breaks allowed). At most 3 MiB decoded and 5 MiB for the whole JSON request.

About this endpoint

What it does

Converts one document — Word, Excel, PowerPoint, OpenDocument, EPUB, RTF, text-based PDF, CSV/TSV, HTML, JSON, XML or plain text — into Markdown. Send the file's name and its bytes as base64; you get back the Markdown plus the detected format and the input and output sizes. No OCR is done and the document is not sent to an external AI model.

Files can be up to 3 MiB (5 MiB for the whole JSON request, base64 included). Capacity is shared across all buyers: 30 requests per minute and 10,000 per UTC day; on 429, wait the Retry-After seconds.

Request Body

FieldTypeRequiredDescription
filenamestringYesThe file's name, 1–255 characters, ending in a supported extension — the extension decides how the file is read. Supported: csv, doc, docm, docx, epub, htm, html, json, md, odp, ods, odt, pdf, pot, pps, ppsm, ppsx, ppt, pptm, pptx, rtf, tsv, txt, xls, xlsb, xlsm, xlsx, xml. Paths and control characters are stripped; HTML markup in the name is rejected.
contentBase64string (base64)YesThe file's bytes as standard padded base64; ASCII spaces, tabs and line breaks are allowed, other invisible characters are rejected. At most 3 MiB once decoded. Text formats must be UTF-8.

Response

A JSON object with the converted Markdown and details about the conversion.

FieldTypeDescription
markdownstringThe document converted to Markdown, up to 5 MiB. Treat it as untrusted content if you render it as HTML.
formatstringFormat the file was read as — its lower-case extension, e.g. csv, docx, pdf.
filenamestringYour filename with any folder path and control characters removed.
inputBytesintegerSize of the decoded input file, in bytes.
outputBytesintegerSize of markdown in bytes (UTF-8).
ocrUsedbooleanAlways false: no OCR is run, so scanned pages are not read.

How formats convert

FormatResult
csv, tsv, xls, xlsx, xlsm, xlsb, odsMarkdown tables. The first row is the header; short rows are padded and extra columns get numbered headers.
pdfText with its line breaks kept; no headings are guessed. Image-only (scanned) PDFs return OCR_REQUIRED.
jsonThe JSON, pretty-printed in a json code block.
rtfText with bold formatting kept.
html, htmReadable text only — headings, lists, tables and links are not kept as Markdown. Scripts and styles are dropped.
txt, md, xmlThe text as-is.

Errors

StatuserrorMeaning
400INVALID_JSONThe request body isn't valid JSON.
4xxINVALID_BASE64contentBase64 isn't valid padded base64.
413—File over 3 MiB decoded, request over 5 MiB, or Markdown over 5 MiB.
422UNSUPPORTED_FORMATThe extension isn't one of the supported formats.
422EMPTY_DOCUMENTThe file has no readable text.
422OCR_REQUIREDA PDF with only images (scanned); it needs OCR, which isn't offered.
4xxCORRUPT_FILEThe file is damaged or not the format its extension says.
4xx—The file is password-protected.
429—Shared rate limit reached; retry after Retry-After seconds.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.