+254748651734

PCI-aware secure payments

API Reference

/

Errors

Errors

MekaPayGroup API uses standard HTTP status codes to indicate whether a request was successful or failed. In case of an error, the API returns a structured response with details to help you identify and resolve the issue.

Error Response Structure

All error responses follow a consistent format:

{
  "status": "error",
  "code": "invalid_request",
  "message": "The request parameters are invalid",
  "errors": {
    "amount": ["The amount field is required"]
  }
}

HTTP Status Codes

The API uses conventional HTTP response codes to indicate the success or failure of a request:

  • 200 - Success: The request was successful
  • 400 - Bad Request: Invalid or missing parameters
  • 401 - Unauthorized: Invalid API credentials
  • 403 - Forbidden: Access to the resource is denied
  • 404 - Not Found: Requested resource does not exist
  • 422 - Unprocessable Entity: Validation errors
  • 429 - Too Many Requests: Rate limit exceeded
  • 500 - Internal Server Error: Unexpected server error

Common Error Types

invalid_request

Request is missing required parameters or contains invalid data.

authentication_error

API keys are missing, invalid, or expired.

permission_error

You do not have permission to perform this action.

resource_not_found

The requested resource could not be found.

rate_limit_error

Too many requests sent in a short period of time.

server_error

An unexpected error occurred on the server.

Validation Errors

When a request fails due to validation issues, the API returns detailed information about the specific fields that caused the error.

{
  "status": "error",
  "code": "validation_error",
  "message": "Validation failed",
  "errors": {
    "email": ["The email field must be a valid email address"],
    "amount": ["The amount must be greater than 0"]
  }
}

Handling Errors

Your application should always handle API errors gracefully. We recommend:

  • Validate request data before sending API calls
  • Handle different HTTP status codes appropriately
  • Retry requests for temporary errors (e.g., 500 or 503)
  • Log error responses for debugging and monitoring