PremiumCDKeys provides webhooks and API endpoints for advanced integrations and automation.
Webhooks notify your systems when events occur in PremiumCDKeys.
| Event | Description | Payload |
|---|---|---|
order.created |
New order received | Order details |
order.fulfilled |
Key purchased | Order + key info |
order.delivered |
Key sent to customer | Delivery confirmation |
order.failed |
Fulfillment failed | Error details |
stock.low |
Stock below threshold | Product + count |
Example order.fulfilled payload:
{ "event": "order.fulfilled", "timestamp": "2024-01-15T10:30:00Z", "data": { "order_id": "12345", "store_order_id": "WC-9876", "product": { "id": "prod_123", "name": "FIFA 24 PC Key" }, "supplier": "codeswholesale", "cost": 20.00, "currency": "EUR", "key": { "delivered": true, "delivery_method": "email" } } }
Verify webhook authenticity using HMAC:
$payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_PCDKEYS_SIGNATURE']; $secret = 'your_webhook_secret'; $expected = hash_hmac('sha256', $payload, $secret); if (hash_equals($expected, $signature)) { // Webhook is valid }
Failed webhooks are retried:
After 5 failures, webhook is paused.
PremiumCDKeys receives webhooks from:
POST /api/webhook/woocommerce/{shop_id}
Events received:
order.createdorder.updatedPOST /api/webhook/shopify/{shop_id}
Events received:
orders/createorders/paidVarious suppliers send:
Generate API keys:
Include in request headers:
Authorization: Bearer your_api_key
Or as query parameter:
?api_key=your_api_key
GET /api/v1/orders
Parameters:
status - Filter by statusfrom - Start dateto - End datelimit - Results per pageResponse:
{ "data": [ { "id": "12345", "status": "delivered", "product": "FIFA 24", "created_at": "2024-01-15T10:00:00Z" } ], "meta": { "total": 150, "page": 1 } }
GET /api/v1/orders/{id}
POST /api/v1/orders/{id}/process
GET /api/v1/products
GET /api/v1/products/{id}/stock
GET /api/v1/suppliers
GET /api/v1/suppliers/{supplier}/products/{product_id}/stock
API rate limits:
| Tier | Requests/Minute |
|---|---|
| Standard | 60 |
| Business | 300 |
| Enterprise | Custom |
Rate limit headers:
X-RateLimit-Limit: 60 X-RateLimit-Remaining: 45 X-RateLimit-Reset: 1642252800
{ "error": { "code": "ORDER_NOT_FOUND", "message": "The requested order does not exist", "details": {} } }
| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED |
401 | Invalid API key |
FORBIDDEN |
403 | Insufficient permissions |
NOT_FOUND |
404 | Resource not found |
RATE_LIMITED |
429 | Too many requests |
SERVER_ERROR |
500 | Internal error |
use PremiumCDKeys\Client; $client = new Client('your_api_key'); $orders = $client->orders()->list(['status' => 'pending']);
import { PremiumCDKeys } from '@premiumcdkeys/sdk'; const client = new PremiumCDKeys('your_api_key'); const orders = await client.orders.list({ status: 'pending' });
Use sandbox for testing:
Enable in Settings → API → Sandbox Mode
Test webhook delivery:
For API support: