Skip to main content
This page is the authoritative reference for every class, method, and type in the FlexOrch TypeScript SDK. For conceptual guides and code walkthroughs, see the pages linked at the bottom.

Client constructor

import { FlexOrch } from "@flexorch/sdk";

const client = new FlexOrch({
  apiKey: "dfx_your_key_here",   // optional if FLEXORCH_API_KEY is set
  baseUrl: "https://api.flexorch.com/v1", // optional
  timeout: 30_000,               // optional, milliseconds
});
apiKey
string
Your FlexOrch API key. Format: dfx_<random_string>. Defaults to the FLEXORCH_API_KEY environment variable if omitted.
baseUrl
string
Override the API base URL. Defaults to https://api.flexorch.com/v1. Useful for testing against a staging environment.
timeout
number
HTTP request timeout in milliseconds. Defaults to 30000 (30 seconds).

client.documents

upload(filePath)

Uploads a single file and returns a Promise<Job>.
const job = await client.documents.upload("invoice.pdf");
filePath
string
required
Path to the local file to upload. Accepts absolute or relative paths.
Returns: Promise<Job>

uploadMany(filePaths)

Uploads multiple files concurrently. Returns a Promise<Job[]> in the same order as the input array.
const jobs = await client.documents.uploadMany(["file1.pdf", "file2.docx"]);
filePaths
string[]
required
Array of local file paths to upload.
Returns: Promise<Job[]>

uploadFromConnector(options)

Pulls files from a connected storage source and creates one job per key.
const jobs = await client.documents.uploadFromConnector({
  connectorId: 1,
  keys: ["reports/q1.pdf"],
});
options.connectorId
number
required
Numeric ID of the connector. Find this in Settings → Connectors.
options.keys
string[]
required
Object keys (paths) within the connector’s storage source.
Returns: Promise<Job[]>

client.jobs

get(jobId)

Fetches the current state of a job.
const job = await client.jobs.get("job_abc123");
jobId
string
required
The unique identifier of the job.
Returns: Promise<Job>

list(options?)

Returns a paginated list of jobs for the authenticated workspace, newest first.
const jobs = await client.jobs.list({ limit: 25, offset: 0 });
options.limit
number
Maximum number of jobs to return. Defaults to 20. Maximum 100.
options.offset
number
Number of jobs to skip for pagination. Defaults to 0.
Returns: Promise<Job[]>

submitFeedback(options)

Submits human feedback on a job’s extraction quality.
await client.jobs.submitFeedback({
  jobId: "job_abc123",
  rating: "negative",
  issue: "wrong_fields",
});
options.jobId
string
required
The unique identifier of the job.
options.rating
string
required
"positive" or "negative".
options.issue
string
Short code describing the problem. Common values: "wrong_fields", "missed_pii", "incorrect_summary", "poor_extraction".
Returns: Promise<void>

client.datasets

build(options)

Assembles a dataset from a list of completed job IDs.
const dataset = await client.datasets.build({
  jobIds: ["job_abc123", "job_def456"],
  name: "my-dataset",
});
options.jobIds
string[]
required
IDs of the completed jobs to include in the dataset.
options.name
string
required
Human-readable name for the dataset. Must be unique within the workspace.
Returns: Promise<Dataset>

export(datasetId, options)

Exports a dataset and returns its contents as a Buffer.
const data = await client.datasets.export("ds_xyz789", { format: "jsonl" });
datasetId
string
required
The unique identifier of the dataset.
options.format
string
required
Export format. One of: "jsonl", "csv", "parquet", "markdown", "arrow".
Returns: Promise<Buffer>

profile(datasetId)

Returns statistical metadata about the dataset.
const profile = await client.datasets.profile("ds_xyz789");
datasetId
string
required
The unique identifier of the dataset.
Returns: Promise<DatasetProfile>

delete(datasetId)

Permanently deletes the dataset export artifact. Underlying jobs are not affected.
await client.datasets.delete("ds_xyz789");
datasetId
string
required
The unique identifier of the dataset to delete.
Returns: Promise<void>

Type definitions

Job

FieldTypeDescription
idstringUnique job identifier (job_…).
statusstringCurrent state: "queued", "running", "completed", or "failed".
qualityGradestring | nullLetter grade: "A", "B", "C", or "D". null until completed.
qualityScorenumber | nullNumeric score from 0.0 to 1.0. null until completed.
piiFindingsCountnumber | nullNumber of PII entities detected. null until completed.
privacyAppliedbooleantrue if redaction or masking was applied during processing.
isDuplicatebooleantrue if the file matches a previously processed document.
originalJobIdstring | nullJob ID of the original upload when isDuplicate is true.
processingSummarystring | nullHuman-readable description of the pipeline result or failure reason.
createdAtDateUTC timestamp when the job was created.

Job methods

MethodReturnsDescription
waitUntilDone(options?)Promise<Job>Polls until the job reaches a terminal state.
options.timeoutnumberTimeout in seconds. Defaults to 300.

Dataset

FieldTypeDescription
idstringUnique dataset identifier (ds_…).
namestringHuman-readable name provided at creation.
statusstring"building" or "ready".
jobCountnumberNumber of jobs included in the dataset.
createdAtDateUTC timestamp when the dataset was created.

DatasetProfile

FieldTypeDescription
recordCountnumberTotal number of records in the dataset.
totalTokensnumberEstimated total token count across all records.
avgQualityScorenumberMean quality score across included jobs.
gradeCountsRecord<string, number>Record counts keyed by grade ("A", "B", "C", "D").
piiTypeCountnumberNumber of distinct PII entity types detected.

Error classes

ClassThrown when
AuthenticationErrorAPI key is missing, malformed, or revoked.
FileTooLargeErrorUploaded file exceeds the plan’s size limit.
JobTimeoutErrorwaitUntilDone() exceeded the configured timeout.
IncompleteJobErrordatasets.build() called with strict: true and a non-completed job.
NotFoundErrorThe requested job or dataset ID does not exist.
RateLimitErrorAPI rate limit exceeded; retry after the indicated interval.
All error classes extend the base FlexOrchError class and expose a message string and a numeric statusCode where applicable.

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.