- Obtaining a list of products to display that can be searched or filtered
- Adding products to the cart and returning an updated cart object for display
- Obtaining shipping rates for a cart
- Collecting a customers’s addresses
Versioning
CoCart API will be safely versioned using root path versioning, in the format/v{major}. For example, /cocart/v2/cart.
The current supported WordPress REST API integration for CoCart is version v2.
CoCart API Namespace
Resources in the CoCart API are all found within thecocart/v2 namespace, and since this API extends the WordPress API, accessing it requires the /wp-json/ base.
Examples:
Versioning Strategy
The main principles of the strategy are:- All breaking changes will be bundled into a new version
- Deprecations for existing versions whenever a new version is announced is 6 months
- In order to provide quicker adoption of new changes, they will be released on on ongoing basis
- All API responses will contain the version of CoCart core via the returned header
CoCart-Versionif you haveWP_DEBUGenabled which will be set to the current version of the plugin you are using.
Breaking Changes
Breaking changes are any changes that require developer resources to maintain existing functionality. This includes resources used for investigation into the changes that need to be made, determination of features/endpoints being deprecated and final implementation of all these changes. A list of breaking changes are things like:- Removing a param from the API request/response
- Modifying the name for any params or endpoints
- Adding/changing optional or required params (e.g., making a customers name a required field in the request)
v2. If breaking changes are necessary that changes the data in the response, we’ll release a new major version. We may deprecate APIs that have been replaced by a newer version.
When doing so, we will expect developers to manage a transition to the new resources within the deprecation timeline of old ones.
Changes we do not consider to be breaking:
- Adding new endpoints
- Adding optional query parameters to API endpoints
- Adding new properties to existing API responses
- Reordering properties in existing API responses
Requirements and limitations
- This is an unauthenticated API. It does not require API keys or authentication tokens for access.
- All API responses return JSON-formatted data.
- Data returned from the API is reflective of the current user (customer). Sessions are token based.
- CoCart API cannot be used to look up other customers and orders by ID; only data belonging to the current user.
- Likewise, CoCart API cannot be used to write store data e.g. settings. For more extensive access, use the authenticated WooCommerce REST API.
- Endpoints that do allow writes, for example, updating the current customer address, require a cart key or user ID by authentication.
- CoCart API is render-target agnostic and should not make assumptions about where content will be displayed. For example, returning HTML would be discouraged unless the data type itself is HTML.
Pagination
If collections contain many results, they may be paginated. When listing resources you can pass the following parameters:
In the example below, we list 20 products per page and return page 2.
Status Codes
The following table gives an overview of how the API functions generally behave.
The following table shows the possible return codes for API requests.
Route Handling
Typically, routes handle the following types of requests:GETrequests to read product, cart, or checkout data.POSTandPUTrequests to update cart and checkout data.DELETErequests to remove cart data.OPTIONSrequests to retrieve the JSON schema for the current route.
POST, PUT and DELETE), but if not you can use the _method property.
Response Headers
CoCart returns specific and required headers for the API to function and help manage data control.Global Headers
If you haveWP_DEBUG set to true, the version of the core of CoCart will return. In addition a timestamp header is also introduced.
CoCart-Version: 4.6.3CoCart-Timestamp: time()
Cart Headers
For the Cart API, three important headers return for managing the cart session. Use them to help track the cart session.- Cart Key:
CoCart-API-Cart-Key: - Cart Expiring:
CoCart-API-Cart-Expiring: - Cart Expiration:
CoCart-API-Cart-Expiration:
CORS Headers
When CORS is enabled, the following headers will return.Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETEAccess-Control-Allow-Credentials: trueVary: OriginAccess-Control-Max-Age: 600- This caches the result of preflight requests (600 is the upper limit for Chromium).X-Robots-Tag: noindexX-Content-Type-Options: nosniff
Access-Control-Allow-Origin: *
Cache Control
Expires: Thu, 01-Jan-70 00:00:01 GMTCache-Control: no-cache, must-revalidate, max-age=0, no-store// If the API is authenticated it will extend by addingprivateat the end.Pragma: no-cache
Last-Modified: Thu, 29-July-25 14:05:30 GMT
Dates
Datetime fields in the APIs conform to the ISO 8601 date and time format in UTC. For example:2025-03-22T11:56:48.520641Z.
Country Codes
Countries are identified in the APIs using ISO 3166-1 Alpha-2 codes. For example:GB and US.
Currency
Currency are identified in the APIs using ISO-4217 codes. This is a three-letter string likeUSD or EUR. The value of a currency is represented by your WooCommerce store settings on the General tab.
Most currencies have a “precision” of two (like USD: $1.23).
AED,VEF,PKR,IDR,HKD,QAR,PHP,NZD,INR,EUR,ARS,THB,MXN,EGP,DZD,SAR,LBP,COP,TRY,SGD,MAD,AUD,USD,MYR,CAD,BRL,GBP.
VND,KRW,CLP,JPY
KWD,IQD,BHD,TND