Skip to main content

Overview

The MailGlyph API uses standardized error responses to help you quickly identify and resolve issues. All errors include:
  • Machine-readable error codes for programmatic handling
  • Human-readable messages explaining what went wrong
  • Helpful suggestions to guide you toward a solution
  • Request IDs for debugging and support requests
  • Field-level validation details when applicable

HTTP Status Codes

200 OK

Request successful.

201 Created

Resource created successfully.

400 Bad Request

Invalid request format or parameters. Check the error details for specific issues.

401 Unauthorized

Authentication failed or missing. Verify your API key.

403 Forbidden

Not authorized to access this resource. Check permissions or workspace status.

404 Not Found

The requested resource does not exist. Verify the resource ID.

422 Unprocessable Entity

Request validation failed. Check the errors array for field-level details.

429 Too Many Requests

Rate limit exceeded. Wait before retrying or upgrade your plan.

500 Internal Server Error

An unexpected server error occurred. Contact support with the request ID.

Error Response Format

All errors follow this standardized format:

Response Fields

Error Codes Reference

All errors include a machine-readable code field for programmatic handling. Here are all possible error codes:

Authentication & Authorization

Validation & Input Errors

Resource Errors

Rate Limiting & Billing

Server Errors

Common Error Examples

Authentication Errors

Invalid API Key

Solution: Check your API key is correct. Secret endpoints require keys starting with sk_, while tracking endpoints use pk_ keys.

Missing Authorization Header

Solution: Add the Authorization header with your API key in Bearer token format.

Validation Errors

Invalid Email Format

Solution: Provide a valid email address. The errors array shows which fields failed validation.

Missing Required Fields

Solution: Include all required fields in your request body.

Resource Errors

Template Not Found

Solution: Verify the template ID exists and belongs to your workspace.

Rate Limiting

Rate Limit Exceeded

Solution: Implement exponential backoff and retry logic. Consider upgrading your plan for higher limits.

Success Response Format

Successful API requests return a standardized format with success: true and a data object:

Response Fields

Handling Errors in Your Code

JavaScript/TypeScript Example

Python Example

Troubleshooting Guide

Using Request IDs

Every error includes a unique requestId that traces the request through our entire system. Request IDs enable: For Developers:
  • Every log entry includes the request ID
  • You can grep logs to find all entries for a specific request
  • Trace a request from API → Database → Queue → Worker
For Support:
  1. Include the request ID in your message
  2. Describe what you were trying to do
  3. Share the full error response if possible
Example: If you receive request ID f47ac10b-58cc-4372-a567-0e02b2c3d479, we can search our logs for that ID and see:
  • The exact request body you sent
  • Which database queries were executed
  • Any background jobs that were triggered
  • The full error stack trace (if applicable)
This helps us quickly locate and diagnose the issue without asking you for additional information.

How to Find Request IDs

Request IDs are included in:
  • Error responses: error.requestId field
  • Response headers: X-Request-ID header (also included in successful responses)
  • Your application logs: Include the header in your logs for correlation

Common Issues and Solutions

Authentication Issues (401)

Problem: INVALID_API_KEY or MISSING_AUTH Solutions:
  • Verify your API key is copied correctly (no extra spaces)
  • Check you’re using the right key type (sk_ for secret, pk_ for public)
  • Ensure the Authorization header uses Bearer token format
  • Verify the key is active and not revoked

Validation Issues (422)

Problem: VALIDATION_ERROR with field errors Solutions:
  • Check the errors array for specific field issues
  • Verify all required fields are included
  • Ensure field types match (strings quoted, numbers unquoted)
  • Review the API reference for correct request format

Not Found Issues (404)

Problem: TEMPLATE_NOT_FOUND, CONTACT_NOT_FOUND, etc. Solutions:
  • Verify the resource ID is correct
  • Check the resource belongs to your workspace
  • Ensure the resource hasn’t been deleted
  • List available resources via the API to confirm IDs

Rate Limit Issues (429)

Problem: RATE_LIMIT_EXCEEDED Solutions:
  • Implement exponential backoff (wait 1s, 2s, 4s, 8s between retries)
  • Reduce request frequency
  • Consider upgrading your plan for higher limits
  • Batch operations when possible

Server Errors (500)

Problem: INTERNAL_SERVER_ERROR Solutions:
  • Note the request ID from the error response
  • Wait a moment and retry the request
  • Check status.mailglyph.com for incidents
  • Contact support with the request ID if the issue persists

Best Practices

  1. Always check the success field before processing responses
  2. Log request IDs for debugging and support requests
  3. Handle errors gracefully with user-friendly messages
  4. Implement retry logic with exponential backoff for transient errors
  5. Monitor error rates to detect issues early
  6. Use error codes for programmatic error handling, not just status codes

Getting Help

If you continue experiencing issues:
  1. Review the error suggestion field for guidance
  2. Check the API Reference for correct usage
  3. Search our documentation for your specific error code
  4. Contact support with your request ID
  5. Join our community for help from other developers