Classify PDFs Using PDF.co API Tester

6 Minutes Read

Use PDF.co’s Document Classifier to identify documents by keywords or phrases. Custom rules let you assign categories such as Invoice, Purchase Order, or Bank Statement without writing code.

Step 1: Open the API Tester

Sign in to your PDF.co account and copy your API key.

Open the Document Classifier API Tester, click Try it, and enter your key in the x-api-key field.

The endpoint is: POST https://api.pdf.co/v1/pdf/classifier

Step 2: Prepare Your Classification Rules

Write one CSV row per category using this structure: ClassName,AND or OR,Keyword1,Keyword2

For example:

Invoice,OR,Invoice Number,Tax Invoice
Purchase Order,OR,Purchase Order,PO Number
Bank Statement,AND,Account Number,Statement Period

OR requires at least one keyword to match. AND requires all keywords in that row to match.

Choose phrases that distinguish your document types. A desktop application is not required to enter or test these rules.

Step 1: PDF Multitool Classifier Test Tool

First, download and open the file in the PDF Multitool Classifier Test Tool.

PDF Multitool Classifier Test Tool

Step 2: Run Test Rules

Run the Test Rules.

Run the Test Rules

Step 3: Copy Rules

Click on the Copy Rules for PDF.co or API Server.

Copy Rules

Step 4: Get rulesCSV Value

Paste the JSON in your favorite text editor and copy the rulesCSV value.

Get rulesCSV Value

Step 5: Open Request Tester

Open the PDF.co Request Tester. This will require that you log in to your PDF.co account. Here’s the direct link: https://app.pdf.co/request-tester.

Step 6: Select PDF Classifier

Under PDF.co API endpoint field, select the /pdf/classifier.

Select PDF Classifier

Step 7: Insert rulesCSV Value

Remove the rulescsv parameter’s default value and paste the rulesCSV value that we copied from the Classifier Test Tool.

Insert rulesCSV Value

Step 8: Run Request

Run the Request button to see the output.

Run Request

Step 9: Preview Output

Click on the output file link to preview.

Preview Output

Step 3: Configure the Request

In the API Tester, set:

  • url: A direct link to the document that PDF.co can access.
  • rulescsv: Your CSV rules, with each category on a separate line.
  • caseSensitive: false to ignore capitalization.
  • inline: true to return the classification in the response.
  • async: false for this small test.

Use the exact lowercase parameter name rulescsv.

If entering a JSON request body, represent the line breaks as \n:

{
  "url": "https://example.com/document.pdf",
  "rulescsv": "Invoice,OR,Invoice Number,Tax Invoice\nPurchase Order,OR,Purchase Order,PO Number\nBank Statement,AND,Account Number,Statement Period",
  "caseSensitive": false,
  "inline": true,
  "async": false
}

Replace the example URL with your actual document link. Leave unrelated optional parameters empty.

Step 4: Run and Review

Send the request and inspect the classification result in the response panel.

Test representative documents from each category. If the classification is incorrect, refine the keywords and repeat the test.

For reusable rules, save the CSV in an accessible location and supply its URL through rulescsvurl rather than entering rulescsv directly. See the Document Classifier documentation.

Step 5: Use the Result in Your Workflow

Use the returned category to route documents to a storage folder, select an extraction process, or update a record in another application.

The classifier identifies the category; your connected workflow performs the routing or filing.

Related Tutorials

See Related Tutorials