API reference

Every Mailazy product capability is API-accessible. Authentication is two-header (key + secret), responses are JSON, errors are typed.

Base URL

https://api.mailazy.com/api/v1

Authentication

Every request requires two headers:

X-API-Key:    pk_live_xxx
X-API-Secret: sk_live_xxx
  • X-API-Key identifies your product. Safe to use in non-secret contexts (build logs, error reports).
  • X-API-Secret proves you own the key. Treat like a password — server-side only.
  • Keys are scoped to a single product (one product = one tenant). Cross-product calls return 404 as if the resource doesn't exist.
  • Rotate from Settings → API. Old credentials revoke instantly; mid-flight requests fail with 401.

Super-admin auth (multi-product)

Owners with multiple products can use a super-admin token instead of per-product keys. Set Authorization: Bearer mzy_admin_xxx and add a X-Product-Slug: <slug> header to scope the request. Super-admin auth is required for product CRUD itself.

Response shape

All success responses return JSON with a 2xx status. Errors return JSON with a 4xx/5xx status and an error field:

{
  "error":   "Template not found",
  "code":    "template_not_found",
  "details": { "slug": "non-existent" }        // sometimes
}

Error codes

StatusMeaning
400Malformed request — bad JSON, malformed CSV.
401Missing / invalid API credentials.
403Authenticated but not allowed (e.g. super-admin endpoint with product key).
404Resource doesn't exist — or exists in a different product.
409Conflicting state — e.g. editing a newsletter while it's in sending.
413Payload too large — usually a CSV over 5MB or 10k rows.
422Validation failure — zod schema rejected the body. Includes field-level details.
429Rate limit. Always carries a Retry-After header.
500Unexpected server error. Includes a requestId to share with support.
502Upstream failure (SMTP provider, AI provider). Body includes the upstream message.
504Upstream timeout (60s on AI generation, 30s on SMTP).

Rate limits

Limits are per-product, applied across all endpoints in the namespace:

NamespaceFreeMarketingScale
/send + SMTP10/s100/sCustom
/templates/generate (AI)20/min20/minCustom
/newsletters/:id/test-send10/min/newsletter10/min/newsletter10/min/newsletter
/templates/:id/test-send10/min/template10/min/template10/min/template
Everything else (CRUD)30/s200/sCustom

Endpoint summary

Send

POST/sendSend a transactional email by template slug or inline HTML.
POST/eventsEmit a product event (triggers automation steps).

Templates

POST/templatesCreate or new-version a template.
GET/templatesList templates (optional ?activeOnly=true).
GET/templates/:idRead one template (optional ?version=N).
POST/templates/generateAI-generate a draft from a prompt.
POST/templates/:id/previewRender the template with a real or synthetic contact.
POST/templates/:id/test-sendSend to one address; no log row.

Newsletters

POST/newslettersCreate draft or scheduled campaign.
GET/newslettersList (filter by status).
GET/newsletters/:idDetail + counts.
PATCH/newsletters/:idEdit (draft/scheduled only).
POST/newsletters/:id/scheduleMove draft → scheduled.
POST/newsletters/:id/send-nowSet scheduledAt = now().
POST/newsletters/:id/cancelStop a scheduled or sending campaign.
DELETE/newsletters/:idDelete (draft only).
GET/newsletters/:id/recipientsCount + sample of current list membership.
POST/newsletters/:id/previewRender preview.
POST/newsletters/:id/test-sendSend test; no log row.

Automations

POST/automationsCreate a multi-step automation.
GET/automationsList automations.
PATCH/automations/:idEdit steps.
DELETE/automations/:idDisable an automation.

Contacts & lists

POST/contactsCreate a single contact.
POST/contacts/importBulk import CSV or JSON.
GET/contactsSearch / list contacts.
POST/listsCreate a list.
POST/lists/from-filterMaterialize a list from a filter.
GET/lists/filter-previewCount + sample for a filter.
POST/lists/:id/membersAdd contacts to a list.
DELETE/lists/:id/members/:contactIdRemove from a list (per-list unsubscribe).
GET/suppressionsList suppressions.
POST/suppressionsSuppress an address globally.
DELETE/suppressions/:idUn-suppress.

Config & observability

GET/PUT/DELETE/smtpPer-product SMTP/SES config.
GET/PUT/DELETE/ai-configPer-product AI generation config.
POST/ai-config/testVerify AI credentials.
POST/GET/DELETE/webhooksSubscribe / list / unsubscribe webhook endpoints.
GET/logsSend log search.

OpenAPI / Postman

A full OpenAPI 3 spec is served at /api/v1/openapi.json. Import directly into Postman, Insomnia, or your client SDK generator. Postman collection downloads also available at the support email.

SDKs

Official SDKs cover Node, Python, Go, Ruby, PHP, and Java. They wrap auth, retries, and SMTP fallback. See the dashboard Settings → API → SDKs for install commands.

Related