{
  "openapi": "3.0.1",
  "info": {
    "title": "PDF & Office to Markdown: Tables, Headings, OCR Fallback",
    "description": "Convert PDFs, DOCX, PPTX and images to clean markdown for RAG: real tables, heading levels, page anchors, per-page token counts. Tesseract OCR runs only on pages without a text layer. Input from URLs, key-value store files or a dataset of links. Per-file error codes.",
    "version": "0.1",
    "x-build-id": "B9v4TD3g3fI5evKEg"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/foresighted_sunset~pdf-office-to-markdown/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-foresighted_sunset-pdf-office-to-markdown",
        "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/foresighted_sunset~pdf-office-to-markdown/runs": {
      "post": {
        "operationId": "runs-sync-foresighted_sunset-pdf-office-to-markdown",
        "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/foresighted_sunset~pdf-office-to-markdown/run-sync": {
      "post": {
        "operationId": "run-sync-foresighted_sunset-pdf-office-to-markdown",
        "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": {
          "urls": {
            "title": "Document URLs",
            "type": "array",
            "description": "Public links to PDF, DOCX, PPTX or image files (PNG, JPEG, TIFF, GIF, BMP, WEBP). Apify storage record URLs (api.apify.com) work too. Leave everything empty to run a small demo (5 pages of the NIST CSF 2.0 PDF plus built-in DOCX, PPTX and PNG samples).",
            "items": {
              "type": "string"
            }
          },
          "keyValueStoreId": {
            "title": "Key-value store with files",
            "type": "string",
            "description": "ID or name of one of your key-value stores holding the files. Selecting it here grants this Actor read-only access to that store (and nothing else in your account). List the record keys below."
          },
          "keyValueStoreKeys": {
            "title": "Record keys in that store",
            "type": "array",
            "description": "Keys of the file records in the key-value store above (e.g. 'contract.pdf'). Without a store, keys are read from this run's own default store.",
            "items": {
              "type": "string"
            }
          },
          "keyValueStoreRecords": {
            "title": "Key-value store records (advanced)",
            "type": "array",
            "description": "Advanced: 'storeIdOrName/key' references. Only stores created by this Actor (or this run's default store, using just 'key') are readable; for your own stores use the two fields above.",
            "items": {
              "type": "string"
            }
          },
          "datasetId": {
            "title": "Dataset of links",
            "type": "string",
            "description": "ID or name of a dataset whose items contain document URLs (for example the output of a crawler). Grants this Actor read-only access to that dataset only."
          },
          "datasetUrlField": {
            "title": "URL field in the dataset",
            "type": "string",
            "description": "Field holding the URL. Dotted paths work, e.g. 'file.url'.",
            "default": "url"
          },
          "maxFiles": {
            "title": "Max files",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Stop after this many files (1-1000).",
            "default": 100
          },
          "pageRange": {
            "title": "Page range (PDF)",
            "type": "string",
            "description": "Only convert these pages of each PDF, e.g. '1-5,9,12-'. Empty = all pages."
          },
          "tableStrategy": {
            "title": "Table detection (PDF)",
            "enum": [
              "lines",
              "text",
              "off"
            ],
            "type": "string",
            "description": "lines = ruled tables (most reliable). text = also whitespace-aligned tables (can over-detect). off = plain text only.",
            "default": "lines"
          },
          "removeHeadersFooters": {
            "title": "Remove repeated headers, footers and page numbers",
            "type": "boolean",
            "description": "Drops lines repeated in the top/bottom margin of at least half the pages (PDFs with 3+ pages).",
            "default": true
          },
          "pageMarker": {
            "title": "Page marker in markdown",
            "enum": [
              "anchor",
              "comment",
              "heading",
              "none"
            ],
            "type": "string",
            "description": "anchor = invisible <a id=\"page-N\"></a> link targets (good for citations). comment = <!-- page: N -->. heading = '## Page N'. none = no markers.",
            "default": "anchor"
          },
          "outputMode": {
            "title": "KV result format",
            "enum": [
              "document",
              "pages"
            ],
            "type": "string",
            "description": "Controls KV result-*.json rows: document = document summary/full markdown; pages = summary plus page rows. The default dataset always holds only nonempty native-text pages. OCR pages, summaries and errors are KV-only; OUTPUT.files lists resultKey/resultUrl.",
            "default": "document"
          },
          "tokenEncoding": {
            "title": "Token encoding",
            "enum": [
              "cl100k_base",
              "o200k_base"
            ],
            "type": "string",
            "description": "tiktoken encoding used for per-page token counts.",
            "default": "cl100k_base"
          },
          "includeSpeakerNotes": {
            "title": "Include speaker notes (PPTX)",
            "type": "boolean",
            "description": "Add each slide's speaker notes as a quote block.",
            "default": true
          },
          "keepInlineFormatting": {
            "title": "Keep bold/italic (DOCX)",
            "type": "boolean",
            "description": "Keep **bold** and *italic* runs from Word documents.",
            "default": true
          },
          "saveMarkdownFiles": {
            "title": "Save .md files to the key-value store",
            "type": "boolean",
            "description": "Stores the full markdown of each file as a record (link in markdownUrl).",
            "default": true
          },
          "maxMarkdownCharsInDataset": {
            "title": "Max markdown characters per KV document summary",
            "minimum": 1000,
            "maximum": 5000000,
            "type": "integer",
            "description": "Maximum markdown characters embedded in each KV document-summary row (legacy input name retained). Complete markdown is available in the .md KV record when saveMarkdownFiles is enabled; default-dataset native page markdown is unchanged.",
            "default": 1000000
          },
          "ocrMode": {
            "title": "OCR",
            "enum": [
              "auto",
              "force",
              "off"
            ],
            "type": "string",
            "description": "auto = OCR only pages without a text layer, and image files. force = OCR every PDF page. off = never OCR.",
            "default": "auto"
          },
          "ocrLanguages": {
            "title": "OCR languages",
            "type": "array",
            "description": "Tesseract language codes. Installed: eng, deu, fra, spa, ita, por, nld. Up to 5.",
            "default": [
              "eng"
            ],
            "items": {
              "type": "string"
            }
          },
          "minTextChars": {
            "title": "Min characters for a page to count as text",
            "minimum": 0,
            "maximum": 1000,
            "type": "integer",
            "description": "Pages with fewer non-space characters than this are OCR'd in auto mode.",
            "default": 20
          },
          "maxOcrPagesPerFile": {
            "title": "Max OCR pages per file",
            "minimum": 0,
            "maximum": 500,
            "type": "integer",
            "description": "Cap on OCR'd pages per file (OCR is slower and billed separately). 0 = no OCR on PDFs.",
            "default": 30
          },
          "ocrDpi": {
            "title": "OCR resolution (DPI)",
            "minimum": 72,
            "maximum": 400,
            "type": "integer",
            "description": "Render resolution for OCR. 200 is a good balance; 300 for small print.",
            "default": 200
          },
          "ocrTimeoutSecs": {
            "title": "OCR timeout per page (s)",
            "minimum": 5,
            "maximum": 300,
            "type": "integer",
            "description": "Give up OCR on a page after this many seconds (page gets an OCR_FAILED warning).",
            "default": 60
          },
          "pdfPassword": {
            "title": "PDF password",
            "type": "string",
            "description": "Password for encrypted PDFs (tried on every PDF). Stored encrypted; never written to the output."
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Larger files fail with FILE_TOO_LARGE before they are fully downloaded.",
            "default": 50
          },
          "maxPagesPerFile": {
            "title": "Max pages per file",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Pages (or slides) converted per file; the rest are skipped with a PAGE_LIMIT warning.",
            "default": 300
          },
          "requestTimeoutSecs": {
            "title": "Download timeout (s)",
            "minimum": 5,
            "maximum": 300,
            "type": "integer",
            "description": "Per-download timeout; 5xx/429 are retried twice.",
            "default": 60
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}