Client constructor
Your FlexOrch API key. Format:
dfx_<random_string>. Defaults to the
FLEXORCH_API_KEY environment variable if omitted.Override the API base URL. Defaults to
https://api.flexorch.com/v1. Useful
for testing against a staging environment.HTTP request timeout in milliseconds. Defaults to
30000 (30 seconds).client.documents
upload(filePath)
Uploads a single file and returns a Promise<Job>.
Path to the local file to upload. Accepts absolute or relative paths.
Promise<Job>
uploadMany(filePaths)
Uploads multiple files concurrently. Returns a Promise<Job[]> in the same order as the input array.
Array of local file paths to upload.
Promise<Job[]>
uploadFromConnector(options)
Pulls files from a connected storage source and creates one job per key.
Numeric ID of the connector. Find this in Settings → Connectors.
Object keys (paths) within the connector’s storage source.
Promise<Job[]>
client.jobs
get(jobId)
Fetches the current state of a job.
The unique identifier of the job.
Promise<Job>
list(options?)
Returns a paginated list of jobs for the authenticated workspace, newest first.
Maximum number of jobs to return. Defaults to
20. Maximum 100.Number of jobs to skip for pagination. Defaults to
0.Promise<Job[]>
submitFeedback(options)
Submits human feedback on a job’s extraction quality.
The unique identifier of the job.
"positive" or "negative".Short code describing the problem. Common values:
"wrong_fields",
"missed_pii", "incorrect_summary", "poor_extraction".Promise<void>
client.datasets
build(options)
Assembles a dataset from a list of completed job IDs.
IDs of the completed jobs to include in the dataset.
Human-readable name for the dataset. Must be unique within the workspace.
Promise<Dataset>
export(datasetId, options)
Exports a dataset and returns its contents as a Buffer.
The unique identifier of the dataset.
Export format. One of:
"jsonl", "csv", "parquet", "markdown",
"arrow".Promise<Buffer>
profile(datasetId)
Returns statistical metadata about the dataset.
The unique identifier of the dataset.
Promise<DatasetProfile>
delete(datasetId)
Permanently deletes the dataset export artifact. Underlying jobs are not affected.
The unique identifier of the dataset to delete.
Promise<void>
Type definitions
Job
| Field | Type | Description |
|---|---|---|
id | string | Unique job identifier (job_…). |
status | string | Current state: "queued", "running", "completed", or "failed". |
qualityGrade | string | null | Letter grade: "A", "B", "C", or "D". null until completed. |
qualityScore | number | null | Numeric score from 0.0 to 1.0. null until completed. |
piiFindingsCount | number | null | Number of PII entities detected. null until completed. |
privacyApplied | boolean | true if redaction or masking was applied during processing. |
isDuplicate | boolean | true if the file matches a previously processed document. |
originalJobId | string | null | Job ID of the original upload when isDuplicate is true. |
processingSummary | string | null | Human-readable description of the pipeline result or failure reason. |
createdAt | Date | UTC timestamp when the job was created. |
Job methods
| Method | Returns | Description |
|---|---|---|
waitUntilDone(options?) | Promise<Job> | Polls until the job reaches a terminal state. |
options.timeout | number | Timeout in seconds. Defaults to 300. |
Dataset
| Field | Type | Description |
|---|---|---|
id | string | Unique dataset identifier (ds_…). |
name | string | Human-readable name provided at creation. |
status | string | "building" or "ready". |
jobCount | number | Number of jobs included in the dataset. |
createdAt | Date | UTC timestamp when the dataset was created. |
DatasetProfile
| Field | Type | Description |
|---|---|---|
recordCount | number | Total number of records in the dataset. |
totalTokens | number | Estimated total token count across all records. |
avgQualityScore | number | Mean quality score across included jobs. |
gradeCounts | Record<string, number> | Record counts keyed by grade ("A", "B", "C", "D"). |
piiTypeCount | number | Number of distinct PII entity types detected. |
Error classes
| Class | Thrown when |
|---|---|
AuthenticationError | API key is missing, malformed, or revoked. |
FileTooLargeError | Uploaded file exceeds the plan’s size limit. |
JobTimeoutError | waitUntilDone() exceeded the configured timeout. |
IncompleteJobError | datasets.build() called with strict: true and a non-completed job. |
NotFoundError | The requested job or dataset ID does not exist. |
RateLimitError | API rate limit exceeded; retry after the indicated interval. |
FlexOrchError class and expose a message string and a numeric statusCode where applicable.
Related guides
Quickstart
Get up and running in five minutes.
Upload
Single, batch, and connector upload patterns.
Jobs
Polling, filtering, and feedback submission.
Datasets
Building, exporting, and profiling datasets.