Create Wishlist Item
Add a product to customer's wishlist
Add Product to Wishlist
Add a product to the customer's wishlist. This endpoint supports both authenticated customers and anonymous users through session tracking.
Endpoint
GET /v1/wishlist
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
Header | Type | Required | Description |
---|---|---|---|
x-api-key | string | Yes | Your API key from the StoreKit dashboard |
Content-Type | string | Yes | Must be application/json |
Request Body
{
"productId": "string"
}
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
productId | string | Yes | The unique identifier of the product to add to wishlist |
Response
Success Response (200 OK)
{
"success": true,
"message": "Wishlist added successfully...!!!"
}
Error Responses
Product Not Found (404)
{
"success": false,
"message": "Product not found"
}
Product Already in Wishlist (409)
{
"success": false,
"message": "Product already in wishlist"
}
Invalid API Key (401)
{
"success": false,
"message": "Invalid or missing API key"
}
Invalid Input Data (422)
{
"success": false,
"message": "Invalid input data"
}
Internal Server Error (500)
{
"success": false,
"message": "Failed to add to wishlist"
}
Code Examples
curl -X POST "https://api.storekit.app/v1/wishlist" \
-H "x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402" \
-H "Content-Type: application/json" \
-d '{
"productId": "prod_123456789"
}'
const response = await fetch("https://api.storekit.app/v1/wishlist", {
method: "POST",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type": "application/json",
},
body: JSON.stringify({
productId: "prod_123456789"
}),
});
const data = await response.json();
if (data.success) {
console.log("Product added to wishlist:", data.message);
} else {
console.error("Error:", data.message);
}
import axios from "axios";
try {
const response = await axios.post("https://api.storekit.app/v1/wishlist", {
productId: "prod_123456789"
}, {
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type": "application/json",
},
});
const { success, message } = response.data;
if (success) {
console.log("Product added to wishlist:", message);
} else {
console.error("Error:", message);
}
} catch (error) {
console.error("Request failed:", error.response?.data || error.message);
}
const https = require("https");
const postData = JSON.stringify({
productId: "prod_123456789"
});
const options = {
hostname: "api.storekit.app",
port: 443,
path: "/v1/wishlist",
method: "POST",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type": "application/json",
"Content-Length": Buffer.byteLength(postData),
},
};
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("Product added to wishlist:", result.message);
} else {
console.error("Error:", result.message);
}
});
});
req.on("error", (error) => {
console.error("Request failed:", error);
});
req.write(postData);
req.end();
import requests
import json
url = "https://api.storekit.app/v1/wishlist"
headers = {
"x-api-key": "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type": "application/json"
}
data = {
"productId": "prod_123456789"
}
try:
response = requests.post(url, json=data, headers=headers)
response.raise_for_status()
result = response.json()
if result['success']:
print(f"Product added to wishlist: {result['message']}")
else:
print(f"Error: {result['message']}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
<?php
$curl = curl_init();
$data = json_encode([
"productId" => "prod_123456789"
]);
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.storekit.app/v1/wishlist",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => [
"x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$result = json_decode($response, true);
if ($httpCode === 200 && $result['success']) {
echo "Product added to wishlist: " . $result['message'] . "\n";
} else {
echo "Error: " . $result['message'] . "\n";
}
?>
$.ajax({
url: "https://api.storekit.app/v1/wishlist",
method: "POST",
headers: {
"x-api-key":
"sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
"Content-Type": "application/json",
},
data: JSON.stringify({
productId: "prod_123456789"
}),
success: function (data) {
if (data.success) {
console.log("Product added to wishlist:", data.message);
// Example: Update UI
$("#wishlist-success").show().text(data.message);
$("#add-to-wishlist-btn").text("Added to Wishlist").prop("disabled", true);
} else {
console.error("Error:", data.message);
$("#wishlist-error").show().text(data.message);
}
},
error: function (xhr, status, error) {
console.error("Request failed:", error);
$("#wishlist-error").show().text("Failed to add product to wishlist");
},
});
Authentication & Session Management
This endpoint automatically handles both authenticated and anonymous users:
- Authenticated users: Products are associated with their customer account
- Anonymous users: Products are tracked using session cookies that are automatically managed
- Session management: For guest users, maintain the same session to preserve wishlist items
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
Customer Context
Info: This endpoint uses customer identification middleware that tracks items by:
- Authenticated users: Items are associated with their
customerId
- Guest users: Items are tracked by
sessionId
for the current browser session automatically
Use Cases
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 wishlist items. 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 wishlist items.
Status Codes
Code | Description |
---|---|
200 | Product successfully added to wishlist |
401 | Invalid or missing API key |
404 | Product not found |
409 | Product already exists in wishlist |
422 | Invalid input data |
500 | Internal server error |