Home
POST/shopping_cart/add_item
Note: This is an Experimental method that is available as a
(Limited Release) to select developers approved by business units.
This method creates an eBay cart for the eBay member, if one does not exist, and adds items to that cart. Because a cart never expires, any item added to the cart will remain in the cart until it is removed.
To use this method, you must submit a RESTful item ID and the quantity of the item. If the quantity value is greater than the number of available, the quantity value is changed to the number available and a warning is returned. For example, if there are 15 baseballs available and you set the quantity value to 50, the service automatically changes the value of quantity to 15.
The response returns all the items in the eBay member's cart; items added to the cart while on ebay.com as well as items added to the cart using the Browse API. The quantity and state of an item changes often. If the item becomes "unavailable" such as, when the listing has ended or the item is out of stock, whether it has just been added to the cart or has been in the cart for some time, the item will be returned in the unavailableCartItems container.
Note: There are differences between how legacy APIs, such as Finding, and RESTful APIs, such as Browse, return the identifier of an "item" and what the item ID represents. If you have an item ID from one of the legacy APIs, you can use the legacy item ID with the getItemByLegacyId method to retrieve the RESTful ID for that item. For more information about how to use legacy IDs with the Buy APIs, see Legacy API compatibility in the Buying Integration guide.
https://api.ebay.com/buy/browse/v1/shopping_cart/add_item
https://api.sandbox.ebay.com/buy/browse/v1/shopping_cart/add_item
For a list of supported sites and other restrictions, see API Restrictions.
This method has no URI parameters.
All requests made to eBay REST operations require you to provide the Authorization
HTTP header for authentication authorization.
In addition, this method requires you to include the Content-Type header and its value should be set to "application/json". See HTTP request headers- opens rest request components page for details.
This request requires an access token created with the authorization code grant flow, using one or more scopes from the following list (please check your Application Keys page for a list of OAuth scopes available to your application):
https://api.ebay.com/oauth/api_scope/buy.shopping.cart
See OAuth access tokens for more information.
Input container/field | Type | Description |
---|---|---|
itemId | string | The eBay RESTful identifier of the item you want added to the cart. Occurrence: Required |
quantity | integer | The number of this item the buyer wants to purchase. If this value is greater than the number available, the service will change this value to the number available. If this happens, a warning is returned. Occurrence: Required |
This call has no response headers.
Output container/field | Type | Description |
---|---|---|
cartItems | array of CartItem | An array of the items in the member's eBay cart. Occurrence: Always |
cartItems.cartItemId | string | The identifier for the item being added to the cart. This is generated when the item is added to the cart. Occurrence: Always |
cartItems.cartItemSubtotal | Amount | This is the subtotal of cost of a specific item in the cart. This does not include taxes, shipping costs, discounts, etc. It is price * quantity. Occurrence: Conditional |
cartItems.cartItemSubtotal.currency | CurrencyCodeEnum | The list of valid currencies. Each ISO 4217 currency code includes the currency name followed by the numeric value. Occurrence: Conditional |
cartItems.cartItemSubtotal.value | string | The value of the discounted amount. Occurrence: Conditional |
cartItems.image | Image | The primary image of the item. This is the image that appears on the eBay view item page for this item. Occurrence: Always |
cartItems.image.height | integer | Reserved for future use. Occurrence: Conditional |
cartItems.image.imageUrl | string | The URL of the image. Occurrence: Always |
cartItems.image.width | integer | Reserved for future use. Occurrence: Conditional |
cartItems.itemId | string | The RESTful identifier of the item. This identifier is generated when the item was listed. Occurrence: Always |
cartItems.itemWebUrl | string | The URL of the eBay view item page for the item. Occurrence: Conditional |
cartItems.price | Price | The cost of the item. Occurrence: Always |
cartItems.price.convertedFromCurrency | CurrencyCodeEnum | The three-letter ISO 4217 code representing the currency of the amount in the convertedFromValue field. This value is the pre-conversion currency. Occurrence: Conditional |
cartItems.price.convertedFromValue | string | The monetary amount before any conversion is performed, in the currency specified by the convertedFromCurrency field. This value is the pre-conversion amount. The value field contains the converted amount of this value, in the currency specified by the currency field. Occurrence: Conditional |
cartItems.price.currency | CurrencyCodeEnum | The three-letter ISO 4217 code representing the currency of the amount in the value field. If currency conversion/localization was performed, this is the post-conversion currency of the amount in the value field. Occurrence: Always |
cartItems.price.value | string | The amount of the currency specified in the currency field. The value of currency defaults to the standard currency used by the country of the eBay site offering the item. If currency conversion/localization was performed, this is the post-conversion amount. Occurrence: Always |
cartItems.quantity | integer | The number of this item the buyer wants to purchase. Occurrence: Conditional |
cartItems.title | string | The title of the item. This can be written by the seller or come from the eBay product catalog. Occurrence: Always |
cartSubtotal | Amount | This is the cost of all the items in the member's eBay cart. This does not include taxes, shipping costs, discounts, etc. It is the sum of each item's price * quantity. Occurrence: Always |
cartSubtotal.currency | CurrencyCodeEnum | The list of valid currencies. Each ISO 4217 currency code includes the currency name followed by the numeric value. Occurrence: Conditional |
cartSubtotal.value | string | The value of the discounted amount. Occurrence: Conditional |
cartWebUrl | string | The URL of the member's eBay cart. Occurrence: Always |
array of CartItem | Occurrence: Conditional | |
unavailableCartItems.cartItemId | string | Occurrence: Always |
unavailableCartItems.cartItemSubtotal | Amount | Occurrence: Conditional |
unavailableCartItems.cartItemSubtotal.currency | CurrencyCodeEnum | Occurrence: Conditional |
unavailableCartItems.cartItemSubtotal.value | string | Occurrence: Conditional |
unavailableCartItems.image | Image | Occurrence: Always |
unavailableCartItems.image.height | integer | Occurrence: Conditional |
unavailableCartItems.image.imageUrl | string | Occurrence: Always |
unavailableCartItems.image.width | integer | Occurrence: Conditional |
unavailableCartItems.itemId | string | Occurrence: Always |
unavailableCartItems.itemWebUrl | string | Occurrence: Conditional |
unavailableCartItems.price | Price | Occurrence: Always |
unavailableCartItems.price.convertedFromCurrency | CurrencyCodeEnum | Occurrence: Conditional |
unavailableCartItems.price.convertedFromValue | string | Occurrence: Conditional |
unavailableCartItems.price.currency | CurrencyCodeEnum | Occurrence: Always |
unavailableCartItems.price.value | string | Occurrence: Always |
unavailableCartItems.quantity | integer | Occurrence: Conditional |
unavailableCartItems.title | string | Occurrence: Always |
warnings | array of ErrorDetailV3 | An array of warning messages. These type of errors do not prevent the call from executing but should be checked. Occurrence: Always |
warnings.category | string | This string value indicates the error category. There are three categories of errors: request errors, application errors, and system errors. Occurrence: Always |
warnings.domain | string | The name of the primary system where the error occurred. This is relevant for application errors. Occurrence: Always |
warnings.errorId | integer | A unique code that identifies the particular error or warning that occurred. Your application can use error codes as identifiers in your customized error-handling algorithms. Occurrence: Always |
warnings.inputRefIds | array of string | An array of reference IDs that identify the specific request elements most closely associated to the error or warning, if any. Occurrence: Conditional |
warnings.longMessage | string | A detailed description of the condition that caused the error or warning, and information on what to do to correct the problem. Occurrence: Conditional |
warnings.message | string | A description of the condition that caused the error or warning. Occurrence: Always |
warnings.outputRefIds | array of string | An array of reference IDs that identify the specific response elements most closely associated to the error or warning, if any. Occurrence: Conditional |
warnings.parameters | array of ErrorParameterV3 | An array of warning and error messages that return one or more variables contextual information about the error or warning. This is often the field or value that triggered the error or warning. Occurrence: Conditional |
warnings.parameters.name | string | This is the name of input field that caused an issue with the call request. Occurrence: Conditional |
warnings.parameters.value | string | This is the actual value that was passed in for the element specified in the name field. Occurrence: Conditional |
warnings.subdomain | string | The name of the subdomain in which the error or warning occurred. Occurrence: NA |
This call can return one of the following HTTP status codes. For an overview of the status codes, see HTTP status codes in Using eBay RESTful APIs.
Status | Meaning |
---|---|
200 | OK |
204 | No Content |
400 | Bad Request |
403 | Insufficient permissions to fulfill the request |
409 | Conflict |
500 | Internal Server Error |
For more on errors, plus the codes of other common errors, see Handling errors.
Code | Domain | Category | Meaning |
---|---|---|---|
10000 | API_BROWSE | APPLICATION | There was a problem with an eBay internal system or process. Contact eBay developer support for assistance. |
10001 | API_BROWSE | REQUEST | The X-EBAY-C-MARKETPLACE-ID value is not supported. The supported values are: {supportedValues}. |
10002 | API_BROWSE | REQUEST | Insufficient permissions to fulfill the request. |
10007 | API_BROWSE | REQUEST | The field: {field} is required. Add the field and resubmit the call. |
10008 | API_BROWSE | REQUEST | The item ID {itemId} is invalid. |
10009 | API_BROWSE | REQUEST | The quantity value is invalid. The quantity must be greater than 0. |
10010 | API_BROWSE | REQUEST | The item does not exist. |
10011 | API_BROWSE | BUSINESS | The item {itemId} is already in the shopping cart. To change the quantity of the item, use the updateQuantity call. |
10016 | API_BROWSE | BUSINESS | You have exceeded the maximum number of items in a cart, which is {MaxCartIems}. To add more items, either remove or purchase some of the items in the cart. |
10017 | API_BROWSE | BUSINESS | The item does not meet the cart criteria and cannot be added to the cart. |
10018 | API_BROWSE | BUSINESS | There is a limit on the quantity of this item that can be purchased. The quantity specified exceeds this limit. |
10019 | API_BROWSE | BUSINESS | The buyer is blocked from purchasing the item you are trying to add to the cart. |
10021 | API_BROWSE | BUSINESS | The item you are trying to add is not available in the quantity specified. Please adjust the quantity and try again. |
10022 | API_BROWSE | BUSINESS | The item you are trying to add is not available for purchase. This can be for several reason such as, the listing has ended or the item is out of stock. |
10023 | API_BROWSE | BUSINESS | The buyer is blocked from purchasing the item because the seller does not ship to the buyer's location. |
10025 | API_BROWSE | REQUEST | The header 'X-EBAY-C-MARKETPLACE-ID' is required. The valid Marketplaces are: {supportedValues}. |
For more on warnings, plus the codes of other common warnings, see Handling errors.
Code | Domain | Category | Meaning |
---|---|---|---|
10004 | API_BROWSE | BUSINESS | The item {itemId} is not available for purchase. This can be for several reason such as, the listing has ended or the item is out of stock. |
10005 | API_BROWSE | BUSINESS | The item {itemId} is revised. |
10006 | API_BROWSE | BUSINESS | The item {itemId} in your cart is not available in the quantity specified. The quantity of this item has been changed to the quantity that is currently available. Please review this change before proceeding to checkout. |
10020 | API_BROWSE | BUSINESS | The buyer is blocked from purchasing the item {itemId}. |
10024 | API_BROWSE | BUSINESS | The buyer is blocked from purchasing the item {itemId} because the seller does not ship to the buyer's location. |
New to making API calls? Please see Making a Call.
Note: Identifiers, such as order IDs or user IDs, and personal data in these samples might be anonymized or may no longer be active on eBay. If necessary, substitute current, relevant eBay data in your requests.
This call creates an eBay cart and adds one item to the cart.
The inputs are itemId and quantity.
POSThttps://api.ebay.com/buy/browse/v1/shopping_cart/add_item
The output is the details of the items in the cart; cartItems containing the item information, and the quantity, price, and subtotal. It also returns the subtotal for all the items in the cart (cartSubtotal) and the URL of the cart (cartWebUrl).