The API key is optional but recommended. It enables transaction visibility in the TON Pay Merchant Dashboard, webhook notifications, and wallet management features.
Function Signature
Transfer Parameters
API Options
Target blockchain network. Use
"mainnet" for production or "testnet" for development and testing.Your TON Pay API key from the Merchant Dashboard. Optional, but required to:
- View transactions in the TON Pay Merchant Dashboard
- Receive webhook notifications about completed transactions
- Manage receiving wallets from the admin panel
Parameter details
Human-readable payment amount. Decimals allowed (e.g., 10.5).
Asset to transfer. Use “TON” for TON coin or a jetton master address/constant (e.g., USDT).
Payee wallet address. Optional if API key is provided - defaults to the merchant’s default wallet address configured in the admin panel.
Payer wallet address. Required for jetton transfers; optional for TON coin. In
UI flows obtain it from TonConnect.
Jetton only. Numeric identifier embedded into the jetton payload for
idempotency/tracking. Ignored for TON coin.
Short note visible to the user in their wallet while signing.
Note visible to the recipient after the transfer is received.
Predefined assets (constants)
You can use built-in constants instead of raw addresses.Response fields
Built transaction message for TonConnect. Pass it to
sendTransaction as
messages: [message].Base64 hash of the signed message body content (payload). Persist and use with
getTonPayTransferByBodyHash.Tracking reference string. Persist and use with
getTonPayTransferByReference.API Key Configuration
The TON Pay API key is optional but highly recommended for production use. It unlocks essential merchant features including transaction tracking, webhook notifications, and centralized wallet management.Obtaining Your API Key
1
Access Merchant Dashboard
Navigate to tonpay.tech/dashboard and log in to your merchant account.
2
Open Developer Settings
Go to Developer → API Keys section.
3
Generate or Copy API Key
Generate a new API key or copy your existing key. Store it securely.
Usage in Code
Why Use an API Key
The API key is optional, but using it provides access to important merchant features:Transaction Visibility in Dashboard
Transaction Visibility in Dashboard
When you create transfers with an API key, they appear in your TON Pay Merchant Dashboard. You can monitor all transactions, track payment statuses, and access detailed transaction history.Without API key: Transactions are processed but not visible in your merchant account.
Webhook Notifications
Webhook Notifications
API key enables webhook notifications for completed transactions. Receive real-time HTTP POST requests when payments succeed or fail.Without API key: No webhook notifications will be sent, requiring manual status polling.
Wallet Management
Wallet Management
API key allows you to manage receiving wallet addresses from the TON Pay admin panel. Centralize wallet configuration and update addresses without code changes. When an API key is provided and
recipientAddr is omitted, the merchant’s default wallet address from the admin panel will be used automatically.Without API key: You must hard-code recipient addresses in your application.Works Without API Key
Works Without API Key
You can create and send TON Pay transfers without an API key. The blockchain transaction will work normally, but you won’t have access to merchant dashboard features.
Testnet Configuration
For development and testing purposes, configure your integration to use the TON testnet before deploying to mainnet.Setting Up Testnet
1
Set Chain to Testnet
Configure the
chain option to "testnet" in your API calls:2
Use Testnet Wallet Addresses
Ensure all wallet addresses are valid testnet addresses. Testnet addresses have the same format as mainnet but represent different accounts on the test network.
3
Obtain Testnet TON
Get testnet TON from a faucet to test transactions:
- TON Testnet Faucet
- Use testnet wallets in Tonkeeper or other TON wallets
4
Configure Testnet Jettons
If testing with jettons (tokens), use the correct testnet jetton master addresses, not mainnet addresses.
Environment-Based Configuration
Use environment variables to easily switch between mainnet and testnet:Testnet Limitations and Differences
Verifying Testnet Transactions
You can verify testnet transactions using testnet block explorers:Best Practices for Testing
Test All Payment Flows
Test All Payment Flows
Test successful payments, failed transactions, user rejections, and edge cases on testnet before mainnet deployment.
Verify Webhook Integration
Verify Webhook Integration
Ensure your webhook endpoint correctly processes testnet webhooks. The payload structure is identical to mainnet.
Test Different Amounts
Test Different Amounts
Test with various amounts including small values, large values, and decimal amounts to ensure proper handling.
Validate Tracking Identifiers
Validate Tracking Identifiers
Verify that
reference and bodyBase64Hash are correctly stored and can be used to query transaction status.Test Error Scenarios
Test Error Scenarios
Intentionally test failure cases like insufficient balance, invalid addresses, and network errors.