Skip to content
HisarPay

Getting started

Authentication

The HisarPay API expects an API key on every request. The key decides which mode you work in, what you can reach and which IP addresses may use it.

API keys

Send the key as a Bearer token in the Authorization header. Every request goes over HTTPS and bodies are JSON.

curl https://hisarpay.com/v1/balances \
  -H "Authorization: Bearer $HISARPAY_API_KEY"
  • Keys are created in the dashboard under Developers → API keys and shown only once. HisarPay stores a hash, not the key itself.
  • A missing, malformed or revoked key gets 401 unauthorized. If your account is suspended, the response is 403 account_not_active.
  • Every response carries an X-Request-Id header. Quote it when you contact support. If you send your own id in the same header (8–64 letters, digits, _ or -), HisarPay uses it.
401 Unauthorized
HTTP/1.1 401 Unauthorized
X-Request-Id: req_5f0c6c1e8a514c7e9d0e2b1f4f6a9c11

{
  "error": {
    "code": "unauthorized",
    "message": "invalid or revoked API key",
    "request_id": "req_5f0c6c1e8a514c7e9d0e2b1f4f6a9c11"
  }
}

Live and test mode

Keys that start with hp_live_ process real payments; keys that start with hp_test_ work in test mode. The two modes keep their data apart: test invoices, links and events never show up in live lists.

Test (hp_test_)Live (hp_live_)
BlockchainNot used; payments are simulatedTRON mainnet
BalanceUntouched; balance endpoints return an empty listReal balance
WithdrawalsNot possibleWith the withdrawals scope
Managing webhook endpointsNot possible (403 test_key)With the webhooks scope
SimulationYesNo (403 live_key)

Your webhook endpoints receive events from both modes. Check the livemode field of each event to tell test events apart.

Scopes

Pick only the scopes you need when you create a key. A key that calls an endpoint outside its scopes gets 403 forbidden. Test keys can never carry the withdrawals and webhooks scopes.

ScopeAllows
readBalances, ledger entries, events, the list of webhook endpoints, rates, coin details, status and chain lookups.
invoicesCreate, read, cancel and simulate invoices and payment links.
webhooksAdd, change and delete webhook endpoints, rotate their signing secret and resend events. Live keys only.
withdrawalsSingle withdrawals to trusted addresses. Live keys only.
reportsAsking for reports and downloading the files.

The API reference lists the scope each endpoint needs.

IP allowlist

You can restrict a key to up to 20 IPv4 or IPv6 addresses or CIDR blocks (for example 203.0.113.0/24). A request from any other address is rejected with 403 forbidden. With an empty list, the key works from anywhere.

Expiry

A key can be given 30, 90, 180 or 365 days when you create it; otherwise it has no end date. We notify and e-mail you 14 and 3 days before it ends, and when it has ended. An expired key gets 401 unauthorized. Creating a live key asks for your password and second factor, and for an authenticator app or a passkey on the account.

Keeping keys safe

  • Use keys on the server only; never send them to a browser or a mobile app.
  • Create a separate key for each integration, so revoking one leaves the others working.
  • To replace a key, create and deploy the new one first, then revoke the old one in the dashboard. Revocation is immediate.
  • The dashboard’s activity log shows API requests together with the key’s prefix. If you see usage you do not recognise, revoke the key right away.