> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lettr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing Domains

> List, add, verify, and delete sending domains with the Lettr Java SDK, ideal for multi-tenant apps and DNS automation.

The `lettr.domains()` service manages your sending domains — useful for multi-tenant apps onboarding customer domains, or for automating DNS verification.

For the concepts behind domain setup (SPF, DKIM, DMARC), see [Sending Domains](/learn/domains/sending-domains).

```java theme={null}
import com.lettr.Lettr;
import com.lettr.services.domains.model.*;

Lettr lettr = new Lettr("your-api-key");
```

## List Domains

```java theme={null}
ListDomainsResponse domains = lettr.domains().list();
for (DomainListItem d : domains.getDomains()) {
    System.out.println(d.getDomain() + " - " + d.getStatus() + " (can send: " + d.isCanSend() + ")");
}
```

<Card title="API Reference" icon="book" href="/api-reference/domains/list-domains">
  GET /domains
</Card>

## Create a Domain

```java theme={null}
CreateDomainResponse newDomain = lettr.domains().create(
    CreateDomainOptions.of("example.com")
);
System.out.println("DKIM selector: " + newDomain.getDkim().getSelector());
System.out.println("DKIM public key: " + newDomain.getDkim().getPublicKey());
```

<Card title="API Reference" icon="book" href="/api-reference/domains/create-domain">
  POST /domains
</Card>

## Get Domain Details

```java theme={null}
Domain domain = lettr.domains().get("example.com");
System.out.println("DKIM status: " + domain.getDkimStatus());
System.out.println("DMARC status: " + domain.getDmarcStatus());
System.out.println("SPF status: " + domain.getSpfStatus());
System.out.println("Primary domain: " + domain.getIsPrimaryDomain());
```

<Card title="API Reference" icon="book" href="/api-reference/domains/get-domain">
  GET /domains/{domain}
</Card>

## Verify Domain DNS

After publishing the records, trigger a verification check:

```java theme={null}
VerifyDomainResponse result = lettr.domains().verify("example.com");
System.out.println("DKIM: " + result.getDkimStatus());
System.out.println("CNAME: " + result.getCnameStatus());
System.out.println("DMARC: " + result.getDmarcStatus());
System.out.println("SPF: " + result.getSpfStatus());

if (result.getDns().getDkimError() != null) {
    System.out.println("DKIM error: " + result.getDns().getDkimError());
}
```

<Tip>
  DNS changes take time to propagate. If verification fails right after publishing, wait a few minutes and retry. See [Domain Verification troubleshooting](/knowledge-base/troubleshooting/domain-verification).
</Tip>

<Card title="API Reference" icon="book" href="/api-reference/domains/verify-domain">
  POST /domains/{domain}/verify
</Card>

## Delete a Domain

```java theme={null}
lettr.domains().delete("example.com");
```

<Warning>
  Deleting a domain stops all sending from it immediately. Emails from a deleted domain fail with a validation error.
</Warning>

<Card title="API Reference" icon="book" href="/api-reference/domains/delete-domain">
  DELETE /domains/{domain}
</Card>

## What's Next

<CardGroup cols={2}>
  <Card title="Sending Domains" icon="globe" href="/learn/domains/sending-domains">
    DNS setup: SPF, DKIM, DMARC
  </Card>

  <Card title="Webhooks" icon="bell" href="/quickstart/java/webhooks">
    Receive delivery and engagement events
  </Card>
</CardGroup>
