Reprocess batch documents
Re-extract documents in a batch.
curl --request POST \
--url https://api.example.com/api/v2/batches/{batch_id}/reprocess/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version_number": 2,
"document_ids": [
2
],
"failed_only": false
}
'import requests
url = "https://api.example.com/api/v2/batches/{batch_id}/reprocess/"
payload = {
"version_number": 2,
"document_ids": [2],
"failed_only": 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({version_number: 2, document_ids: [2], failed_only: false})
};
fetch('https://api.example.com/api/v2/batches/{batch_id}/reprocess/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"batch": {
"id": 123,
"name": "<string>",
"status": "<string>",
"total_files": 123,
"succeeded_count": 123,
"failed_count": 123,
"default_version_number": 123
},
"reprocessed_doc_count": 123,
"estimated_credit_cost": 123
}{}{}{}Authorizations
Body
Body for POST /api/v2/batches/{batch_id}/reprocess/.
Resets the extraction state of one or more BatchDocuments and requeues
them for processing against a different (newer or older) StructVersion.
Each affected doc is treated as a brand-new extraction — its
ChatAttachment.extraction_result and
ChatAttachment.extraction_struct_version are cleared so the next
Lynx call starts from a clean slate.
Fields:
version_number: Target StructVersion.version_number (must
belong to the batch's parent struct, must NOT be deprecated).
document_ids: Optional list of BatchDocument PKs to reprocess.
When omitted (or empty), every doc in the batch is reprocessed.
Subset semantics let the user re-extract a single misbehaving
doc without re-running the whole batch (saves credits).
failed_only: When True, additionally restrict the reprocess
scope to BatchDocument rows in the FAILED state. Combines
with document_ids (intersection) when both are supplied.
Added in Task 7b (extraction-failure-surfacing) so users can
recover the ~234 historical broken docs that the Task 6
backfill flips from COMPLETED to FAILED — per-row reprocess at
that scale is impractical.
Response
Response shape for POST /api/v2/batches/{batch_id}/reprocess/.
Fields:
batch: The updated parent batch (status flipped to PROCESSING when
any doc was reset).
reprocessed_doc_count: Number of BatchDocuments whose extraction
state was actually cleared. Zero when document_ids matched
no rows (still 200 — the request was valid, it just had no
effect).
estimated_credit_cost: Best-effort millicredit estimate for the
reprocess job. Computed up-front from per-doc page counts so
the SPA can render a "this will cost ~X credits" confirmation
before the user clicks confirm. The actual deduction happens
inside process_batch when each doc finishes.
curl --request POST \
--url https://api.example.com/api/v2/batches/{batch_id}/reprocess/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version_number": 2,
"document_ids": [
2
],
"failed_only": false
}
'import requests
url = "https://api.example.com/api/v2/batches/{batch_id}/reprocess/"
payload = {
"version_number": 2,
"document_ids": [2],
"failed_only": 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({version_number: 2, document_ids: [2], failed_only: false})
};
fetch('https://api.example.com/api/v2/batches/{batch_id}/reprocess/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"batch": {
"id": 123,
"name": "<string>",
"status": "<string>",
"total_files": 123,
"succeeded_count": 123,
"failed_count": 123,
"default_version_number": 123
},
"reprocessed_doc_count": 123,
"estimated_credit_cost": 123
}{}{}{}
