---
title: Domain
icon: globe
description: Set up, configure, and run the Reloop domain microservice locally.
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


Custom sending domains, DKIM keys, DNS verification, and tracking subdomain setup.

<Tip>
Run [`bun setup`](/docs/setup) once from the monorepo root. Env files come from `bun setup` / `bun env:setup`.
</Tip>


## Overview

| Property | Value |
| :--- | :--- |
| **Directory** | `apps/backend/domain` |
| **Port** | `8011` |
| **Local URL** | [https://local.reloop.sh/api/domain](https://local.reloop.sh/api/domain) |
| **Swagger UI** | [https://local.reloop.sh/api/domain/openapi](https://local.reloop.sh/api/domain/openapi) |
| **Stack** | ElysiaJS · PostgreSQL · Redis · NATS |


## Quick start

```bash
bun be:domain:dev
```

Or `bun backend:dev` / `bun dev`.


## Environment

`apps/backend/domain/.env` — from `bun setup` / `bun env:setup`.

```bash
PG_URL=postgresql://reloop:reloop123@localhost:5432/reloop
REDIS_URL=redis://:reloop123@localhost:6379
PORT=8011
BASE_URL="https://local.reloop.sh"
HOST_DOMAIN=reloop.sh
DKIM_SELECTOR=reloop
NATS_URL=nats://localhost:4222
NODE_ENV=development
```

| Variable | Required | Default |
| :--- | :--- | :--- |
| `PG_URL` | **YES** | `postgresql://...` |
| `REDIS_URL` | **YES** | `redis://...` |
| `PORT` | **YES** | `8011` |
| `BASE_URL` | **YES** | `https://local.reloop.sh` |
| `HOST_DOMAIN` | **YES** | `reloop.sh` |
| `DKIM_SELECTOR` | **YES** | `reloop` |
| `NATS_URL` | **YES** | `nats://localhost:4222` |


## Commands

| Command | Description |
| :--- | :--- |
| `bun be:domain:dev` | Start dev server with hot reloading |
| `bun run --filter=be-domain build` | Compile production bundle |
| `bun run --filter=be-domain start` | Run compiled production build |
| `bun run --filter=be-domain check-types` | TypeScript type-check |


## Architecture

| Layer | Detail |
| :--- | :--- |
| **DNS verification** | Validates DKIM, SPF, DMARC, MX, and CNAME records per domain capability |
| **Inbound validation** | Used by [inbound](/docs/setup/backend/inbound) to verify recipient addresses |
| **Schema** | `domain` and `domain_dns_record` in `packages/db/src/schema/domain.ts` |
| **Events** | Publishes domain lifecycle events to NATS |


## Next

<CardGroup cols={2}>
  <Card icon="rocket" title="Setup" href="/setup">
    One-command local bootstrap
  </Card>
  <Card icon="globe" title="Port reference" href="/setup/port">
    Gateway routes and ports
  </Card>
  <Card icon="mail-receive" title="Inbound" href="/setup/backend/inbound">
    MX receiver that checks recipients
  </Card>
  <Card icon="mail-single" title="Mail" href="/setup/backend/mail">
    Outbound send API
  </Card>
</CardGroup>
