Execute Paid API Action
Executes a server-priced metered non-order API action under strict purchase rate limits, spend caps, fraud detection, and atomic balance deduction (referenceType: "API_ACTION").
Supported Metered Actions
actionType | Server Cost (USDT) | Description |
|---|---|---|
BULK_CATALOG_EXPORT | 0.500000 | Returns up to 100 active catalog products in a compact export structure. |
STOCK_RESERVATION_PING | 0.100000 | Returns active catalog product count and live server timestamp. |
- cURL
- JavaScript (fetch)
- Python (requests)
- PHP
curl -sS -X POST "https://api.example.com/api/v1/actions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"actionType": "STOCK_RESERVATION_PING",
"idempotencyKey": "action-ping-0001",
"metadata": {
"source": "sync-worker"
}
}'
const res = await fetch("https://api.example.com/api/v1/actions", {
method: "POST",
headers: {
"x-api-key": process.env.GPKEYS_API_KEY ?? "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"actionType": "STOCK_RESERVATION_PING",
"idempotencyKey": "action-ping-0001",
"metadata": {
"source": "sync-worker"
}
}),
});
const data = await res.json();
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${data?.error?.code ?? "UNKNOWN"} - ${data?.error?.message}`);
}
console.log(data);
import os
import requests
headers = {
"x-api-key": os.environ.get("GPKEYS_API_KEY", "YOUR_API_KEY"),
"Content-Type": "application/json",
}
payload = {
"actionType": "STOCK_RESERVATION_PING",
"idempotencyKey": "action-ping-0001",
"metadata": {
"source": "sync-worker"
}
}
resp = requests.post("https://api.example.com/api/v1/actions", json=payload, headers=headers, timeout=15)
if resp.status_code == 402:
raise RuntimeError(f"Insufficient balance: {resp.json()}")
resp.raise_for_status()
print(resp.json())
<?php
$apiKey = getenv('GPKEYS_API_KEY') ?: 'YOUR_API_KEY';
$payload = <<<'JSON'
{
"actionType": "STOCK_RESERVATION_PING",
"idempotencyKey": "action-ping-0001",
"metadata": {
"source": "sync-worker"
}
}
JSON;
$ch = curl_init('https://api.example.com/api/v1/actions');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'x-api-key: ' . $apiKey,
'Content-Type: application/json',
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP {$status}\n{$body}\n";
Request Body (application/json)
| Field | Type | Required | Description |
|---|---|---|---|
actionType | enum | Yes | "BULK_CATALOG_EXPORT" or "STOCK_RESERVATION_PING". |
idempotencyKey | string | Yes | 8–128 chars, automatically scoped per user account (userId:idempotencyKey). |
metadata | object | No | Flat key-value map (string | number | boolean). |
Success Response (201 Created / 200 OK Replay)
{
"actionType": "STOCK_RESERVATION_PING",
"amountCharged": "0.100000",
"balanceAfter": "99.900000",
"ledgerTransactionId": "cld_action_001",
"created": true,
"result": {
"activeProductCount": 3,
"checkedAt": "2026-11-30T18:10:05.000Z"
}
}
Error Responses
Follows the exact same error taxonomy as POST /api/v1/purchases (400, 401, 402 INSUFFICIENT_BALANCE, 403 API_KEY_CAP_EXCEEDED, 403 FRAUD_DETECTED, 429 RATE_LIMITED, 500 INTERNAL_ERROR).