Run Extract Sync

POST /extract/sync

Run extract based on the passed in request parameters

This is a synchronous API endpoint. The request waits for the extraction process to complete and returns the result directly in the response.

Request

Headers

An API Key is required to access this endpoint.

Name
Value

x-api-key

your_api_key

Params

Either file or URL is required but not both. See Accepted File Types.

Name

Type

Description

file

file

File used for extraction

url

string

URL of the document used for extraction

schema

JSON (optional)

JSON schema

excludeOCRResult

boolean

Excludes OCR result from the response. Defaults to false

maintainFormat

boolean

Maintains format from the previous page. Defaults to false

pageRange

number[]

Only run on a specific page range. Defaults to all pages.

Ex: pageRange=[1,2,3] will run on the first three pages.

extractPerPage

boolean

Runs the extraction on each page and returns an array of results. Good for applications with lots of repeated content. Defaults to false

webhookId

string (optional)

Unique ID for the webhook

Example JSON Schema

This is a JSON Schema, which defines the structure and validation rules for the JSON. For more examples and details, see JSON Schema Examples.

{
    "type": "object",
    "properties": {
        "bill_to": {
            "type": "string",
            "description": "The name of person who receives the invoice"
        },
        "ship_to": {
            "type": "string",
            "description": "The location of the person who receives the invoice"
        },
        "balance_due": {
            "type": "number",
            "description": "The total balance due"
        }
    }
}

Response

The API returns the response in JSON format.

The request will return a 200 with the result.

Example

{
  "result": {
    "ocr": {
      "pages": [
        {
          "page": 1,
          "content": "## SuperStore\\n\\n**INVOICE**  \\n# 47905\\n\\n**Date:**  \\nSep 13 2012\\n\\n**Ship Mode:**  \\nFirst Class\\n\\n**Balance Due:**  \\n$23,581.71\\n\\n---\\n\\n**Bill To:**  \\nAaron Hawkins\\n\\n**Ship To:**  \\nKamina, Katanga,  \\nDemocratic Republic of the Congo\\n\\n| Item                             | Quantity | Rate     | Amount     |\\n|----------------------------------|----------|----------|------------|\\n| Apple Smart Phone, Full Size     | 6        | $3,817.26 | $22,903.56 |\\n| Phones, Technology, TEC-PH-3148  |          |          |            |\\n\\n**Subtotal:** $22,903.56  \\n**Shipping:** $678.15  \\n**Total:** $23,581.71\\n\\n---\\n\\n**Notes:**  \\nThanks for your business!\\n\\n**Terms:**  \\nOrder ID : CG-2012-AH1003033-41165",
          "contentLength": 683
        }
      ],
      "fileName": "invoice_aaron20hawkins_47905",
      "inputTokens": 828,
      "outputTokens": 198,
      "completionTime": 6460
    },
    "extracted": {
      "bill_to": "Aaron Hawkins",
      "ship_to": "Kamina, Katanga, Democratic Republic of the Congo",
      "balance_due": 23581.71
    },
    "inputTokens": 284,
    "outputTokens": 30
  }
}

Last updated