Skip to content

Error Codes

This page lists all API error codes returned by Galatext APIs. Errors are returned with a JSON body containing an error object with code and message fields.

Error Response Format

json
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description of the error.",
    "statusCode": 422
  }
}

HTTP Status Codes

StatusMeaning
200 OKRequest succeeded
202 AcceptedRequest accepted for processing
400 Bad RequestMalformed request syntax
401 UnauthorizedMissing or invalid authentication
402 Payment RequiredInsufficient credits
403 ForbiddenAuthenticated but not permitted
404 Not FoundResource not found
409 ConflictResource conflict (e.g., duplicate)
413 Payload Too LargeRequest exceeds size limits
422 Unprocessable EntityValidation error
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorServer-side error
503 Service UnavailableTemporary service outage

Error Codes Reference

Authentication Errors

StatusError CodeDescriptionSolution
401MISSING_API_KEYNo API key provided in requestAdd x-api-key header to your request
401INVALID_API_KEYThe provided API key is not validCheck your API key in the dashboard
401EXPIRED_API_KEYAPI key has been revoked or expiredGenerate a new API key
401INVALID_TOKENJWT token is invalid or malformedRe-authenticate to get a new token
401EXPIRED_TOKENJWT token has expiredRefresh your token

Validation Errors

StatusError CodeDescriptionSolution
422VALIDATION_ERRORGeneral validation failureCheck the errors array for details
422INVALID_PHONE_NUMBERPhone number not in valid E.164 formatUse format +254712345678 (country code + number)
422MESSAGE_TOO_LONGMessage exceeds 1600 charactersShorten your message
422EMPTY_MESSAGEMessage body is emptyProvide message content
422INVALID_SENDER_IDSender ID is not valid or not approvedUse a valid/sender ID or request approval
422EMPTY_RECIPIENTSRecipients array is emptyProvide at least one recipient
422TOO_MANY_RECIPIENTSToo many recipients for your tierReduce batch size or upgrade your plan
422INVALID_MEDIA_URLMedia URL is invalid or inaccessibleProvide a valid, publicly accessible HTTPS URL
422UNSUPPORTED_MEDIA_TYPEMedia format not supportedCheck supported formats documentation

Account & Billing Errors

StatusError CodeDescriptionSolution
402INSUFFICIENT_CREDITSAccount balance too lowTop up credits from the dashboard
402ACCOUNT_SUSPENDEDAccount has been suspendedContact support
403ACCOUNT_NOT_VERIFIEDAccount email not verifiedVerify your email address
403ACCOUNT_RESTRICTEDAccount has temporary restrictionsCheck dashboard for details

WhatsApp Errors

StatusError CodeDescriptionSolution
403WHATSAPP_OPT_IN_REQUIREDRecipient has not opted inCollect opt-in before sending
403WHATSAPP_NUMBER_NOT_REGISTEREDSender number not registeredRegister a phone number in the dashboard
403WHATSAPP_TEMPLATE_NOT_APPROVEDTemplate not yet approvedWait for approval or check rejection reason
422WHATSAPP_TEMPLATE_INVALIDTemplate parameters don't matchCheck template variable count and order
422WHATSAPP_MEDIA_TOO_LARGEMedia exceeds size limitCompress or resize your media

Rate Limit Errors

StatusError CodeDescriptionSolution
429RATE_LIMIT_EXCEEDEDToo many requests per secondImplement backoff and retry logic
429DAILY_QUOTA_EXCEEDEDExceeded daily message quotaUpgrade your plan or wait for reset

Server Errors

StatusError CodeDescriptionSolution
500INTERNAL_ERRORUnexpected server errorRetry after a few seconds
503SERVICE_UNAVAILABLEService temporarily unavailableCheck status.galatext.com

Webhook Errors

StatusError CodeDescriptionSolution
400INVALID_WEBHOOK_URLWebhook URL is not validProvide a valid HTTPS URL
400WEBHOOK_VERIFICATION_FAILEDWebhook endpoint not respondingEnsure your endpoint returns 200 OK
400DUPLICATE_WEBHOOKWebhook URL already registeredUse a different URL or update existing

Handling Errors

JavaScript

javascript
async function sendSMS() {
  try {
    const response = await fetch('https://api.galatext.com/api/sms/send', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': process.env.GALATEXT_API_KEY
      },
      body: JSON.stringify({
        phoneNumber: '+254712345678',
        message: 'Hello!'
      })
    });

    const data = await response.json();

    if (!data.success) {
      switch (data.error.code) {
        case 'INSUFFICIENT_CREDITS':
          console.error('Please top up your account');
          break;
        case 'RATE_LIMIT_EXCEEDED':
          // Implement exponential backoff
          await new Promise(r => setTimeout(r, 1000));
          return sendSMS();
        default:
          console.error(`Error ${data.error.code}: ${data.error.message}`);
      }
      return;
    }

    console.log('Success:', data.data);
  } catch (error) {
    console.error('Network error:', error);
  }
}

Python

python
import time
import requests

def send_sms_with_retry():
    for attempt in range(3):
        response = requests.post(
            'https://api.galatext.com/api/sms/send',
            headers={
                'Content-Type': 'application/json',
                'x-api-key': 'YOUR_API_KEY'
            },
            json={
                'phoneNumber': '+254712345678',
                'message': 'Hello!'
            }
        )

        data = response.json()

        if data.get('success'):
            return data['data']

        error_code = data.get('error', {}).get('code')

        if error_code == 'RATE_LIMIT_EXCEEDED':
            wait = 2 ** attempt  # Exponential backoff
            time.sleep(wait)
            continue

        raise Exception(f"{error_code}: {data['error']['message']}")

    raise Exception("Max retries exceeded")

Best Practices

  • Always check success — Don't assume requests succeed
  • Use exponential backoff — For 429 and 5xx errors
  • Handle all error codes — Gracefully degrade functionality
  • Log error details — Capture error codes for debugging
  • Monitor error rates — Sudden increases may indicate configuration issues

Powered by Galatex Softwares