Skip to main content
When you upload a document, FlexOrch returns a Job object immediately. The job moves through a processing pipeline — OCR, extraction, PII detection, and quality scoring — before reaching a terminal state. This page shows you how to track that lifecycle and act on the results.

Job states

StateMeaning
queuedDocument received; waiting for a processing slot.
runningPipeline is actively processing the document.
completedAll stages finished successfully.
failedPipeline encountered an unrecoverable error.

Get a job by ID

Retrieve a job you created earlier by passing its ID to client.jobs.get().
import os
from flexorch import FlexOrch

client = FlexOrch(api_key=os.environ["FLEXORCH_API_KEY"])

job = client.jobs.get("job_abc123")
print(f"Status: {job.status}")

Wait for completion

Call job.wait_until_done() to block the current thread until the job reaches completed or failed. The SDK polls automatically with exponential back-off — you do not need to write a polling loop yourself.
job = client.documents.upload("report.pdf")
job = job.wait_until_done()

if job.status == "completed":
    print("Processing finished.")
else:
    print(f"Job failed: {job.processing_summary}")
wait_until_done() raises JobTimeoutError if the job has not finished within the SDK’s default timeout (300 seconds). Pass timeout=600 to extend it for large files.
from flexorch.exceptions import JobTimeoutError

try:
    job = job.wait_until_done(timeout=600)
except JobTimeoutError:
    print("Job is taking longer than expected — check the dashboard.")

Access extraction results

Once a job is completed, you can read quality and PII data directly from the job object.
print(f"Quality grade:        {job.quality_grade}")         # "A" | "B" | "C" | "D"
print(f"Quality score:        {job.quality_score:.2f}")      # 0.0 – 1.0
print(f"PII findings:         {job.pii_findings_count}")
print(f"Privacy applied:      {job.privacy_applied}")        # True if redaction ran
print(f"Processing summary:   {job.processing_summary}")

Quality grades at a glance

GradeScore rangeRecommendation
A0.90 – 1.00Ready for training or retrieval as-is.
B0.75 – 0.89Good quality; minor cleanup may help.
C0.50 – 0.74Review before including in datasets.
D0.00 – 0.49Low quality; consider re-scanning source.

List jobs

client.jobs.list() returns a list of your most recent jobs, newest first.
jobs = client.jobs.list()

for job in jobs:
    print(f"{job.id}  {job.status}  grade={job.quality_grade}")
Use limit and offset for pagination:
page_1 = client.jobs.list(limit=25, offset=0)
page_2 = client.jobs.list(limit=25, offset=25)

Filter by quality grade

Standard Python list comprehensions work well for filtering:
high_quality = [
    j for j in client.jobs.list(limit=100)
    if j.quality_grade in ("A", "B")
]

print(f"High-quality jobs: {len(high_quality)}")

Submit feedback

If the extraction result is wrong or a quality grade is inaccurate, you can submit feedback to help improve the model:
client.jobs.submit_feedback(
    job_id="job_abc123",
    rating="negative",
    issue="wrong_fields",
)
rating
string
required
"positive" or "negative".
issue
string
A short issue code describing the problem. Common values: "wrong_fields", "missed_pii", "incorrect_summary", "poor_extraction".
Feedback is aggregated across your workspace. Consistent negative feedback on specific document types triggers a re-evaluation by the FlexOrch model team.

Next steps

Build Datasets

Turn completed jobs into structured, exportable datasets.

API Reference

Full parameter and return-type reference for all job methods.