Available
Classify an email
Classify an email's subject, body, and every attachment into finance document types without extracting anything.
Updated 2026-09-07
POST https://app.docparser.dev/api/v1/email-classify
Persists an email classification job, enqueues it, and returns 202 Accepted. Classification answers two questions asynchronously: what kind of finance document the email is about, judged from subject and body alone, and what kind of document each attachment is. Nothing is extracted. Submit the attachments you care about to /documents afterwards with the type_id the classifier reported.
This endpoint replaces email attachment mode on /documents, which now rejects an attachments array with a 400 pointing here.
Request
| Field | Type | Required | Description |
|---|---|---|---|
attachments | URL string[] | Yes; at least one | Publicly fetchable attachment URLs. Each is classified individually, in this order. |
subject | string | No; defaults to "" | Email subject. Preferred over the body when the two disagree. |
body | string | No; defaults to "" | Email body text. |
webhookUrl | string | No; defaults to "" | Relative path joined to the API key’s registered base URL. |
documentId | string | integer | Yes | Caller-supplied email identifier. Returned as document_id in the webhook, as the type you sent. |
consumerRefId | non-empty string | Yes | Caller-supplied correlation reference, scoped to the organization during retrieval. |
typeId | integer | No; defaults to 1 | The product the email belongs to: 1 for Accounts Payable, 2 for Accounts Receivable. Not a document type. |
geminiModelKey | string | No | Optional explicit model for this job. See Submit documents. |
tags | object | No | Attribution labels, e.g. {"business": "acme-foods"}: up to 20 keys, values up to 256 characters. Echoed in the webhook as tags. See Tag requests. |
typeId selects a product, and the response is tagged with it:
typeId | product | product_name |
|---|---|---|
| 1 | ap | Accounts Payable |
| 2 | arc | Accounts Receivable |
{
"attachments": [
"https://files.example.com/mail/remittance-4471.pdf",
"https://files.example.com/mail/pod-4471.pdf"
],
"subject": "Payment advice for INV-4471",
"body": "Please find the remittance advice attached.",
"webhookUrl": "/hooks/docparser",
"documentId": 4471,
"consumerRefId": "mail-4471",
"typeId": 1
} Accepted response
{
"jobId": "5ca1ab1e-314d-4b2d-b9d6-8e68870b840f",
"consumerRefId": "mail-4471",
"typeId": 1,
"product": "ap",
"status": "initiated"
} What the classifier returns
Both the email and each attachment are classified into one of these document types. The type_id values are the same ones /documents accepts, so a classified attachment can be submitted for extraction directly. creditNote is classification-only today, and unknown covers supporting documents such as proof of delivery or agreements.
| Field | Type | type_id | Description |
|---|---|---|---|
invoice | Invoice | 0 | Submit to /documents with this typeId to extract it. |
po | Purchase Order | 1 | Submit to /documents with this typeId to extract it. |
grn | Goods Receipt Note | 2 | Submit to /documents with this typeId to extract it. |
debitNote | Debit Note | 3 | Submit to /documents with this typeId to extract it. |
paymentAdvice | Payment Advice | 11 | Submit to /documents with this typeId to extract it. |
creditNote | Credit Note | 12 | Classification only; no extraction schema. |
unknown | Unknown | -1 | Not a finance document, or the attachment could not be read. |
Retrieve
GET https://app.docparser.dev/api/v1/email-classify/:consumerRefId
Returns the most recent persisted email_classification_jobs row for the authenticated organization and consumer reference, serialized with camelCase property names. processedData carries the classification, extractionStats the token counts and model, and the webhook and error fields behave as they do for document jobs.
The delivered webhook payload is documented under Webhooks.
Compatibility with the previous service
Integrations written against the previous email classification service keep working without changes. The paths POST /api/v1/email-classify/classify and GET /api/v1/email-classify/get?consumer_ref_id=… accept its snake_case request body (webhook_url, document_id, consumer_ref_id, type_id, gemini_model_key), answer with its response shapes (job_id, consumer_ref_id, type_id, product on acceptance; the stored record with processed_data, openai_stats and webhook_status on retrieval), and take the x_client_id / x_client_secret header spellings. An absolute webhook_url is accepted on these paths only when it lives under the API key’s registered base URL.
Errors
400— an emptyattachmentsarray, an absolutewebhookUrl, or atypeIdother than 1 or 2 (Unsupported typeId. Use 1 for AP or 2 for ARC.).401and403— as for every public endpoint.404withEmail classification job not found.— no organization-scoped job matched the reference.500withFailed to create email classification job.— the job could not be persisted.