Skip to content

SDKs

Official client libraries for integrating with the TopMail API.

TypeScript / Node.js

The official TopMail SDK for TypeScript and Node.js provides a fully typed client with built-in error handling, pagination helpers, and idempotency support.

Installation

npm install @topmail/sdk

Quick Start

# The SDK is for Node.js/TypeScript.
# For shell scripts, use cURL directly:
curl https://api.topmail.so/api/v1/health \
-H "Authorization: Bearer tm_live_abc123"

Available Resources

The SDK provides typed methods for all API resources.

ResourceMethodsDescription
topmail.contactslist, get, create, update, deleteManage contacts and their attributes
topmail.listslist, get, create, update, delete, addMembers, removeMembersManage contact lists and memberships
topmail.emailsend, batch, getStatus, getBatchStatusSend emails and check delivery status
topmail.suppressionslist, add, removeManage the email suppression list
topmail.webhookssubscribe, unsubscribe, testManage webhook subscriptions
topmail.trackingproductViewTrack product views and browsing behavior
topmail.conversionslist, createTrack revenue and conversion events
topmail.segmentslist, get, create, update, delete, estimateCount, listContactsCreate and manage audience segments
topmail.tagslist, get, create, update, delete, contacts.assign, contacts.removeTag contacts for organization and automation
topmail.automationslist, get, activate, pause, trigger, listRunsControl automation workflows programmatically
topmail.healthcheckCheck API and service health status

Error Handling

The SDK throws typed errors that you can catch and handle programmatically.

# Check the HTTP status code and error response body:
# {"error": {"code": "validation_error", "message": "..."}}

Configuration

The SDK accepts an optional configuration object for customizing behavior.

# cURL does not use the SDK configuration.
# Set the base URL and headers directly:
curl https://api.topmail.so/api/v1/health \
-H "Authorization: Bearer tm_live_abc123"

Idempotency

For send and batch endpoints, pass an idempotency key to prevent duplicate operations from network retries.

curl -X POST https://api.topmail.so/api/v1/email/send \
-H "Authorization: Bearer tm_live_abc123" \
-H "Idempotency-Key: order-confirmation-12345" \
-H "Content-Type: application/json" \
-d '{"to": "user@example.com", "subject": "Order confirmed", "html": "<p>Done!</p>"}'

Resources

Developer Docs - TopMail