{"schema_version":"1.0","publisher":"Primitive SDKs","canonical_url":"https://test.abhinandan.one/cli-overview/cli-domains-and-routes","markdown_url":"https://test.abhinandan.one/cli-overview/cli-domains-and-routes.md","article":{"id":"1425eaf0-7302-47e8-ab90-f269e48d51d8","article_slug":"cli-domains-and-routes","parent_article_slug":"cli-overview","parent_article_title":"What is the Primitive CLI?","kind":"guide","published_at":"2026-08-11T18:54:52.75505+00:00","keywords":["primitive routes add","primitive domains-zone-file","primitive routes test","primitive routes reorder","recipient routing","wildcard route match"],"meta_description":"Bind a recipient address to an endpoint or function with primitive routes add, then verify DNS with primitive domains-zone-file.","og_image_url":null,"source_file_paths":[],"recording_id":null,"replayable":false,"task_name":"Managing Domains and Recipient Routes","category":"CLI","summary":null,"description":"Configure inbound domain DNS with the CLI and bind recipient addresses to endpoints or Primitive Functions using the primitive routes command group.","content_kind":"repo_page","content_markdown":"Use the `primitive routes` command group to control which endpoint or [Primitive Function](functions-and-routing-concepts) 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.\n\nRecipient routing is gated by an organization entitlement. Routes you create are inert until that entitlement is enabled on your org.\n\n<Note>\n\nRecipient routing rules and the underlying `RoutingDecision` webhook field are explained once, in full, on [Primitive Functions and Recipient Routing](functions-and-routing-concepts). This page covers the CLI commands only.\n\n</Note>\n\n## Check domain DNS\n\nBefore 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:\n\n```bash\nprimitive domains-zone-file\n```\n\nAdd 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.\n\n## Add a recipient route\n\n<Steps>\n\n<Step title=\"Decide the destination: a function or an existing endpoint\">\n\nRouting 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.\n\n</Step>\n\n<Step title=\"Add an exact-match route\">\n\nBind one address to a function:\n\n```bash\nprimitive routes add alice@acme.com --function <function-id>\n```\n\nBind one address to an existing endpoint instead:\n\n```bash\nprimitive routes add ops@acme.com --endpoint <endpoint-id>\n```\n\n</Step>\n\n<Step title=\"Add a wildcard route for a pattern of addresses\">\n\nPass `--match wildcard` to route every address matching a pattern, for example every `support+*@acme.com` alias:\n\n```bash\nprimitive routes add 'support+*@acme.com' --match wildcard --endpoint <endpoint-id>\n```\n\nQuote wildcard patterns so your shell doesn't expand the `*`.\n\n</Step>\n\n<Step title=\"Confirm the rule exists\">\n\n```bash\nprimitive routes list\n```\n\nExpect the new rule in the output with its priority, match type, and destination.\n\n</Step>\n\n</Steps>\n\n<Warning>\n\nA 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`.\n\n</Warning>\n\n## Preview where an address resolves\n\nBefore mail actually arrives, verify which rule wins for a given address and see the rule trace:\n\n```bash\nprimitive routes test alice@acme.com\n```\n\nExpected 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.\n\n## Change rule priority\n\nRouting rules are evaluated in priority order. Update a single rule's priority:\n\n```bash\nprimitive routes update <route-id> --priority 5\n```\n\nReorder several rules in one call by setting an explicit priority per rule id:\n\n```bash\nprimitive routes reorder --set <route-id>=10 --set <other-id>=20\n```\n\nConfirm the resulting order with `primitive routes list`, and check the effect on a specific address with `primitive routes test`.\n\n## Remove a route\n\n```bash\nprimitive routes remove <route-id>\n```\n\n<Tip>\n\nRun `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.\n\n</Tip>\n\n## Next steps\n\n<CardGroup cols={2}>\n\n<Card title=\"Primitive Functions and Recipient Routing\" href=\"functions-and-routing-concepts\">\n\nUnderstand the routing model and RoutingDecision webhook field these commands configure.\n\n</Card>\n\n<Card title=\"Primitive Functions: Deploy, Route, and Manage\" href=\"cli-functions\">\n\nScaffold, deploy, and route the functions you bind recipient addresses to.\n\n</Card>\n\n<Card title=\"Inbox Setup and Status\" href=\"cli-inbox\">\n\nCheck overall inbound readiness, including domain and endpoint summaries.\n\n</Card>\n\n<Card title=\"What is the Primitive CLI?\" href=\"cli-overview\">\n\nSee how the routes command group fits into the full CLI command surface.\n\n</Card>\n\n</CardGroup>","canonical_base_url":"https://test.abhinandan.one","seo_indexing_enabled":true,"last_modified":"2026-08-21T18:22:43.359885+00:00","video_url":null,"voiceover_url":null,"tools_used":[],"demonstrated_by":[],"steps":[],"related_links":[],"intro":null,"prerequisites":[],"verification":[],"troubleshooting":[],"suggest_edit_url":null,"raise_issue_url":"https://github.com/abhi-browzer/primitive-sdks/issues/new?title=Docs+feedback%3A+Managing+Domains+and+Recipient+Routes&body=Page%3A+https%3A%2F%2Ftest.abhinandan.one%2Fcli-domains-and-routes","page_feedback_enabled":true,"verified_ref":null,"verified_at":"2026-08-11T18:38:45.205849+00:00"}}