Get Orders
Retrieve all orders for the customer
Get Orders
Retrieve all orders for the customer. This endpoint returns order history associated with the current session or authenticated customer.
Endpoint
GET /v1/order
Base URL: https://api.storekit.app
Authentication
Info: All API requests require authentication using an API key. Generate your API key from the StoreKit Dashboard under API Key Usage section.
Headers
Name | Type | Required | Description |
---|---|---|---|
x-api-key | string | Yes | Your API key for authentication |
Response
Success Response (200 OK)
Returns a list of orders with metadata:
{
"success": true,
"data": [
{
"id": "cmcoxuqsu0001zv0pwsimssgp",
"total": 100,
"status": "PENDING",
"address": null,
"customerEmail": "[email protected]",
"customerName": "izhar",
"customerPhone": "9090990900099",
"shippingAddress": "unknows",
"billingAddress": null,
"createdAt": "2025-07-04T14:57:28.110Z",
"updatedAt": "2025-07-04T14:57:28.110Z",
"customerId": "cmcoq34z20004zvn7hqlfttgu",
"storeId": "cmbug7xjl000ezviur9su2gja"
},
{
"id": "cmcoxvuzj0001zv8dejyy41c9",
"total": 100,
"status": "PENDING",
"address": null,
"customerEmail": "[email protected]",
"customerName": "izhar",
"customerPhone": "9090990900099",
"shippingAddress": "unknows",
"billingAddress": null,
"createdAt": "2025-07-04T14:58:20.191Z",
"updatedAt": "2025-07-04T14:58:20.191Z",
"customerId": "cmcoq34z20004zvn7hqlfttgu",
"storeId": "cmbug7xjl000ezviur9su2gja"
}
],
"count": 2,
"message": "list of all ordered items"
}
Response Schema
Field | Type | Description |
---|---|---|
success | boolean | Indicates if the request was successful |
data | array | Array of order objects |
count | number | Total number of orders |
message | string | Descriptive message about the operation |
Order Object
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the order |
total | number | Total amount of the order |
status | string | Current status of the order (e.g., "PENDING") |
address | string | null | Primary address (if specified) |
customerEmail | string | Customer's email address |
customerName | string | Customer's name |
customerPhone | string | Customer's phone number |
shippingAddress | string | Shipping address for the order |
billingAddress | string | null | Billing address (if different from shipping) |
createdAt | string | ISO 8601 timestamp when order was created |
updatedAt | string | ISO 8601 timestamp when order was last updated |
customerId | string | ID of the customer who placed the order |
storeId | string | ID of the store where the order was placed |
Error Responses
401 Unauthorized
{
"error": "API key is required"
}
422 Unprocessable Entity
{
"success": false,
"message": "Invalid input data"
}
500 Internal Server Error
{
"success": false,
"message": "Failed to get all orders"
}
Code Examples
curl -X GET "https://api.storekit.app/v1/order" \
-H "x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402"
const response = await fetch("https://api.storekit.app/v1/order", {
method: "GET",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
},
});
const data = await response.json();
if (data.success) {
console.log(`Found ${data.count} orders:`, data.data);
// Display order details
data.data.forEach(order => {
console.log(`Order #${order.id}: $${order.total} - ${order.status}`);
});
} else {
console.error("Error:", data.message);
}
import axios from "axios";
try {
const response = await axios.get("https://api.storekit.app/v1/order", {
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
},
});
const { success, data, count, message } = response.data;
if (success) {
console.log(`Found ${count} orders:`, data);
// Process each order
data.forEach(order => {
console.log(`Order: ${order.id} - Status: ${order.status}`);
});
} else {
console.error("Error:", message);
}
} catch (error) {
console.error("Request failed:", error.response?.data || error.message);
}
const https = require("https");
const options = {
hostname: "api.storekit.app",
port: 443,
path: "/v1/order",
method: "GET",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
},
};
const req = https.request(options, (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
const result = JSON.parse(data);
if (result.success) {
console.log(`Found ${result.count} orders:`);
result.data.forEach(order => {
console.log(`- Order ${order.id}: $${order.total} (${order.status})`);
});
} else {
console.error("Error:", result.message);
}
});
});
req.on("error", (error) => {
console.error("Request failed:", error);
});
req.end();
import requests
import json
url = "https://api.storekit.app/v1/order"
headers = {
"x-api-key": "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402"
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
if data['success']:
print(f"Found {data['count']} orders:")
for order in data['data']:
print(f"- Order {order['id']}: ${order['total']} ({order['status']})")
print(f" Customer: {order['customerName']} ({order['customerEmail']})")
print(f" Created: {order['createdAt']}")
print()
else:
print(f"Error: {data['message']}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.storekit.app/v1/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402"
],
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$data = json_decode($response, true);
if ($httpCode === 200 && $data['success']) {
echo "Found " . $data['count'] . " orders:\n";
foreach ($data['data'] as $order) {
echo "- Order " . $order['id'] . ": $" . $order['total'] . " (" . $order['status'] . ")\n";
echo " Customer: " . $order['customerName'] . " (" . $order['customerEmail'] . ")\n";
echo " Created: " . $order['createdAt'] . "\n\n";
}
} else {
echo "Error: " . $data['message'] . "\n";
}
?>
$.ajax({
url: "https://api.storekit.app/v1/order",
method: "GET",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
},
success: function (data) {
if (data.success) {
console.log(`Found ${data.count} orders:`, data.data);
// Example: Display in UI
$("#order-count").text(data.count);
$("#order-list").empty();
data.data.forEach(function (order) {
$("#order-list").append(`
<div class="order-item" data-id="${order.id}">
<h3>Order #${order.id}</h3>
<p>Total: $${order.total}</p>
<p>Status: ${order.status}</p>
<p>Customer: ${order.customerName}</p>
<p>Email: ${order.customerEmail}</p>
<p>Phone: ${order.customerPhone}</p>
<p>Shipping: ${order.shippingAddress}</p>
<p>Created: ${new Date(order.createdAt).toLocaleDateString()}</p>
</div>
`);
});
} else {
console.error("Error:", data.message);
}
},
error: function (xhr, status, error) {
console.error("Request failed:", error);
},
});
Authentication & Session Management
This endpoint automatically handles both authenticated and anonymous users:
- Authenticated users: Orders are retrieved based on their customer account
- Anonymous users: Orders are tracked using session cookies that are automatically managed
No manual session management is required - the API handles this automatically through cookies.
Important Notes
- Session data is automatically managed through cookies
- API key is required for all requests and can be generated in your StoreKit Dashboard
- Orders are automatically filtered to show only those belonging to the current customer/session
Customer Context
Info: This endpoint uses customer identification middleware that retrieves orders by:
- Authenticated users: Orders are filtered by
customerId
- Guest users: Orders are tracked by
sessionId
for the current browser session automatically
Use Cases
- Display order history on customer account pages
- Show recent orders in customer dashboard
- Build order tracking functionality
- Generate order reports and analytics
- Implement order management features
Quick Start
Step 1: Get your API Key
Navigate to your StoreKit Dashboard and go to the API Key Usage section to generate your API key.
Step 2: Make the request
Use any of the code examples above to fetch the orders. The API will automatically identify the customer based on their session.
Step 3: Handle the response
Check the success
field and use the data
array to display order information. The count
field tells you how many orders were found.
Status Codes
Status Code | Description | Response Example |
---|---|---|
200 | Success - Orders retrieved successfully | { "success": true, "data": [...], "count": 2, "message": "list of all ordered items" } |
401 | Unauthorized - Missing or invalid API key | { "error": "API key is required" } |
422 | Unprocessable Entity - Invalid input data | { "success": false, "message": "Invalid input data" } |
500 | Internal Server Error - Failed to fetch orders | { "success": false, "message": "Failed to get all orders" } |