Skip to content

Add a listing to a cart

POST
/carts/{url_key}
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.

url_key
required
string

The cart’s url_key, returned when the cart is created.

Example

k3v9q2m8x1c7z5b4n6t0p2r8s1d3f7
Media typeapplication/json
object
listing_id
required

Id of the listing to add.

integer

Example

4242
quantity

Number of units to add. 0 is refused: remove the item instead.

integer
default: 1 >= 1

Example

1
options

Options the buyer selected on the listing, as key/value pairs. They are stored on the item as sent.

object

Example

{
"size": "M"
}
properties

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"
}
addons

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.

Array<integer>

Example

[
12,
13
]
admin_addons

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.

Array<integer>

Example

[
7
]
variants

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.

Array<integer>

Example

[
4243
]
ofid

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.

string

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.

Media typeapplication/json
object
success
boolean
message

Present when success is true.

string
error

Present when success is false.

string

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.

Media typeapplication/json

Error body returned by several cart endpoints.

object
success

Error body of the cart endpoints that report success and error.

boolean
error

Human-readable reason.

string

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.

Media typeapplication/json

Error body returned by several cart endpoints.

object
success

Error body of the cart endpoints that report success and error.

boolean
error

Human-readable reason.

string

Example

{
"success": false,
"error": "Cart not found"
}

No open cart has this key: it does not exist or is closed.

Media typeapplication/json

Error body returned by several cart endpoints.

object
success

Error body of the cart endpoints that report success and error.

boolean
error

Human-readable reason.

string

Example

{
"success": false,
"error": "Cart not found"
}