API Programs > Add To Cart API

Add to Cart API


The Walgreens Add to Cart API allows users of third-party applications and websites to quickly add products to a cart on Walgreens.com and then transfer that customer to checkout that cart. This retail focused Add to Cart API is designed to increase customer interaction inside of your third-party retail shopping experience. By combining this API with our Digital Offers API you can allow customers to clip coupons for, and add products to a cart on walgreens.com to complete their checkout.

Documentation/Services Highlights:

  • First version of the documentation, let us know if we need to add anything!

Below are the technical steps you will need to go through in order to get your integration configured and branded correctly:


The services listed below make up the complete list of services that are required in order to complete all phases of the Add to Cart experience. Please note that all of the service endpoints documented below are brand new for this version of the API.

Add To Cart

  • Add To Cart:
    POST api/cart/addToCart/v1
  • Open Checkout:
    POST {TRANSFER_URL}

Client ID Generation:

Generating the ClientID is a very simple process, it requires 6 simple steps:

  • 1. Load the SSL certificate file that you will receive from the Walgreens API team
  • 2. Read the Public Key from the certificate file
  • 3. Concatenate your clientKey+":"+FIRST_SKUID+":"+ClientCartId
  • 4. Convert the string from step 3 to UTF-8 bytes
  • 5. Encrypt the UTF-8 bytes using the X509 public certificate provided by the Walgreens API team using the RSA cipher algorithm
  • 6. Encode the encrypted UTF-8 bytes using a Base64 encoding

Create New Cart

This service is used to add products to cart to obtain the "transferURL" used for finishing the checkout.

Endpoint URL

Sandbox:
https://services-qa.walgreens.com/api/cart/addToCart/v1
Production:
https://services.walgreens.com/api/cart/addToCart/v1

Endpoint Information

Request format JSON
Response format JSON
Authentication? Yes
Rate limited? Yes
Requests Per Minute 300

Request Body

Name Optionality Description Example
affId required Your AffiliateID. "AAAAAAAAAA"
clientId required The clientID security token for your integration. "AAAAAA"
apiKey required Your API Key. "AbCdEfGhIjKlMnOpQrStUvWxYz"
clientCartId required Your own unique ID generated for each cart you create. "ABCDEF"
products required Array of ProductInfo containing the customer selected products.. [ProductInfo]

Example Request

curl --request POST \ 
--url https://services-qa.walgreens.com/api/cart/addToCart/v1 \
--header 'Content-Type: application/json' \
--data '{ \
    "affId":"YOUR_AFFILIATE_ID", \
    "apiKey":"YOUR_API_KEY", \
    "clientId":"YOUR_GENERATED_CLIENT_ID", \
    "clientCartId":"YOUR_GENERATED_CLIENT_CART_ID", \ 
    "products":[ \
        {
	        "skuId":"CUSTOMER_SELECTED_SKU_ID", \
	        "qty":"CUSTOMER_SELECTED_QUANTITY", \
                "type":"SKU_PRODUCT_TYPE" \
        },
        //Repeated for each customer selection of products
    ]
}' \
						

Example Response

{
    "cartTransferReferenceId": "WALGREENS GENERATED CART ID"L",
    "clientCartId": "YOUR GENERATED CART ID",
    "statusCode": "WALGREENS CART LEVEL STATUS CODE",
    "transferURL": "CART TRANSFER LANDING URL"
    "items":[
        {
            "skuId": "CUSTOMER SELECTED SKU ID",
            "qtyInCart": "QUANTITY ADDED TO CART",
            "statusCode": "PRODUCT ADDED TO CART STATUS CODE"
        },
        //Repeated for each customer selection of products
    ]
}
						

Open Checkout URL

This service is used to open the "transferURL" used for finish checkout.

Endpoint URL

Sandbox:
[transferURL]
Production:
[transferURL]

Endpoint Information

Request format JSON
Response format JSON
Authentication? Yes
Rate limited? Yes
Requests Per Minute 300

Example Request

{
"https://www.walgreens.com/store/checkout/cart_transfer.jsp?cartTransferReferenceId=YOUR_CART_REFRENCE_ID&action=transfer&ClientCode=YOUR_CLIENT_CODE"
}
                        

Example Response

{
"The walgreens.com checkout page..."
}
					

ProductInfo Object

Contains the product information for each product that the customer wants to add to the cart:

Name Optionality Description Example
skuId required The unique identifier value for each product. "ABCDEF"
qty required The quantity of the item the customer is attempting to transfer. "1"
type required The product type of the product. "DL"

Status Codes

Error Codes for Add to Cart Service

Obviously we don't want any errors to happen, but sometimes they do and as a result we respond the following error codes. The table below helps explain why each of the error codes could occur:

Code Level Message
000 Product Item added to cart with requested quantity
001 Product Item is out of stock
002 Product Quantity adjusted, please compare with requested
003 Product Invalid ProductInfo object
004 Product Item is a store only item, not able to add to online cart
901 Cart Cart transfer successful, all items and requested quantities added to cart
902 Cart Cart transfer partially successful, some items added to cart, not all items
903 Cart Cart transfer failure, no products added to cart
904 Cart Invalid request, please check the JSON formatting
905 Cart Invalid affId, please verify the affId
906 Cart Invalid clientId, please verify the clientId