Attached documents
Upload files for selected business records, certificates, and lot COAs, then apply them through the matching document workflow.
The upload flow keeps a file private, then attaches it to the exact product, customer, supplier, purchase order, sales order, or bill your workflow selected. Product files can also be assigned as the product's current SDS.
The same completed upload supplies a certificate's supporting document or a lot's COA. Those workflows accept PDF, PNG, JPEG, or WebP, and use their own maintenance endpoints and write access. See Certification Intelligence and Lots for assignment, dates, previews, and readback.
Endpoint map
| Endpoint | Scope | Use it for |
|---|---|---|
POST /document-uploads | documents:upload | Prepare one private file upload and return the values needed to send it. |
GET /products/{id}/documents | products:read or search:read | List document links attached to one visible product. Product responses also include the product SDS pointer when present. |
POST /products/{id}/documents | products:write | Attach one uploaded file or HTTPS document link to an active product. |
PUT /products/{id}/sds | products:write | Assign one uploaded PDF or image as the product's current SDS. |
PUT /products/{id}/sds-selection | products:write | Select an uploaded document already attached to the product as its current SDS. |
GET /customers/{id}/documents | customers:read or search:read | List document links attached to one visible customer. |
POST /customers/{id}/documents | customers:write | Attach one uploaded file or HTTPS document link to an active customer. |
GET /purchase-orders/{id}/documents | purchase-order-execution:read | List document links attached to one visible purchase order. |
POST /purchase-orders/{id}/documents | purchase-order-documents:write | Attach one uploaded file or HTTPS document link to a visible purchase order. |
GET /suppliers/{id}/documents | suppliers:read or search:read | List document links attached to one visible supplier. |
POST /suppliers/{id}/documents | suppliers:write | Attach one uploaded file or HTTPS document link to an active supplier. |
GET /orders/{id}/documents | sales-order-documents:read | List attachments on one visible sales order, with permitted lot COA copies. |
POST /orders/{id}/documents | sales-order-documents:write | Attach a completed upload or external HTTPS link to one visible sales order. |
GET /bills/{id}/documents | bill-documents:read | List attachments on one bill. |
POST /bills/{id}/documents | bill-documents:write | Attach a completed upload or external HTTPS link to one bill. |
Document lists stay scoped to the selected parent, return up to 100 rows oldest first, and report truncated: true when more visible rows exist. Product, customer, and supplier reads can include archived parents, while order and bill reads follow the selected record and the acting person's current access.
Read attached documents
Fetch attached documents only after search, a finder, or a detail response has selected the exact parent id.
curl "$SHELFCYCLE_API_BASE_URL/products/product-id/documents" \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY"
{
"data": {
"documents": [
{
"type": "document",
"id": "document-id",
"fileName": "ACE Spec.pdf",
"createdAt": "2026-07-02T18:00:00.000Z",
"urlClass": "external",
"access": {
"mode": "raw",
"url": "https://example.com/ACE-Spec.pdf"
},
"integrity": { "status": "not_verified", "reason": "external_or_legacy_link" }
}
],
"truncated": false,
"sds": {
"fileName": "ACE SDS.pdf",
"access": { "mode": "signed", "url": "https://...", "expiresAt": "2026-07-02T18:15:00.000Z" }
}
}
}
ShelfCycle-hosted files return short-lived signed read URLs. External HTTPS links return access.mode: "raw". If an old ShelfCycle file points outside the authenticated org prefix, the row can return access.mode: "unavailable" without a URL.
Every listed document includes integrity. A verified API-upload attachment reports status: "verified" with its saved checksumSha256, sizeBytes, contentType, and verifiedAt. External links and files attached through the app report not_verified with reason: "external_or_legacy_link". An API upload without a recorded receipt reports unavailable with reason: "legacy_receipt_not_recorded". These details describe verification when the file was attached, not a new scan or a guarantee of its present contents.
Sales-order and bill access
Sales-order documents require sales-order-documents:read plus current Order viewing access and visibility of that order. Attaching requires sales-order-documents:write, current Order update permission, and the same order visibility. orders:read alone does not grant document access.
Bill documents use bill-documents:read plus Bill viewing access, or bill-documents:write plus Bill update permission for attachments. bills:read alone does not grant document access. Use a bill UUID; a supplier credit is not a bill document parent and returns 404 not_found. Full-access keys include all four document scopes.
curl "$SHELFCYCLE_API_BASE_URL/orders/$ORDER_ID/documents" \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY"
curl "$SHELFCYCLE_API_BASE_URL/bills/$BILL_ID/documents" \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY"
Sales-order lists omit invoice PDF copies. Lot COA copies require lots:read and current Product and Lot viewing access; check effectiveCapabilities.orders.documents.lotCoaCopies in GET /me. A copy is identified by the current lot COA URL or the literal, case-sensitive text _COA_ anywhere in its filename, including user uploads. Rows outside this access do not count toward the 100-row limit. An order's COA copy is the file carried by that shipment; the Lot COA endpoint reads the lot's current COA instead.
Orders and bills of every status can receive attachments. Attaching a file leaves the order, bill, payments, and accounting unchanged.
Upload a private file
Start with the local file's name, size, content type, and lowercase hexadecimal SHA-256 checksum. The file can be from 1 byte through 15 MiB.
General attachments accept PDF; JPG/JPEG, PNG, GIF, WebP, and BMP images; and DOCX, XLSX, and PPTX files. A current Product SDS can be a PDF or one of the supported image types.
FILE_PATH="./ACE-SDS.pdf"
FILE_NAME="$(basename "$FILE_PATH")"
FILE_SIZE="$(wc -c < "$FILE_PATH" | tr -d ' ')"
FILE_SHA256="$(shasum -a 256 "$FILE_PATH" | awk '{print $1}')"
UPLOAD_RESPONSE="$(curl "$SHELFCYCLE_API_BASE_URL/document-uploads" \
-X POST \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"fileName\":\"$FILE_NAME\",\"contentType\":\"application/pdf\",\"sizeBytes\":$FILE_SIZE,\"checksumSha256\":\"$FILE_SHA256\"}")"
UPLOAD_URL="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.upload.url')"
UPLOAD_CONTENT_LENGTH="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.upload.headers["Content-Length"]')"
UPLOAD_CONTENT_TYPE="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.upload.headers["Content-Type"]')"
UPLOAD_CHECKSUM="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.upload.headers["x-amz-checksum-sha256"]')"
DOCUMENT_FILE_NAME="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.document.fileName')"
DOCUMENT_URL="$(printf '%s' "$UPLOAD_RESPONSE" | jq -r '.data.document.url')"
The response contains two separate values:
data.uploadtells the client where and how to send the file during the next 10 minutes.data.documentis the exact{fileName,url}value to use when attaching the uploaded file or assigning it as a Product SDS.
{
"data": {
"type": "document_upload_grant",
"id": "upload-id",
"upload": {
"method": "PUT",
"url": "https://upload-url",
"headers": {
"Content-Length": "124000",
"Content-Type": "application/pdf",
"If-None-Match": "*",
"x-amz-checksum-sha256": "base64-checksum"
},
"expiresAt": "2026-07-22T18:10:00.000Z"
},
"document": {
"fileName": "ACE-SDS.pdf",
"url": "https://shelfcycle-file-url"
}
}
}
Send the file to data.upload.url with every returned header exactly as provided. Do not send the ShelfCycle API key with this request.
curl "$UPLOAD_URL" \
-X PUT \
--data-binary "@$FILE_PATH" \
-H "Content-Length: $UPLOAD_CONTENT_LENGTH" \
-H "Content-Type: $UPLOAD_CONTENT_TYPE" \
-H "If-None-Match: *" \
-H "x-amz-checksum-sha256: $UPLOAD_CHECKSUM"
After the file upload succeeds, use the returned data.document value to attach or assign it. Request a fresh upload when the 10-minute upload window has expired.
Attach an uploaded file
Submit the returned data.document value to the selected record's document route with a stable idempotency key. The record-specific write scope and the acting user's current permission control the attachment.
curl "$SHELFCYCLE_API_BASE_URL/customers/customer-id/documents?dryRun=true" \
-X POST \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: intake:customer-id:w9-upload" \
-d "$(jq -n --arg fileName "$DOCUMENT_FILE_NAME" --arg url "$DOCUMENT_URL" '{fileName:$fileName,url:$url}')"
{
"data": {
"type": "write_readiness",
"operation": "customer_documents.create",
"status": "ready",
"wouldWrite": false,
"checks": [
{ "code": "scope_authorized", "status": "passed" },
{ "code": "target_available", "status": "passed" },
{ "code": "idempotency_available", "status": "passed" },
{ "code": "duplicate_check_clear", "status": "passed" }
],
"duplicateCandidates": [],
"verification": {
"available": true,
"path": "/api/v1/customers/customer-id/documents",
"fallback": "detail_get"
},
"requestId": "request-id"
}
}
Execute the same request without dryRun=true when your integration policy allows it. A successful uploaded-file attachment returns a durable integrity receipt:
{
"data": {
"type": "document",
"id": "document-id",
"fileName": "ACE-SDS.pdf",
"createdAt": "2026-08-11T18:00:00.000Z",
"urlClass": "shelfcycle",
"access": {
"mode": "signed",
"url": "https://...",
"expiresAt": "2026-08-11T18:15:00.000Z"
},
"idempotencyStatus": "created",
"integrity": {
"status": "verified",
"checksumSha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"sizeBytes": 124000,
"contentType": "application/pdf",
"verifiedAt": "2026-08-11T18:00:00.000Z"
}
}
}
integrity.status: "verified" confirms that ShelfCycle matched the stored file's checksum, size, and content type when it attached the file. Reusing the same route, idempotency key, and body returns the existing document row with idempotencyStatus: "replayed" and the same stored integrity receipt, even when the original response was lost.
An external HTTPS link returns integrity.status: "not_verified". An uploaded file attached before integrity receipts were recorded can return integrity.status: "unavailable" on replay. A dry run checks that the upload is ready but creates no receipt; execution verifies the upload again and records the receipt.
The upload scope prepares the file but does not attach it. The matching record write scope controls the association. To receive a readable URL in the create response, the key must also be able to read that target record; otherwise access.mode is unavailable and no URL is returned.
For a sales order, use the same completed upload with its dedicated document write scope:
curl "$SHELFCYCLE_API_BASE_URL/orders/$ORDER_ID/documents?dryRun=true" \
-X POST \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: intake:sales-order:delivery-document-001" \
-d "$(jq -n --arg fileName "$DOCUMENT_FILE_NAME" --arg url "$DOCUMENT_URL" '{fileName:$fileName,url:$url}')"
Use /bills/$BILL_ID/documents and bill-documents:write for a bill attachment. Preview operations are sales_order_documents.create and bill_documents.create. A preview without Idempotency-Key reports a blocked readiness check; include a stable key for a ready preview and for execution. After review, remove dryRun=true; a new attachment returns 201 created, and an identical retry returns 200 replayed. Keep the same route, key, filename, and URL, and verify through the matching GET list. Exact replay retains the saved receipt even if that URL later becomes a lot's COA, subject to current record access.
These two routes accept only a completed POST /document-uploads descriptor or an external HTTPS link. Reusing another stored ShelfCycle file, an invoice PDF URL, or a current lot COA URL returns 422 upload_integrity_invalid on url without attaching. A descriptor can be passed between keys in the same organization; the attaching key needs its target write scope, not documents:upload again. Possession of the descriptor does not grant read access.
Classify product documents
For POST /products/{id}/documents, add optional kind: "sds" or kind: "tds" beside fileName and url. Keep the usual Idempotency-Key for attaching the file. The receipt echoes data.kind when provided. Classification alone leaves the current SDS file as it was. Use the selection request below to make a document current.
GET /products/{id}/documents returns kind (sds, tds, or null) and selected on each document. selected: true identifies the current selection. data.sds identifies the current SDS file, including files assigned directly through PUT /products/{id}/sds.
Select an attached safety data sheet
Use a documentId from the product's document list. Select a file uploaded to ShelfCycle and attached to the same product. Selecting an unclassified document marks it as sds. The request needs products:write, current Product update permission, and the product's latest updatedAt as If-Match for a change.
curl "$SHELFCYCLE_API_BASE_URL/products/$PRODUCT_ID/sds-selection?dryRun=true" \
-X PUT \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY" \
-H "Content-Type: application/json" \
-H "If-Match: $PRODUCT_UPDATED_AT" \
-d "$(jq -n --arg documentId "$SDS_DOCUMENT_ID" '{documentId:$documentId}')"
After a ready preview, repeat the request without dryRun=true. The selection and the current SDS file update together. Use the returned updatedAt for the next product change and verify selected and data.sds through the document list. Repeating the current selection returns 200 with idempotencyStatus: "replayed" and needs no If-Match. A changed selection with a missing or outdated version returns 409 stale_record.
The route returns 422 with a specific code on documentId for a document outside the product (document_not_on_product), a dismissed document (document_dismissed), a TDS (document_is_tds), or an external link (document_not_uploaded). For an external sheet, upload and attach its file to the product before selecting it.
Assign the current Product SDS
Use the same uploaded data.document value with the latest product updatedAt. A dry run is available before assignment.
curl "$SHELFCYCLE_API_BASE_URL/products/product-id/sds?dryRun=true" \
-X PUT \
-H "Authorization: Bearer $SHELFCYCLE_API_KEY" \
-H "Content-Type: application/json" \
-H "If-Match: 2026-07-22T17:45:00.000Z" \
-d "$(jq -n --arg fileName "$DOCUMENT_FILE_NAME" --arg url "$DOCUMENT_URL" '{fileName:$fileName,url:$url}')"
Remove dryRun=true to assign the SDS after the readiness response is ready. The response reports the product ID, file name, new updatedAt, and whether the SDS was updated, replayed, or repaired. If this request creates an attachment, it has kind: "sds". Assigning a different file clears the prior document selection and retains the attached files. Assigning the same file preserves its selection. Verify the current file and attached documents with GET /products/{id}/documents.
Use uploads for certificates and lot COAs
For COA import, request a grant with purpose: "coa", complete the PUT, then send {document: data.document} to POST /coas. Add lotId to link the certificate as a lot candidate, or omit it to leave the certificate unassigned. Use POST /lots/{id}/coas when specifying the lot in the path. The upload accepts PDF, PNG, JPEG, and WebP up to 15 MiB. The import saves the file by default. Send skipAi: false to request background reading. Save the returned certificate ID and reconcile an uncertain response before resubmitting. See Lots for complete requests. Use ordinary uploads for the assignments below.
Certificate filing and lot COA assignment use the descriptor returned by a completed POST /document-uploads flow. Keep the returned fileName and url together; those requests use uploaded files rather than arbitrary external links. Certification responses return recorded filenames without a file URL. Lot COA reads also return coa.access, and COA write receipts include a readable link only with lots:read and current Product/Lot viewing access. See Lots for access modes and version handling.
Attach an existing HTTPS link
All six document routes also accept an existing external HTTPS file link, subject to the sales-order and bill URL rules above. Document create accepts exactly fileName and url; the response identifies external links with integrity.status: "not_verified" so callers can distinguish them from verified uploads.
URL rules
Document URLs must use https and cannot contain embedded credentials. External HTTPS links are accepted. ShelfCycle bucket links are accepted only when the bucket key belongs to the authenticated org; signed URL query strings are normalized before duplicate checks.
Exact duplicate URLs on the same parent are blocked with duplicate_document. Requests with fields other than fileName and url are blocked with unsupported_document_field.
Sensitive files
Attached files may contain tax, quality, commercial, or regulatory context. Use the narrowest parent route, keep signed URLs out of logs, and avoid echoing request bodies that contain sensitive source links.
Choose the exact parent record before attaching a file, keep upload and signed read URLs out of logs, and verify the final attachment or Product SDS through that record's document list.