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:
| Field | Type | Notes |
|---|---|---|
file | binary | Required. 10 MB cap. |
entityType | string | purchase_order | work_order | sales_order. |
entityId | uuid | Must 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
| HTTP | code | Condition |
|---|---|---|
| 404 | not_found | The (entityType, entityId) parent doesn't exist in this org. |
| 422 | validation_failed | Missing file part, bad entityType, or malformed entityId. |
Workflow
Calls W165 Upload document.