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

# Job Management

> Manage and track async jobs using the JavaScript SDK

The SDK provides methods to retrieve job status, cancel jobs, and list jobs for async operations.

***

## Retrieve Job Status

```javascript theme={null}
// Start an async job
const jobResponse = await client.parse.runJob({ input: upload.file_id });
const jobId = jobResponse.job_id;

// Retrieve job status
const job = await client.job.retrieve(jobId);

// Check status
if (job.status === "Completed") {
  console.log("Job completed!");
  const result = job.result; // ParseResponse, ExtractResponse, etc.
  if (result && 'chunks' in result.result) {
    console.log(`Found ${result.result.chunks.length} chunks`);
  }
} else if (job.status === "Pending") {
  console.log("Job still processing...");
  console.log(`Progress: ${job.progress || 0}%`);
} else if (job.status === "Failed") {
  console.log(`Job failed: ${job.reason}`);
}
```

***

## Polling for Completion

```javascript theme={null}
async function waitForJob(client, jobId) {
  while (true) {
    const job = await client.job.retrieve(jobId);
    
    if (job.status === "Completed") {
      return job.result;
    } else if (job.status === "Failed") {
      throw new Error(`Job failed: ${job.reason}`);
    }
    
    console.log(`Status: ${job.status}, Progress: ${job.progress || 0}%`);
    await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
  }
}

// Usage
const jobResponse = await client.parse.runJob({ input: upload.file_id });
const result = await waitForJob(client, jobResponse.job_id);
```

***

## Cancel a Job

```javascript theme={null}
// Cancel a running job
await client.job.cancel(jobId);
```

***

## List All Jobs

```javascript theme={null}
// Get all jobs with pagination
const response = await client.job.getAll({
  limit: 50,
  exclude_configs: true  // Exclude raw_config to reduce response size
});

for (const job of response.jobs) {
  console.log(`${job.job_id}: ${job.status} (${job.type})`);
}

// Get next page
if (response.next_cursor) {
  const nextPage = await client.job.getAll({
    cursor: response.next_cursor,
    limit: 50
  });
}
```

***

## Next Steps

* Learn about [error handling](/sdk/javascript/error-handling) for robust applications
