Skip to main content
Try it live: Document Classifier → API Tester — send a real request from your browser.

POST /v1/pdf/classifier

Document Classifier can automatically find class of input PDF, JPG, PNG document by analyzing its content using the built-in AI or custom defined classification rules. The best way to develop, test and maintain classification rules is to use Classifier Tester Tool from PDF.co Document Classifier UI . Use this tool to quickly edit and test rules on single PDFs and on folders.

Attributes

Attributes are case-sensitive and should be inside JSON for POST request. for example: { "url": "https://example.com/file1.pdf" }

rulescsv

Rules are in CSV format where each row contains: class name, logic (AND or OR (default)), and keywords separated by a comma. Each row is separated by the \n symbol. You can use regular expressions for keywords with this syntax: /keyword or regexp/i where i is the case-insensitive flag. Please note that all \ symbols should add the prefix \ because of JSON format, so \d becomes \\d and so on.
Custom Rules Example 1 for rulescsv.
Custom Rules Example 2.

Document Classifier Usage Guide

This Document Classifier checks content of input PDF, JPG, PNG, or TIFF. It uses AI to automatically determine the class of the document (e.g., finance, invoice) and returns the result to the user. Custom-defined classification rules can also be used. Use this Document Classifier to quickly build a workflow for sorting input documents and PDF files.

How to Create and Test Custom Classification Rules

Classification rules are stored in CSV format, one line per class, with the following format:
Where:
  • className – The name of the class. It will be returned if rules from this class match the document.
  • logicType – (Optional) Logic to use for keywords. Can be OR (default) or AND. OR means the class is identified if one or more keywords match. AND means all keywords must match. If not specified, OR is assumed.
  • keyword1, keyword2, keyword3 – Keywords or phrases to check. Can include regular expressions, e.g., /\d+/ or /Medical Report|Med Report/i.

Sample Rules

Query parameters

No query parameters accepted.

Responses

Example Payload

To see the request size limits, please refer to the Request Size Limits.

Example Response

To see the main response codes, please refer to the Response Codes page.
Inconsistent URL Encoding in cURL Output: When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (&) may appear as \u0026 in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you’re parsing the response programmatically, your JSON parser will handle this conversion automatically.

Code Samples