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",
    "hint": "Detailed guidance with examples or documentation links"
  },
  "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
hintDetailed guidance with examples or documentation links (for complex errors)
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_="hello@yourdomain.com",
        to=["user@example.com"],
        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
invalid_raw_messageRaw MIME message is invalidCheck the hint field for detailed guidance

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 or use sandbox mode
suppressed_recipientEmail is on suppression listRemove from suppressions or skip

Sandbox Errors

These errors occur when using sandbox mode (sending from @arkhq.io addresses):
CodeDescriptionSolution
sandbox_recipient_not_allowedRecipient is not an organization memberAdd recipient to your team at arkhq.io/org/team, or set up a custom domain to send to anyone
sandbox_rate_limit_exceededDaily sandbox limit (10 emails/day) reachedWait 24 hours for the limit to reset, or set up a custom domain for unlimited sending
Sandbox Mode: Sandbox is designed for testing the API without domain verification. Use sandbox@arkhq.io as the sender to send test emails to organization members. No billing charges apply to sandbox emails.

Billing Errors

Billing errors occur when your account doesn’t have an active plan or has exceeded its email limit.
CodeDescriptionSolution
billing_not_configuredBilling hasn’t been set upVisit billing settings to choose a plan
insufficient_balanceEmail limit reached for current planUpgrade your plan or wait for your next billing cycle
billing_errorBilling system temporarily unavailableRetry your request; the system will fail-open if issues persist
Fail-open design: If the billing system experiences temporary issues, emails are still accepted to prevent service disruption. You’re only charged for successfully processed emails.

Handling Billing Errors in SDKs

import ark
from ark import Ark

client = Ark()

try:
    email = client.emails.send(
        from_="hello@yourdomain.com",
        to=["user@example.com"],
        subject="Hello",
        html="<p>Hello!</p>"
    )
except ark.BadRequestError as e:
    if e.code == "insufficient_balance":
        print("Upgrade your plan at https://arkhq.io/org/billing")
    elif e.code == "billing_not_configured":
        print("Set up billing at https://arkhq.io/org/billing")

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