{
  "openapi": "3.0.1",
  "info": {
    "title": "Document to Markdown: PDF, DOCX, XLSX, PPTX & OCR for AI",
    "description": "Convert PDF (OCR for scans), DOCX, XLSX, PPTX, HTML, EML and images to clean Markdown for LLMs and RAG. Tables as Markdown, per-page text, token counts, heading-aware chunks. PDF text extractor: $4 per 1,000 files, OCR $10 per 1,000 pages.",
    "version": "1.0",
    "x-build-id": "OGgN73OA89LnG1WpH"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/terracotta_hauyne~document-to-markdown-for-ai/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-terracotta_hauyne-document-to-markdown-for-ai",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/terracotta_hauyne~document-to-markdown-for-ai/runs": {
      "post": {
        "operationId": "runs-sync-terracotta_hauyne-document-to-markdown-for-ai",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/terracotta_hauyne~document-to-markdown-for-ai/run-sync": {
      "post": {
        "operationId": "run-sync-terracotta_hauyne-document-to-markdown-for-ai",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "documentUrls": {
            "title": "Document URLs",
            "type": "array",
            "description": "Direct links to files: PDF, DOCX, XLSX, PPTX, HTML, EML, PNG, JPG, TIFF, WebP, TXT, CSV. The link must open the file without login. Links to private networks and cloud metadata addresses are blocked.",
            "items": {
              "type": "string"
            }
          },
          "uploadedFile": {
            "title": "Upload a file",
            "type": "string",
            "description": "Optional. Upload one file here (it is stored in Apify and read like a URL). For several private files use the key-value store or base64 fields below."
          },
          "sourceKeyValueStoreId": {
            "title": "Key-value store ID or name",
            "type": "string",
            "description": "Optional. Key-value store that holds your files, used with \"Record keys\". Leave empty to read the keys from this run's default store."
          },
          "sourceKeys": {
            "title": "Record keys",
            "type": "array",
            "description": "Keys of binary file records in the key-value store above. Each record is one document. The key's file extension helps to detect the type, but the content decides.",
            "items": {
              "type": "string"
            }
          },
          "base64Files": {
            "title": "Base64 files",
            "type": "array",
            "description": "Files sent inline, for API and agent use: a list of objects like {\"filename\": \"report.pdf\", \"contentBase64\": \"JVBERi0...\"}. A data: URI is accepted as contentBase64 too."
          },
          "ocr": {
            "title": "OCR mode",
            "enum": [
              "auto",
              "off",
              "force"
            ],
            "type": "string",
            "description": "auto reads the text layer of a PDF and uses OCR only for pages that have none (billed per OCR page). Images are always OCRed unless off. force OCRs every PDF page and replaces its text layer, for PDFs whose embedded text is garbage. Printed text only; no handwriting.",
            "default": "auto"
          },
          "ocrLanguages": {
            "title": "OCR languages",
            "type": "array",
            "description": "Languages of the scanned text (Tesseract). Pick every language that appears on the page; more languages are slightly slower. Printed text only.",
            "items": {
              "type": "string",
              "enum": [
                "eng",
                "deu",
                "fra",
                "spa",
                "ita",
                "por",
                "nld",
                "pol",
                "ces",
                "swe",
                "rus",
                "tur",
                "ara",
                "hin",
                "vie",
                "jpn",
                "kor",
                "chi_sim",
                "chi_tra"
              ],
              "enumTitles": [
                "English",
                "German",
                "French",
                "Spanish",
                "Italian",
                "Portuguese",
                "Dutch",
                "Polish",
                "Czech",
                "Swedish",
                "Russian",
                "Turkish",
                "Arabic",
                "Hindi",
                "Vietnamese",
                "Japanese",
                "Korean",
                "Chinese (simplified)",
                "Chinese (traditional)"
              ]
            },
            "default": [
              "eng"
            ]
          },
          "ocrResolutionDpi": {
            "title": "OCR render resolution (DPI)",
            "minimum": 72,
            "maximum": 400,
            "type": "integer",
            "description": "Resolution at which PDF pages are rendered for OCR. 200 reads normal print (10 pt and up) well; use 300 for fine print. Higher is slower and uses more memory.",
            "default": 200
          },
          "maxOcrPagesPerDocument": {
            "title": "Max OCR pages per document",
            "minimum": 0,
            "maximum": 2000,
            "type": "integer",
            "description": "Cost guard. Pages without text beyond this number are left empty and a warning is added.",
            "default": 50
          },
          "includePages": {
            "title": "Include pages[]",
            "type": "boolean",
            "description": "Add the Markdown of each page (PDF page, sheet, slide) next to the full text. Turn off to halve the item size.",
            "default": true
          },
          "includeTables": {
            "title": "Include tables[]",
            "type": "boolean",
            "description": "Add every table as its own Markdown table with page, row and column counts.",
            "default": true
          },
          "includeChunks": {
            "title": "Include RAG chunks",
            "type": "boolean",
            "description": "Add chunks[]: text split at headings and paragraph boundaries with the heading path, page range and token estimate, ready for an embedding model.",
            "default": false
          },
          "chunkSize": {
            "title": "Chunk size (tokens)",
            "minimum": 50,
            "maximum": 8000,
            "type": "integer",
            "description": "Target chunk size in estimated tokens (about 4 characters per token). A paragraph or table is never cut unless it is bigger than this.",
            "default": 800
          },
          "chunkOverlap": {
            "title": "Chunk overlap (tokens)",
            "minimum": 0,
            "maximum": 4000,
            "type": "integer",
            "description": "Whole paragraphs from the end of the previous chunk repeated at the start of the next one, up to this many tokens. Must be smaller than the chunk size.",
            "default": 80
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Larger files fail with a clear message and are not charged.",
            "default": 50
          },
          "maxPagesPerDocument": {
            "title": "Max pages per document",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "PDFs, slide decks and TIFFs with more pages fail with a clear message and are not charged.",
            "default": 100
          },
          "maxSheetRows": {
            "title": "Max rows per sheet",
            "minimum": 1,
            "maximum": 200000,
            "type": "integer",
            "description": "Spreadsheet and CSV rows (after the header) converted per sheet. Extra rows are cut and a warning is added.",
            "default": 2000
          },
          "maxDocuments": {
            "title": "Max documents per run",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Documents beyond this number are not attempted.",
            "default": 100
          },
          "downloadTimeoutSecs": {
            "title": "Download timeout (seconds)",
            "minimum": 10,
            "maximum": 1800,
            "type": "integer",
            "description": "Maximum time to download one file.",
            "default": 120
          },
          "pdfPassword": {
            "title": "PDF password",
            "type": "string",
            "description": "Optional. Password for encrypted PDFs; used for every PDF in the run."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}