Skip to content

Markdown to HTML API

Overview

Convert Markdown to HTML. Body mode converts synchronously; URL and file modes submit an asynchronous job.

The converter supports .txt and .md inputs. Its Markdown renderer supports tables, autolinks, strikethrough, task lists, and tag filtering.

Endpoint

POST https://api.apidatatools.com/markdown-to-html-api

Authentication

Include your API key in the x-api-key header with every request.

Input modes

Mode Behavior
body Sends raw Markdown text and converts it synchronously. This is the default mode.
url Submits a URL to a supported input file for asynchronous conversion.
file Submits a pre-uploaded file reference for asynchronous conversion.

Headers

Header names are case-insensitive. Use the lowercase spellings shown here.

Header Type Required Default / values Description
x-api-key String Yes Your API key Authenticates the request.
x-source-type String No Default: body. Values: body, url, file Selects the input mode.

Accepted file extensions

URL and file modes accept .txt and .md files.

Request body

Body mode

Send the Markdown as raw text—not as a JSON object.

URL mode

Send a JSON object with a url property containing an http or https URL to a supported file:

{"url":"https://example.com/input.md"}

File mode

Send a JSON object with a file property containing the exact storage key returned by the upload workflow:

{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}

curl examples

Body mode

curl -X POST 'https://api.apidatatools.com/markdown-to-html-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  --data-raw '# Hello'

URL mode

curl -X POST 'https://api.apidatatools.com/markdown-to-html-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: url' \
  -H 'Content-Type: application/json' \
  --data '{"url":"https://example.com/input.md"}'

File mode

curl -X POST 'https://api.apidatatools.com/markdown-to-html-api' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'x-source-type: file' \
  -H 'Content-Type: application/json' \
  --data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'

Success responses

Synchronous body mode

A successful conversion returns HTTP 200. The file value is a temporary download URL; preview contains a preview of the converted HTML.

{
  "request_id": "REQUEST_ID",
  "status": "success",
  "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
  "preview": "<h1>Hello</h1>"
}

Asynchronous URL and file modes

A successful job submission returns HTTP 202:

{
  "status": "accepted",
  "job_id": "JOB_ID",
  "status_url": "https://api.apidatatools.com/jobs/JOB_ID",
  "request_id": "REQUEST_ID"
}

Async job status

Check a submitted job with:

GET https://api.apidatatools.com/jobs/{job_id}

Include x-api-key on the status request as well. The response includes request_id, job_id, status, created_at, and updated_at. Timestamps are integers.

Queued or processing

For queued and processing jobs, the response also includes a message and retry interval:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "queued",
  "created_at": 1730000000,
  "updated_at": 1730000000,
  "message": "Your job is being processed.",
  "retry_after": 2
}

The status value may be queued or processing.

Success

A completed job includes a result object:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "success",
  "created_at": 1730000000,
  "updated_at": 1730000002,
  "result": {
    "status": "success",
    "file": "https://downloads.apidatatools.com/OUTPUT_FILE",
    "preview": "<h1>Hello</h1>"
  }
}

Failed

A failed job includes an error object:

{
  "request_id": "REQUEST_ID",
  "job_id": "JOB_ID",
  "status": "failed",
  "created_at": 1730000000,
  "updated_at": 1730000002,
  "error": {
    "code": "ERROR_CODE",
    "message": "Error message",
    "details": {}
  }
}

Error handling

Error responses use this envelope:

{
  "status": "error",
  "error": "ERROR_CODE",
  "request_id": "REQUEST_ID",
  "details": {
    "message": "Description of the error"
  }
}

Additional fields may appear in details. The HTTP statuses below are based on the endpoint and status-handler behavior.

HTTP status Error codes When it can occur
400 EMPTY_BODY, INVALID_BODY_ENCODING, INVALID_SOURCE_TYPE, MISSING_INPUT_FILE, EMPTY_MARKDOWN, INVALID_UTF8, MARKDOWN_TO_HTML_ERROR Invalid or empty request input, or a conversion error.
400 INVALID_BODY, INVALID_URL, URL_UNREACHABLE, URL_NOT_OK, INVALID_FILE, FILE_UNAVAILABLE, INVALID_FILE_EXTENSION Invalid URL/file-mode request or input unavailable or unsupported.
400 INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, DDB_ERROR Status request has a missing or unknown job ID, does not have access to the job, or encounters a job lookup error.
401 UNAUTHORIZED Authentication is missing or invalid.
404 USER_NOT_FOUND, UNKNOWN_FUNCTION The authenticated user or requested API endpoint is not found.
413 PAYLOAD_TOO_LARGE, FILE_TOO_LARGE The request body or input file exceeds the applicable limit.
429 QUOTA_EXCEEDED, RATE_LIMITED The account’s quota or rate limit has been reached.
500 PLAN_NOT_FOUND, CONFIG_ERROR, PLAN_CONFIG_ERROR, INTERNAL_ERROR Plan configuration, asynchronous job configuration, or request processing fails.

Asynchronous processing failures are reported in the job’s failed status response rather than as a new HTTP response to the original submission. These can include INVALID_JOB, DOWNLOAD_FAILED, FILE_TOO_LARGE, UPLOAD_FAILED, or INTERNAL_ERROR.

Notes

  • Request-body and file-size limits, quotas, rate limits, and download retention depend on your plan. See API tool limits.
  • Download URLs are temporary; retention depends on your plan.