Frontmatter
What it is
Section titled “What it is”One call that takes a Markdown document, reads the YAML block between the --- lines at the top, and returns it as JSON next to the rest of the document as body. A document without frontmatter returns frontmatter: null and the whole text as body.
When to use it
Section titled “When to use it”- Your agent’s cue: it has to read or index Markdown files that carry metadata at the top: blog posts, docs pages, notes, agent instructions.
- You’ll reach for it when a hand-written YAML parser in the app has failed on the third file with a tab, a quote or a date in it.
Real use cases
Section titled “Real use cases”Building without a terminal
Section titled “Building without a terminal”You are building a blog in Base44 that imports posts written as Markdown files. A backend function sends each file to MarkdownScribe and stores frontmatter as the post’s metadata and body as its content. date: 2026-10-13 comes back as the string "2026-10-13" and start: 12:30 as "12:30", exactly as written, so the post’s date never shifts by a timezone and a time never turns into a number of minutes.
Working with a coding agent
Section titled “Working with a coding agent”Your coding agent generated a batch of pages and one of them has a nested mapping on the wrong line. The call returns invalid_frontmatter with kind, line and column, counted from the first line of the document, plus the parser’s message. The agent opens the file at that position and fixes it; a document with no frontmatter at all is not an error.
In a pipeline
Section titled “In a pipeline”A build step validates every page before publishing with mdscribe frontmatter docs/. A page with a tab in the indentation, a block that is a list instead of key/value pairs, or a +++ block that is not YAML fails the step with exit code 5 and the error’s kind, line, column and message in the log. Pages that pass print their fields as JSON, ready to feed the next step.
Why through the API
Section titled “Why through the API”- Values as the author wrote them. Dates and times stay strings; nothing is converted to a timestamp or a number behind your back.
- Errors with a position. When the YAML cannot be used, you get the line and column and a reason, not a
nullthat looks like a document without frontmatter. - Nothing executes. The frontmatter is data. Whatever a file contains, parsing it runs no code.
Copy-ready example
Section titled “Copy-ready example”curl https://api.markdownscribe.com/v1/md/frontmatter \ -H "X-API-Key: $MDSCRIBE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"markdown":"---\ntitle: Release notes\ndate: 2026-10-13\nstart: 12:30\ntags: [api, markdown]\n---\n\n# Release notes\n\nWhat changed this week.\n"}'TypeScript SDK
Section titled “TypeScript SDK”import { MarkdownScribeClient } from "@markdownscribe/sdk";
const client = new MarkdownScribeClient({ apiKey: process.env.MDSCRIBE_API_KEY! });const result = await client.frontmatter({ markdown: "---\ntitle: Release notes\ndate: 2026-10-13\nstart: 12:30\ntags: [api, markdown]\n---\n\n# Release notes\n\nWhat changed this week.\n",});Save the markdown value above as release-notes.md, then:
mdscribe frontmatter release-notes.mdResponse
Section titled “Response”Captured from the API on 2026-10-23.
{ "frontmatter": { "title": "Release notes", "date": "2026-10-13", "start": "12:30", "tags": [ "api", "markdown" ] }, "body": "\n# Release notes\n\nWhat changed this week.\n", "meta": { "request_id": "01M5MY6KH7WFYQC6RJFDTF6GNS", "duration_ms": 3, "credits": 1 }}Credits, limits and errors
Section titled “Credits, limits and errors”1 credit per call. Each response says what it cost in the X-Credits-Charged header. Error responses are never charged.
- Input:
markdown, up to 1,048,576 characters. The frontmatter must start on the first line, between---delimiters, and be a YAML mapping (key: valuepairs). - Output:
frontmatteris an object, ornullwhen the document has no frontmatter block.bodyis everything after the closing---.
| Error | When |
|---|---|
invalid_frontmatter |
The block is not valid YAML (invalid_yaml), is a list or a scalar instead of a mapping (not_an_object), or is not YAML at all, such as a TOML +++ block (unsupported_language). line and column point at the problem. Nothing is charged. |
validation |
markdown is missing or the body is not valid JSON. |
payload_too_large |
The document is longer than 1,048,576 characters. |
unauthorized, insufficient_credits, rate_limited |
The key, the balance or the per-minute limit, as on every operation. |
Alternatives, and when MarkdownScribe is worth it
Section titled “Alternatives, and when MarkdownScribe is worth it”Checked on 2026-10-23 against the tool’s own documentation.
- gray-matter.
npm install gray-matter, thenmatter(text)returnsdataandcontentin a Node.js program (github.com/jonschlinkert/gray-matter). Use MarkdownScribe when your agent runs where it cannot add a dependency (the Lovable or Base44 editor), when you want the parse error’s line and column in a fixed JSON shape, or when you want format, lint, table of contents and frontmatter from one key with one error format and one bill.