Add library documents to a batch
Add existing library documents to a batch.
curl --request POST \
--url https://api.example.com/api/v2/batches/{batch_id}/documents/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_ids": [
2
],
"version_number": 2,
"per_doc_versions": {}
}
'import requests
url = "https://api.example.com/api/v2/batches/{batch_id}/documents/"
payload = {
"document_ids": [2],
"version_number": 2,
"per_doc_versions": {}
}
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_ids: [2], version_number: 2, per_doc_versions: {}})
};
fetch('https://api.example.com/api/v2/batches/{batch_id}/documents/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"added": [
{
"id": 123,
"document_id": 123,
"original_filename": "<string>",
"status": "<string>",
"processing_order": 123,
"version_number": 123,
"extraction_status": "<string>",
"extracted_field_count": 1,
"expected_field_count": 1,
"extraction_message": "<string>"
}
],
"skipped": [
{
"document_id": 123,
"reason": "<string>",
"duplicate_of": 123
}
]
}{}{}Authorizations
Body
Body for POST /api/v2/batches/{batch_id}/documents/.
Adds existing library documents (referenced by ChatAttachment.pk) to
a batch. The batch's parent struct is implicit via
Batch.default_struct_version — every per-doc version override must
refer to the same struct.
Fields:
document_ids: ChatAttachment PKs of docs in the user's library to
attach to the batch. At least one is required. Order is
preserved when assigning BatchDocument.processing_order.
version_number: Optional override for the batch's
default_struct_version for all added docs in this request.
None means "use the batch's current default version".
per_doc_versions: Optional fine-grained per-doc override map
{document_id: version_number}. Keys must be a subset of
document_ids. A doc id present in this map takes precedence
over the request-level version_number.
Response
Response shape for POST /api/v2/batches/{batch_id}/documents/.
added lists the new BatchDocument rows in creation order.
skipped lists docs that were not added with a human-readable
reason — the request as a whole still returns 201.
curl --request POST \
--url https://api.example.com/api/v2/batches/{batch_id}/documents/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document_ids": [
2
],
"version_number": 2,
"per_doc_versions": {}
}
'import requests
url = "https://api.example.com/api/v2/batches/{batch_id}/documents/"
payload = {
"document_ids": [2],
"version_number": 2,
"per_doc_versions": {}
}
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_ids: [2], version_number: 2, per_doc_versions: {}})
};
fetch('https://api.example.com/api/v2/batches/{batch_id}/documents/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"added": [
{
"id": 123,
"document_id": 123,
"original_filename": "<string>",
"status": "<string>",
"processing_order": 123,
"version_number": 123,
"extraction_status": "<string>",
"extracted_field_count": 1,
"expected_field_count": 1,
"extraction_message": "<string>"
}
],
"skipped": [
{
"document_id": 123,
"reason": "<string>",
"duplicate_of": 123
}
]
}{}{}
