Skip to main content
Version: v1.0.0(int)

E165: Upload document

POST /api/documents

Attaches a file to a purchase order, work order, or sales order. The only true file upload in v1.0.0: multipart/form-data with the binary under field file (10 MB cap) and the parent named by entityType + entityId text fields. The file lands in GCS via L3; the response is JSON metadata.

Authentication

Standard tenant route. Requires Authorization: Bearer <firebase-id-token> and X-Org-Id: <org-id>. Access: Member.

Request

multipart/form-data fields:

FieldTypeNotes
filebinaryRequired. 10 MB cap.
entityTypestringpurchase_order | work_order | sales_order.
entityIduuidMust resolve to a parent in the caller's org.

Response — 201 Created

{ "id": "uuid", "orgId": "uuid", "entityType": "sales_order", "entityId": "uuid", "name": "packing-slip.pdf", "gcsPath": "orgs/<org>/sales-orders/<so>/<uuid>-packing-slip.pdf", "mimeType": "application/pdf", "sizeBytes": 18244, "createdAt": "..." }

Errors

HTTPcodeCondition
404not_foundThe (entityType, entityId) parent doesn't exist in this org.
422validation_failedMissing file part, bad entityType, or malformed entityId.

Workflow

Calls W165 Upload document.