Create Product
Create a new product for billing and invoicing.
POST
https://api.zenpayz.com/merchant/api/v1/productsBearer · API key
Request
Headers
| Header | Description |
|---|---|
Authorization REQUIRED | Bearer {api_key} |
X-Signature REQUIRED | HMAC-SHA256 signature |
X-Timestamp REQUIRED | ISO 8601 timestamp |
X-Secret-Salt REQUIRED | Secret salt for HMAC validation |
Content-Type REQUIRED | application/json |
Body Parameters
| Parameter | Type | Description |
|---|---|---|
name REQUIRED | string | Product name (1-255 characters) |
description OPTIONAL | string | Product description |
price REQUIRED | number | Product price (minimum 0) |
currency OPTIONAL | string | Currency code (default: INR). One of USD, INR, EUR, GBP |
sku OPTIONAL | string | Stock keeping unit (1-100 characters) |
status OPTIONAL | string | Product status (default: ACTIVE). One of ACTIVE, INACTIVE, ARCHIVED |
categoryId OPTIONAL | number | Category ID to assign the product to |
images OPTIONAL | array | Array of product images |
pricingTiers OPTIONAL | array | Array of pricing tiers |
metadata OPTIONAL | object | Custom key-value pairs |
Response
Success (201 Created)
{
"success": true,
"data": {
"productId": "prod_a1b2c3d4e5f6g7h8",
"name": "Pro Plan",
"description": "Professional subscription plan with advanced features",
"price": 4999,
"currency": "INR",
"sku": "PRO-PLAN-001",
"status": "ACTIVE",
"categoryId": 1,
"images": [
{
"url": "https://example.com/images/pro-plan.png",
"alt": "Pro Plan",
"isPrimary": true
}
],
"pricingTiers": [
{
"name": "Monthly",
"price": 4999,
"description": "Billed monthly",
"features": ["Unlimited access", "Priority support"]
}
],
"metadata": {},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"message": "Product created successfully",
"error": null,
"meta": {
"request_id": "req_xxxxx",
"timestamp": "2024-01-15T10:30:00.000Z",
"processing_time_ms": 45,
"api_version": "v1",
"endpoint": "POST /products",
"user_type": "merchant"
}
}
Error Responses
| Code | HTTP | Message |
|---|---|---|
| VALIDATION_ERROR | 400 | Invalid request parameters |
| UNAUTHORIZED | 401 | Invalid API key |
| DUPLICATE_SKU | 409 | Product with this SKU already exists |
Examples
- cURL
- JavaScript
- SDK
curl -X POST https://api.zenpayz.com/merchant/api/v1/products \
-H "Authorization: Bearer zp_test_xxxxx" \
-H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
-H "X-Signature: a1b2c3d4e5f6..." \
-H "X-Secret-Salt: your_secret_salt" \
-H "Content-Type: application/json" \
-d '{
"name": "Pro Plan",
"description": "Professional subscription plan with advanced features",
"price": 4999,
"currency": "INR",
"sku": "PRO-PLAN-001",
"status": "ACTIVE",
"categoryId": 1,
"images": [
{
"url": "https://example.com/images/pro-plan.png",
"alt": "Pro Plan",
"isPrimary": true
}
],
"pricingTiers": [
{
"name": "Monthly",
"price": 4999,
"description": "Billed monthly",
"features": ["Unlimited access", "Priority support"]
}
]
}'
const response = await fetch('https://api.zenpayz.com/merchant/api/v1/products', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'X-Timestamp': timestamp,
'X-Signature': signature,
'X-Secret-Salt': secretSalt,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Pro Plan',
description: 'Professional subscription plan with advanced features',
price: 4999,
currency: 'INR',
sku: 'PRO-PLAN-001',
status: 'ACTIVE',
categoryId: 1,
images: [
{
url: 'https://example.com/images/pro-plan.png',
alt: 'Pro Plan',
isPrimary: true,
},
],
pricingTiers: [
{
name: 'Monthly',
price: 4999,
description: 'Billed monthly',
features: ['Unlimited access', 'Priority support'],
},
],
}),
});
const result = await response.json();
console.log(result.data.productId); // prod_a1b2c3d4e5f6g7h8
const product = await zenpays.products.create({
name: 'Pro Plan',
description: 'Professional subscription plan with advanced features',
price: 4999,
currency: 'INR',
sku: 'PRO-PLAN-001',
status: 'ACTIVE',
categoryId: 1,
images: [
{
url: 'https://example.com/images/pro-plan.png',
alt: 'Pro Plan',
isPrimary: true,
},
],
pricingTiers: [
{
name: 'Monthly',
price: 4999,
description: 'Billed monthly',
features: ['Unlimited access', 'Priority support'],
},
],
});
console.log(product.productId); // prod_a1b2c3d4e5f6g7h8