{
  "openapi": "3.0.1",
  "info": {
    "title": "AI PDF to JSON & Invoice OCR: Receipt, Bank Statement Parser",
    "description": "AI PDF to JSON and invoice OCR parser. Turn invoices, receipts, bank statements, POs and scanned PDFs, photos or DOCX into validated JSON, CSV and Excel. Line items, math checks, per-field confidence, your own fields. No API key. $0.01/doc, failed docs free.",
    "version": "1.0",
    "x-build-id": "MMJUtdC1bBF5EhkaG"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rs-automation-labs~ai-document-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rs-automation-labs-ai-document-extractor",
        "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/rs-automation-labs~ai-document-extractor/runs": {
      "post": {
        "operationId": "runs-sync-rs-automation-labs-ai-document-extractor",
        "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/rs-automation-labs~ai-document-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-rs-automation-labs-ai-document-extractor",
        "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": "Links to PDF, JPG/PNG/WebP/TIFF, DOCX, HTML or TXT/CSV files. Google Drive and Dropbox share links work. Apify key-value store records: kvs://<storeId>/<key>.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "uploadedFiles": {
            "title": "Upload files",
            "type": "array",
            "description": "Upload documents from your computer. They are stored in a key-value store and processed like URLs."
          },
          "documentType": {
            "title": "Document type",
            "enum": [
              "auto",
              "invoice",
              "receipt",
              "bank_statement",
              "purchase_order",
              "resume",
              "business_card",
              "generic_form",
              "contract",
              "shipping_document",
              "custom"
            ],
            "type": "string",
            "description": "Pick a preset (fields, validation rules and line-item tables are built in), 'Auto-detect' to classify each document first, or 'Custom schema only' to extract just your own fields. Government ID documents are not supported (privacy).",
            "default": "auto"
          },
          "customFields": {
            "title": "Custom fields (simple)",
            "type": "array",
            "description": "One field per line: 'name (type): description'. Types: string, number, integer, boolean, date, currency, email, phone, url, percent, array, or 'date[]' etc. for lists. Add * after the name to make it required, e.g. 'totalAmount* (number): Grand total'. Added to the preset's fields, or used alone with 'Custom schema only'.",
            "items": {
              "type": "string"
            }
          },
          "customSchema": {
            "title": "Custom JSON schema (advanced)",
            "type": "object",
            "description": "A JSON Schema ({\"type\": \"object\", \"properties\": {...}, \"required\": [...]}) or a simple map {\"fieldName\": \"description\"}. Nested objects and arrays of objects (tables) are supported, up to 4 levels and 150 fields."
          },
          "instructions": {
            "title": "Extra instructions for the AI (optional)",
            "type": "string",
            "description": "E.g. 'Amounts are in thousands', 'Use the ship-to address as customer address', 'Translate item descriptions to English'."
          },
          "model": {
            "title": "AI model",
            "enum": [
              "fast",
              "accurate",
              "openai/gpt-4.1-mini",
              "anthropic/claude-haiku-4.5",
              "custom"
            ],
            "type": "string",
            "description": "Fast is cheap and good for clean PDFs and receipts. Accurate handles dense tables, handwriting and poor scans better (about 3-6x the AI cost). Or enter any OpenRouter model id with vision, e.g. 'openai/gpt-4.1-mini'.",
            "default": "fast"
          },
          "customModel": {
            "title": "Custom model id",
            "type": "string",
            "description": "Used when 'AI model' is 'Custom'. Any OpenRouter model id that accepts images, e.g. 'google/gemini-3-flash-preview'."
          },
          "fallbackModel": {
            "title": "Fallback model",
            "type": "string",
            "description": "Used automatically when the main model errors, times out or returns invalid JSON. Leave empty for the default (openai/gpt-4.1-mini); 'none' disables it."
          },
          "openRouterApiKey": {
            "title": "Your OpenRouter API key (optional)",
            "type": "string",
            "description": "Pay OpenRouter directly instead of through your Apify account. Recommended on the Apify FREE plan."
          },
          "keyValueStoreId": {
            "title": "Read documents from a key-value store",
            "type": "string",
            "description": "Process files stored in one of your key-value stores (ID or username~store-name)."
          },
          "keyValueStoreKeys": {
            "title": "Keys to process",
            "type": "array",
            "description": "Record keys in that store. Wildcards allowed (e.g. 'invoice-*'). Leave empty for all records.",
            "items": {
              "type": "string"
            }
          },
          "datasetId": {
            "title": "Read document URLs from a dataset",
            "type": "string",
            "description": "A dataset whose items contain document URLs, e.g. the output of a scraper."
          },
          "datasetUrlField": {
            "title": "Dataset field with the URL",
            "type": "string",
            "description": "Field holding the document URL (dot notation for nested fields; arrays of URLs are supported).",
            "default": "url"
          },
          "processingMode": {
            "title": "Reading mode",
            "enum": [
              "auto",
              "vision",
              "text"
            ],
            "type": "string",
            "description": "Auto uses the PDF text layer when it exists and sends only scanned/image pages to the vision model (cheapest, most precise). 'Always vision' sends every page as an image (best for complex layouts). 'Text only' never sends images.",
            "default": "auto"
          },
          "dateFormat": {
            "title": "Date order for ambiguous dates",
            "enum": [
              "auto",
              "DMY",
              "MDY"
            ],
            "type": "string",
            "description": "How to read dates like 03/04/2026. Auto infers it from the document (country, other dates).",
            "default": "auto"
          },
          "defaultCurrency": {
            "title": "Default currency",
            "type": "string",
            "description": "ISO code used when a document shows only '$' or no currency, e.g. USD, CAD, INR."
          },
          "confidenceThreshold": {
            "title": "Review threshold",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Fields below this confidence (0-1) are listed in 'lowConfidenceFields' and the document gets 'needsReview: true'.",
            "default": 0.7
          },
          "maxDocuments": {
            "title": "Max documents",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Upper limit of documents per run (protects your budget).",
            "default": 100
          },
          "maxPagesPerDocument": {
            "title": "Max pages per document",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Only the first N pages are read. Long documents are split into parts automatically.",
            "default": 30
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Files larger than this are skipped with a free FILE_TOO_LARGE error.",
            "default": 25
          },
          "imageResolution": {
            "title": "Page image size (px)",
            "minimum": 800,
            "maximum": 3000,
            "type": "integer",
            "description": "Longest side of page images sent to the vision model. Higher reads small print better but costs more AI tokens.",
            "default": 1600
          },
          "includeFlatData": {
            "title": "Add flattened fields (flatData)",
            "type": "boolean",
            "description": "Adds a one-level 'flatData' object (vendor.name, total, lineItems.count ...) that exports cleanly to CSV/Excel/Sheets.",
            "default": true
          },
          "saveCsvFiles": {
            "title": "Save CSV files",
            "type": "boolean",
            "description": "Saves RESULTS.csv (one row per document) and TABLE-<name>.csv (one row per line item / transaction) to the key-value store.",
            "default": true
          },
          "includeRawText": {
            "title": "Include document text",
            "type": "boolean",
            "description": "Adds the extracted text layer ('rawText', up to 100k characters) to each record.",
            "default": false
          },
          "webhookUrl": {
            "title": "Webhook URL (optional)",
            "type": "string",
            "description": "Receives a POST with the run summary and extracted data when the run finishes (Zapier, Make, n8n, Slack-compatible 'text')."
          },
          "concurrency": {
            "title": "Parallel documents",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "How many documents are processed in parallel. 3 is safe for 256 MB memory.",
            "default": 3
          },
          "maxRetries": {
            "title": "Retries per AI call",
            "minimum": 0,
            "maximum": 5,
            "type": "integer",
            "description": "Retries for rate limits, timeouts and upstream errors before the fallback model is tried.",
            "default": 2
          },
          "requestTimeoutSecs": {
            "title": "AI request timeout",
            "minimum": 30,
            "maximum": 600,
            "type": "integer",
            "description": "Timeout for one AI request. Large scanned documents may need longer.",
            "default": 180
          },
          "maxOutputTokens": {
            "title": "Max AI output tokens per part",
            "minimum": 1000,
            "maximum": 64000,
            "type": "integer",
            "description": "Raise for documents with hundreds of line items. Parts that hit the limit are split and retried automatically.",
            "default": 12000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}