{"components":{"securitySchemes":{"ResellerApiKeyAuth":{"description":"Reseller API Key issued via Telegram bot /api or \ud83d\udd11 API Access button (AK_...)","in":"header","name":"X-API-Key","type":"apiKey"},"ResellerBearerAuth":{"description":"Bearer token using your Reseller API Key (AK_...)","scheme":"bearer","type":"http"}}},"info":{"contact":{"name":"Perfect Deal Reseller Support","url":"https://t.me/askmenowanything"},"description":"Official B2B REST API documentation for Perfect Deal resellers and automated clients.\\n\\nUse your secret Reseller API Key (`AK_...`) issued via the Telegram bot (`/api` or \ud83d\udd11 API Access) to authenticate requests via the `X-API-Key` header (or `Authorization: Bearer <AK_...>`).\\n\\nFeatures include live wallet balance inspection, product catalog with wholesale tiered pricing, automated FIFO serial key delivery, order ledger tracking, and real-time HMAC-SHA256 signed webhooks.","license":{"name":"Proprietary Commercial License","url":"https://opensource.org/licenses"},"title":"Perfect Deal Reseller REST API & Webhook Gateway","version":"1.0.0"},"openapi":"3.0.3","paths":{"/api/v1/me":{"get":{"description":"Returns account profile, current wallet balance ($ USD), total deposited, total spent, and referral earnings.","responses":{"200":{"content":{"application/json":{"example":{"success":true,"user":{"referral_code":"REF-ABC123","referral_earnings":15.5,"telegram_id":1846506306,"total_deposited":500.0,"total_spent":349.25,"username":"reseller_pro","wallet_balance":150.75}}}},"description":"Profile and balance information"},"401":{"description":"Missing or invalid API Key"},"403":{"description":"Account is suspended or banned"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Get Reseller Profile & Live Wallet Balance","tags":["Reseller API v1"]}},"/api/v1/order":{"post":{"description":"Atomically purchases product from reseller wallet balance. Delivers FIFO serial keys instantly or dispatches to multi-provider upstream.","requestBody":{"content":{"application/json":{"schema":{"properties":{"product_id":{"description":"Target product ID","example":1,"type":"integer"},"quantity":{"default":1,"description":"Quantity to purchase","example":1,"type":"integer"}},"required":["product_id"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"example":{"deliverables":["CHATGPT-KEY-XXXX-YYYY-ZZZZ"],"download_url":"https://premiumshop.store/download/ORD-739281-DV","order_code":"ORD-739281-DV","order_id":512,"product_name":"ChatGPT Plus 1 Month","quantity":1,"raw_delivery":"CHATGPT-KEY-XXXX-YYYY-ZZZZ","status":"completed","success":true,"total_paid":15.0,"unit_price":15.0}}},"description":"Order successfully created and delivered"},"400":{"description":"Insufficient wallet balance, stock depleted, or invalid quantity"},"401":{"description":"Missing or invalid API Key"},"404":{"description":"Product not found or inactive"},"502":{"description":"Supplier API error if fulfilled via upstream"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Execute Purchase Order & Claim License Keys","tags":["Reseller API v1"]}},"/api/v1/order/{order_identifier}":{"get":{"description":"Fetches a specific order by order code (e.g. ORD-739281-DV) or numeric database ID, including delivered assets and download link.","parameters":[{"description":"Order code (e.g. ORD-739281-DV) or numeric order ID","in":"path","name":"order_identifier","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"example":{"order":{"amount":15.0,"completed_at":"2026-09-08T18:00:01","created_at":"2026-09-08T18:00:00","delivered_products":["CHATGPT-KEY-XXXX-YYYY-ZZZZ"],"download_url":"https://premiumshop.store/download/ORD-739281-DV","order_code":"ORD-739281-DV","order_id":"ORD-739281-DV","quantity":1,"service":"ChatGPT Plus 1 Month","status":"success"},"success":true}}},"description":"Order details with license assets"},"401":{"description":"Missing or invalid API Key"},"404":{"description":"Order not found"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Get Order Details & Delivered License Keys","tags":["Reseller API v1"]}},"/api/v1/orders":{"get":{"description":"Retrieves order history with pagination (page, limit), delivery status, and purchased assets.","parameters":[{"description":"Page number (1-based)","in":"query","name":"page","schema":{"default":1,"type":"integer"}},{"description":"Orders per page (max 200)","in":"query","name":"limit","schema":{"default":50,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"example":{"limit":50,"orders":[{"amount":15.0,"created_at":"2026-09-08T18:00:00","delivered_products":["CHATGPT-KEY-XXXX-YYYY-ZZZZ"],"order_id":"ORD-739281-DV","quantity":1,"service":"ChatGPT Plus 1 Month","status":"success"}],"page":1,"success":true,"total_orders":14,"total_pages":1}}},"description":"Paginated orders list"},"401":{"description":"Missing or invalid API Key"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Query Paginated Reseller Order Ledger","tags":["Reseller API v1"]}},"/api/v1/products":{"get":{"description":"Retrieves active digital products with base price, bulk discount tiers (tier1, tier2, tier3), live stock counts, and category info.","responses":{"200":{"content":{"application/json":{"example":{"count":2,"products":[{"category_id":3,"category_name":"AI & Subscriptions","description":"Private account with full warranty","id":1,"name":"ChatGPT Plus 1 Month","price":15.0,"product_type":"key","stock_count":42,"tier1_price":15.0,"tier2_price":13.5,"tier3_price":12.0}],"success":true}}},"description":"Catalog product list"},"401":{"description":"Missing or invalid API Key"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"List Products with Tiered Wholesale Prices & Stock","tags":["Reseller API v1"]}},"/api/v1/reseller/webhook":{"get":{"description":"Returns the currently registered outbound webhook callback URL and secret configuration status.","responses":{"200":{"content":{"application/json":{"example":{"has_secret":true,"success":true,"webhook_url":"https://your-bot.com/api/callbacks/orders"}}},"description":"Webhook configuration"},"401":{"description":"Missing or invalid API Key"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Get Outbound Webhook Configuration","tags":["Reseller API v1"]},"post":{"description":"Registers or updates callback URL for instant order notifications. Payloads are signed with HMAC-SHA256.","requestBody":{"content":{"application/json":{"schema":{"properties":{"webhook_secret":{"description":"Secret key for HMAC-SHA256 signature verification","example":"my_super_secret_hmac_key","type":"string"},"webhook_url":{"description":"HTTPS callback endpoint","example":"https://your-bot.com/api/callbacks/orders","format":"uri","type":"string"}},"required":["webhook_url"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"example":{"message":"Reseller webhook configuration saved successfully","success":true,"webhook_url":"https://your-bot.com/api/callbacks/orders"}}},"description":"Webhook configured successfully"},"400":{"description":"Invalid webhook URL format"},"401":{"description":"Missing or invalid API Key"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Configure Outbound Webhook URL & HMAC Secret","tags":["Reseller API v1"]}},"/api/v1/reseller/webhook/test":{"post":{"description":"Sends a real-time signed test ping event to your registered webhook URL to verify network reachability and HMAC signature handling.","responses":{"200":{"content":{"application/json":{"example":{"response_preview":"{\"status\":\"ok\"}","status_code":200,"success":true}}},"description":"Webhook test ping succeeded"},"400":{"description":"No webhook URL configured or remote endpoint returned failure"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Test Outbound Webhook Connectivity","tags":["Reseller API v1"]}},"/api/v1/stats":{"get":{"description":"Returns financial metrics (deposits & sales across today, 7d, 30d, 365d, all_time) and product-level volume breakdown.","responses":{"200":{"content":{"application/json":{"example":{"deposits":{"30d":500.0,"365d":500.0,"7d":200.0,"all_time":500.0,"today":50.0},"products_breakdown":[{"name":"ChatGPT Plus 1 Month","quantity_sold":12,"revenue":180.0,"service_id":"service_1"}],"sales":{"30d":349.25,"365d":349.25,"7d":120.0,"all_time":349.25,"today":15.0},"success":true}}},"description":"Reseller financial and sales telemetry"},"401":{"description":"Missing or invalid API Key"}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"summary":"Get Reseller Financial Telemetry & Sales Breakdown","tags":["Reseller API v1"]}}},"security":[{"ResellerApiKeyAuth":[]},{"ResellerBearerAuth":[]}],"servers":[{"description":"Active Production Gateway","url":"/"}],"tags":[{"description":"Downstream B2B Reseller & Client REST API: Balance, Catalog, Automated Orders & Webhooks","name":"Reseller API v1"}]}
