{
  "openapi": "3.1.0",
  "info": {
    "title": "Invoice & Receipt OCR",
    "version": "1.0.0",
    "summary": "Turn a photo, scan, or PDF of an invoice or receipt into structured JSON: vendor, line items, tax, and total.",
    "description": "Turn an invoice or receipt photo, scan, or PDF into structured JSON: vendor, line items, tax, and total, for accounting and accounts-payable automation tools.\n\nGenerated from the service's own TypeScript contract types, so this document describes what the API actually returns. Operated by EAC Ventures, LLC.\n\nSubscribe, including the free tier: https://rapidapi.com/aervik-labs-aervik-labs-default/api/invoice-receipt-ocr-structured-line-item-extraction-api\n\nKnown limits:\n- One document per request; a multi-page PDF is one request. A base64 file can be up to 15,000,000 characters and a file_url up to 2,048.\n- A document with more content than fits in one response is refused with a 422 rather than returned in part.\n- Not returned: invoice number, due date, purchase order number, vendor address or tax ID, bill-to details, payment terms, tip, discount, shipping, balance due, tax split by rate, document type, or the page a line item came from.\n- vendor and currency are not checked against the document; currency is the model’s reading.\n- A date whose day and month could be read either way round, or that is quoted with no year, and an amount whose decimal mark or sign reads more than one way, are returned as null with a warning.\n- confidence is the model’s own rating, not a calibrated accuracy figure.\n- Nothing on the document is redacted, and an altered or fake invoice is not detected.\n\nSources, freshness and live health: https://aerviklabs.com/sources.json (https://aerviklabs.com/data-sources/#invoice-ocr). What we do when something cannot be established: https://aerviklabs.com/trust/\n\nThis OpenAPI document is available under the MIT License (Copyright (c) 2026 EAC Ventures, LLC). Use of the API itself is governed by its Terms of Service, not by that license.",
    "contact": {
      "name": "Aervik Labs",
      "url": "https://aerviklabs.com/about/"
    },
    "x-aervik-provenance": {
      "sources_json": "https://aerviklabs.com/sources.json",
      "data_sources_page": "https://aerviklabs.com/data-sources/#invoice-ocr",
      "trust_page": "https://aerviklabs.com/trust/",
      "read_method": "input-only",
      "known_limits": [
        "One document per request; a multi-page PDF is one request. A base64 file can be up to 15,000,000 characters and a file_url up to 2,048.",
        "A document with more content than fits in one response is refused with a 422 rather than returned in part.",
        "Not returned: invoice number, due date, purchase order number, vendor address or tax ID, bill-to details, payment terms, tip, discount, shipping, balance due, tax split by rate, document type, or the page a line item came from.",
        "vendor and currency are not checked against the document; currency is the model’s reading.",
        "A date whose day and month could be read either way round, or that is quoted with no year, and an amount whose decimal mark or sign reads more than one way, are returned as null with a warning.",
        "confidence is the model’s own rating, not a calibrated accuracy figure.",
        "Nothing on the document is redacted, and an altered or fake invoice is not detected."
      ]
    },
    "termsOfService": "https://ocr.aerviklabs.com/terms"
  },
  "externalDocs": {
    "description": "Product page",
    "url": "https://aerviklabs.com/apis/invoice-ocr/"
  },
  "servers": [
    {
      "url": "https://invoice-receipt-ocr-structured-line-item-extraction-api.p.rapidapi.com",
      "description": "RapidAPI gateway"
    }
  ],
  "security": [
    {
      "RapidApiKey": []
    }
  ],
  "paths": {
    "/extract": {
      "post": {
        "operationId": "extractInvoice",
        "summary": "Extract an invoice or receipt (image or PDF) into structured fields",
        "parameters": [
          {
            "$ref": "#/components/parameters/RapidApiHost"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "405": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtractRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "RapidApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-RapidAPI-Key",
        "description": "Your RapidAPI application key."
      }
    },
    "parameters": {
      "RapidApiHost": {
        "name": "X-RapidAPI-Host",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "const": "invoice-receipt-ocr-structured-line-item-extraction-api.p.rapidapi.com"
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Stable machine-readable code. On extraction_failed, 422 means the document could not be extracted as sent (the model provider refused it, the reply was not a recognizable invoice, or it has more content than fits in one response, so send pages one at a time); 502 means the extraction did not complete for another reason, such as the provider failing, timing out, rate limiting or returning a reply that could not be used, and a retry may succeed."
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ],
        "description": "Every non-2xx JSON response from the API itself. `error` is a stable machine-readable code; `message` is for humans and may change. Codes this API can return: `blocked_file_url`, `extraction_failed`, `input_too_large`, `invalid_base64`, `invalid_file_url`, `invalid_json`, `method_not_allowed`, `missing_input`, `multiple_inputs`, `not_found`, `pdf_url_unsupported`, `provider_misconfigured`, `unauthorized`, `unsupported_url_scheme`. RapidAPI answers authentication, subscription and rate-limit failures itself, in its own format."
      },
      "ExtractRequest": {
        "type": "object",
        "properties": {
          "file_url": {
            "type": "string",
            "description": "A public https URL of an image, up to 2,048 characters. Send exactly one of file_url or base64_image; a URL whose path ends in .pdf is rejected (pdf_url_unsupported), so send a PDF as base64_image."
          },
          "base64_image": {
            "type": "string",
            "description": "The image or PDF file, base64-encoded (standard or URL-safe alphabet, padded or not; line breaks and a data: URL prefix are accepted), up to 15,000,000 characters. Send exactly one of file_url or base64_image."
          },
          "mime_type": {
            "type": "string",
            "description": "The media type of base64_image. When omitted, the type a data: URL prefix declares is used, then application/pdf if the file begins with %PDF-, otherwise image/jpeg."
          }
        }
      },
      "ExtractResponse": {
        "type": "object",
        "properties": {
          "vendor": {
            "type": [
              "string",
              "null"
            ]
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The document's date as YYYY-MM-DD. null when no valid date was read, when the date could not be traced to the document, or when a date printed only in numbers reads either way round (03/10/2026 could be March 10 or October 3)."
          },
          "line_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "subtotal": {
            "type": [
              "number",
              "null"
            ]
          },
          "tax": {
            "type": [
              "number",
              "null"
            ],
            "description": "The tax amount as read from the document. null when no tax amount was read, which is not the same as a tax of zero."
          },
          "total": {
            "type": [
              "number",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "The model's reading of the currency, requested as an ISO 4217 code such as USD, or null. It is not checked against the document or validated as a code: a receipt that prints only $ does not say which dollar."
          },
          "confidence": {
            "type": "number",
            "description": "The model's own self-assessment of the extraction, 0 to 1; it is not a calibrated accuracy figure and nothing this API checks changes it. 0 when the model gives none."
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceWarning"
            },
            "description": "Present only when a check found something to report; a clean extraction has no warnings key. Its absence means none of the checks found a problem, not that every value is correct."
          }
        },
        "required": [
          "vendor",
          "date",
          "line_items",
          "subtotal",
          "tax",
          "total",
          "currency",
          "confidence"
        ]
      },
      "InvoiceWarning": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "line_items_not_a_list",
              "unreadable_number",
              "totals_mismatch"
            ],
            "description": "line_items_not_a_list: no list of line items came back, so none could be read (an invoice with no line items returns an empty list and no warning); unreadable_number: a value, including date, is returned as null because it could not be read or traced to the document, or no amount was read at all; totals_mismatch: the line totals that were read do not reconcile with the subtotal (or with the total when no subtotal was read), or the subtotal and tax do not reconcile with the total."
          },
          "message": {
            "type": "string",
            "description": "A plain-language explanation, safe to show an end user. It never repeats the document's content."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "LineItem": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": [
              "number",
              "null"
            ],
            "description": "null when it was not read or could not be traced to the document. A line may have no quantity or unit price, such as a flat fee, so a null here does not always come with a warning."
          },
          "unit_price": {
            "type": [
              "number",
              "null"
            ],
            "description": "null when it was not read or could not be traced to the document. A line may have no quantity or unit price, such as a flat fee, so a null here does not always come with a warning."
          },
          "total": {
            "type": [
              "number",
              "null"
            ],
            "description": "The line's amount, or null when it was not read or could not be traced to the document; null never means zero. Every null line total comes with an unreadable_number warning."
          }
        },
        "required": [
          "description",
          "quantity",
          "unit_price",
          "total"
        ]
      }
    }
  }
}
