Skip to main content
POST
Classify a document to route it to a pipeline

Overview

Routing step (optional, runs before extraction) — Classify takes a raw document, not a saved extraction. Use it to decide which pipeline (and therefore which /extract settings) a document should be routed to.
POST /classify is a lightweight routing step that runs before /extract. Given a raw document and a set of caller-defined classifications, it returns which classification the document belongs to — plus that classification’s pipeline_id, so you can send the document to the right pipeline next. Why classify before extract: extraction settings (chunking, schema, tables, …) differ per document type, so you need to know the type before you extract. By default, /classify evaluates the first five pages and costs 0.5 credits per page — half the /extract rate. See Credits.

Accepted Document Types

/classify uses the same upload path as /extract — the same accepted formats, the same size limits, and both direct file uploads and file_url. Formats that need normalizing (.webp, .csv, .xlsb) are converted on upload before classification, exactly as they are for /extract.
How a format is handled affects billing, not acceptance: PDFs and images are billed only for the pages in the effective page_range, while Office and HTML files are billed for every page. See Credits.

Async Mode

Set async: true to return immediately with a job ID for polling. See Polling for Results. On completion, the job’s result carries the same body as the sync response.
/classify is currently REST-only: it is not yet exposed as a Python/TypeScript SDK method, a CLI command, or an MCP tool. Call it over HTTP as shown below.

Request

Provide either file (multipart upload) or file_url (JSON body) — not both.

Request Body

Classify Config (classify_config)

  • <name> is any label you choose; Pulse returns exactly one of these names.
  • description tells Pulse what belongs in each class — make it specific and mutually distinct.
  • pipeline_id is optional routing metadata. When provided, it must reference a pipeline your organization owns (otherwise the request is rejected with PIPELINE_003). The matched classification’s pipeline_id is echoed back so you can route the document next.

Always include a catch-all classification

Classification is forced-choice. /classify always returns one of the names you supplied — there is no built-in “none of the above”, no null result, and no confidence score. A document that matches none of your classifications is not rejected: it is assigned to whichever class comes closest, with nothing in the response to flag it as a poor match.
Define the escape hatch yourself: add a catch-all classification and leave off its pipeline_id.
A null classify_output.pipeline_id then becomes your “don’t extract this” signal:
Branch on it before you route — send those documents to manual review instead of into a pipeline built for a different document type.
Give the catch-all a description that says what it absorbs, not just the word “other”. A thin description competes poorly against your detailed classes, and Pulse will keep preferring a wrong-but-well-described class over a vague catch-all. For the same reason, keep the specific descriptions tight — a broad description like “financial documents” pulls in documents the catch-all should have caught.
Without a catch-all there is no clean “no match” outcome — you get either a confidently wrong classification, or a PROC_001 error in the case where Pulse answers off-list, since any name outside your classifications keys is rejected.

Response

Synchronous Response (200)

Async Response (202)


Example Usage

Example Response

classification is returned at the top level for quick access and repeated inside classify_output, which keeps the routing decision (classification, pipeline_id, page_range) self-contained for pipeline consumers. Both always hold the same value.

Routing to a Pipeline

/classify only tells you which pipeline to use — it does not execute it. Take the returned pipeline_id and run that pipeline with the same document; its own extraction settings then apply. classify can also be used as the first step of an ad-hoc pipeline, where it classifies the raw document before the downstream steps run. It cannot be combined with batch_extract (classify needs a single document), and it is currently supported with inline config only.

Credits

/classify is billed at 0.5 credits per page — half the /extract rate (1 credit/page).
  • PDFs / images: billed for the pages in the (defaulted/clamped) page_range.
  • Office / HTML: billed for every page, even when page_range is smaller.
See the full rate table in Credit Usage.

Error Responses


Best Practices

Classification is forced-choice, so a document that fits none of your classes is still assigned to one of them. A catch-all with no pipeline_id gives unexpected documents somewhere to land and gives you a null pipeline_id to branch on. See Always include a catch-all classification.
The description tells Pulse what belongs in each class. Describe what the documents contain, not just their name, and make classes clearly distinguishable from each other. This matters most for the catch-all, which loses to better-described classes when its own description is vague.
The first 5 pages are usually enough to identify a document type. An explicit page_range has no hard cap, but large ranges scale credits linearly.
Classification is a probabilistic hint, not a guarantee, and the response carries no confidence score — a borderline guess and a certain match look identical. Validate downstream where correctness matters. Nothing from /classify is persisted — the routed pipeline’s /extract produces the durable output.

Authorizations

x-api-key
string
header
required

Body

Request body for classifying a document. Provide exactly one of file (multipart upload) or file_url (JSON body). In multipart/form-data requests, classify_config is sent as a JSON string form field.

classify_config
object
required

Candidate classifications the document is matched against.

file
file

Document to upload directly (multipart/form-data only). Required unless file_url is provided.

file_url
string<uri>

Public or pre-signed URL that Pulse will download and classify. Required unless file is provided.

page_range
string

Pages to inspect, e.g. "1-5" or "1,3,5-7". Defaults to the first 5 pages, clamped to the document length. For Office/HTML formats, every page is billed.

async
boolean
default:false

If true, returns immediately with a job_id for polling via GET /job/{jobId}. Otherwise processes synchronously.

parent_job_id
string<uuid>

Optional parent job id for tracking.

Response

Classification result (when async=false or omitted)

Result of document classification.

classification
string
required

The winning classification name — one of the keys from the request's classifications object.

classify_output
object
required

Details of the winning classification.

job_id
string<uuid>

Identifier of the request for tracking and support.

credits_used
number<float> | null

Number of credits consumed by this request.