Overview
Base URL, authentication, content type, CORS, and a quick-start example for the CloudCart REST JSON:API.
Base URL
All requests target your store's domain:
https://{shop}.cloudcart.com/api/v2/{resource}Replace {shop} with your subdomain or use a custom domain if configured.
Authentication
Every request requires an API key in the X-CloudCart-ApiKey header:
X-CloudCart-ApiKey: your-api-key-hereSee the Authentication page for setup instructions and best practices.
Content Type
Requests and responses use the JSON:API media type:
| Header | Value | When |
|---|---|---|
Content-Type | application/vnd.api+json | POST and PATCH requests |
Accept | application/vnd.api+json | Recommended on all requests |
CORS
The API supports Cross-Origin Resource Sharing for browser-based apps.
Never expose your API key in client-side code. Use a backend proxy to keep it secret.
Standard Endpoints
Every resource supports these operations:
| Method | Path | Description |
|---|---|---|
| GET | /api/v2/{resource} | List all |
| GET | /api/v2/{resource}/{id} | Get one |
| POST | /api/v2/{resource} | Create |
| PATCH | /api/v2/{resource}/{id} | Update |
| DELETE | /api/v2/{resource}/{id} | Delete |
Some resources are read-only or support a subset of these -- check each resource page for details.
Response Structure
Every response includes these top-level members:
| Member | Type | Description |
|---|---|---|
data | array or object | An array for list endpoints, a single object for get/create/update. |
included | array | Side-loaded related resources (when using ?include=). |
meta | object | Metadata. For lists, contains total_count. |
links | object | Pagination links: first, prev, next, last. |
Boolean Fields
CloudCart uses string values "yes" and "no" instead of true/false:
{ "active": "yes", "digital": "no" }Using true/false, 1/0, or "true"/"false" will return a validation error. Always use "yes" or "no".
Quick Start
Fetch your two most recent products:
curl "https://mystore.cloudcart.com/api/v2/products?page[size]=2&sort=-date_added" \
-H "X-CloudCart-ApiKey: $CLOUDCART_API_KEY"const response = await fetch(
'https://mystore.cloudcart.com/api/v2/products?page[size]=2&sort=-date_added',
{
headers: { 'X-CloudCart-ApiKey': process.env.CLOUDCART_API_KEY },
}
);
const data = await response.json();$response = Http::withHeaders([
'X-CloudCart-ApiKey' => $apiKey,
])->get('https://mystore.cloudcart.com/api/v2/products', [
'page' => ['size' => 2],
'sort' => '-date_added',
]);
$data = $response->json();import requests
response = requests.get(
'https://mystore.cloudcart.com/api/v2/products',
params={'page[size]': 2, 'sort': '-date_added'},
headers={'X-CloudCart-ApiKey': api_key},
)
data = response.json(){
"data": [
{
"id": "142",
"type": "products",
"attributes": {
"name": "Classic Cotton T-Shirt",
"active": "yes",
"price_from": 2999
}
}
],
"meta": { "total_count": 48 },
"links": {
"first": "/api/v2/products?page[number]=1&page[size]=2",
"next": "/api/v2/products?page[number]=2&page[size]=2",
"last": "/api/v2/products?page[number]=24&page[size]=2"
}
}Key Concepts
Resources and relationships
The API is built around resources — products, orders, customers, categories, etc. Resources are connected through relationships. For example, a product belongs to a category, has variants (with prices and stock), and has images.
By default, a request only returns the resource itself with lightweight relationship references (just IDs). To get the full related data in the same response, use ?include=:
# Get a product with its variants and images in ONE request
curl ".../api/v2/products/1042?include=variants,images" \
-H "X-CloudCart-ApiKey: ..."The related resources appear in an included array alongside the main data:
{
"data": {
"id": "1042",
"type": "products",
"attributes": { "name": "Classic T-Shirt", "price_from": 2999 },
"relationships": {
"variants": {
"data": [{ "id": "2001", "type": "variants" }]
}
}
},
"included": [
{
"id": "2001",
"type": "variants",
"attributes": { "sku": "TEE-S", "price": "29.99", "quantity": 80 }
}
]
}You can even nest includes with dot notation — ?include=variants.images loads each variant's images too.
Filtering
You can filter on any field automatically — the API auto-discovers every column in the database. Just pass the field name as a query parameter:
?filter[active]=yes— only active products?filter[status]=3— orders with status 3?filter[email][email protected]— find a customer by email
Some resources also have special filters like filter[sku] on products to search across variants. See each resource page for details.
Sorting
Add ?sort= to order results. Prefix with - for descending:
?sort=name— alphabetical (A → Z)?sort=-date_added— newest first?sort=-views— most popular first
Each resource defines which fields are sortable — check the resource page for the list.
Pagination
Results are paginated with a default of 20 items per page (max 100):
?page[number]=2— go to page 2?page[size]=50— 50 results per page
Every paginated response includes links with first, next, prev, and last URLs — follow next until it's absent to iterate through all records.
Combining everything
All query features work together. Fetch the 5 most recent active products with their variants:
curl ".../api/v2/products?filter[active]=yes&sort=-date_added&page[size]=5&include=variants" \
-H "X-CloudCart-ApiKey: ..."For full details, see Pagination, Filtering & Sorting.
What's Next
Authentication
API key setup and security best practices.
Pagination, Filtering & Sorting
Filter on any column, paginate, sort, include relationships, and append computed fields.
Error Handling
Understand error responses and common status codes.
Rate Limits
Per-domain throttling and response headers.
Products
Start working with the most common resource.