DocumentationInit and configuration

Init and configuration

MailingCore.init — apiKey, baseUrl, and timeout options.

Call MailingCore.init() once before any SDK method. Typically at app startup or in a server module.

Basic setup

import { MailingCore } from 'mailingcore-js'

MailingCore.init({
  apiKey: process.env.MAILINGCORE_API_KEY!,
})

Configuration options

ParameterTypeDefaultDescription
apiKeystringrequiredAPI key (mc_live_... or mc_test_...)
baseUrlstringhttps://api.mailingcore.comAPI base URL
timeoutnumber30000Request timeout in milliseconds

Staging / local development

MailingCore.init({
  apiKey: process.env.MAILINGCORE_API_KEY!,
  baseUrl: 'http://localhost:3010', // local API
  timeout: 60000,
})

See Environments for production vs test keys.

Tenant resolution

When using an API key, the tenant is resolved automatically from the key. You do not need X-Tenant-Id in SDK calls.

Verify initialization

if (!MailingCore.config) {
  throw new Error('MailingCore not initialized')
}

Continue with Send with the SDK or Send with template.