Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Learning to Use Cortex API

Learning to Use Cortex API

Before you do anything, take a look at our URI Standards to get a basic understanding of how to access Cortex API resources. Then follow the steps outlined below to make your first Cortex API call to retrieve a customer's cart.

Step 1: Get an Access Token

Start by getting a Cortex API access token. All customers, both PUBLIC customers (customers without an account) and REGISTERED customers (customers with an account), require access tokens. Without an access token, the client application will receive a 401 status code when it tries to access a resource.

To get an access token, follow the directions in these sections:

Step 2: Make a Request

Make the following request to retrieve the customer's cart.

1. Construct a GET request to the carts resource, set the content-type to application/json, and set the requests authorization header to Bearer with the customer's access key.

Content-Type: application/json
Authorization: Bearer c7326d79-9273-4820-b45d-587f90d1dc9b
GET http://www.onlinestore.com/carts/mobee/default
The user's cart returns in a JSON object in the request response body:
{
    "self": {
        "type": "application/vnd.elasticpath.cart",
        "uri": "/commerce-legacy/carts/<scope>/<cartid>",
        "href": "http://www.onlinestore.com/carts/<scope>/<cartid>",
        "max-age": 0
    },
    "links": [
        {
            "type": "application/vnd.elasticpath.total",
            "rel": "total",
            "rev": "cart",
            "href": "http://www.onlinestore.com/totals/carts/<scope>/<cartid>",
            "uri": "/commerce-legacy/totals/carts/<scope>/<cartid>"
        },
        {
            "type": "application/vnd.elasticpath.order",
            "rel": "order",
	   "rev": "cart",
            "href": "http://www.onlinestore.com/orders/carts/<scope>/<orderid>",
            "uri": "/commerce-legacy/orders/carts/<scope>/<orderid>"
        },
        {
            "type": "application/vnd.elasticpath.links",
            "rel": "lineitems",
            "rev": "cart",
            "href": "http://www.onlinestore.com/carts/<scope>/<cartid>/lineitems",
            "uri": "/commerce-legacy/carts/<scope>/<cartid>/lineitems"
        }
    ],
    "total-quantity": 0
}

Step 3: Make API Calls

Now that you've made your first API call, the rest is up to you! Remember, all your calls require an access token, so make sure to include it in the response header. Take a look at the reading list below for some more basic API calls.

Recommended Reading for Getting Started

To get a better understanding of how the API works, we recommend reading the following sections:

  • Searching For Items - Describes the calls required to search for items.
  • Add an Item to a Cart - Describes the calls required to add an item to a customer's cart.
  • Purchasing: From Start to Finish - Describes an overview of all the calls required for a basic purchase workflow.
  • API REFERENCE GUIDE - This guide lists all Cortex API resources, methods, and response fields.