Ctrl + K
10 sections
REST API v1

Gately Developer Documentation

All monetary amounts are formatted as exact decimal strings. Select any SDK language at the top to update all examples.

Platform Concept

Custodial Tier (0.5% + gas)

The Custodial Tier lets you start accepting crypto immediately with zero setup fee and no gas pre-funding. Gately manages the hot pool infrastructure and credits your internal double-entry ledger as soon as confirmations complete.

  • Fee & Minimum: 0.5% + network gas per settled payment, with a 0.2 USDT minimum invoice.
  • Concurrency: Up to 10 concurrent open invoices per merchant.
  • Supported Networks: Low-gas chains only — BSC, opBNB, Base, Polygon, and TON.
  • Matching & Over/Underpayments: EVM chains reserve a unique 4-decimal suffix (e.g. 12.5001) for 15 minutes; TON uses a unique memo_tag. Overpayments credit the full received amount minus fee, and underpayments still credit your ledger so funds are never lost.
Platform Concept

Non-Custodial Tier ($1 one-time, 0% ongoing fee)

In the Non-Custodial Tier, there is no shared pooling—every merchant receives their own completely separate, specially provisioned seed wallet and isolated chain setup. Mnemonics are encrypted at rest with AES-256-GCM and never logged or exposed after setup.

  • Per-User Isolation (Zero Pooling): Each user gets a dedicated, independent BIP-39 seed wallet per chain—funds never mix with any other merchant or Gately pool.
  • Fee Structure: $1 one-time activation fee unlocks all supported chains, then 0% ongoing platform fee forever.
  • User-Managed Gas: You fund and manage all network gas fees yourself (TRX energy, ETH, BNB, TON, or LTC UTXOs) and withdraw directly via dashboard or POST /v1/payouts.
  • Supported Networks: Available across all networks—and exclusively required for TRON (TRC20), Ethereum (ERC20), and Litecoin (Native SegWit).
Platform Concept

Hybrid Mode & Settlement Mode Switching

Once you unlock the Non-Custodial Tier ($1 one-time across all chains), Dashboard → Settings lets you switch freely between Custodial, Non-Custodial, and Hybrid Mode:

  • Custodial Switch: Routes all new invoices through Gately's shared pool (0.5% + gas, zero gas setup). Available to every account by default.
  • Non-Custodial Switch: Routes all new invoices to your isolated per-user BIP-39 seed wallets (0% platform fee, you manage gas).
  • Hybrid Mode: Combines both—pass the optional tier parameter ("pooled" or "dedicated") on POST /v1/invoices to choose per invoice, or omit tier to let Gately automatically select the optimal route for that chain.

1. Settlement Modes & Toggle Switching

In Dashboard → Settings, merchants can switch between three settlement modes. Custodial Mode is active for everyone by default, while Non-Custodial and Hybrid Modes unlock across all chains after a single $1 one-time activation:

Custodial Mode ("pooled")
  • Available immediately to all users
  • 0.5% + network gas fee, 0.2 USDT minimum
  • Max 10 concurrent open invoices per merchant
  • Chains: BSC, opBNB, Base, Polygon, TON
Non-Custodial Mode ("dedicated")
  • Unlocks all chains for $1 one-time, 0% ongoing fee
  • Isolated per-user BIP-39 seed wallets
  • Required for TRON (TRC20), Ethereum (ERC20), Litecoin
  • Merchant manages network gas
Hybrid Mode (Auto / Optional tier)
  • Requires $1 Non-Custodial activation
  • Pass optional tier per invoice on POST /v1/invoices
  • If tier is omitted, Gately auto-routes to the optimal mode for that chain

2. Authentication

Generate an API key in your merchant dashboard and pass it via X-API-Key or Authorization: Bearer gtl_live_....

curl
curl https://api.gately.top/v1/merchant/balances \
  -H "X-API-Key: gtl_live_your_api_key"
const res = await fetch("https://api.gately.top/v1/merchant/balances", {
  headers: { "X-API-Key": process.env.GATELY_API_KEY }
});
const data = await res.json();
import os, requests

res = requests.get(
    "https://api.gately.top/v1/merchant/balances",
    headers={"X-API-Key": os.environ["GATELY_API_KEY"]},
)
print(res.json())
req, _ := http.NewRequest("GET", "https://api.gately.top/v1/merchant/balances", nil)
req.Header.Set("X-API-Key", os.Getenv("GATELY_API_KEY"))
resp, err := http.DefaultClient.Do(req)
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.gately.top/v1/merchant/balances"))
    .header("X-API-Key", System.getenv("GATELY_API_KEY"))
    .GET().build();
HttpResponse<String> res = HttpClient.newHttpClient()
    .send(req, HttpResponse.BodyHandlers.ofString());

3. Create an Invoice (Hosted Link & Direct Wallet)

Gately supports two top-level integration types on POST /v1/invoices, with two sub-modes for Hosted Checkout:

  • Type 1A — Fixed Hosted Checkout: Pass fiat_amount, chain, and asset. Gately locks the wallet address immediately and returns checkout_url.
  • Type 1B — Flexible Hosted Checkout: Pass only fiat_amount (omit chain and asset). When the customer opens checkout_url, they choose their preferred blockchain and token first—the deposit address and quote are generated only after selection.
  • Type 2 — Direct / Headless Wallet UI: Pass fiat_amount, chain, and asset, then render the returned deposit_address, expected_amount, and memo_tag directly inside your own app.
curl
# Fixed Hosted Checkout or Direct Wallet (chain + asset specified):
curl -X POST https://api.gately.top/v1/invoices \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gtl_live_your_api_key" \
  -d '{
    "external_id": "order_1042",
    "chain": "bsc",
    "asset": "USDT",
    "fiat_amount": 12.50,
    "redirect_url": "https://yourstore.com/thanks"
  }'

# Flexible Hosted Checkout (amount only — customer picks chain & token at checkout):
curl -X POST https://api.gately.top/v1/invoices \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gtl_live_your_api_key" \
  -d '{
    "external_id": "order_1043",
    "fiat_amount": 12.50,
    "redirect_url": "https://yourstore.com/thanks"
  }'
const res = await fetch("https://api.gately.top/v1/invoices", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": process.env.GATELY_API_KEY
  },
  body: JSON.stringify({
    external_id: "order_1042",
    chain: "bsc",
    asset: "USDT",
    fiat_amount: 12.5,
    redirect_url: "https://yourstore.com/thanks"
  })
});
const invoice = await res.json();
// Option A: redirect to invoice.checkout_url
// Option B: render invoice.deposit_address & invoice.expected_amount
import os, requests

res = requests.post(
    "https://api.gately.top/v1/invoices",
    headers={"X-API-Key": os.environ["GATELY_API_KEY"]},
    json={
        "external_id": "order_1042",
        "chain": "bsc",
        "asset": "USDT",
        "fiat_amount": 12.50,
        "redirect_url": "https://yourstore.com/thanks",
    },
)
invoice = res.json()
payload := strings.NewReader(`{"external_id":"order_1042","chain":"bsc","asset":"USDT","fiat_amount":12.50}`)
req, _ := http.NewRequest("POST", "https://api.gately.top/v1/invoices", payload)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", os.Getenv("GATELY_API_KEY"))
resp, err := http.DefaultClient.Do(req)
String json = """
    {"external_id":"order_1042","chain":"bsc","asset":"USDT","fiat_amount":12.50}""";
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.gately.top/v1/invoices"))
    .header("Content-Type", "application/json")
    .header("X-API-Key", System.getenv("GATELY_API_KEY"))
    .POST(HttpRequest.BodyPublishers.ofString(json)).build();

4. Webhook Events & HMAC-SHA256 Verification

Gately sends signed POST events (invoice.paid, invoice.overpaid, invoice.underpaid) to your webhook_url with exponential backoff retries. Verify X-Gately-Signature using your webhook_secret:

curl
# Incoming HTTP Headers from Gately:
# X-Gately-Event: invoice.paid
# X-Gately-Signature: <hmac-sha256-hex>
import crypto from "node:crypto";

export function verifyGatelyWebhook(rawBody, signature, secret) {
  const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
import hmac, hashlib

def verify_gately_webhook(raw_body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, expected)
mac := hmac.New(sha256.New, []byte(webhookSecret))
mac.Write(rawBody)
expected := hex.EncodeToString(mac.Sum(nil))
valid := hmac.Equal([]byte(signatureHeader), []byte(expected))
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
String expected = HexFormat.of().formatHex(mac.doFinal(rawBody));
boolean valid = MessageDigest.isEqual(expected.getBytes(), signatureHeader.getBytes());

5. Idempotent Payouts

POST /v1/payouts requires an Idempotency-Key header so network retries never broadcast duplicate transactions.

curl
curl -X POST https://api.gately.top/v1/payouts \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gtl_live_your_api_key" \
  -H "Idempotency-Key: payout-req-987123" \
  -d '{
    "chain": "tron",
    "asset": "USDT",
    "to_address": "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
    "amount": "25.00"
  }'
const res = await fetch("https://api.gately.top/v1/payouts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": process.env.GATELY_API_KEY,
    "Idempotency-Key": crypto.randomUUID()
  },
  body: JSON.stringify({
    chain: "tron",
    asset: "USDT",
    to_address: "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
    amount: "25.00"
  })
});
import os, uuid, requests

res = requests.post(
    "https://api.gately.top/v1/payouts",
    headers={
        "X-API-Key": os.environ["GATELY_API_KEY"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "chain": "tron",
        "asset": "USDT",
        "to_address": "TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7",
        "amount": "25.00",
    },
)
req, _ := http.NewRequest("POST", "https://api.gately.top/v1/payouts", body)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", os.Getenv("GATELY_API_KEY"))
req.Header.Set("Idempotency-Key", uuid.NewString())
HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.gately.top/v1/payouts"))
    .header("Content-Type", "application/json")
    .header("X-API-Key", System.getenv("GATELY_API_KEY"))
    .header("Idempotency-Key", UUID.randomUUID().toString())
    .POST(HttpRequest.BodyPublishers.ofString(json)).build();

6. Rate Limits

To protect API availability across all merchants, Gately enforces a fixed-window rate limit backed by Redis (with automatic in-memory fail-open fallback):

  • API Request Limit: 120 requests per minute per client IP (resolved from Cloudflare's CF-Connecting-IP header).
  • Exceeded Response: HTTP 429 Too Many Requests with {"error": "rate limit exceeded"}.
  • Custodial Concurrency Cap: Up to 10 concurrent open invoices per merchant on the Custodial Tier (15-minute expiry window).

7. Error Codes

All API errors return a standard JSON payload: {"error": "human-readable message"} paired with the appropriate HTTP status code:

HTTP Status Meaning & Common Causes
400 Bad Request Invalid JSON, unsupported chain/asset, below 0.2 USDT custodial minimum, 10 open custodial invoice cap reached, missing Idempotency-Key, or invalid destination address.
401 Unauthorized Missing, invalid, revoked, or expired X-API-Key or Bearer JWT token.
404 Not Found Invoice or merchant resource does not exist or does not belong to your account.
409 Conflict Email address is already registered.
429 Too Many Requests Exceeded the 120 requests/minute per-IP rate limit. Back off and retry.
500 Internal Server Error Unexpected server or database error. Safe to retry idempotent requests using the same Idempotency-Key.