Skip to main content
The Ark API uses conventional HTTP response codes and returns detailed error information to help you diagnose and fix issues. All SDKs provide typed exceptions for easy error handling.

Error Response Format

All error responses follow this structure:
{
  "success": false,
  "error": {
    "code": "validation_error",
    "message": "Human-readable error message",
    "field": "fieldName",
    "suggestion": "How to fix the error"
  },
  "meta": {
    "requestId": "req_abc123"
  }
}
FieldDescription
codeMachine-readable error code
messageHuman-readable description
fieldThe field that caused the error (if applicable)
suggestionRecommended action to fix the error
requestIdUnique ID for support requests

HTTP Status Codes

StatusDescription
200Success
201Resource created
207Partial success (batch operations)
400Bad request - invalid parameters
401Unauthorized - invalid or missing API key
403Forbidden - insufficient permissions
404Resource not found
409Conflict - resource already exists
422Unprocessable - semantic error
429Rate limit exceeded
500Server error

SDK Exception Types

All SDKs provide typed exceptions that map to HTTP status codes:
ExceptionHTTP StatusDescription
BadRequestError400Invalid request parameters
AuthenticationError401Invalid or missing API key
PermissionDeniedError403Insufficient permissions
NotFoundError404Resource not found
UnprocessableEntityError422Validation error
RateLimitError429Too many requests
InternalServerError5xxServer error
APIConnectionErrorNetwork/connection issue

Handling Errors with SDKs

import ark
from ark import Ark

client = Ark()

try:
    email = client.emails.send(
        from_="[email protected]",
        to=["[email protected]"],
        subject="Hello",
        html="<p>Hello!</p>"
    )
    print(f"Email sent: {email.data.id}")

except ark.BadRequestError as e:
    # Invalid request parameters
    print(f"Bad request: {e.message}")
    if hasattr(e, 'code'):
        print(f"Error code: {e.code}")

except ark.AuthenticationError:
    # Invalid or missing API key
    print("Authentication failed - check your API key")

except ark.RateLimitError as e:
    # Too many requests - wait and retry
    print("Rate limited - slow down requests")
    # Access retry-after header if available
    # retry_after = e.response.headers.get('retry-after')

except ark.NotFoundError:
    # Resource not found
    print("Resource not found")

except ark.APIConnectionError:
    # Network error - safe to retry
    print("Network error - retrying...")

except ark.APIError as e:
    # Catch-all for other API errors
    print(f"API error: {e.message}")

Error Codes Reference

Authentication Errors

CodeDescriptionSolution
authentication_requiredNo API key providedAdd Authorization: Bearer <key> header
invalid_api_keyAPI key is malformedCheck key format (should start with ark_)
expired_api_keyAPI key has been revokedGenerate a new key
permission_deniedKey lacks required scopeUse a key with appropriate permissions

Validation Errors

CodeDescriptionSolution
validation_errorRequest failed validationCheck the field and suggestion
invalid_email_formatEmail address is invalidFix the email format
missing_required_fieldRequired field not providedAdd the missing field
invalid_field_valueField value is not allowedCheck allowed values

Resource Errors

CodeDescriptionSolution
resource_not_foundResource doesn’t existCheck the ID
already_existsResource already existsUse existing or choose different identifier
invalid_stateOperation not allowed in current stateCheck resource status

Sending Errors

CodeDescriptionSolution
domain_not_verifiedSending domain not verifiedComplete domain setup
suppressed_recipientEmail is on suppression listRemove from suppressions or skip
quota_exceededMonthly sending limit reachedUpgrade plan or wait for reset

Automatic Retries

All SDKs automatically retry failed requests with exponential backoff for:
  • Connection errors
  • 408 Request Timeout
  • 409 Conflict
  • 429 Rate Limit
  • 5xx Server Errors
Default: 2 retries. Configure per-client:
client = Ark(max_retries=5)  # 5 retries
client = Ark(max_retries=0)  # Disable retries

Getting Help

If you encounter persistent errors:
  1. Check the requestId in the error response
  2. Review your request parameters
  3. Check the status page for outages
  4. Contact support with the requestId