> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trelent.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Job status & progress

> Understand job statuses and track progress via batch phases

Jobs report a top-level `status` and a list of `batches`. Each batch has a `phase` so you can track progress incrementally.

<ResponseExample>
  ```json 200 OK (completed) theme={null}
  {
    "job_id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "batches": [
      {
        "uid": "batch-abc123",
        "phase": "completed",
        "started_at": "2024-12-01T10:00:00Z",
        "finished_at": "2024-12-01T10:02:30Z"
      }
    ],
    "delivery": {
      "document.pdf": {
        "markdown_delivery": {
          "type": "s3-signed-url",
          "url": "https://..."
        },
        "images": {}
      }
    },
    "errors": null
  }
  ```
</ResponseExample>

### Status enums

* `queued`: The job was accepted and will start shortly.
* `running`: Processing is in progress.
* `completed`: All batches are finished and delivery details are available.

### Batches and phases

Each job has one or more `batches`. For each batch:

* `uid`: unique identifier
* `phase`: one of `queued`, `running`, or `completed`
* `started_at`, `finished_at`: optional timestamps

Track progress by counting how many batches are `completed` vs total.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { DataIngestionClient, DataIngestionConfig, JobStatus } from "@trelent/data-ingestion";

    const client = new DataIngestionClient();

    async function getProgress(jobId: string) {
      const status = await client.getJobStatus(jobId, { includeMarkdown: false });
      const total = status.batches.length;
      const completedBatches = status.batches.filter(b => b.phase === "completed").length;
      const isDone = status.status === JobStatus.Completed;
      return { 
        isDone,
        completedBatches, 
        total, 
        percent: total ? Math.round((completedBatches / total) * 100) : 0 
      };
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from trelent_data_ingestion_sdk.client import DataIngestionClient
    from trelent_data_ingestion_sdk.config import SDKConfig

    client = DataIngestionClient()

    def get_progress(job_id: str):
        status = client.get_job_status(job_id, include_markdown=False)
        total = len(status.batches)
        done = sum(1 for b in status.batches if str(b.phase) == "completed" or getattr(b, "phase", None) == "completed")
        percent = round((done / total) * 100) if total else 0
        return { "overall": status.status, "done": done, "total": total, "percent": percent }
    ```
  </Tab>
</Tabs>

### Reading delivery details

When `status` is `completed`, `delivery` provides either S3 pointers or signed URLs keyed by the original input identifier.
