cURL
Local file
curl -X POST "https://api.markpdf.tech/convert/raw?filename=report.pdf&mode=fast" \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/pdf" \
--data-binary @report.pdf
URL signed
curl -X POST "https://api.markpdf.tech/convert/from-url" \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"url": "https://bucket.s3.amazonaws.com/report.pdf?X-Amz-Signature=...",
"filename": "report.pdf",
"mode": "fast"
}'
Response JSON
curl -X POST "https://api.markpdf.tech/convert/raw?filename=report.pdf&mode=fast&response_format=json" \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/pdf" \
--data-binary @report.pdf | jq .
Handling of 202 (auto-async)
Complete bash script that handles 202 automatically:#!/usr/bin/env bash
set -euo pipefail
API_URL="https://api.markpdf.tech"
API_KEY="YOUR_API_KEY"
FILE="$1"
# Send conversion
HTTP_CODE=$(curl -s -o /tmp/flash-response.json -w "%{http_code}" \
-X POST "${API_URL}/convert/raw?filename=$(basename "$FILE")&mode=fast" \
-H "x-api-key: ${API_KEY}" \
-H "content-type: application/pdf" \
--data-binary "@${FILE}")
if [ "$HTTP_CODE" = "200" ]; then
cat /tmp/flash-response.json
exit 0
fi
if [ "$HTTP_CODE" = "202" ]; then
JOB_ID=$(jq -r '.job_id' /tmp/flash-response.json)
DELAY=$(jq -r '.retry_after_seconds // 5' /tmp/flash-response.json)
echo "Encolado como job ${JOB_ID}, polling cada ${DELAY}s..." >&2
while true; do
sleep "$DELAY"
STATUS=$(curl -s "${API_URL}/jobs/${JOB_ID}" -H "x-api-key: ${API_KEY}")
STATE=$(echo "$STATUS" | jq -r '.status')
case "$STATE" in
completed)
echo "$STATUS" | jq -r '.body'
exit 0
;;
failed)
echo "Error: $(echo "$STATUS" | jq -r '.error')" >&2
exit 1
;;
*)
echo "Estado: ${STATE}..." >&2
;;
esac
done
fi
echo "Error HTTP ${HTTP_CODE}:" >&2
cat /tmp/flash-response.json >&2
exit 1
chmod +x convert.sh
./convert.sh report.pdf > resultado.md
Check status of a job
curl -s "https://api.markpdf.tech/jobs/JOB_ID_AQUI" \
-H "x-api-key: YOUR_API_KEY" | jq .
