Attach order documents
const url = 'https://api.tradecloud1.com/v2/api-connector/order/documents';const options = { method: 'POST', headers: {Authorization: '<Authorization>', 'Content-Type': 'application/json'}, body: '{"order":{"companyId":"faa3ea58-b46d-40fe-9b27-7481796717e1","purchaseOrderNumber":"PO-12345","documents":[{"code":"123456789","revision":"B","name":"Tradecloud API Manual","objectId":"00f03b98-2511-489f-9695-13791b3f66b6","url":"https://my-company.com/storage/my_file.pdf","type":"General","description":"General document"}]},"lines":[{"position":"0001","documents":[{"code":"123456789","revision":"B","name":"Tradecloud API Manual","objectId":"00f03b98-2511-489f-9695-13791b3f66b6","url":"https://my-company.com/storage/my_file.pdf","type":"General","description":"General document"}]}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradecloud1.com/v2/api-connector/order/documents \ --header 'Authorization: <Authorization>' \ --header 'Content-Type: application/json' \ --data '{ "order": { "companyId": "faa3ea58-b46d-40fe-9b27-7481796717e1", "purchaseOrderNumber": "PO-12345", "documents": [ { "code": "123456789", "revision": "B", "name": "Tradecloud API Manual", "objectId": "00f03b98-2511-489f-9695-13791b3f66b6", "url": "https://my-company.com/storage/my_file.pdf", "type": "General", "description": "General document" } ] }, "lines": [ { "position": "0001", "documents": [ { "code": "123456789", "revision": "B", "name": "Tradecloud API Manual", "objectId": "00f03b98-2511-489f-9695-13791b3f66b6", "url": "https://my-company.com/storage/my_file.pdf", "type": "General", "description": "General document" } ] } ] }'Attach documents to an order header and lines by the buyer. Requires Integration role. Attached documents are merged with existing order(line) documents. If a document for an order(line) has the same code as an existing document at that order(line), the original will be overwritten. Otherwise, the newly attached document will be appended.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Attach order documents by buyer
object
Documents to be attached to the purchase order header.
object
The optional Tradecloud company ID of the buyer. Only needed when the integration user is authorized for multiple companies.
Example
faa3ea58-b46d-40fe-9b27-7481796717e1The purchase order number as known by the ERP.
Example
PO-12345Document references and meta data. Order header documents are optional. The total number of documents is limited to 100 documents per order header.
Either use the Tradecloud object-storage API to upload your document, or your company’s content server, or provide only document meta data.
object
Document code or number. The document code should be unique within your company and immutable.
Example
123456789Document revision (or version) code or number
Example
BDocument short name
Example
Tradecloud API ManualTradecloud object identifier which was returned by the Tradecloud object-storage API upload
Example
00f03b98-2511-489f-9695-13791b3f66b6Location of the document if is not stored in Tradecloud.
Example
https://my-company.com/storage/my_file.pdfThe type of the attached document. Eg. General, Class Product Certificate, Manual, Packing Instructions, etc…
Example
GeneralDescription of the attached document.
Example
General documentThe lines of the purchase order with documents to be attached. You only have to send the lines which have documents to be attached.
Documents to be attached to the purchase order line.
object
Required position in the purchase order. The position should be unique within the order and immutable.
Example
0001Document references and meta data. The total number of documents is limited to 100 documents per order line.
Either use the Tradecloud object-storage API to upload your document, or your company’s content server, or provide only document meta data.
object
Document code or number. The document code should be unique within your company and immutable.
Example
123456789Document revision (or version) code or number
Example
BDocument short name
Example
Tradecloud API ManualTradecloud object identifier which was returned by the Tradecloud object-storage API upload
Example
00f03b98-2511-489f-9695-13791b3f66b6Location of the document if is not stored in Tradecloud.
Example
https://my-company.com/storage/my_file.pdfThe type of the attached document. Eg. General, Class Product Certificate, Manual, Packing Instructions, etc…
Example
GeneralDescription of the attached document.
Example
General documentResponses
Section titled “Responses”Successfully verified and attached order documents.
Successfully queued order documents. Documents have not yet been verified.
Bad request, the user should check the response body for more info.
object
Example
missing.propertyExample
Property X was missingNot authenticated, the user should authenticate using a valid access token, use Basic Authentication, or refresh to get a valid token. May or may not contain a structured response body
object
Example
Authentication failedThe number of authentication attempts left before the user is banned. Applicable when authentication through Basic Authentication fails.
Example
2Int describing the number of seconds left before the user is allowed to attempt a login with Basic Authentication again.
Example
300Not authorized, the user is authenticated but does not have the necessary permission.
object
Example
Not authorized for this actionOrder not found.
An unexpected error occurred, Tradecloud ops will be alerted. May or may not contain a structured response body.
object
Example
some.errorExample
Some error occurredThe cause of this error. Free-format JSON object.
object
Service is not healthy (bad gateway), Tradecloud ops will be alerted. Will not contain a structured response body.
Service is unavailable (overloaded or down for maintenance), Tradecloud ops will be alerted. May or may not contain a structured response body.
object
Example
Could not retrieve data from external source.Service is unavailable (gateway timeout), Tradecloud ops will be alerted. Will not contain a structured response body.
