Cancel an Asynchronous Job
/py-scripts/v2/jobs/{jobId}/cancel
Request
-
jobId(required): string
The id of the asynchronous job
There's no request body for this operation.
Back to TopResponse
- application/json
200 Response
400 Response
401 Response
404 Response
500 Response
Examples
Cancel a running asynchronous job by following these steps:
- Submit the job with
asyncFlagset totrue. - Send a
POSTrequest to the cancel endpoint using the job ID. - Check the job status.
- Fetch the job result.
An asynchronous job runs in the background after it is submitted. If you need to stop
a job before it finishes, send a cancellation request using the job ID returned in
the Location header. You can then check the job status and retrieve
the result to confirm that the job was cancelled. The following steps show this
process.
Step 1: Submit an asynchronous job
The following example submits the model_tuning_comments function with asyncFlag set to true.
curl -i -k -X POST \
--header "Authorization: Bearer ${token}" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
-d '{
"input": "BREASTCANCER",
"parameters": "{\"oml_input_type\":\"pandas.DataFrame\"}",
"asyncFlag": true,
"comments": "Model tuning job."
}' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v2/table-apply/model_tuning_comments"
The response includes HTTP status 201 Created and a Location header containing the job ID.
HTTP/2 201 Created
server: nginx/1.14.1
date: Thu, 23 Jul 2026 15:46:25 GMT
content-length: 0
strict-transport-security: max-age=31536000;includeSubDomains
x-content-type-options: nosniff
set-cookie: JSESSIONID=node0a2ukgrg0zetn34usmt4qdu7p16.node0;
Path=/oml; Secure; HttpOnly
expires: Thu, 01 Jan 1970 00:00:00 GMT
location: https://<oml-cloud-service-location-url>/oml/api/py-scripts/
v2/jobs/<job_id>
Step 2: Cancel the job
Wait for 10 seconds, then send a POST request to /py-scripts/v2/jobs/{jobId}/cancel. The request has no body.
sleep 10
curl -i -k -X POST \
--header "Authorization: Bearer ${token}" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v2/jobs/<job_id>/cancel"
A successful request returns HTTP status 200 OK. {"result":"job cancelled
successfully"}
Step 3: Check the job status
Call the job status endpoint with the job ID.
curl -i -k -X GET \
--header "Authorization: Bearer ${token}" \
--header 'Accept: application/json' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v2/jobs/<job_id>"
The response redirects to the job result URL with HTTP status 302 Found.
HTTP/2 302 Found
server: nginx/1.14.1
date: Thu, 23 Jul 2026 15:50:43 GMT
content-length: 0
strict-transport-security: max-age=31536000;includeSubDomains
x-content-type-options: nosniff
content-location: https://<oml-cloud-service-location-url>/oml/api/py-scripts/v2/jobs/<job_id>/result
Step 4: Fetch the job result
Send a request to the URL in the Content-Location header.
curl -i -k -X GET \
--header "Authorization: Bearer ${token}" \
--header 'Accept: application/json' \
"<oml-cloud-service-location-url>/oml/api/py-scripts/v2/jobs/<job_id>/result"
The result has HTTP status 200 OK and reports the job status as
CANCLLED.
{
"result": null,
"comments": "Model tuning job. Before Model Tuning.",
"status": "CANCELLED"
}