Skip to content
Thrive Tech Services
Thrive Tech Services
HomeServicesProductsDocsEnterpriseContactAbout
LoginRegister

Error Handling

Comprehensive error handling strategies for the ThriveTech API, including error codes, recovery strategies, and best practices.


Error Response Format

All errors follow a consistent JSON structure:

json
{
"error": "error_code",
"message": "Human-readable error message",
"details": { "field": "Additional context" },
"correlationId": "uuid-for-support-tracking"
}

HTTP Status Codes

StatusCategoryDescription
400Client ErrorInvalid request parameters
401AuthenticationInvalid or missing credentials
402Payment RequiredPayment verification failed
403ForbiddenInsufficient permissions
404Not FoundResource doesn't exist
409ConflictResource state conflict
422ValidationRequest validation failed
429Rate LimitedToo many requests
500Server ErrorInternal server error
503UnavailableService temporarily unavailable

Error Codes Reference

Authentication Errors (401)

Error CodeDescriptionRecovery
invalid_api_keyAPI key is invalid or revokedVerify key in dashboard
missing_api_keyAPI key header not providedAdd authentication header
expired_api_keyAPI key has expiredGenerate new key
invalid_tokenJWT token is invalidRe-authenticate
expired_tokenJWT token has expiredRefresh token

License Errors

Error CodeStatusDescriptionRecovery
invalid_license404License key not foundVerify license key
license_expired403License has expiredPrompt for renewal
license_suspended403License is suspendedContact support
license_revoked403License has been revokedCheck refund status
trial_already_used409Trial already activatedPrompt for purchase
device_limit_reached409Max devices exceededDeactivate a device
device_mismatch403License not valid for deviceActivate on this device

Payment Errors (402)

Error CodeDescriptionRecovery
payment_not_foundPayment not found in storeVerify transaction ID
payment_failedPayment was declinedRetry payment
payment_pendingPayment is processingWait for webhook
receipt_invalidInvalid receipt dataGet fresh receipt
store_unavailablePayment store unreachableRetry later

Validation Errors (400/422)

Error CodeDescriptionRecovery
invalid_requestMalformed request bodyCheck request format
missing_fieldRequired field missingAdd required field
invalid_fieldField value invalidFix field value
invalid_device_fingerprintInvalid fingerprint formatRegenerate fingerprint

Rate Limit Errors (429)

Error CodeDescriptionRecovery
rate_limit_exceededToo many requestsWait for reset time
quota_exceededDaily quota exceededUpgrade plan or wait

Retry Strategy

Use exponential backoff with jitter for transient errors:

javascript
async function requestWithRetry(fn, maxRetries = 3, baseDelay = 1000) {
let lastError;
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error) {
lastError = error;
// Don't retry client errors (4xx) except rate limits
if (error.statusCode >= 400 && error.statusCode < 500
&& error.statusCode !== 429) {
throw error;
}
if (attempt === maxRetries - 1) throw error;
const delay = Math.min(
baseDelay * Math.pow(2, attempt) + Math.random() * 1000,
30000
);
await new Promise(resolve => setTimeout(resolve, delay));
}
}
throw lastError;
}

Offline Mode

When validation fails due to network issues, allow a grace period before blocking functionality:

  1. Cache validation results — Store the last successful validation response locally
  2. Check grace period — Allow offline use for a configurable period (recommended: 7 days)
  3. Prompt reconnection — After the grace period, prompt the user to connect to the internet
javascript
// Simplified offline validation
function validateOffline(cachedLicense) {
const daysSinceValidation =
(Date.now() - new Date(cachedLicense.lastValidated)) / (1000 * 60 * 60 * 24);
if (daysSinceValidation > 7) {
return { valid: false, reason: 'Please connect to the internet to validate your license.' };
}
if (new Date(cachedLicense.validUntil) < new Date()) {
return { valid: false, reason: 'Your license has expired.' };
}
return { valid: true, offline: true, gracePeriodRemaining: Math.ceil(7 - daysSinceValidation) };
}

Multi-Language Error Messages

Error messages support localization via the Accept-Language header. Supported: en-US, es-ES.


Contacting Support

When contacting support, include:

  1. Correlation ID — from the error response
  2. Error Code — the specific error code
  3. Timestamp — when the error occurred
  4. Client Version — your application version
GuidesAPI Reference

Was this helpful?