---
title: "The Nextmail SDKs"
description: "Each operation is a method on the client. The API and the SDKs share the same scopes and limits."
url: "https://nextmail.sh/developers/sdk"
---

# Every click in the app is a method you can call.

The window below shows one session as code. Open the mailbox tab, read a thread, star it or search, and each click comes back as a call in your language.

[Open console](https://nextmail.sh/console) [Get Started](https://nextmail.sh/signup.md?next=%2Fconsole)[Read the SDK docs](https://nextmail.sh/docs/sdks.md)

Park Studio Pro

Inbox

Everything addressed to you, minus spam.

Homepage copy, final round

9:41

Sarah Chen

Invoice 2214 for August

9:12

Northwind Cloud

Can we move Thursday?

8:55

Omar Haddad

Signed contract attached

8:30

Mia Chen

Your code is 481 207

8:02

Lumen

Photos from Saturday

Yesterday

Leo Martin

Your flight to Lisbon is confirmed

Yesterday

Skyline Travel

Quarterly numbers are in

Wed

Ken Ito

Coffee next week?

Tue

Priya Raman

Your session, as code

```
await nextmail.threads.list({ folder: 'inbox' })
```

Last response

GET /threads?folder=inbox

```
{  "items": [    {      "object": "thread",      "id": "t1"    },    {      "object": "thread",      "id": "t2"    },    {      "object": "thread",      "id": "t3"    },    {      "object": "thread",      "id": "t4"    },    {      "object": "thread",      "id": "t5"    },    {      "object": "thread",      "id": "t6"    },    {      "object": "thread",      "id": "t7"    },    {      "object": "thread",      "id": "t8"    },    {      "object": "thread",      "id": "t9"    }  ],  "hasMore": false,  "nextCursor": null}
```

What your clicks call

Open a thread, star it, search or reply.

## The SDK, a building block for email.

Each operation is a method on the client. The API and the SDKs share the same scopes and limits.

npm install @nextmail/sdk

```
import { init, nextmail } from '@nextmail/sdk' init({ apiKey: process.env.NEXTMAIL_API_KEY }) const email = await nextmail.emails.send({  from: 'Acme Billing <billing@acme.com>',  to: 'ada@example.de',  subject: 'Your September invoice',  html: '<p>The invoice is attached.</p>',}) console.log(email.id, email.status)
```

### Install, then make one call

Install the package, then call the client from your code.

[Read the docs : Install, then make one call](https://nextmail.sh/docs/sdk.md)

### TypeScript SDK

A client with zero dependencies for Node 20 and up, Bun, Deno and Cloudflare Workers.

[Read the docs : TypeScript SDK](https://nextmail.sh/docs/sdk.md)

- TypeScript
- Python
- Ruby
- PHP
- Go
- Java
- C#

### Seven languages

The same methods in TypeScript, Python, Ruby, PHP, Go, Java and C#.

[Read the docs : Seven languages](https://nextmail.sh/docs/sdk.md)

POST /emails 201

POST /emails 201

Idempotency-Key: invoice:inv\_2026\_09\_4192 Same message

### Safe retries

A retry with the same idempotency key never sends twice.

[Read the docs : Safe retries](https://nextmail.sh/docs/sdk.md)

639

### Every operation

Each documented operation has a method in every SDK.

[Read the docs : Every operation](https://nextmail.sh/docs/sdk.md)

Install

## One line to install. Seven languages to write in.

`npm install @nextmail/sdknpm install @nextmail/sdk`

793 SDK methods · 639 API operations · one OpenAPI document

- [TypeScript](https://nextmail.sh/docs/sdk.md)
- [Python](https://nextmail.sh/docs/python.md)
- [Ruby](https://nextmail.sh/docs/ruby.md)
- [PHP](https://nextmail.sh/docs/php.md)
- [Go](https://nextmail.sh/docs/go.md)
- [Java](https://nextmail.sh/docs/java.md)
- [C#](https://nextmail.sh/docs/csharp.md)

## Write one call. Delivery is on us.

Anything that speaks HTTP can send. TypeScript, Python, Ruby, PHP, Go, Java and C# get typed clients, and every message reports back as it is queued, sent and delivered.

[Open console](https://nextmail.sh/console) [Get Started](https://nextmail.sh/signup.md?next=%2Fconsole)[Read the API reference](https://nextmail.sh/docs/api/reference.md)

`npm install @nextmail/sdk`

```
123456789101112import { init, nextmail } from '@nextmail/sdk' init({ apiKey: process.env.NEXTMAIL_API_KEY }) const email = await nextmail.emails.send({  from: 'Acme Billing <billing@acme.com>',  to: 'ada@example.de',  subject: 'Your September invoice',  html: '<p>The invoice is attached.</p>',}) console.log(email.id, email.status)
```

What happens next

1. Request accepted msg\_4b7e…
2. Queued email.queued
3. Sent email.sent
4. Delivered email.delivered

## 793 methods. Grouped the way you call them.

A namespace for each part of the product, so emails.send and domains.verify are where you would look for them. Every method is in all seven languages.

- [Domains](https://nextmail.sh/docs/sdk/reference/domains.md) 58
- [Threads](https://nextmail.sh/docs/sdk/reference/threads.md) 47
- [Calendar](https://nextmail.sh/docs/sdk/reference/calendar.md) 47
- [Contacts](https://nextmail.sh/docs/sdk/reference/contacts.md) 43
- [Your account](https://nextmail.sh/docs/sdk/reference/account.md) 32
- [Templates](https://nextmail.sh/docs/sdk/reference/templates.md) 30
- [Webhooks](https://nextmail.sh/docs/sdk/reference/webhooks.md) 30
- [Knowledge base](https://nextmail.sh/docs/sdk/reference/knowledge.md) 28
- [Automations](https://nextmail.sh/docs/sdk/reference/automations.md) 27
- [Sign-up forms](https://nextmail.sh/docs/sdk/reference/forms.md) 25
- [Emails](https://nextmail.sh/docs/sdk/reference/emails.md) 23
- [API keys](https://nextmail.sh/docs/sdk/reference/keys.md) 22
- [and 48 more namespaces](https://nextmail.sh/docs/sdk/reference/methods.md)

## Send once. Exactly when you meant to.

A retry never sends twice, a send can wait up to a year, and an undo window lasts up to fifteen minutes.

invoice.ts

`await nextmail.emails.send({`

`from: 'Acme Billing <billing@acme.com>',`

`to: 'ada@example.de',`

`subject: 'Your September invoice',`

`html: invoiceHtml,`

1`attachments: [{ fileId: invoicePdf.id }],`

`}, {`

2`idempotencyKey: 'invoice:inv_2026_09_4192',`

`})`

What happens

1. 09:41:02 status: sent
   
   Accepted and sent. The PDF is large, so it travels as a download link.
2. 09:41:07 timeout
   
   The connection drops before your code reads the answer.
3. 09:41:08 Idempotency-Key
   
   The SDK sends it again with the same key.
4. 09:41:08 replayed: true
   
   Nextmail returns the first result instead of sending twice.

A retry never sends twice.

## Coming from Resend? Change two lines.

Point the Resend SDK at Nextmail and keep your code, then bring contacts, templates and webhooks across.

.env 2 lines

1. ~~RESEND\_API\_KEY=re\_…~~
2. RESEND\_API\_KEY=nm\_live\_…
3. RESEND\_BASE\_URL=https://api.nextmail.sh/compat/resend

send.ts 0 lines changed

```
import { Resend } from 'resend'

const resend = new Resend(process.env.RESEND_API_KEY)

await resend.emails.send({
  from: 'Acme Billing <billing@acme.com>',
  to: 'ada@example.de',
  subject: 'Your September invoice',
})
```

- Answered in Resend's own shapes and error names
  
  - send
  - batch
  - get
  - list
  - reschedule
  - cancel
- Bring the rest with one key
  
  - Suppressions
  - Audiences
  - Contacts
  - Templates
  - Webhooks

Two differences: a message takes one reply-to address, and an inline image referenced by content id arrives as an ordinary attachment.

[Read the Resend guide](https://nextmail.sh/docs/knowledge/developers/switch-from-resend.md)

## Four doors. One mailbox behind them.

REST, the SDK, the command line and MCP reach the same operations, with the same scopes and the same limits.

- [REST POST /emails](https://nextmail.sh/developers/api.md)
- [SDKs nextmail.emails.send()](https://nextmail.sh/developers/sdk.md)
- [CLI nextmail send](https://nextmail.sh/developers/cli.md)
- [MCP sendEmail](https://nextmail.sh/developers/mcp.md)

Nextmail

- [Domains](https://nextmail.sh/docs/sdk/reference/domains.md)
- [Inboxes](https://nextmail.sh/docs/sdk/reference/domains.md)
- [Sending](https://nextmail.sh/docs/sdk/reference/emails.md)
- [Receiving](https://nextmail.sh/docs/sdk/reference/threads.md)
- [Webhooks](https://nextmail.sh/docs/sdk/reference/webhooks.md)
- [Live events](https://nextmail.sh/docs/sdk/reference/live-events.md)
- [Calendar](https://nextmail.sh/docs/sdk/reference/calendar.md)
- [Contacts](https://nextmail.sh/docs/sdk/reference/contacts.md)
- [Attachments](https://nextmail.sh/docs/sdk/reference/files.md)
