Skip to main content

GET /api/jobs/:id

Retrieves the current status and metadata for a specific job.

Path Parameters

id
string
required
The unique job identifier returned from /api/generate.

Response

status
string
Always "success" if the job exists.
job
object
Job details object containing the following fields:

Example Request

curl http://localhost:8080/api/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890

Example Response

{
  "status": "success",
  "job": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "state": "running",
    "cancelRequested": false,
    "resultPath": null,
    "errorMessage": null,
    "createdAt": "2024-03-15T10:30:00.000Z",
    "startedAt": "2024-03-15T10:30:05.123Z",
    "completedAt": null
  }
}

Error Response

{
  "status": "error",
  "message": "Job not found."
}
HTTP Status: 404 Not Found

GET /api/jobs/:id/events

Retrieves progress events for a specific job. Supports incremental polling by providing the last received event ID.

Path Parameters

id
string
required
The unique job identifier.

Query Parameters

after
integer
default:"0"
Return only events with an ID greater than this value. Used for incremental polling.Example: after=42 returns events with ID 43, 44, 45, etc.

Response

status
string
Always "success" if the job exists.
events
array
Array of event objects, ordered by creation time (oldest first).

Example Request

# Get all events
curl http://localhost:8080/api/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/events

# Get events after ID 42
curl http://localhost:8080/api/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/events?after=42

Example Response

{
  "status": "success",
  "events": [
    {
      "id": 43,
      "type": "log",
      "level": "info",
      "message": "Generating script...",
      "payload": null,
      "timestamp": 1710499805.123
    },
    {
      "id": 44,
      "type": "log",
      "level": "success",
      "message": "Script generated successfully",
      "payload": {"wordCount": 250},
      "timestamp": 1710499812.456
    },
    {
      "id": 45,
      "type": "log",
      "level": "info",
      "message": "Searching for footage...",
      "payload": null,
      "timestamp": 1710499813.789
    }
  ]
}

Error Response

{
  "status": "error",
  "message": "Job not found."
}
HTTP Status: 404 Not Found

POST /api/jobs/:id/cancel

Requests cancellation of a specific job. The job will be cancelled gracefully at the next checkpoint.

Path Parameters

id
string
required
The unique job identifier to cancel.

Response

status
string
"success" if cancellation was requested.
message
string
Always "Cancellation requested."

Example Request

curl -X POST http://localhost:8080/api/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel

Example Response

{
  "status": "success",
  "message": "Cancellation requested."
}

Error Response

{
  "status": "error",
  "message": "Job not found."
}
HTTP Status: 404 Not Found
Cancellation is not immediate. The job will be cancelled at the next safe checkpoint. Check the cancelRequested field in the job status to confirm the request was received.

POST /api/cancel

Cancels the latest active job (running or queued). Prioritizes running jobs over queued jobs.
This endpoint cancels ANY active job, not a specific one. Use POST /api/jobs/:id/cancel to cancel a specific job.

Response

status
string
"success" if a job was found and cancellation was requested.
message
string
Always "Cancellation requested."
jobId
string
The ID of the job that was cancelled.

Example Request

curl -X POST http://localhost:8080/api/cancel

Example Response

{
  "status": "success",
  "message": "Cancellation requested.",
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Error Response

{
  "status": "error",
  "message": "No active job found."
}
HTTP Status: 404 Not Found

Build docs developers (and LLMs) love