---
title: "Managing Domains and Recipient Routes"
canonical: "https://test.abhinandan.one/cli-overview/cli-domains-and-routes"
markdown_url: "https://test.abhinandan.one/cli-overview/cli-domains-and-routes.md"
publisher: "Primitive SDKs"
kind: "guide"
content_type: "reference"
category: "CLI"
parent: "cli-overview"
description: "Bind a recipient address to an endpoint or function with primitive routes add, then verify DNS with primitive domains-zone-file."
keywords: ["primitive routes add", "primitive domains-zone-file", "primitive routes test", "primitive routes reorder", "recipient routing", "wildcard route match"]
last_modified: "2026-08-11T18:54:53.089732+00:00"
published_at: "2026-08-11T18:54:52.75505+00:00"
sections:
  - {anchor: "check-domain-dns", title: "Check domain DNS"}
  - {anchor: "add-a-recipient-route", title: "Add a recipient route"}
  - {anchor: "step-decide-the-destination-a-function-or-an-existing-endpoint", title: "Decide the destination: a function or an existing endpoint"}
  - {anchor: "step-add-an-exact-match-route", title: "Add an exact-match route"}
  - {anchor: "step-add-a-wildcard-route-for-a-pattern-of-addresses", title: "Add a wildcard route for a pattern of addresses"}
  - {anchor: "step-confirm-the-rule-exists", title: "Confirm the rule exists"}
  - {anchor: "preview-where-an-address-resolves", title: "Preview where an address resolves"}
  - {anchor: "change-rule-priority", title: "Change rule priority"}
  - {anchor: "remove-a-route", title: "Remove a route"}
  - {anchor: "next-steps", title: "Next steps"}
---

> Documentation index: https://test.abhinandan.one/llms.txt

# Managing Domains and Recipient Routes

Configure inbound domain DNS with the CLI and bind recipient addresses to endpoints or Primitive Functions using the primitive routes command group.

Use the `primitive routes` command group to control which endpoint or [Primitive Function](https://test.abhinandan.one/functions-and-routing-concepts.md) handles inbound mail for a given recipient address, and `primitive domains-zone-file` to check the DNS records your inbound domain needs. You need this whenever you want per-address routing (`alice@acme.com` goes to one function, everyone else falls through to a default) instead of a single catch-all inbox.

Recipient routing is gated by an organization entitlement. Routes you create are inert until that entitlement is enabled on your org.

> **Note:** Recipient routing rules and the underlying `RoutingDecision` webhook field are explained once, in full, on [Primitive Functions and Recipient Routing](https://test.abhinandan.one/functions-and-routing-concepts.md). This page covers the CLI commands only.

## Check domain DNS

Before mail can route anywhere, your inbound domain needs the right DNS records. Print the zone file entries for your inbound domain with `primitive domains-zone-file`, the command that emits the DNS records Primitive needs to receive mail for that domain:

```bash
primitive domains-zone-file
```

Add the printed records at your DNS provider, then confirm the domain status with `primitive domains list` or `primitive inbox-status`. Run `primitive domains-zone-file --help` for the exact flag list, and `primitive domains --help` for the rest of the domain lifecycle commands.

## Add a recipient route

### 1. Decide the destination: a function or an existing endpoint

Routing an address to a Primitive Function creates that function's route-target endpoint for you in the same call, so `--function <function-id>` is the shortest path. Routing to an existing endpoint with `--endpoint <endpoint-id>` requires you to know the endpoint id up front.

### 2. Add an exact-match route

Bind one address to a function:

```bash
primitive routes add alice@acme.com --function <function-id>
```

Bind one address to an existing endpoint instead:

```bash
primitive routes add ops@acme.com --endpoint <endpoint-id>
```

### 3. Add a wildcard route for a pattern of addresses

Pass `--match wildcard` to route every address matching a pattern, for example every `support+*@acme.com` alias:

```bash
primitive routes add 'support+*@acme.com' --match wildcard --endpoint <endpoint-id>
```

Quote wildcard patterns so your shell doesn't expand the `*`.

### 4. Confirm the rule exists

```bash
primitive routes list
```

Expect the new rule in the output with its priority, match type, and destination.

> **Warning:** A route is inert until the recipient routing entitlement is enabled for your org. If mail isn't reaching the function or endpoint you configured, first confirm the entitlement, then confirm the route with `primitive routes test`.

## Preview where an address resolves

Before mail actually arrives, verify which rule wins for a given address and see the rule trace:

```bash
primitive routes test alice@acme.com
```

Expected output includes the winning rule (or explicit fallback if no rule matches) and the ordered list of rules that were evaluated. Use this to debug overlapping wildcard and exact rules without waiting for a real inbound email.

## Change rule priority

Routing rules are evaluated in priority order. Update a single rule's priority:

```bash
primitive routes update <route-id> --priority 5
```

Reorder several rules in one call by setting an explicit priority per rule id:

```bash
primitive routes reorder --set <route-id>=10 --set <other-id>=20
```

Confirm the resulting order with `primitive routes list`, and check the effect on a specific address with `primitive routes test`.

## Remove a route

```bash
primitive routes remove <route-id>
```

> **Tip:** Run `primitive routes test <address>` again after removing or reordering rules to confirm the address now resolves the way you expect, rather than trusting `routes list` alone.
