Skip to main content

Cancel Job

Endpoint: Cancel Job

This endpoint allows users to cancel a specific job associated with an app. The job is identified by its job_id, and the app it belongs to is identified by its app_id. A job can only be canceled if it is still in progress or queued.

URL

PUT https://api.rungen.ai/app/{app_id}/job/{job_id}

Path Parameters

ParameterTypeRequiredDescription
app_idStringYesThe unique identifier of the app the job belongs to.
job_idStringYesThe unique identifier of the job to cancel.

Headers

HeaderTypeRequiredDescription
X-Authenticated-User-IdStringYesThe unique identifier of the user canceling the job.
x-api-keyStringYesYour API key for authentication.
x-team-idStringNoThe unique identifier for the team. If omitted, the request operates in the user's personal context.

Example Request

curl --location --request PUT 'https://api.rungen.ai/app/48cfa519-f5fc-4bf1-8476-1345536a2c7a/job/09e04b85-2ff2-4f1b-acf0-ae97ce3bafb8' \
--header 'X-Authenticated-User-Id: ee4988a7-48e2-44ae-81f5-178a44ebeb58' \
--header 'x-api-key: 123456789abc'

Response

Success

Status Code: 200 OK

Response Body:

{
"data": {
"job_id": "09e04b85-2ff2-4f1b-acf0-ae97ce3bafb8",
"status": "CANCELED"
}
}

Response Fields

FieldTypeDescription
data.job_idStringThe unique identifier of the canceled job.
data.statusStringThe updated status of the job (CANCELED).

Error Responses

Status Code: 404 Not Found

Example Response Body:

{
"error": "Job with ID '09e04b85-2ff2-4f1b-acf0-ae97ce3bafb8' not found for App ID '48cfa519-f5fc-4bf1-8476-1345536a2c7a'."
}

Status Code: 403 Forbidden

Example Response Body:

{
"error": "Unauthorized access. Invalid API key."
}

Status Code: 409 Conflict

Example Response Body:

{
"error": "Job cannot be canceled because it has already completed."
}

Notes

  • Job Status: A job can only be canceled if it is in the QUEUED or RUNNING state. Attempting to cancel a job that is COMPLETED or FAILED will result in a conflict error.
  • Authentication: Ensure the x-api-key and X-Authenticated-User-Id headers are valid. If working within a team context, include the x-team-id header to access team jobs.
  • Team Context: If the x-team-id header is provided, the cancellation action will apply to the job within the specified team.