Skip to main content

Overview

The Mighty Networks API uses standard HTTP status codes to indicate the success or failure of requests. Proper error handling is essential for building robust integrations.

HTTP Status Codes

Error Response Format

All errors return a JSON response containing an error property:

Example Error Responses

Authentication Error (401)

Not Found Error (404)

Validation Error (422)

Common Error Types

1. Authentication Errors (401)

Causes:
  • Missing Authorization header
  • Invalid or expired API token
  • Malformed Bearer token
Example:
How to Handle:

2. Permission Errors (403)

Causes:
  • Token lacks required scopes/permissions
  • Attempting to access resources outside your Network
  • Admin-only operation with non-admin token
Example:
How to Handle:

3. Resource Not Found (404)

Causes:
  • Invalid resource ID
  • Resource was deleted
  • Incorrect Network ID
  • Typo in endpoint URL
How to Handle:

4. Validation Errors (422)

Causes:
  • Invalid field values
  • Missing required fields
  • Data format errors
How to Handle:

5. Rate Limit Errors (429)

Causes:
  • Exceeded requests per minute limit
  • Too many requests in short time
How to Handle: See the Rate Limits guide for detailed handling strategies.

Error Handling Patterns

Basic Error Handling

Comprehensive Error Handler

Custom Error Classes

Retry Logic

Python Error Handling

Basic Pattern

Custom Exception Classes

Retry with Backoff

Best Practices

  1. Always Check Status Codes - Don’t assume requests succeed
  2. Parse Error Messages - Extract meaningful information from error responses
  3. Implement Retries - Retry transient errors (5xx, 429)
  4. Don’t Retry 4xx Errors - Client errors won’t succeed on retry (except 429)
  5. Log Errors - Keep detailed error logs for debugging
  6. Handle Gracefully - Provide user-friendly error messages
  7. Monitor Errors - Track error rates to identify issues
  8. Validate Input - Catch errors before making API calls

Common Pitfalls

❌ Ignoring Status Codes

✅ Check Response Status

❌ Generic Error Messages

✅ Specific Error Handling

Next Steps

Rate Limits

Handle rate limit errors effectively.

Authentication

Troubleshoot authentication errors.

Admin API

Review API endpoint documentation.

Pagination

Handle pagination errors.