Error Codes 
This page provides information about the error codes that can be returned by the TronZap API.
Error Response Format 
When an error occurs, the API will return a response with a non-zero error code and an error message:
json
{
    "code": 1,
    "error": "Error message description"
}Error Code List 
| Code | Description | Resolution | 
|---|---|---|
| 0 | Success | Not an error. The request was successful. | 
| 1 | Authentication error | Check your API token and ensure your signature is calculated correctly. | 
| 2 | Invalid service or parameters | Check that the service name and parameters are correct. | 
| 5 | Wallet not found | Verify the wallet address or contact support if you believe this is an error. | 
| 6 | Insufficient funds | Add funds to your account or reduce the amount of energy you're requesting. | 
| 10 | Invalid TRON address | Check the TRON address format. It should be a valid 34-character TRON address. | 
| 11 | Invalid energy amount | Ensure the requested energy amount is valid. | 
| 12 | Invalid duration | Check that the duration parameter is valid. | 
| 20 | Subscription not found | Verify the subscription ID or external ID is correct. | 
| 21 | Cannot stop subscription | Review subscription limits; adjust the transaction limit or complete pending transactions. | 
| 24 | Address not activated | Activate the address first by making an address activation transaction. | 
| 25 | Address already activated | The address is already activated. No action needed. | 
| 30 | AML check not found | Re-run the AML check or contact support to confirm the verification status. | 
| 35 | Service not available | The service is temporarily unavailable for use. | 
| 500 | Internal`````` server error | Contact support if this error persists. | 
Handling Errors 
When consuming the API, you should implement error handling logic for all possible error codes. Here are some recommendations:
Authentication Errors (Code 1) 
Authentication errors indicate issues with your API credentials or signature calculation. You should:
- Verify your API token is correct
 - Check your signature calculation logic
 - Ensure your API secret is not exposed in client-side code
 
Resource Errors (Codes 5, 6, 10, 20) 
Resource errors indicate issues with the provided resources. You should:
- Validate TRON addresses before sending them to the API
 - Check account balance before making transactions
 - Verify transaction IDs when checking status
 
Business Logic Errors (Codes 24, 25) 
Business logic errors indicate issues with the requested operation. You should:
- Implement address activation check before attempting energy purchase
 - Skip address activation if already activated
 
