{
  "openapi": "3.0.1",
  "info": {
    "title": "Text to JSON: Extract Structured Data from Any Document",
    "description": "Turn messy text, emails, HTML, PDFs and Word docs into clean JSON that matches your own schema. Invoices, receipts, forms, listings and emails. Free rule-based extraction, or bring your own LLM key. Built for AI agents and MCP.",
    "version": "1.0",
    "x-build-id": "JKZoACoPBndXA9KDd"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/birchwood-data~text-to-data/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-birchwood-data-text-to-data",
        "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/birchwood-data~text-to-data/runs": {
      "post": {
        "operationId": "runs-sync-birchwood-data-text-to-data",
        "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/birchwood-data~text-to-data/run-sync": {
      "post": {
        "operationId": "run-sync-birchwood-data-text-to-data",
        "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",
        "required": [
          "schema"
        ],
        "properties": {
          "text": {
            "title": "Text or HTML to extract from",
            "type": "string",
            "description": "Paste one document: an email, invoice, receipt, form, listing, chat message, HTML page source, etc. For several documents use 'Multiple texts' or 'Document URLs'."
          },
          "schema": {
            "title": "Output schema (what JSON you want back)",
            "type": "object",
            "description": "Either a standard JSON Schema ({\"type\":\"object\",\"properties\":{...}}) or a simple shorthand: {\"name\": \"string\", \"total\": \"number\", \"date\": \"date\", \"email\": \"email\", \"paid\": \"boolean\", \"status\": \"open|closed\", \"tags\": [\"string\"], \"items\": [{\"description\": \"string\", \"qty\": \"integer\"}]}. Shorthand types: string, number, integer, boolean, date, datetime, email, url, phone, 'a|b|c' (enum). Nested objects and arrays of objects (tables / line items) are supported."
          },
          "texts": {
            "title": "Multiple texts (batch)",
            "type": "array",
            "description": "Optional. A JSON array of documents: plain strings, or objects like {\"id\": \"msg-1\", \"text\": \"...\"} (the id is copied to the output). Each document becomes one output item."
          },
          "urls": {
            "title": "Document URLs (PDF, DOCX, HTML, TXT, JSON, CSV)",
            "type": "array",
            "description": "Optional. Public links to documents. PDFs (with a text layer), Word .docx, web pages, text, JSON and CSV files are supported. Max 25 MB each. Scanned image-only PDFs need OCR first.",
            "items": {
              "type": "string"
            }
          },
          "instructions": {
            "title": "Extra instructions (LLM mode)",
            "type": "string",
            "description": "Optional hints for the LLM, e.g. 'Amounts are in EUR', 'customer = the company being billed', 'dates are day-first'. Ignored by the rule-based extractor."
          },
          "mode": {
            "title": "Extraction mode",
            "enum": [
              "auto",
              "rules",
              "llm"
            ],
            "type": "string",
            "description": "auto = use your LLM key if you provide one, otherwise the free rule-based extractor. rules = always rule-based (fast, deterministic, no AI cost). llm = always use your LLM key.",
            "default": "auto"
          },
          "llmProvider": {
            "title": "LLM provider",
            "enum": [
              "openai",
              "anthropic",
              "gemini",
              "openrouter",
              "groq",
              "mistral",
              "deepseek",
              "openai-compatible"
            ],
            "type": "string",
            "description": "Which provider your API key is for. Your key is billed by that provider directly; this Actor never adds a markup.",
            "default": "openai"
          },
          "llmApiKey": {
            "title": "Your LLM API key",
            "type": "string",
            "description": "Optional. Your own API key for the provider above. Stored encrypted by Apify, used only for this run, never logged or saved to the output."
          },
          "llmModel": {
            "title": "Model",
            "type": "string",
            "description": "Optional model ID. Defaults: OpenAI gpt-6-luna, Anthropic claude-haiku-4-5, Gemini gemini-3.1-flash-lite, OpenRouter openai/gpt-6-luna, Groq llama-3.3-70b-versatile, Mistral mistral-small-latest, DeepSeek deepseek-chat. Required for 'openai-compatible'."
          },
          "llmBaseUrl": {
            "title": "Custom base URL",
            "type": "string",
            "description": "Optional. For 'openai-compatible' (e.g. https://your-host/v1) or to route a provider through a proxy/gateway."
          },
          "fallbackToRules": {
            "title": "Fall back to rule-based extraction if the LLM fails",
            "type": "boolean",
            "description": "If your LLM call errors (bad key, quota, timeout), still return a rule-based result instead of failing that document. The LLM error is reported in 'llmError'.",
            "default": true
          },
          "includeSourceText": {
            "title": "Include the cleaned source text in the output",
            "type": "boolean",
            "description": "Adds 'sourceText' (the plain text we extracted from the document) to each output item. Handy for debugging or RAG.",
            "default": false
          },
          "maxCharsPerDocument": {
            "title": "Max characters per document",
            "minimum": 1000,
            "maximum": 1000000,
            "type": "integer",
            "description": "Longer documents are truncated to this many characters (the output says 'truncated': true).",
            "default": 120000
          },
          "maxConcurrency": {
            "title": "Documents processed in parallel",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "How many documents to fetch/extract at the same time.",
            "default": 3
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}