> For the complete documentation index, see [llms.txt](https://docs-lunar.earthly.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-lunar.earthly.dev/sql-api/views/domains.md).

# domains

Schema reference for the domains SQL view — one row per domain with its description, owner, and metadata for grouping components.

```
domains
```

The `domains` view provides information about all domains defined in Lunar. Domains represent logical groupings of components that share similar characteristics or purposes.

## Schema

| Column        | Type    | Description                                                                            |
| ------------- | ------- | -------------------------------------------------------------------------------------- |
| `name`        | `TEXT`  | The identifier for the domain in hierarchical dotted format (e.g. `payments.checkout`) |
| `description` | `TEXT`  | A description of the domain                                                            |
| `owner`       | `TEXT`  | The owner of the domain                                                                |
| `meta`        | `JSONB` | Arbitrary metadata associated with the domain                                          |

## Notes

* Domains are defined primarily in the Lunar configuration but can also come from catalogers
* Domains can be used to organize and categorize components
* Components can be assigned to specific domains to create logical groupings
* Domains can be hierarchical, with a parent-child relationship represented by a dotted notation. For example, in the domain name `auth.sso.providers`, `auth` is the parent domain of `auth.sso`, and `auth.sso` is the parent domain of `auth.sso.providers`. The full domain name is stored in the `name` column using dotted notation.

## Usage examples

List all domains in the system:

```sql
SELECT *
FROM domains
ORDER BY name;
```

Find domains owned by a specific person or team:

```sql
SELECT *
FROM domains
WHERE owner = 'platform-team@example.com';
```

Get a count of components by domain:

```sql
SELECT 
  d.name AS domain_name,
  COUNT(c.name) AS component_count
FROM domains d
LEFT JOIN components c ON c.domain = d.name
GROUP BY d.name
ORDER BY component_count DESC;
```

Find all subdomains of a specific parent domain:

```sql
SELECT *
FROM domains
WHERE name LIKE 'payments.%'
ORDER BY name;
```

Find the direct subdomains of a specific domain (only one level down):

```sql
SELECT *
FROM domains
WHERE name LIKE 'payments.%'
  AND name NOT LIKE 'payments.%.%'
ORDER BY name;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs-lunar.earthly.dev/sql-api/views/domains.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
