curl "https://api.chatgrid.ai/v1/jobs/ccdd1122-3344-5566-7788-99aabbccddee" \
-H "Authorization: Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
async function waitForJob(jobId: string, apiKey: string): Promise<any> {
while (true) {
const resp = await fetch(`https://api.chatgrid.ai/v1/jobs/${jobId}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await resp.json();
if (data.status === "completed") return data.result;
if (data.status === "failed") throw new Error(data.error);
await new Promise((r) => setTimeout(r, 2000));
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "processing",
"result": null,
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:00.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "completed",
"result": { "chunks": 12 },
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:02:30.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "failed",
"result": null,
"error": "Failed to parse document: unsupported format",
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:05.000Z"
}
}
Jobs
Get Job
Retrieves the status and result of a background job.
GET
/
v1
/
jobs
/
{id}
curl "https://api.chatgrid.ai/v1/jobs/ccdd1122-3344-5566-7788-99aabbccddee" \
-H "Authorization: Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
async function waitForJob(jobId: string, apiKey: string): Promise<any> {
while (true) {
const resp = await fetch(`https://api.chatgrid.ai/v1/jobs/${jobId}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await resp.json();
if (data.status === "completed") return data.result;
if (data.status === "failed") throw new Error(data.error);
await new Promise((r) => setTimeout(r, 2000));
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "processing",
"result": null,
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:00.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "completed",
"result": { "chunks": 12 },
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:02:30.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "failed",
"result": null,
"error": "Failed to parse document: unsupported format",
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:05.000Z"
}
}
Poll this endpoint to check an async job. The
status field can be
processing, completed, or failed.
curl "https://api.chatgrid.ai/v1/jobs/ccdd1122-3344-5566-7788-99aabbccddee" \
-H "Authorization: Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
async function waitForJob(jobId: string, apiKey: string): Promise<any> {
while (true) {
const resp = await fetch(`https://api.chatgrid.ai/v1/jobs/${jobId}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await resp.json();
if (data.status === "completed") return data.result;
if (data.status === "failed") throw new Error(data.error);
await new Promise((r) => setTimeout(r, 2000));
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "processing",
"result": null,
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:00.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "completed",
"result": { "chunks": 12 },
"error": null,
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:02:30.000Z"
}
}
{
"object": "job",
"data": {
"id": "ccdd1122-3344-5566-7788-99aabbccddee",
"type": "document_process",
"status": "failed",
"result": null,
"error": "Failed to parse document: unsupported format",
"created_at": "2026-03-15T11:00:00.000Z",
"updated_at": "2026-03-15T11:00:05.000Z"
}
}
⌘I