Attach a file to an order
const url = 'https://acme.mykreezalid.com/front_api/v1/orders/4242/attachments';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"type":"USER_MANUAL","name":"Invoice October","url":"https://example.com/files/invoice-4242.pdf","file":"data:application/pdf;base64,JVBERi0xLjQK"}'};
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://acme.mykreezalid.com/front_api/v1/orders/4242/attachments \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "type": "USER_MANUAL", "name": "Invoice October", "url": "https://example.com/files/invoice-4242.pdf", "file": "data:application/pdf;base64,JVBERi0xLjQK" }'Attaches a file to an order. The signed-in member must be the customer or the vendor of the order. Send the file either as a public link in url (the file is downloaded and stored) or inline in file as a base64 data URI, not both. The stored file gets a public link, returned in url.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Identifier of the order.
Example
4242Request Bodyrequired
Section titled “Request Bodyrequired”object
Kind of document.
Name to show for the attachment.
Example
Invoice OctoberPublic http or https link to the file. Links to private or reserved addresses are refused. The stored file keeps the last segment of the link as its name.
Example
https://example.com/files/invoice-4242.pdfThe file as a data URI: data:<media type>;base64,<content>. The stored file name ends with the subtype of the media type (pdf for application/pdf).
Example
data:application/pdf;base64,JVBERi0xLjQKResponses
Section titled “Responses”The file is attached.
object
A file attached to an order by its customer or its vendor.
object
Identifier of the member who attached the file.
Identifier of the member who last changed the attachment. Returned by the list and read operations only.
Name given to the attachment.
Public link to the file.
Name of the stored file.
Example
{ "attachment": { "id": 4242, "order_id": 4243, "createdBy": 4244, "name": "Invoice October", "type": "USER_MANUAL", "filename": "6526f1a3b2c4d.pdf" }}The file at url cannot be downloaded, or url is not an allowed link.
Error body returned by the Front API when it refuses a request.
object
HTTP status code, repeated in the body.
Human-readable reason.
Example
{ "code": 403, "status": "error", "message": "Token not found in request"}No signed-in member; the signed-in member is neither the customer nor the vendor of the order (or the order does not exist); type is missing or unknown; both url and file are sent; or file does not start with data.
Error body returned by the Front API when it refuses a request.
object
HTTP status code, repeated in the body.
Human-readable reason.
Example
{ "code": 403, "status": "error", "message": "Token not found in request"}The uploaded file is larger than the marketplace allows. The message gives the limit.
Error body returned by the Front API when it refuses a request.
object
HTTP status code, repeated in the body.
Human-readable reason.
Example
{ "code": 403, "status": "error", "message": "Token not found in request"}The file could not be stored or the attachment could not be saved.
object
Example
{ "errors": "can not save attachment"}