Upload one batch item

POST/lang2fhir/batch/{job_id}/items

Stores one item of a job from a multipart upload. A batch's items arrive one per request. The item carries either a document extraction (whose input file rides as raw bytes in the file part) or a create extraction (JSON only, no file).

The upload enforces these rules:

  • Set exactly one of document or create. Setting both, or neither, is a 400.
  • When document is set, file is required — it supplies the document's binary content (PDF or image).
  • When create is set, file is forbidden — a create item carries no file.
  • document and create must each be a JSON object.

Only the item's structure is checked here: the fields inside document or create are not validated at upload. A body that is well-formed JSON but not a valid request for its endpoint is still accepted with 202 and fails later during processing, recorded as an item error. A wrong-typed field the endpoint cannot decode fails as invalid_input; a body that decodes but the pipeline rejects (for example, a missing required field) fails as processing_failed.

Supplying request_id makes the upload idempotent on that token. A re-upload under the same token overwrites the same item rather than adding a second, so a client that lost an upload's response can safely re-send it. The response's deduplicated is true only when the re-uploaded payload matches the one already stored; a same-token upload with a changed payload overwrites in place and returns false.

Set a request_id on every upload: re-sending under the same token is the only way to repair a lost or incomplete upload, including the one a finalize 409 reports. Without one, a re-send adds a new item instead of replacing the missing one, and the job cannot be finalized.

Uploads are rejected once the job has been finalized (409), once it holds its 500-item limit (409), or when the item is too large (413 — see the raw-file limit in the API description).

RequiresBearerauthentication

Path parameters

job_idstringrequired

Body parameters

documentobjectoptional

The JSON body of POST /lang2fhir/document/multi, without its base64 content field — the uploaded file supplies the content. Accepts that endpoint's fields (version, provider, patient_reference, implementation_guide, detection_effort, validation_method, config). This is the multi-resource body: it has no single-resource field, and the item's result is a DocumentMultiResponse (a Bundle of resources). Mutually exclusive with create; requires file.

createobjectoptional

The JSON body of POST /lang2fhir/create/multi. Accepts that endpoint's fields (text, version, provider, patient_reference, implementation_guide, detection_effort, validation_method, resource_review). This is the multi-resource body: it has no single-resource field, and the item's result is a CreateMultiResponse (a Bundle of resources). Mutually exclusive with document; must not be accompanied by a file.

filestring (binary)optional

The document's binary content (PDF, PNG, JPEG, or TIFF). Required with document; forbidden with create.

request_idstringoptional

Optional idempotency token (max 256 bytes). Re-uploading under the same token overwrites the same item instead of adding a new one. The token is scoped to this job; the same token in another job is independent and creates a separate item.

idstringoptional

Optional caller-supplied correlation label (max 512 bytes), echoed back on status and result listings so you can match the server's item_id to your own record.

Returns  

Item accepted

Response fields

job_idstringoptional
request_idstringoptional
statusstringoptional
finalizedbooleanoptional
total_itemsintegeroptional
errorobjectoptional
kindstringoptional
messagestringoptional
created_atstringoptional
updated_atstringoptional
completed_atstringoptional
expires_atstringoptional
item_idstringoptional
idstringoptional
deduplicatedbooleanoptional
POSTRequest
# Get authentication token
PHENOML_TOKEN=$(curl -X POST "https://experiment.app.pheno.ml/v2/auth/token" \
  -u "$PHENOML_CLIENT_ID:$PHENOML_CLIENT_SECRET" \
  | jq -r '.access_token')

curl -X POST "https://experiment.app.pheno.ml/lang2fhir/batch/{job_id}/items" \
  -H "Authorization: Bearer $PHENOML_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "document": {},
  "create": {},
  "file": "example",
  "request_id": "<access_token>",
  "id": "abc-123-def-456"
}'
202 AcceptedExample Response
{
  "job_id": "l2f_batch_6f1d2c3a-8b4e-4f5a-9c7d-0e1f2a3b4c5d",
  "request_id": "submit-2025-09-02-batch-001",
  "status": "pending",
  "finalized": false,
  "total_items": 12,
  "error": {
    "kind": "processing_failed",
    "message": "the item could not be converted"
  },
  "created_at": "2024-01-15T09:30:00Z",
  "updated_at": "2024-01-15T09:30:00Z",
  "completed_at": "2024-01-15T09:30:00Z",
  "expires_at": "2024-01-15T09:30:00Z",
  "item_id": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
  "id": "chart-note-0042",
  "deduplicated": false
}