Classify Document in Power Automate
PDF4me Classify Document classifies PDF documents based on expressions (regular expressions or JavaScript) that you define on dev.pdf4me.com. You create document classes with search patterns—e.g. pdf4me_invoice with regex invoice(.*)—and when a PDF is sent to the action, PDF4me matches the document content against your rules and returns the Class Name. Use the Class Name in Conditions, Switch, or follow-up actions to route, rename, or process documents by type in Microsoft 365 flows.
Important: Classification rules are defined and stored in your PDF4me account. Create your classes first at Classify Document, then use the action in Power Automate. For full setup, see Set Up Classify Document.
Authenticating Your API Request
To access the PDF4me Web API through Power Automate, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user.

Key Features
- Expression-Based Classification: Define document classes with Regular Expression or JavaScript on dev.pdf4me.com
- Class Name Output: Returns the matched class (e.g.
pdf4me_invoice,Invoice) for routing and filtering - Custom Rules: Match document content with regex patterns (e.g.
invoice(.*),contract(.*)) - Flow Integration: Use Class Name in Conditions, Switch, SharePoint, OneDrive, and Microsoft 365 apps
- One Credit per Classification: Each Classify Document run uses 1 credit
Parameters
Complete list of parameters for the Classify Document action. Configure these parameters to control document classification.
Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.
| Parameter | Type | Description | Example |
|---|---|---|---|
| File Content*** | Binary | Source Document Content • Map file content from previous action • Supports PDF and other document formats • Can be from SharePoint, OneDrive, email • Must be valid document file | [File Content from Get File] |
| File Name | String | Document File Name • Name of the file to classify • Used for processing identification • Should include proper file extension • Optional but recommended | Invoice_12345.pdf |
Class setup: Create classes at Classify Document. Add a class (e.g. pdf4me_invoice) with a regex (e.g. invoice(.*)). Save Changes so Power Automate can use them.

Output
Classify Document returns the Class Name that matched your PDF based on your classification rules. It does not return or modify the PDF file. Use the file content from your trigger or previous step if you need to pass the PDF onward.
- Table
- JSON
- Flow Integration
Table View
Response data in a structured table format:
| Parameter | Type | Description |
|---|---|---|
| Class Names | String | The matched class (e.g. pdf4me_invoice, Invoice). Use in Conditions, Switch, or the next action |
| Trace Id | String | Unique trace identifier for tracking and debugging |
JSON Response Format
{
"Class Names": "pdf4me_invoice",
"Trace Id": "trace-abc123xyz"
}
Power Automate Flow Usage
Use classification results in subsequent actions:
- Conditional Routing: Route based on Class Names to specific workflows
- Switch on Type: Use Switch condition on Class Names to branch your flow
- Folder Organization: File documents in type-specific SharePoint folders by Class Name
- Metadata: Set SharePoint properties (document type, category) from Class Names
- Process Automation: Trigger different processing paths based on document type
:::tip How Classify Document Works
- Create classes on dev.pdf4me.com: Go to Classify Document, click Edit, add classes with Class Name and Regular Expression (or JavaScript). Example:
pdf4me_invoicewithinvoice(.*). Click Save Changes. - Map File Content and File Name in Power Automate: The action takes File Content (required) and File Name (optional) from your trigger or previous step.
- Use Class Name in the next step: Route with Switch or Condition, apply metadata, or save to type-specific folders.
For detailed setup, see Set Up Classify Document. :::
Workflow Examples
The PDF4me Classify Document action in Power Automate provides comprehensive workflow templates designed for real-world business scenarios:
- Route by Document Type
- Inbox Processing
- Archive Organization
- Compliance Sorting
Route Invoices vs Contracts to Different Folders
Complete Workflow Steps:
- Trigger: Document uploaded to SharePoint or OneDrive folder
- Get File Content: Retrieve document from inbox
- Classify Document: Map File Content and File Name; action returns Class Names
- Switch on Class Names: Use Switch condition on Class Names
- Invoice Path: If
invoice, route to AP processing workflow - Contract Path: If
contract, route to legal review workflow - Receipt Path: If
receipt, route to expense folder - Save to SharePoint: Save in type-specific folder for each path
Business Benefits:
- Automates document sorting by type using your regex/JavaScript rules
- Routes documents to the right folder without manual review
- Works with any classes you define (invoices, contracts, receipts, forms, etc.)
Classify Email Attachments and Route by Type
Complete Workflow Steps:
- Trigger: Email with attachment arrives in shared inbox
- Get Attachment: Extract PDF from email
- Classify Document: Map attachment content and filename; get Class Names
- Switch on Class Names: Branch by document type
- Apply Metadata: Set SharePoint metadata from Class Names
- File Document: Store in type-specific SharePoint folder
- Notify Team: Alert relevant team of new document
Business Benefits:
- Automates inbox document routing by type
- Routes documents to correct departments based on your classification rules
- Enables type-specific metadata and folder organization
Archive Classification by Document Type
Complete Workflow Steps:
- Trigger: Document uploaded to archive processing folder
- Get Document: Retrieve document for classification
- Classify Document: Get Class Names for document type
- Create Metadata: Generate SharePoint metadata from Class Names
- Set Properties: Apply document type, category, tags
- Move to Archive: Transfer to type-specific archive folder by Class Name
- Update Index: Add to searchable document index
Business Benefits:
- Organizes archived documents by type using your classification rules
- Creates searchable archive with metadata from Class Names
- Enables fast document retrieval by type
Compliance Document Sorting by Type
Complete Workflow Steps:
- Trigger: Compliance document received for processing
- Get Document: Retrieve document from compliance inbox
- Classify Document: Get Class Names for document type
- Switch on Class Names: Route by compliance document type
- Route to Reviewer: Send to appropriate compliance reviewer per path
- Track Processing: Log Class Names and routing details
- File Properly: Store in compliance category folder
- Update Audit: Record classification in compliance audit database
Business Benefits:
- Routes compliance documents by type using your classification rules
- Ensures proper handling of each document type
- Maintains audit trail with Class Names
Industry Use Cases & Applications
- Finance & Banking
- Legal & Professional Services
- Healthcare & Medical
- Corporate & Business
Finance & Banking Use Cases
- Invoice Routing: Route invoices by class (e.g. regex matching "invoice") to AP workflow
- Receipt Processing: Identify receipts for expense management using expression patterns
- Document Sorting: Organize financial documents by type using your classification rules
Legal & Professional Services Use Cases
- Contract Identification: Classify contracts using regex (e.g.
contract(.*)) for contract management - Document Routing: Route documents to appropriate legal teams based on Class Name
- Case File Management: Classify case-related documents with custom expressions
Healthcare & Medical Use Cases
- Medical Record Classification: Identify patient record types using expression rules
- Claim Type Identification: Classify insurance claim documents with regex
- Form Classification: Categorize medical forms by type
Corporate & Business Use Cases
- Document Inbox Sorting: Classify incoming business documents using your rules
- Mixed Folder Sorting: Sort mixed PDFs (invoices, receipts, forms) into type-specific folders
- Metadata from Class: Set SharePoint properties from Class Names for searchability
Related Blogs
Step-by-step guides to classify and route documents by type: