API reference · Custom Cart

Create Custom Cart

POSThttps://api.sandbox.cws.digital/customCart/create

Description

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:

FormFields
By manufacturer databrand, mfrPartCode, composition and warehouseId, all four together.
By attributeskuAttributeName, skuAttributeValue and warehouseId, all three together. Available to those who have contracted the product catalog service with their own attribute.
By your product codepartnerPartCode 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

Content-Typeapplication/jsonRequired
Edit the body with
FieldTypeRequiredDescriptionValue
cartNamestringNo

Cart name, for you to identify it later.

documentstringYes

CPF or CNPJ of the customer, with or without punctuation. The customer must be registered in the cart store.

productsarray of objectYes

Cart items. Up to 100 items.

Fields in products[]

storeDocumentstringNo

CNPJ of the store where the cart is created. Without it, your store applies. See Cart store.

sellerDocumentstringNo

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.

sellerEmailstringNo

E-mail of the seller responsible for the cart, registered in the cart store.

cartTypeNamestringNo

Cart type name.

cartTypeExternalIdstringNo

External id of the cart type, in your system.

metadataarray of objectNo

Free data pairs for you to attach to the cart.

Fields in metadata[]

Items of products[]
products[]
FieldTypeRequiredDescriptionValue
quantityintegerYes

Product quantity. Greater than zero.

warehouseIdintegerConditional

Id of the item's warehouse, from the seller who owns the stock. Goes together with any identification form.

brandstringConditional

Manufacturer brand. Goes together with mfrPartCode, composition and warehouseId.

mfrPartCodestringConditional

Product code at the manufacturer. Goes together with brand, composition and warehouseId.

compositionstringConditional

Product composition (e.g. UNITARY). Goes together with brand, mfrPartCode and warehouseId.

skuAttributeNamestringConditional

Name of the product attribute. Goes together with skuAttributeValue and warehouseId.

skuAttributeValuestringConditional

Value of the product attribute. Goes together with skuAttributeName and warehouseId.

partnerPartCodestringConditional

Your product code in the warehouse. Goes together with warehouseId.

keystringNo

Your own key for the item. It identifies the item in the complement sum and in the deletion by customKey.

storeExternalIdstringNo

Id of the item in your system, saved in the cart item.

Items of metadata[]
metadata[]
FieldTypeRequiredDescriptionValue
keystringNo

Data name.

valuestringNo

Data value.

typestringNo

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.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request POST \
  --url 'https://api.sandbox.cws.digital/customCart/create' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "cartName": "Proposta Ana Paula — setembro",
  "document": "466.935.373-08",
  "products": [
    {
      "brand": "Bosch",
      "mfrPartCode": "TESTE-API-001",
      "composition": "UNITARY",
      "warehouseId": 1001,
      "quantity": 2
    }
  ]
}'

Response

Click Try it to see the real response here, or pick a documented example: