A document has its own identity and owner. Uploading bytes, confirming their identity, and attaching the document to a claim are separate operations.
Create an upload grant
Set size to the actual file length in bytes and content_type to its media type. The document type must match your business configuration when you supply one.
curl --fail-with-body --cacert "$CA_CERT" -H @pledge-auth.header \
-H 'Content-Type: application/json' "$API/documents" \
--data '{"content_type":"application/pdf","size":48213}' \
--output upload.json
The response identifies the document and contains upload.url, upload.fields, and an expiry. The declared size is an example; a different file size will fail confirmation. Tenant quotas and configured upload limits apply.
Transfer the file
Send a multipart POST directly to the returned upload URL. Include every returned form field unchanged, followed by the file. An SDK should build the multipart request from the response rather than concatenate a shell command from returned data.
The grant authorizes only its designated upload. Do not send the Pledge bearer token to the object store. Configure the upload client’s trust for the object-store endpoint separately if it uses a private CA.
Confirm the upload
DOCUMENT_ID=$(jq -r '.id' upload.json)
curl --fail-with-body --cacert "$CA_CERT" -H @pledge-auth.header \
-X POST "$API/documents/$DOCUMENT_ID/confirm"
Confirmation reads the stored bytes, checks their size, calculates the hash, and pins the version. Repeating confirmation is idempotent. A later upload to the same key cannot replace the version already retained as evidence.
An unversioned bucket is not a valid installation. A size mismatch requires correcting the uploaded bytes; a storage outage requires restoring the dependency and retrying.
Attach to a claim
Read the claim’s current round. Prepare attachment.json with that round and the confirmed document ID:
{
"round": 1,
"documents": [{"document_id": "replace-with-confirmed-id"}]
}
curl --fail-with-body --cacert "$CA_CERT" -H @pledge-auth.header \
-H 'Content-Type: application/json' -H 'Accept: application/json' \
-H 'Idempotency-Key: attach-office-visit-bill-1' \
--data-binary @attachment.json "$API/claims/CLM-1001/documents"
Use a unique key for the intended attachment and reuse it only for exact retries. The caller must be allowed to attach to the claim and use the document. An unconfirmed document, stale round, or incompatible state is refused.
Verify and retain
Read GET /claims/{id}/documents to inspect required, missing, and attached documents. Processing is asynchronous; do not require a replica read to reflect an accepted command immediately.
GET /documents/{id}/content retrieves the confirmed content according to access policy. Once attached, a document cannot be deleted as an unused upload. Preserve object versions and the associated records in your backup plan.