Customize and Extend Your Customer Data with the BigCommerce v3 Customers API

Derrek Pearson
BigCommerce Developer Blog
6 min readMar 28, 2019

--

We are excited to announce that the v3 Customers API is now in open beta! The v3 Customers API represents a complete rewrite of our v2 Customers API, and in the process, we’ve made tremendous advances in efficiency and performance. We’ve also added new capabilities that allow developers to define their own customer attributes, unlocking new and exciting features on the BigCommerce platform.

The v3 Customers API allows developers to actually extend the customer record with attributes: name value pairs that attach additional data to the customer model. You can build applications that base logic around customer attributes to create personalized experiences and targeted marketing. For example, a merchant selling made-to-order clothing might want to record a customer’s measurements and use that data to pre-fill an order form. Or, a merchant selling pet supplies might want to record the name, birthday, and breed of a customer’s dog to send the customer personalized promotions.

Customer attributes can also be used to extend the customer model to better integrate with third-party backend solutions, like ERPs and CRMs.

In the next phase of development, we’ll be adding storefront access to customer attributes, to allow developers even more flexibility for building dynamic storefronts.

Increased Efficiency

The v3 Customers API incorporates many of the patterns we introduced with the v3 Catalog API, dramatically improving efficiency. We’re seeing response times that are twice as fast as the time it takes to perform the same task using the v2 Customers API.

In addition to faster response times, the v3 API supports “batching” for all operations. This means that you can create or update multiple customer records in a single call — something that wasn’t possible with the v2 API.

The v3 Customers API also allows you to bundle subresources into a single request. On the v2 Customers API, subresources were divided into their own endpoints. Addresses and form fields needed to be fetched separately from the main customer record, each in a separate request. Now, with the v3 Customers API, you can include subresources like addresses in a single request, using a query parameter.

The v3 Customers API makes powerful use of filters. One major architectural difference between the v2 and v3 Customers APIs is that v3 exists as a single endpoint that accepts filters to refine the request. For example, I may want to request the records for 3 specific customers, by their IDs. With the v2 Customers API, that was 3 requests. With the v3 Customers API, you can use a filter to drill down to exactly the records that you need:

/v3/customers?id:in=27,28,24

We’re excited by the advances we’re making in efficiency and performance, but even more exciting are the new capabilities made possible by customer attributes.

Customer Attributes

Customer attributes are a simple concept that have far-reaching applications. A customer attribute is a key value pair whose data type can be a string, number, or date, assigned to a customer record. Beyond that, the usage is entirely up to you as a developer — and we’re already seeing customer attributes applied to creative problem solving.

Store a customer’s:

  • Clothing size
  • VIP status
  • Birthday
  • Favorite sports team
  • Active social media platforms
  • Any data you want!

B2B businesses can use customer attributes to sync fields with CRM tools, such as job title or wholesaler ID.

Today, customer attributes can be read and managed by backend applications through our REST API, but in the future, we’ll be opening access to read customer attribute data on the storefront, using GraphQL. We’re also working on supporting customer attributes with Stencil Handlebars expressions, allowing you create templating logic around attributes. This sets the stage for a new class of tools that will allow you to create dynamic and personalized storefront experiences.

Sample Workflow: AI Chatbot

The Customers API allows you to perform complex actions to segment customers and pull out valuable insights, providing an exceptional customer experience. Let’s imagine that you want to build an AI chatbot for a store selling skin care products. The chatbot asks the customer a series of questions about their skin type and routine, which it uses to make personalized product recommendations each time the customer logs in. As the customer makes purchases and interacts with the chatbot, the app saves relevant data to the customer record to build a profile of customer preferences. Finally, the chatbot can show the customer a personalized page of product recommendations, creating a storefront experience tailored to the customer’s particular attributes.

Retrieving the Customer Record

The v3 Customers API makes it possible to get all of a customer’s data in a single API call. When a customer logs in to their account on the storefront, the chatbot app could reach out to the Customers API for their most up-to-date records, using filters to narrow the request to a single customer ID and includes parameters to pull in every relevant subresource:

https://api.bigcommerce.com/stores/{{store_hash}}/v3/customers?id:in=27&include=attributes,storecredit,addresses,formfields

Creating New Customer Attributes

When the chatbot engages a customer in conversation, it can pull out insights that would be useful to store for future recommendations.

Chatbot collecting customer information

When the chatbot app learns a new customer preference, the app can store new insights as an attribute against the customer record. The attribute can be referenced in future support conversations and marketing campaigns to provide a personalized recommendation to the customer, and can be used to build out a product recommendation page.

For example, based on the conversation above, the app could create a new customer attribute for this customer, storing their preference for products formulated for sensitive skin.

First, create the attribute. We’ll define a name and data type:

POST /customers/attributes

[
{
"name": "Skin concern",
"type": "string"
}
]

Assign the attribute to a customer and define its value using the Upsert Customer Attribute Values endpoint. The v3 Customers API uses upsert rather than insert for PUT requests — that means that the API will check for an existing value and update it if one is found; if no record is found then a new one will be created.

Include the attribute ID of the attribute created in the previous step, the ID of the customer to assign the value to, and the value to store against that customer.

PUT /customers/attribute-values

[
{
"attribute_id": 2,
"value": "Sensitive",
"customer_id": 27
}
]

Personalizing Product Recommendations

The next time a customer visits the site, the chatbot can retrieve the customer’s record and note their preference for products for sensitive skin.

Chatbot generates recommendations from customer attributes

Then, the chatbot could display a page with a curated selection of products, based on data that the chatbot has gathered from customer conversations and stored as attributes.

Conclusion

The v3 Customers API modernizes the customers endpoint, allowing developers to make API calls in half the time it took to perform similar actions in v2. Developers can take advantage of improved performance while leveraging powerful new features like Customer Attributes. This opens the door for a new class of merchant solutions that provide personalized shopping experiences and robust third-party integrations by expanding the customer model.

Developers can get started using the v3 Customers API today — no signup required to join the open beta. Visit our Developer Documentation for our complete overview and API reference. During the beta period, we’ll be gathering your feedback, iterating, and adding new features. Tell us your use cases and what you’re building by leaving us a comment below!

--

--

Derrek Pearson
BigCommerce Developer Blog

Senior Product Manager at BigCommerce. Based in San Francisco, CA.