Skip to main content
Document uploads are processed asynchronously. After uploading, you can check the status to know when processing is complete.

Checking status

import { Agentset } from "agentset";

const agentset = new Agentset({
  apiKey: process.env.AGENTSET_API_KEY,
});

const ns = agentset.namespace("YOUR_NAMESPACE_ID");

const job = await ns.ingestion.get("YOUR_JOB_ID");
console.log(`Job status: ${job.status}`);

Polling for completion

For longer-running uploads, you can poll until processing completes or fails.
import { Agentset } from "agentset";

const agentset = new Agentset({
  apiKey: process.env.AGENTSET_API_KEY,
});

const ns = agentset.namespace("YOUR_NAMESPACE_ID");

let job = await ns.ingestion.get("YOUR_JOB_ID");

while (job.status !== "COMPLETED" && job.status !== "FAILED") {
  await new Promise((resolve) => setTimeout(resolve, 10000));
  job = await ns.ingestion.get("YOUR_JOB_ID");
  console.log(`Job status: ${job.status}`);
}

if (job.status === "COMPLETED") {
  console.log("Job completed successfully!");
} else {
  console.log("Job failed");
}

Statuses

StatusDescription
PENDINGUpload is queued and waiting to be processed
PROCESSINGUpload is currently being processed
COMPLETEDUpload finished successfully
FAILEDUpload encountered an error

Next steps