Skip to the documentation
TypeScript

Types and helpers

What else the package exports.

Runtime exports

ExportWhat it is
init, nextmailConfigure the shared client once, then import nextmail anywhere. It builds itself from NEXTMAIL_API_KEY if init never ran.
getClient, resetClientThe shared client itself, and a way to drop it so the next call builds a fresh one, which is what a test wants between cases.
createNextmail, createClient, NextmailA separate client. createNextmail reads the environment for anything you leave out (createClient is the same function), and new Nextmail (also the default export) takes only what you pass.
createTempMailA disposable-inbox client that carries no API key, and the one part of the package that runs in a browser.
NextmailApiError, NextmailNetworkErrorThe two error classes. An NextmailApiError carries the parsed error response as body, and fields when a form sign-up was refused.
verifyWebhookSignatureConstant-time, with a replay window. Resolves to the parsed payload and throws on any failure.
toBase64Chunked, for attachment bytes.
isApiKeyWhether a string has the oe_live_ or oe_test_ shape. A shape check, not proof the key still works.
isSealed, MESSAGE_ENCRYPTION_FORMATSWhether a message’s body is ciphertext, and the five envelopes ingest can name. isSealed is false for the two SIGNED formats, whose bodies arrived in the clear, which is why it ships rather than being left to a caller to derive from the union.
LANGUAGES, resolveLanguage, languageByCode, isRtlLanguageThe bundled language table, and the lookups a language picker needs.
API_SCOPESThe scope vocabulary, for a key-creation screen.
WEBHOOK_EVENTS, WEBHOOK_SIGNATURE_HEADERSThe events an endpoint can subscribe to, and the names of the headers a delivery carries.
RULE_FIELDS, RULE_OPERATORS, RULE_ACTIONSThe vocabulary a rule’s conditions and actions are built from.
PAGE_LIMITSThe largest and the default limit on most paged lists: 100 and 25. contacts.list, audiences.listContacts and the tracking lists take up to 200 with a default of 50, and tempMail.listMessages takes up to 50.
ERROR_TYPESThe frozen error vocabulary.
VERSIONThe package version.
THREAD_SORTS, PEOPLE_SORTS, CONTACT_THREAD_SORTS, FILE_SORTSThe orders the thread, people, contact thread and file lists can be sorted in.
FILE_KINDS, FILE_DIRECTIONS, CONTACT_BLOCK_LISTS, CONTACT_PHOTO_TYPESThe filters of the file list, the two workspace blocklists, and the image types a contact photo can be.
BROADCAST_STATUSES, BROADCAST_RECIPIENT_FILTERS, SUPPRESSION_REASONS, WEBHOOK_REPLAY_ERROR_CODESWhere a broadcast stands, which of its copies to list, why an address is suppressed, and why a webhook replay was refused.
PROVIDER_IMPORT_PROVIDERS, PROVIDER_IMPORT_RESOURCES, PROVIDER_IMPORT_STATUSES, PROVIDER_IMPORT_DOMAIN_STATESWhich provider an import reads, what it can bring across, where a run stands, and where each domain it found stands.
FILE_USAGESWhy a file is kept rather than deletable: received, sent, linked or scheduled.
isAccessTokenWhether a string has the shape of an OAuth access token: 1 to 512 characters, not beginning oe_. Added in 0.0.6.
CREDENTIAL_KINDS, STEP_UP_METHODS, STEP_UP_ERROR_CODESWhich credential me.get() and me.ping() describe (apiKey or oauth), how a verification code is checked (email or totp), and the codes a verification can fail with. Added in 0.0.6.
FORM_STATUSES, FORM_SUBMISSION_STATUSES, FORM_FIELD_TYPES, FORM_STARTER_SLUGS, FORM_*The values a form, its fields and its sign-ups take, in sixteen sets: statuses, field types, starters, fonts, widths, and the reasons an answer is refused.

Types

Every request and response has one, and they are exported from the package root. There are no deep imports, so the file layout stays an implementation detail that can move without a major version. …Resource is what the API returns, …Create, …Patch, …Input and …Send are what you pass, and …Options holds filters and per-call options.

  • Client: ClientOptions, TempMailOptions, TransportOptions, RequestOptions, RequestScope, SendScope, InboxScope, ListOptions, Page, ApiKeyMode, FetchLike.
  • Errors: ErrorType, ApiErrorPayload, ApiErrorProps.
  • Emails: EmailSend, EmailListOptions, EmailTranslate, EmailResource, SentEmailResource, EmailRecipientResource, EmailEventResource, EmailStatus, EmailSource, EmailTransport, EmailTrackingSummary, EmailTranslationResource, TranslationResource, RecipientStatus, BatchItemResource, BatchResultResource.
  • Templates: TemplateCreate, TemplatePatch, TemplateContent, TemplateListOptions, TemplatePreviewInput, TemplateSend, TemplateResource, TemplateDetailResource, TemplateVersionResource, TemplatePreviewResource, SentTemplateEmailResource, DeletedTemplateResource, TemplateEngine, TemplateProp, TemplateSlot, TemplateStatus, TemplateValueKind.
  • Tracking: TrackingListOptions, TrackingStatsOptions, TrackingHitOptions, TrackingResource, TrackingSummary, TrackingRecipientResource, TrackingLinkResource, TrackingOpenResource, TrackingClickResource, TrackingStatsResource, TrackingGrain.
  • Threads and drafts: ThreadListOptions, ThreadPatch, ThreadResource, ThreadSummaryResource, UpdatedThreadResource, TrashedThreadResource, SnoozedThreadResource, DraftInput, DraftListOptions, DraftResource, DraftSummaryResource, SavedDraftResource, DeletedDraftResource.
  • Labels, contacts, domains and addresses: LabelInput, LabelColor, LabelResource, DeletedLabelResource, ContactCreate, ContactPatch, ContactListOptions, ContactSource, ContactResource, ContactDetailResource, ContactAudienceResource, ContactAudiencesSet, DeletedContactResource, DomainPatch, DomainResource, DomainDetailResource, DomainSendingState, DomainTracking, DomainTrackingState, AddressBookResource, AddressResource, SendableDomainResource.
  • Audiences: AudienceCreate, AudiencePatch, AudienceListOptions, AudienceContactListOptions, AudienceMemberSort, AudienceContactAdd, AudienceContactsBatch, AudienceImport, AudienceImportRow, AudienceGrowthOptions, AudienceResource, AudienceBuiltin, AudienceContactResource, AudienceMemberResource, RemovedAudienceContactResource, DeletedAudienceResource, EmptiedAudienceResource, AudienceBatchAddResource, AudienceBatchRemoveResource, AudienceImportResource, AudienceGrowthResource, AudienceGrowthTotals, AudienceGrowthSeries, AudienceGrowthBucket.
  • Broadcasts: BroadcastCreate, BroadcastPreviewInput, BroadcastListOptions, BroadcastResource, BroadcastCounts, BroadcastStatus, BroadcastPreviewResource, BroadcastRecipientResource, BroadcastRecipientContentResource, BroadcastRecipientListOptions, BroadcastRecipientFilter, BroadcastStatsResource, BroadcastStatsOptions, BroadcastStatsTotals, BroadcastStatsBucket.
  • Rules: RuleCreate, RulePatch, RuleListOptions, RuleRunListOptions, RuleTestInput, RuleResource, RuleRunResource, RuleTestResource, DeletedRuleResource, RuleCondition, RuleConditionInput, RuleAction, RuleActionType, RuleField, RuleOperator.
  • Webhooks: WebhookCreate, WebhookPatch, WebhookResource, CreatedWebhookResource, DeletedWebhookResource, WebhookDeliveryResource, WebhookDeliveryDetailResource, WebhookDeliveryAttempt, WebhookReplayResource, WebhookReplayRefusal, WebhookReplayErrorCode, WebhookTestResource, WebhookEvent, WebhookPayload, EmailOpenedData, EmailClickedData, EmailDownloadedData, VerifyWebhookProps, WebhookSignatureHeaders.
  • Calendar and settings: CalendarRangeOptions, CalendarOccurrenceResource, CalendarEventResource, CalendarAttendeeResource, SettingsPatch, SettingsResource.
  • Roles, members and keys: RoleCreate, RolePatch, RoleDeleteOptions, RoleResource, DeletedRoleResource, PermissionResource, MemberAdd, MemberPatch, MemberAddressGrant, MemberResource, MemberAddressResource, RemovedMemberResource, MemberAccess, KeyResource, PingResource.
  • Disposable inboxes: TempInboxCreate, TempMessageListOptions, TempInboxResource, CreatedTempInboxResource, DeletedTempInboxResource, TempDomainResource, TempMessageResource, TempMessagesResource, TempMessageDetailResource, DeletedTempMessageResource.
  • Shared: RecipientInput, AttachmentInput, AttachmentResource, MessageResource, MessageEncryption, MessageEncryptionFormat, TrackingRequest, TranslateOptions, SendTranslateOptions, LanguageResource, ApiScope, Permission, BuiltinRole, HitKind.
  • Access tokens and verification codes, added in 0.0.6: AccessTokenProvider, CredentialKind, ApiKeySelfResource, OauthTokenSelfResource, ApiKeyPingResource, OauthTokenPingResource, StepUpBegin, StepUpVerify, StepUpMethod, StepUpErrorCode, StepUpStatusResource, StepUpChallengeResource, StepUpVerifiedResource.
  • Forms: FormCreate, FormPatch, FormListOptions, FormResource, FormDetailResource, FormDocument, FormField, FormCopy, FormStyle, FormSettings, FormSettingsInput, FormStats, FormAudience, FormStarterResource, FormStarterDetailResource, FormAnalyticsOptions, FormAnalyticsResource, FormSubmissionListOptions, FormSubmissionResource, FormAnswer, ResentFormConfirmationResource, FormSubscribeValues, FormSubscriptionResource, FormFieldProblem, FormSubmittedEventData, FormConfirmedEventData.

An endpoint this does not wrap yet

An SDK release should never be what stands between you and an endpoint that already works. nextmail.raw.request() takes a path and options and resolves to the parsed body, with the client’s key, base URL, timeout and retry policy applied.

escape-hatch.ts
const result = await nextmail.raw.request<Whatever>('/something-new', {  method: 'POST',  query: { dryRun: true },  body: { name: 'Invoices' },  repeatable: true,})

A GET is retried like any other read. Any other method is sent once unless you pass repeatable: true, which is your assertion that it may be sent twice. query skips values that are undefined, and signal works as it does on every other method.

What it deliberately does not do

  • It validates no request body. The server's schema is the only copy of the rules, and a second copy here would eventually refuse an address a newer server accepts, in a version somebody pinned two years ago.
  • It ships no zod and no runtime dependencies at all.
  • It reshapes a response in one way only: a collection’s data array is lifted out of its envelope. A paged list hands it back as items beside hasMore and nextCursor, contacts.listPeople as items beside hasMore, nextCursor and seen, emails.sendBatch as items beside sent and failed, templates.listSends as items beside total, page and pageSize, tempMail.listMessages as items beside hasMore, nextCursor and expiresAt, and addresses.list as addresses beside unrestricted, domains, hasMore and nextCursor. imports.listFailures is the one list left as the API sends it, { object, data, nextCursor }. Everywhere else it is a plain array. Every resource inside keeps the documented HTTP shape.

The package’s parity check keeps this honest. It fails the build when a documented operation has no method, when a method points at an operation the OpenAPI document does not have or sends a different request, and when a method declares scopes the operation does not require.