API reference · Custom Cart
Create Custom Cart
https://api.sandbox.cws.digital/customCart/createDescription
Creates a cart with pre-selected products for a customer and returns the access link to the cart, for you to send to the customer.
The customer opens the link and completes the purchase with the items already assembled.
How to identify the product
Each item must carry one of these forms:
| Form | Fields |
|---|---|
| By manufacturer data | brand, mfrPartCode, composition and warehouseId, all four together. |
| By attribute | skuAttributeName, skuAttributeValue and warehouseId, all three together. Available to those who have contracted the product catalog service with their own attribute. |
| By your product code | partnerPartCode and warehouseId, both together. |
All items in the same request must use the same form. A request that mixes forms is rejected as a whole with 400.
The examples use the sandbox test product, which is already registered: change only the warehouseId to the id of one of your warehouses.
Request body
application/jsonRequired| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| cartName | string | No | Cart name, for you to identify it later. | |
| document | string | Yes | CPF or CNPJ of the customer, with or without punctuation. The customer must be registered in the cart store. | |
| products | array of object | Yes | Cart items. Up to 100 items. Fields in products[] | |
| storeDocument | string | No | CNPJ of the store where the cart is created. Without it, your store applies. See Cart store. | |
| sellerDocument | string | No | CPF or CNPJ of the seller who owns the stock of the items. Without it, the stock is yours. See Seller who owns the stock. | |
| sellerEmail | string | No | E-mail of the seller responsible for the cart, registered in the cart store. | |
| cartTypeName | string | No | Cart type name. | |
| cartTypeExternalId | string | No | External id of the cart type, in your system. | |
| metadata | array of object | No | Free data pairs for you to attach to the cart. Fields in metadata[] |
products[]| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| quantity | integer | Yes | Product quantity. Greater than zero. | |
| warehouseId | integer | Conditional | Id of the item's warehouse, from the seller who owns the stock. Goes together with any identification form. | |
| brand | string | Conditional | Manufacturer brand. Goes together with | |
| mfrPartCode | string | Conditional | Product code at the manufacturer. Goes together with | |
| composition | string | Conditional | Product composition (e.g. | |
| skuAttributeName | string | Conditional | Name of the product attribute. Goes together with | |
| skuAttributeValue | string | Conditional | Value of the product attribute. Goes together with | |
| partnerPartCode | string | Conditional | Your product code in the warehouse. Goes together with | |
| key | string | No | Your own key for the item. It identifies the item in the | |
| storeExternalId | string | No | Id of the item in your system, saved in the cart item. |
metadata[]| Field | Type | Required | Description | Value |
|---|---|---|---|---|
| key | string | No | Data name. | |
| value | string | No | Data value. | |
| type | string | No | Data type. |
Business rules
The cart link comes in the message field
The response has no field of its own for the URL: the link arrives in message.
Cart store
Without storeDocument, the cart is created in your store when it has an active portal. Without a portal, it goes to the only store with an active portal you are linked to; with none or more than one, send the storeDocument.
With storeDocument, the cart is created in the store of that CNPJ. The store must have an active portal, and you must be its owner or have an authorized link with it.
The customer of document and the seller of sellerEmail are looked up in the cart store, and the link belongs to that store.
Seller who owns the stock
Without sellerDocument, the stock is yours. With sellerDocument, the warehouse and the stock of each item must belong to the seller of that document, and you must be that seller or the owner of the cart store.
A warehouse of another seller or an inactive one is treated as product not found.
Customer's open cart
When the cart type allows reusing the customer's open cart, the items go into it, and status comes as updated.
Responses
- 401
Missing, malformed or expired token.