Upload an attachment for a CartItem

POST /checkout/upload

Some option sets allow users to upload a picture. E.g. this is usefull when a merchant wants to allow customers to upload a picture for a cake topping. With this endpoint, you can upload a picture and save the CartUpload object to the cart in your app. File uploads will get removed automatically over time if the order has not been placed.

Request

File upload

This endpoint requires uploaded files in the HTTP request. You can check the examples on the right for more information or read more about this on MDN.

Key Description
files Multiple files allowed by adding the [] at the end of the key name.

Example request 1 Simple upload

POST /checkout/upload HTTP/1.1
Host: api.bakeronline.be
X-VERSION: 1.5.0
Accept-Language: en-US,en;q=0.5
Content-Type: multipart/form-data;boundary="boundary"

--boundary
Content-Disposition: form-data; name="files"; filename="test.png"
Content-Type: image/png

...<Binary file here depending on Content-Transfer-Encoding field>...
--boundary--

Example request 2 Multiple upload

POST /checkout/upload HTTP/1.1
Host: api.bakeronline.be
X-VERSION: 1.5.0
Accept-Language: en-US,en;q=0.5
Content-Type: multipart/form-data;boundary="boundary"

--boundary
Content-Disposition: form-data; name="files[]"; filename="test.png"
Content-Type: image/png

...<Binary file here depending on Content-Transfer-Encoding field>...
--boundary
Content-Disposition: form-data; name="files[]"; filename="test.png"
Content-Type: image/png

...<Binary file here depending on Content-Transfer-Encoding field>...
--boundary--

Example request 3 Uploading extension check

POST /checkout/upload HTTP/1.1
Host: api.bakeronline.be
X-VERSION: 1.5.0
Accept-Language: en-US,en;q=0.5
Content-Type: multipart/form-data;boundary="boundary"

--boundary
Content-Disposition: form-data; name="files"; filename="test.txt"
Content-Type: image/png

...<Binary file here depending on Content-Transfer-Encoding field>...
--boundary--

Response

Array of CartUpload: [CartUpload]

CartUpload

Field Type Description
id Int An integer value
url URL An URL field starting with http:// or https://

Example response 1 Simple upload

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 113

[
    {
        "id": 85,
        "url": "https://bakeronline.be/uploads/temp-uploads/v227/test.png"
    }
]

Example response 2 Multiple upload

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 224

[
    {
        "id": 86,
        "url": "https://bakeronline.be/uploads/temp-uploads/v228/test.png"
    },
    {
        "id": 87,
        "url": "https://bakeronline.be/uploads/temp-uploads/v229/test.png"
    }
]

Example response 3 Uploading extension check

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
Content-Length: 73

[
    {
        "code": "upload-error",
        "message": "2096"
    }
]
Version update available Please adjust your integration to the latest stable version (1.5.2)
1.5.0 stable