Skip to main content

GpkeysBot Reseller & Customer API Overview

The GpkeysBot Customer API (/api/v1) gives resellers, automation scripts, and server-side storefronts programmatic access to digital product catalogs, real-time account balances, instant balance-backed purchases, order delivery payloads, and immutable ledger history.

How API Keys Work with Your Account​

Every API key in GpkeysBot is cryptographically bound to one owning user account:

  • Shared Account Balance: Purchases and paid actions made with an API key draw directly from the owning user's USDT balance (balances.available).
  • Pre-Execution Enforcement: Every /api/v1/* request verifies that the key is active, not revoked or expired, that the owning user is ACTIVE, that rate limits and fraud checks pass, and that the user's balance state is valid before running the handler.
  • Atomic Purchases & HTTP 402: Paid actions (POST /api/v1/purchases, POST /api/v1/actions) serialize concurrent transactions with PostgreSQL row-level locking (SELECT ... FOR UPDATE). If funds are insufficient, the API rejects the request with 402 Payment Required (INSUFFICIENT_BALANCE), rolls back any changes, and deducts nothing.
  • Strict Tenant Isolation: An API key can never access another user's balance, orders, downloads, API keys, or ledger transactions.

Core Concepts​

ConceptDescriptionPrimary Endpoint
API KeyBearer/header credential (gpk_live_...) tied to one user, optionally constrained by perRequestCap, monthlySpendCap, and expiresAt.GET /api/v1/key
BalanceOwning user's fixed-point 6-decimal USDT balance ("48.500000"). Always transmitted as a string—never parse as binary float for billing logic.GET /api/v1/balance
ProductsActive digital goods (LICENSE_KEY, ACCOUNT, FILE, LINK, TEXT, COURSE, MANUAL) with server-authoritative pricing and stock counts.GET /api/v1/catalog/products
PurchasesIdempotent balance debits creating DELIVERED orders with digital payloads or download pointers. Requires a caller-supplied idempotencyKey.POST /api/v1/purchases
LedgerAppend-only financial record capturing userId, apiKeyId, requestType, signed amount, timestamp, and balanceAfter.GET /api/v1/ledger

Base URLs​

  • Web Portal & Docs: Configured via DOCS_SITE_URL in .env (supports / and /api/ paths)
  • Production API Host: https://api.example.com placeholder (configured via API_PUBLIC_URL in .env; TODO(verify) confirm production host)
  • Local Documentation Mock: http://localhost:4010 (included in this repository via pnpm mock)

Next Steps​

  1. Follow the 5-Minute Quickstart to make your first authenticated call and purchase.
  2. Explore schemas live in the Interactive API Reference.
  3. Copy tested integration prompts for your stack in Build with AI for Resellers.