Add a listing to a cart
const url = 'https://acme.mykreezalid.com/front_api/v1/carts/k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"listing_id":4242,"quantity":1,"options":{"size":"M"},"properties":{"Engraving":"Happy birthday"},"addons":[12,13],"admin_addons":[7],"variants":[4243],"ofid":"example"}'};
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/carts/k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7 \ --header 'Content-Type: application/json' \ --data '{ "listing_id": 4242, "quantity": 1, "options": { "size": "M" }, "properties": { "Engraving": "Happy birthday" }, "addons": [ 12, 13 ], "admin_addons": [ 7 ], "variants": [ 4243 ], "ofid": "example" }'Adds a published, approved listing to the cart, in the order of its vendor (the order is created when needed). Adding the same listing again with the same options, properties, variants and offer adds to the quantity of the existing item; any difference creates a separate item. The listing’s available quantity is not checked. Works without a token for a guest cart; a member’s cart only accepts that member’s token. When you send a token and the cart is a guest cart, the cart (and the guest’s other carts and orders) is attached to the signed-in member first.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The cart’s url_key, returned when the cart is created.
Example
k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7Request Bodyrequired
Section titled “Request Bodyrequired”object
Id of the listing to add.
Example
4242Number of units to add. 0 is refused: remove the item instead.
Example
1Options the buyer selected on the listing, as key/value pairs. They are stored on the item as sent.
object
Example
{ "size": "M"}Free-form properties of the item (for example a personalisation text), as name/value pairs. They are stored on the item as sent.
object
Example
{ "Engraving": "Happy birthday"}Ids of the listing’s add-ons to include. Ids that are not add-ons of this listing are ignored. A single id is accepted too.
Example
[ 12, 13]Ids of the marketplace-wide add-ons to include. Ids that do not apply to this listing are ignored. A single id is accepted too.
Example
[ 7]Ids of the listing’s variants to buy. The item’s amount is then the sum of the variants’ prices times the quantity. A single id is accepted too.
Example
[ 4243]Token of an offer made on this listing to the cart’s buyer and not yet closed. Its amount replaces the listing’s price. Ignored when variants are sent.
Responses
Section titled “Responses”success is true when the listing was added. success is false, with the reason in error, when the listing is no longer available for purchase or a selected variant does not belong to it.
object
Present when success is true.
Present when success is false.
Example
{ "success": true, "message": "Listing successfully added to cart", "error": "This product is no longer available for purchase."}quantity is 0, or the item could not be saved.
Error body returned by several cart endpoints.
object
Error body of the cart endpoints that report success and error.
Human-readable reason.
Example
{ "success": false, "error": "Cart not found"}The cart belongs to a member and the request is not made by that member (body below), or the ofid offer cannot be used.
Error body returned by several cart endpoints.
object
Error body of the cart endpoints that report success and error.
Human-readable reason.
Example
{ "success": false, "error": "Cart not found"}No open cart has this key: it does not exist or is closed.
Error body returned by several cart endpoints.
object
Error body of the cart endpoints that report success and error.
Human-readable reason.
Example
{ "success": false, "error": "Cart not found"}