---
title: "Java SDK"
description: "The official Java client for the Nextmail API. One artifact with no dependencies, and one method for every endpoint."
url: "https://nextmail.sh/docs/java"
area: "Java"
category: "Getting started"
---

# Java SDK

The official Java client for the Nextmail API. One artifact with no dependencies, and one method for every endpoint.

## What it is

One artifact over the whole API, from sending, templates and tracking to threads, contacts, domains, webhooks and disposable inboxes. It has a method for every method of the TypeScript SDK under the same name, an exception class for every kind of refusal, retries that cannot duplicate a send, and a webhook signature verifier. It needs Java 17 or later and nothing else: requests go through `java.net.http.HttpClient`, and the JSON reader and writer are its own.

**Install**

_Maven_

```xml
<dependency>
    <groupId>sh.nextmail</groupId>
    <artifactId>nextmail</artifactId>
    <version>0.0.1</version>
</dependency>
```

_Gradle_

```text
implementation("sh.nextmail:nextmail:0.0.1")
```

**SendEmail.java**

```
import java.util.Map;
import sh.nextmail.Body;
import sh.nextmail.Nextmail;

public final class SendEmail {
    public static void main(String[] args) {
        Nextmail client = new Nextmail();

        Map<String, Object> email = client.emails().send(Body.of(
            "from", "Acme Billing <billing@acme.com>",
            "to", "ada@example.com",
            "subject", "Your September invoice",
            "html", "<p>Invoice attached.</p>"
        ));

        System.out.println(email.get("id") + " " + email.get("status"));
    }
}
```

## Where to go

- [Install](https://nextmail.sh/docs/java/install.md): Add the artifact and send your first message.
- [Configuration](https://nextmail.sh/docs/java/configuration.md): Every option, and what the client refuses.
- [Send an email](https://nextmail.sh/docs/java/emails/send.md): Attachments, scheduling and batches.
- [Errors and retries](https://nextmail.sh/docs/java/errors.md): What is thrown, and what is tried again.
- [Pagination](https://nextmail.sh/docs/java/pagination.md): One page, every page, or one item at a time.
- [Verify webhooks](https://nextmail.sh/docs/java/webhooks/verify.md): Check a delivery before you trust it.
- [Every method](https://nextmail.sh/docs/java/reference/methods.md): The complete list, one row each.

## It wraps the same API as every other client

Everything here is the surface the API reference documents and the TypeScript SDK wraps, so read the API reference for what an endpoint does and this for how to call it from Java. Every TypeScript method has a Java twin, and the parity check of the package runs both with the same arguments and fails unless they send byte for byte the same request.

- [API reference](https://nextmail.sh/docs/api/overview.md): What each endpoint does, and how it fails.
