Skip to content

Job Management

Monitor and manage your processing jobs with status checks and real-time streaming.

GET /api/v1/jobs/{id}

Get the current status and details of a processing job.

ParameterTypeRequiredDescription
idstringJob ID (path parameter)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "image_resize",
"status": "completed",
"source_bucket": "my-bucket",
"source_key": "photo.jpg",
"dest_bucket": "my-bucket",
"dest_key": "photo-resized.jpg",
"parameters": {
"width": 800,
"height": 600
},
"result": {
"output_url": "s3://my-bucket/photo-resized.jpg",
"file_size": 245760,
"duration": 1.23,
"metadata": {
"width": 800,
"height": 600,
"format": "jpeg"
}
},
"created_at": "2025-10-18T22:00:00Z",
"updated_at": "2025-10-18T22:00:02Z",
"completed_at": "2025-10-18T22:00:02Z",
"duration_seconds": 1.23
}

pending

Job is queued, waiting for a worker

Queue position may be included

processing

Worker is actively processing the job

Progress updates via SSE

completed

Job finished successfully

Result data available

failed

Job encountered an error

Error message in response

Terminal window
curl -H "X-API-Key: your_api_key_here" \
http://localhost:8080/api/v1/jobs/550e8400-e29b-41d4-a716-446655440000

GET /api/v1/jobs/{id}/stream

Subscribe to real-time job status updates via Server-Sent Events (SSE).

ParameterTypeRequiredDescription
idstringJob ID (path parameter)

Server-Sent Events stream with updates:

event: status
data: {"status":"pending","message":"Job queued"}
event: status
data: {"status":"processing","message":"Processing started"}
event: progress
data: {"percent":50,"message":"Processing frame 50/100"}
event: complete
data: {"status":"completed","result":{...}}
EventDescription
statusJob status changed
progressProcessing progress update
completeJob completed (success or failure)
errorError occurred
const eventSource = new EventSource(
`http://localhost:8080/api/v1/jobs/${jobId}/stream`
);
eventSource.addEventListener('status', (e) => {
const data = JSON.parse(e.data);
console.log('Status:', data.status);
});
eventSource.addEventListener('progress', (e) => {
const data = JSON.parse(e.data);
console.log('Progress:', data.percent + '%');
});
eventSource.addEventListener('complete', (e) => {
const data = JSON.parse(e.data);
console.log('Completed:', data);
eventSource.close();
});
eventSource.addEventListener('error', (e) => {
console.error('Error:', e);
eventSource.close();
});

Learn more in the SSE Guide.


GET /api/v1/jobs

Get a list of all jobs with optional filtering.

ParameterTypeDescription
statusstringFilter by status: pending, processing, completed, failed
limitintegerMaximum results (default: 100, max: 1000)
{
"jobs": [
{
"id": "job-1",
"type": "image_resize",
"status": "completed",
"created_at": "2025-10-18T22:00:00Z"
},
{
"id": "job-2",
"type": "video_thumbnail",
"status": "processing",
"created_at": "2025-10-18T22:01:00Z"
}
],
"total": 2
}
Terminal window
curl -H "X-API-Key: your_api_key_here" \
"http://localhost:8080/api/v1/jobs?limit=50"

When a job completes successfully, the result object contains:

{
"output_url": "s3://bucket/output.jpg",
"file_size": 245760,
"duration": 1.23,
"metadata": {
"width": 800,
"height": 600,
"format": "jpeg"
}
}
{
"colors": ["#3B82F6", "#10B981", "#F59E0B"],
"percentages": [45.2, 32.1, 22.7]
}
{
"keywords": ["sunset", "beach", "ocean", "tropical"],
"confidence_scores": [0.95, 0.92, 0.89, 0.87]
}
{
"output_url": "s3://bucket/thumbnail.jpg",
"file_size": 125440,
"timestamp": "00:00:05",
"metadata": {
"width": 1280,
"height": 720
}
}

Polling (GET /jobs/{id})

Best for:

  • Simple status checks
  • Batch processing
  • Background jobs

Pros:

  • Simple to implement
  • Works everywhere

Cons:

  • Higher latency
  • More API calls

Streaming (SSE)

Best for:

  • Real-time UI updates
  • Long-running jobs
  • Progress tracking

Pros:

  • Instant updates
  • Efficient

Cons:

  • Requires SSE support
  • Keeps connection open

When a job fails, the response includes an error message:

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "failed",
"error": "Source file not found in S3: my-bucket/photo.jpg",
"created_at": "2025-10-18T22:00:00Z",
"updated_at": "2025-10-18T22:00:01Z"
}

Progress Bars

Show real-time progress in your UI with SSE

Status Dashboards

Monitor all jobs with the list endpoint

Retry Logic

Check failed jobs and retry with corrected parameters

Analytics

Track job completion rates and processing times


async function waitForJob(jobId, maxAttempts = 30) {
let attempt = 0;
while (attempt < maxAttempts) {
const response = await fetch(`/api/v1/jobs/${jobId}`, {
headers: { 'X-API-Key': apiKey }
});
const job = await response.json();
if (job.status === 'completed' || job.status === 'failed') {
return job;
}
// Exponential backoff: 1s, 2s, 4s, 8s, ...
const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
await new Promise(resolve => setTimeout(resolve, delay));
attempt++;
}
throw new Error('Job timeout');
}