Skip to main content
POST
/
extract
/
jobs
Start Extraction Job
curl --request POST \
  --url https://api.contextual.ai/v1/extract/jobs \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "document_id": "<string>",
  "schema_id": "<string>",
  "config": {
    "model": "gemini-2.5-flash",
    "per_key_attribution": false,
    "temperature": 0,
    "enable_thinking": true,
    "additional_instructions": "<string>",
    "enable_agentic_array_extraction": false
  },
  "stream": false
}
'
import requests

url = "https://api.contextual.ai/v1/extract/jobs"

payload = {
    "document_id": "<string>",
    "schema_id": "<string>",
    "config": {
        "model": "gemini-2.5-flash",
        "per_key_attribution": False,
        "temperature": 0,
        "enable_thinking": True,
        "additional_instructions": "<string>",
        "enable_agentic_array_extraction": False
    },
    "stream": False
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    document_id: '<string>',
    schema_id: '<string>',
    config: {
      model: 'gemini-2.5-flash',
      per_key_attribution: false,
      temperature: 0,
      enable_thinking: true,
      additional_instructions: '<string>',
      enable_agentic_array_extraction: false
    },
    stream: false
  })
};

fetch('https://api.contextual.ai/v1/extract/jobs', 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://api.contextual.ai/v1/extract/jobs",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'document_id' => '<string>',
    'schema_id' => '<string>',
    'config' => [
        'model' => 'gemini-2.5-flash',
        'per_key_attribution' => false,
        'temperature' => 0,
        'enable_thinking' => true,
        'additional_instructions' => '<string>',
        'enable_agentic_array_extraction' => false
    ],
    'stream' => false
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.contextual.ai/v1/extract/jobs"

	payload := strings.NewReader("{\n  \"document_id\": \"<string>\",\n  \"schema_id\": \"<string>\",\n  \"config\": {\n    \"model\": \"gemini-2.5-flash\",\n    \"per_key_attribution\": false,\n    \"temperature\": 0,\n    \"enable_thinking\": true,\n    \"additional_instructions\": \"<string>\",\n    \"enable_agentic_array_extraction\": false\n  },\n  \"stream\": false\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.contextual.ai/v1/extract/jobs")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"document_id\": \"<string>\",\n  \"schema_id\": \"<string>\",\n  \"config\": {\n    \"model\": \"gemini-2.5-flash\",\n    \"per_key_attribution\": false,\n    \"temperature\": 0,\n    \"enable_thinking\": true,\n    \"additional_instructions\": \"<string>\",\n    \"enable_agentic_array_extraction\": false\n  },\n  \"stream\": false\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.contextual.ai/v1/extract/jobs")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"document_id\": \"<string>\",\n  \"schema_id\": \"<string>\",\n  \"config\": {\n    \"model\": \"gemini-2.5-flash\",\n    \"per_key_attribution\": false,\n    \"temperature\": 0,\n    \"enable_thinking\": true,\n    \"additional_instructions\": \"<string>\",\n    \"enable_agentic_array_extraction\": false\n  },\n  \"stream\": false\n}"

response = http.request(request)
puts response.read_body
{
  "job_id": "<string>",
  "created_at": "<string>",
  "estimated_completion": "<string>"
}
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request model for starting a structured extraction job.

document_id
string
required

ID of the document to extract from

schema_id
string
required

ID of the schema to use for extraction

config
ExtractConfig · object | null

Configuration options for the extraction process

stream
boolean
default:false

Whether to stream the results as they become available. If true, the response will be a stream of JSON objects.

Response

Successful Response

Response model for extraction job creation.

job_id
string
required

Unique ID of the extraction job

status
enum<string>
required

Current status of the job

Available options:
pending,
processing,
retrying,
completed,
failed,
cancelled
created_at
string
required

Timestamp when the job was created

estimated_completion
string
required

Estimated completion time