Skip to main contentSkip to navigation
[email protected]
Client AreaSupport
Hosting Mammoth
HostingMammothYour Data, Our Responsibility
Home
Solutions
Hosting Services
Store
Pricing
About
Blog
API
Contact

Stay Ahead of the Curve

Get the latest insights on cybersecurity, AI innovations, and enterprise data solutions delivered to your inbox.

Hosting Mammoth
HostingMammothEnterprise Solutions

Enterprise-grade data solutions. Hosting, recovery, cybersecurity, and AI-powered services for businesses worldwide.

[email protected]
Sun - Fri, 9:00am - 5:00pm

Services

  • Cloud Hosting
  • Data Recovery
  • Cybersecurity
  • Legal Support
  • MSP Services
  • Web Development
  • AI Services
  • Free Server Migration

Hosting

  • VPS Hosting (NVMe SSD)
  • VDS Hosting (NVMe)
  • Storage VPS (High SSD)
  • GPU Servers
  • Managed Services
  • Cloud Firewall
  • Load Balancer
  • One-Click Apps
  • n8n Hosting
  • Object Storage
  • FAQ

Company

  • Store
  • Pricing
  • About Us
  • Locations
  • Blog
  • Testimonials
  • Contact
  • Affiliate Program
  • White-Label
  • Terms of Service
  • Privacy Policy
  • Browser Cookies
  • SLA

Support

  • Client Area
  • Submit Ticket
  • Knowledge Base
  • Server Status
  • API Documentation

© 2026 Hosting Mammoth. All rights reserved.

Knowledge Base
Getting StartedAccount ManagementVPS HostingGPU ServersStorage VPSCloud FirewallLoad BalancerServer ManagementBilling & PaymentsSupport & TicketsAffiliate ProgramReseller ProgramMarketplace & Appsn8n HostingManaged ServicesServer MigrationAPI & DevelopersSecurityTroubleshootingGlossaryInstall Guides
  1. Home
  2. /
  3. Support
  4. /
  5. API & Developers
  6. /
  7. Api Errors
GUIDEAPI & Developers

API Error Codes & Handling

4 min read

When an API request fails, Data Mammoth returns a structured error response with a status code, error code, and human-readable message. This guide covers all error codes, their meanings, and how to handle them in your application.

Error Response Format

All API errors follow this structure:

json
{
  "error": {
    "code": "not_found",
    "message": "The requested server was not found.",
    "status": 404,
    "details": {}
  }
}
FieldDescription
codeMachine-readable error code (use this for programmatic handling)
messageHuman-readable description of the error
statusHTTP status code
detailsAdditional context (may include field-level validation errors)

HTTP Status Codes

Client Errors (4xx)

StatusCodeDescriptionAction
400bad_requestThe request body is malformed or missing required fieldsCheck your request body and parameters
401unauthorizedAuthentication failed — invalid or missing API keyVerify your API key and Authorization header
403forbiddenYou do not have permission for this actionCheck API key permissions and account status
404not_foundThe requested resource does not existVerify the resource ID or endpoint path
405method_not_allowedThe HTTP method is not supported for this endpointCheck the API documentation for allowed methods
409conflictThe request conflicts with the current resource statee.g., trying to start a server that is already running
422validation_errorThe request data failed validationCheck the details field for specific field errors
429rate_limitedRate limit exceededWait and retry with backoff

Server Errors (5xx)

StatusCodeDescriptionAction
500internal_errorAn unexpected server error occurredRetry after a short delay; contact support if persistent
502bad_gatewayA backend service is temporarily unavailableRetry after a short delay
503service_unavailableThe API is temporarily unavailable (maintenance)Check status page; retry later
504gateway_timeoutThe request timed outRetry; consider simplifying the request

Common Error Scenarios

Validation Errors (422)

When submitted data fails validation, the details field lists specific issues:

json
{
  "error": {
    "code": "validation_error",
    "message": "Validation failed.",
    "status": 422,
    "details": {
      "name": ["Name is required."],
      "plan": ["The selected plan is not available in the chosen region."],
      "os": ["The selected OS image is not valid."]
    }
  }
}

Handling: Parse the details object and fix each field-level error.

Authentication Errors (401)

json
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key or token expired.",
    "status": 401
  }
}

Handling: Check the API key, refresh JWT tokens, or generate a new key.

Resource Conflicts (409)

json
{
  "error": {
    "code": "conflict",
    "message": "Cannot stop a server that is already stopped.",
    "status": 409
  }
}

Handling: Check the current resource state before performing actions.

Rate Limiting (429)

json
{
  "error": {
    "code": "rate_limited",
    "message": "Rate limit exceeded.",
    "status": 429,
    "details": {
      "retry_after": 30
    }
  }
}

Handling: Wait for the retry_after period, then retry. See API Rate Limits & Best Practices.

Error Handling Best Practices

1. Always Check the Status Code

python
response = requests.get(url, headers=headers)

if response.status_code == 200: data = response.json()["data"] elif response.status_code == 429: retry_after = response.json()["error"]["details"]["retry_after"] time.sleep(retry_after) elif response.status_code == 401: refresh_token() else: error = response.json()["error"] log_error(error["code"], error["message"])

2. Implement Retry Logic for Transient Errors

Retry on 429, 500, 502, 503, and 504 errors with exponential backoff. Do not retry on 400, 401, 403, 404, or 422 errors — these indicate issues that need to be fixed.

3. Log Errors for Debugging

Log the full error response (code, message, details) along with the request that caused it. This makes troubleshooting much easier.

4. Display User-Friendly Messages

Use the message field for user-facing error messages, but consider mapping code values to your own messages for a better user experience.

5. Handle Unexpected Errors

Always include a default error handler for unexpected status codes:

python
else:
    print(f"Unexpected error: {response.status_code}")
    print(response.text)

What to Do Next

  • API Rate Limits & Best Practices — Handle rate limiting.
  • API Pagination & Filtering — Navigate results efficiently.
  • API Authentication — Fix authentication errors.
  • How to Submit a Support Ticket — Report persistent API issues.

Was this article helpful?

← Back to API & DevelopersBrowse all categories →

Still have questions?

Contact Support →Submit a Ticket