# Domains Lists

Schema: [ListDomains](schemas.md#listdomains)

## DSP line-item attachment eligibility

The DSP API uses `/domain-lists` and `/targeting-profiles/{id}/domain-lists` for
domain-list creation and attachment. A line item must have a targeting profile
and must not have `COMPLETED` or `ARCHIVED` status to receive a new attachment.
Flight dates do not restrict attachment: expired and future flights remain
eligible, including when the line item is `DRAFT`.
Both creation with `lineItemIds` and standalone attachment reject
`COMPLETED` or `ARCHIVED` line items with `422`.

`GET /line-items?selectable=true&domainListId={id}` excludes completed and archived
line items and those without targeting profiles.
Selectable line-item responses still include `statusValue` and `isWithinFlight`.
The create and detail attachment pickers use status for eligibility;
`isWithinFlight` is informational and does not prevent selection or attachment.
Attachment does not require `ACTIVE` status, completed payment, or an active campaign.
Other statuses remain eligible regardless of the line-item flight, subject to
the existing ownership and targeting-profile requirements. Existing attachments
are not removed by this restriction.

The Targeting Profile editor receives `lineItem.domainListAttachmentError`
(`string | null`) from its bootstrap endpoint. When present, it displays this
error above Domain Lists and blocks new selections, including automatic
selection after creating a list in another tab. Existing selections can still
be removed. Profile creation with domain lists and profile updates that add new
domain-list IDs enforce the same eligibility rules server-side; retaining or
removing existing attachments is permitted.

The editor hides unavailable, unselected domain lists (inactive or empty lists,
or lists blocked by the line item's attachment eligibility). Selected unavailable
lists remain visible with a disabled checkbox and a Remove button. Removing one
hides it from the available choices. Search and scrolling controls use the count
of available or selected lists, not hidden lists.
When the line item cannot accept attachments, the editor's applied allow/block
counts are zero. Below the always-visible information message, the editor shows
either the restriction error or the applied-list summary, never both. Retained
selections are marked not applied and remain visible only for removal.
The line-item detail page uses the same bootstrap eligibility and shared summary
helper, so its applied domain-list counts match the Targeting Profile editor.

The editor's View hover/focus preview is rendered outside the list's scroll
container. It opens below the link when space permits, flips above when needed,
and remains within the viewport without changing list scroll dimensions.
Positioning updates after preview data loads and during scrolling or resizing.

The `/lists/domains` endpoints below describe the legacy list API.

## POST /lists/domains — Add a new list

Body: `ListDomains` (required). Invalid domain names are ignored.

Responses: `201` created, `400` errors, `422` unprocessable entity.

## GET /lists/domains — List all lists

`200`: array of `{ id, name }`. `404`: none found.

## GET /lists/domains/{listId} — Find list by ID

`200`: `{ id, name }`. `404`: not found.

## PATCH /lists/domains/{listId} — Update a list

Body: `ListDomains` (required). Responses: `400` invalid ID, `404` not found, `405` validation exception.

## DELETE /lists/domains/{listId} — Delete a list

`204` deleted, `404` not found.

## GET /lists/domains/{listId}/domains — Items in the list

Returns the domains in the list. `200` success, `404` not found.
