AI Invoice Parser#

Process invoices faster than ever by extracting data and structuring it automatically with our advanced AI. Get quick and accurate data from any invoice, no matter the layout.

The AI Invoice parser automatically detects invoice layouts without the manual effort previously required to supply document parsing templates for reference.

Note

This method extracts data from your PDF invoices and returns a well-structured JSON format for your use.

Available Methods#

/ai-invoice-parser#

  • Method: POST

  • Endpoint: /v1/ai-invoice-parser

Attributes#

Note

Attributes are case-sensitive and should be inside JSON for POST request, for example:

{
    "url": "https://example.com/file1.pdf",
    "callback": "https://example.com/callback/url/you/provided"
}

Attribute

Description

Required

url

URL to the source file. 1

yes

callback

The callback URL (or Webhook) used to receive the POST data.

no

Payload#

{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/document-parser/sample-invoice.pdf",
    "callback": "https://example.com/callback/url/you/provided"
}

Response 2#

Note

You can use jobId to identify the corresponding callback response. Use the /job/check API to poll the job status.

{
  "error":false,
  "status":"created",
  "jobId":"7830deca-2e66-11ef-9ad3-8eff830e7461",
  "credits":100,
  "remainingCredits":106674,
  "duration":33
}

Callback Response#

{
    "status": "success",
    "message": "Success",
    "pageCount": 1,
    "body": {
        "vendor": {
            "name": "ACME Inc.",
            "address": {
                "streetAddress": "1540  Long Street",
                "city": "Jacksonville",
                "state": "FL",
                "postalCode": "32099",
                "country": "US"
            },
            "contactInformation": {
                "phone": "352-200-0371",
                "fax": "904-787-9468"
            }
        },
        "customer": {
            "billTo": {
                "name": "Lanny Lane Ltd.",
                "address": {
                    "streetAddress": "82  Gorby Lane",
                    "city": "Columbia",
                    "state": "IN",
                    "postalCode": "39429",
                    "country": "US"
                }
            },
            "shipTo": {
                "name": "Same as recipient"
            }
        },
        "invoice": {
            "invoiceNo": "67893566",
            "invoiceDate": "JAN 5, 2025"
        },
        "paymentDetails": {
            "total": "$1,272.35",
            "subtotal": "$1,262.35",
            "tax": "$10.00",
            "shipping": "$0.00"
        },
        "lineItems": [
            [
                {
                    "quantity": "2",
                    "description": "Item 1",
                    "unit_price": "9.95",
                    "total": "19.90"
                },
                {
                    "quantity": "5",
                    "description": "Item 2",
                    "unit_price": "20.00",
                    "total": "100.00"
                },
                {
                    "quantity": "1",
                    "description": "Item 3",
                    "unit_price": "19.95",
                    "total": "19.95"
                },
                {
                    "quantity": "1",
                    "description": "Item 4",
                    "unit_price": "123.00",
                    "total": "123.00"
                },
                {
                    "quantity": "10",
                    "description": "Item 5",
                    "unit_price": "99.95",
                    "total": "999.50"
                }
            ]
        ]
    },
    "jobId": "7830deca-2e66-11ef-9ad3-8eff830e7461",
    "credits": 100,
    "remainingCredits": 106472,
    "duration": 33
}

CURL#

curl -X POST \
   -H "content-type: application/json" \
   -H "x-api-key: <your_api_key>" \
   -d '{ "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/document-parser/sample-invoice.pdf", "callback": "https://example.com/callback/url/you/provided" }' \
   https://api.pdf.co/v1/ai-invoice-parser

Invoice Schema#

The body object contains all the metadata you need to understand your invoice content and contains the following attributes:

"body": {
      "vendor": { .... },
      "customer": { .... },
      "invoice": { .... },
      "paymentDetails": { .... },
      "others": { .... },
      "lineItems": { .... }

The vendor Object#

An object containing the customer details.

Attribute

Type

Description

name

string

A string containing the name of the vendor.

address

object

An object containing the address details. See the address object.

contactInformation

object

An object containing the vendor contact details. See the contactInformation object.

entityId

object

A string containing the vendor’s entity ID, supports various IDs like EIN, ABN, VAT, GST, etc.


The customer object#

An object containing the customer details.

Attribute

Type

Description

billTo

object

An object containing the customer billing details

shipTo

object

An object containing the customer shipping details

customer.billTo#

Attribute

Type

Description

name

string

The customer name

address

object

See the address object

contactInformation

object

See the contactInformation object

entityId

string

A string containing the customer’s entity ID, supports various IDs like EIN, ABN, VAT, GST, etc.

customer.shipTo#

Attribute

Type

Description

name

string

The customer name

address

object

See the address object


The invoice object#

An object containing the invoice details.

Attribute

Type

Description

invoiceNo

string

Invoice number

invoiceDate

string

Date of invoice

poNo

string

Purchase order number

orderNo

string

Sales order number


The paymentDetails object#

An object containing the payment details.

Attribute

Type

Description

paymentTerms

string

Terms of payment

dueDate

string

Payment due date

total

string

Total amount due

subtotal

string

Subtotal amount

tax

string

Tax amount

discount

string

Discount amount

shipping

string

Shipping amount

bankingInformation

object

An object containing the banking information for the payment.

paymentDetails.bankingInformation#

Attribute

Type

Description

bankName

string

Name of the bank

accountHolderName

string

Name of the account holder

accountNumber

string

Bank account number

iban

string

International Bank Account Number (IBAN)

swiftBicCode

string

SWIFT/BIC code of the bank

bankAddress

object

See the address object

bankRoutingCode

string

Routing code for domestic payments, such as the US routing number, UK’s sort code, and Australia’s BSB

bankCode

string

Institution number within the Canadian banking network

branchNumber

string

Branch-specific code, such as Canada’s Transit Number, Brazil’s Branch code, and Israel’s Branch Code

purposeCode

string

Specifies the transaction’s intent

additionalNotes

string

Payment instructions or other notes


The others object#

An object containing the additional notes.

Attribute

Type

Description

notes

string

Additional notes such as delivery instructions or other notes


The lineItems object#

An object detailing the line items in an invoice.

Important

Note: there is no common structure due to significant variability between invoices!

A typical invoice might list purchase items with details such as name, quantity or price of each individual item.


Common objects#

There are a couble of objects which are commonly used in the schema in a few places, these are as follows.

address object#

Attribute

Type

Description

streetAddress

string

Street address

city

string

City name

state

string

State/county name

postalCode

string

Postal/ZIP code

country

string

Country code/name

contactInformation object#

Attribute

Type

Description

phone

string

Phone number of the vendor

fax

string

Fax number of the vendor

email

string

Email address of the vendor

Setting up the Callback URL#

The callback URL should be a webhook which listens to responses from the parsing results. You can setup your own webhook or use one from a provider.

Note

If you are unsure about webhooks or callbacks, please read this Wikipedia article to get started.

Footnotes

1

Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API check out the File Upload section. Note: If you experience intermittent Access Denied or Too Many Requests errors, please try to add cache: to enable built-in URL caching. (e.g cache:https://example.com/file1.pdf) For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.

2

Main response codes as follows:

Code

Description

200

Success

400

Bad request. Typically happens because of bad input parameters, or because the input URLs can’t be reached, possibly due to access restrictions like needing a login or password.

401

Unauthorized

402

Not enough credits

445

Timeout error. To process large documents or files please use asynchronous mode (set the async parameter to true) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using the pages parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.