curl --request POST \
--url https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel \
--header 'unstructured-api-key: <api-key>'import requests
url = "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel"
headers = {"unstructured-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'unstructured-api-key': '<api-key>'}};
fetch('https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"unstructured-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("unstructured-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel")
.header("unstructured-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["unstructured-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "9eb6c914-02a5-4c5d-8490-a06476946a38",
"status": "queued",
"file_id": "<string>",
"filename": "<string>",
"cancellation_requested": false,
"source": {
"file_id": "<string>",
"filename": "<string>",
"mimetype": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
},
"error": {
"code": "invalid_input",
"message": "<string>"
},
"result": {
"id": "<string>",
"status": "processing",
"profile": "balanced",
"markdown": "<string>",
"format_version": "2.0",
"metadata": {
"page_count": 123
},
"extracted_data": [
{
"data": "<unknown>",
"field_metadata": {}
}
],
"elements": [
{
"element_id": "<string>",
"type": "<string>",
"text": "<string>",
"metadata": {
"page_number": 123,
"coordinates": {},
"text_as_html": "<string>"
}
}
],
"source": {
"file_id": "<string>",
"filename": "<string>",
"mimetype": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
},
"warnings": []
}
}{
"code": "unauthorized",
"message": "Authentication required: send either an 'unstructured-api-key' header or 'Authorization: Bearer <token>'."
}{
"code": "forbidden",
"message": "You are not allowed to change this job."
}{
"code": "not_found",
"message": "No such job."
}{
"code": "parse_job_failed",
"message": "The job could not be cancelled. Retry the request."
}Request cancellation of a job
Request cancellation of a queued or processing job. Read the returned job snapshot and keep polling until the job reaches a final status.
curl --request POST \
--url https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel \
--header 'unstructured-api-key: <api-key>'import requests
url = "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel"
headers = {"unstructured-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'unstructured-api-key': '<api-key>'}};
fetch('https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"unstructured-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("unstructured-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel")
.header("unstructured-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://transform.unstructured.io/api/v2/jobs/{jobId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["unstructured-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "9eb6c914-02a5-4c5d-8490-a06476946a38",
"status": "queued",
"file_id": "<string>",
"filename": "<string>",
"cancellation_requested": false,
"source": {
"file_id": "<string>",
"filename": "<string>",
"mimetype": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
},
"error": {
"code": "invalid_input",
"message": "<string>"
},
"result": {
"id": "<string>",
"status": "processing",
"profile": "balanced",
"markdown": "<string>",
"format_version": "2.0",
"metadata": {
"page_count": 123
},
"extracted_data": [
{
"data": "<unknown>",
"field_metadata": {}
}
],
"elements": [
{
"element_id": "<string>",
"type": "<string>",
"text": "<string>",
"metadata": {
"page_number": 123,
"coordinates": {},
"text_as_html": "<string>"
}
}
],
"source": {
"file_id": "<string>",
"filename": "<string>",
"mimetype": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
},
"warnings": []
}
}{
"code": "unauthorized",
"message": "Authentication required: send either an 'unstructured-api-key' header or 'Authorization: Bearer <token>'."
}{
"code": "forbidden",
"message": "You are not allowed to change this job."
}{
"code": "not_found",
"message": "No such job."
}{
"code": "parse_job_failed",
"message": "The job could not be cancelled. Retry the request."
}Authorizations
Path Parameters
Identifies one piece of work, whichever path submitted it. The same id the blocking call returns.
"9eb6c914-02a5-4c5d-8490-a06476946a38"
Response
The current job state after the cancellation request.
A job's state, carrying parsed content as soon as it is available.
Identifies one piece of work, whichever path submitted it. The same id the blocking call returns.
"9eb6c914-02a5-4c5d-8490-a06476946a38"
Terminal values match the blocking call's own status values.
queued, processing, failed, completed, completed_with_warnings, cancelled The authoritative source/input file ID. This is the ID accepted by GET /api/v2/upload/{fileId}, never a job ID, result artifact ID, storage key, or signed URL. Null for legacy or unassociated jobs.
The document's original uploaded filename.
True after cancellation has been requested for this job.
The associated original uploaded source file, when known.
Show child attributes
Show child attributes
A machine-readable code and an actionable message.
Show child attributes
Show child attributes
Null until parsed content is available.
Show child attributes
Show child attributes
Was this page helpful?

