DocumentationError handling

Error handling

MailingCoreError — status codes, detail messages, and recovery.

The SDK throws MailingCoreError for API error responses (4xx/5xx).

Basic pattern

import { MailingCore, MailingCoreError } from 'mailingcore-js'

try {
  await MailingCore.send({
    to: '[email protected]',
    subject: 'Hello',
    htmlBody: '<p>Hi</p>',
  })
} catch (err) {
  if (err instanceof MailingCoreError) {
    console.error(err.status)   // 429
    console.error(err.detail)   // "Monthly email quota exceeded"
    console.error(err.type)     // optional machine-readable type
  } else {
    throw err // network, timeout, init errors
  }
}

Common status codes

StatusMeaningAction
400Invalid payloadFix request fields
401Invalid or missing API keyCheck key and authentication
403Missing scope or tenantReview API keys and scopes
404Resource not foundVerify template version ID
429Rate limit or quota exceededSee Rate limits and Quota headers
500Server errorRetry with backoff; contact support if persistent

Non-API errors

ErrorCause
MailingCore not initializedCall MailingCore.init() first
Request timed out after NmsIncrease timeout in init or check network
AbortErrorRequest exceeded configured timeout

Retry guidance

  • 429 (rate limit) — wait for X-RateLimit-Reset or exponential backoff
  • 429 (quota) — upgrade plan or wait for billing cycle
  • 5xx — retry with idempotencyKey to avoid duplicates
  • 4xx (except 429) — do not retry without fixing the request