# Domain routes: list, update, delete

URL: /code/api/domain/records-list · Id: `page:code/api/domain/records-list`

> The Domain Verbs list, update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Domain](/business/nouns/domain), one group of [Domain routes](/code/api/domain).

### Domain.list
Returns Domains, newest first, one page at a time. [Verb page](/business/nouns/domain/list?interface=api).

```text
GET /{namespace}/domains
```

Query: the inputs. Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | No | At most this many records, up to 100. The default is 20. |
| `after` | `string` | No | The cursor from the previous page. |
| `where` | `string` | No | A filter over the properties, such as `paidAt = null and total.amount > 500`. |
| `sort` | `string` | No | Properties to sort by, comma-separated; a leading minus sorts descending. |
| `total` | `boolean` | No | True adds the match count as `meta.total`, exact up to 10,000 matches and estimated above. |
| `facets` | `string` | No | Properties to count by value, comma-separated, returned as `meta.facets`. |
| `fields` | `string` | No | Properties to return on each record, comma-separated; `$id` and `$type` always return. |
| `include` | `string` | No | Related records to embed in place of their URLs, comma-separated. |
| `depth` | `integer` | No | How many levels of related records to embed. The default is 1. |
| `q` | `string` | No | Words to match across the text properties, ranked by relevance. |
| `match` | `string` | No | Ranks the search by `words`, or `meaning`; words is the default. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domains` | list of [Domain](/business/nouns/domain) | Yes | One page of Domains. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl "https://api.sb/kilnbakery.com/domains?limit=20" \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/kilnbakery.com",
  "$type": "Domain",
  "domains": [
    {
      "$id": "https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH",
      "$type": "Domain",
      "hostname": "kilnbakery.com",
      "role": "canonical",
      "state": "verifying"
    }
  ],
  "meta": {
    "limit": 20,
    "after": "domain_VbYut4CTsH"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/domains?limit=20",
    "next": "https://api.sb/kilnbakery.com/domains?after=domain_VbYut4CTsH"
  }
}
```

### Domain.update
Changes the given properties of a Domain. [Verb page](/business/nouns/domain/update?interface=api).

```text
PATCH /{namespace}/domains/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Domain.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Domain. |
| `hostname` | `string` | No | The name, such as `leaseline.app`. |
| `role` | `string` | No | What the Domain does for the Thing it serves; a defensive name takes `redirect`. |
| `acquired` | `string` | No | One of `claimed`, `purchased`, or `connected`. |
| `registrant` | [Party](/business/nouns/party) | No | The owner of record: the holding Company while held, or the holder of a self-serve Startup’s Stripe account. |
| `expiresAt` | `datetime` | No | When the registration ends, as the registrar reports it; empty for a claimed Domain. |
| `autoRenew` | `boolean` | No | True when renewal runs without a Decision; false sends the Domain through renewal review. |
| `renewalPrice` | `money` | No | What the next renewal costs, which for a premium name differs from the purchase price. Never randomized. |
| `transferableAt` | `datetime` | No | The first moment the registrar allows a transfer out, after any registration, transfer or registrant lock. |
| `names` | `string` | No | How its subdomains are given out: explicit records only, or one-label claims by other Startups. |
| `publicSuffix` | `boolean` | No | True once the public suffix list browsers ship carries the Domain; an issuing Domain gives out no label before then. |
| `registrarAccount` | `string` | No | The registrar account that holds the Domain: one per Startup, never shared with a sibling. |
| `registryLock` | `boolean` | No | True when the registry refuses transfer, update and delete until a verified out-of-band request lifts it. |
| `certificate` | `json` | No | Certificate state (`pending`, `active`, `renewing` or `failed`), its expiry, and the failing check with its fix. |
| `validation` | `string` | No | `delegated` proves control through a CNAME to the platform; `serving` is for an apex that cannot hold one. |
| `walletsEnabled` | `boolean` | No | True once Stripe lists the Domain as a payment method domain on the Startup’s account. |
| `carriedIdentity` | `boolean` | No | True once the Domain received mail, hosted a Mailbox or verified an outside account; it never resets. |
| `to` | [Domain](/business/nouns/domain) | No | For a redirect: the canonical Domain it forwards to permanently, path and query kept. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The Domain. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"hostname":"kilnbakery.com"}'
```

```json
{
  "api": "https://api.sb/kilnbakery.com",
  "domain": {
    "$id": "https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH",
    "$type": "Domain",
    "hostname": "kilnbakery.com",
    "role": "canonical",
    "state": "verifying"
  },
  "action": {
    "$id": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k",
    "operation": "Domain.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```

### Domain.delete
Deletes a Domain: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/domain/delete?interface=api).

```text
DELETE /{namespace}/domains/{id}
```

Path: `id`. Emits `Domain.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Domain. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The Domain. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X DELETE https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/kilnbakery.com",
  "domain": {
    "$id": "https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH",
    "$type": "Domain",
    "hostname": "kilnbakery.com",
    "role": "canonical",
    "state": "verifying"
  },
  "action": {
    "$id": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k",
    "operation": "Domain.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```