Baskets

Version 1.1 by Shop Team on 2019/08/01 11:21

Create a basket

Method

URL

Example

POST

/api/v1/baskets

Send a payload as shown below in the request body to create a new basket with any number of basket items in it. A request like this should usually be performed once a new customer interacts with the add-to-basket button for the first time while on your site.

Example Payload
{
  "basketItems" :
      [
         {
           "quantity" : 1,
           "element" :
               {
                 "id" : "praawgg73zU5gzZN0gaM-812-7",
                 "type" : "sprd:sellable",
                 "properties" :
                     [
                        {
                          "key" : "size",
                          "value" : "3"
                        },
                        {
                          "key" : "appearance",
                          "value" : "2"
                        }
                     ],
                 "shop" :
                     {
                       "id" : "100488332"
                     }
               }
         }
      ]
}


Field

Description

basketItems

An array that can contain 0-n entries.

basketItems/quantity

The quantity of the specific basket item that the customer selected.

basketItems/type

A constant for all Partner Area based shops. Always use "sprd:sellable".

basketItems/properties

This array of key-value-pairs must always contain values for "size" and "appearance".

basketItems/shop/id

The id of your shop.

A successful request is answered with HTTP status code 201 and a response payload looking like this:

Response Payload
{
   "href": "https://api.spreadshirt.net/api/v1/baskets/5ad33740-30ad-41b0-846f-9e1f0c6824b5",
   "id": "5ad33740-30ad-41b0-846f-9e1f0c6824b5"
}

The value of the "id" field should then be remembered in the customer's session because it allows to read or update the same basket as described next.


Tags:
Created by Shop Team on 2019/08/01 11:03