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 accepts the same document formats and upload methods as /extract, including direct file uploads and file_url. See Supported File Types.

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.

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.

Response

Synchronous Response (200)

Async Response (202)


Example Usage

Example Response


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

Add an entry like "other" with a description such as “Any document that does not fit the other classifications” so unexpected documents don’t get force-fitted into a wrong class.
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.
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. 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.