Skip to content

Attach a file to an order

POST
/orders/{orderId}/attachments
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.

orderId
required
integer

Identifier of the order.

Example

4242
Media typeapplication/json
object
type
required

Kind of document.

string
Allowed values: USER_MANUAL WARRANTY CERTIFICATES DELIVERY_BILL CUSTOMER_INVOICE OTHER
name

Name to show for the attachment.

string

Example

Invoice October
url

Public 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.

string format: uri

Example

https://example.com/files/invoice-4242.pdf
file

The 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).

string

Example

data:application/pdf;base64,JVBERi0xLjQK

The file is attached.

Media typeapplication/json
object
attachment

A file attached to an order by its customer or its vendor.

object
id
integer
order_id
integer
createdBy

Identifier of the member who attached the file.

integer
updatedBy

Identifier of the member who last changed the attachment. Returned by the list and read operations only.

integer
nullable
name

Name given to the attachment.

string
nullable
type
string
Allowed values: USER_MANUAL WARRANTY CERTIFICATES DELIVERY_BILL CUSTOMER_INVOICE OTHER
url

Public link to the file.

string format: uri
filename

Name of the stored file.

string
created
string format: date-time
modified
string format: date-time

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.

Media typeapplication/json

Error body returned by the Front API when it refuses a request.

object
code

HTTP status code, repeated in the body.

integer
status
string
message

Human-readable reason.

string

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.

Media typeapplication/json

Error body returned by the Front API when it refuses a request.

object
code

HTTP status code, repeated in the body.

integer
status
string
message

Human-readable reason.

string

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.

Media typeapplication/json

Error body returned by the Front API when it refuses a request.

object
code

HTTP status code, repeated in the body.

integer
status
string
message

Human-readable reason.

string

Example

{
"code": 403,
"status": "error",
"message": "Token not found in request"
}

The file could not be stored or the attachment could not be saved.

Media typeapplication/json
object
errors
string

Example

{
"errors": "can not save attachment"
}