# Domain routes: register, release, renew, search

URL: /code/api/domain/verbs-register · Id: `page:code/api/domain/verbs-register`

> The Domain Verbs register, release, renew, search 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.register
Register buys a hostname for a Startup and points it at the Startup’s address. [Verb page](/business/nouns/domain/register?interface=api).

```text
POST /{namespace}/domains/register
```

Body, as JSON: the inputs. Emits [`Domain.registered`](/business/events/Domain.registered).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `hostname` | `string` | Yes | The hostname to buy. |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup it serves. |

**Returns**

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

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The operation is part of an Offer the caller has not accepted or paid for. | [`payment-required`](/code/api/errors/payment-required) | Accept the Offer named in the response, then retry the call. | [Offer.accept](/business/nouns/offer/accept) |
| 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. |
| The record changed since it was read, so the write would overwrite a newer version. | [`conflict`](/code/api/errors/conflict) | Read the record again, then retry the write against its current state. | None. |

**Example**

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

```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.register",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```

### Domain.release
Release lets a Domain’s registration or claim end, keeping its record, history and aliases. [Verb page](/business/nouns/domain/release?interface=api).

```text
POST /{namespace}/domains/{domain}/release
```

Path: `domain`. Body, as JSON: the other inputs. Emits [`Domain.released`](/business/events/Domain.released).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The Domain to let go. |
| `reason` | `text` | Yes | Why it is released, recorded as a Decision. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The released 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. |
| A Domain whose `carriedIdentity` is true: it received mail, hosted a Mailbox or verified an outside account | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |
| A canonical Domain while the Startup is Live | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |

**Example**

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

```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.release",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```

### Domain.renew
Renew extends a Domain’s registration by whole years at its renewal price, paid by its owner of record. [Verb page](/business/nouns/domain/renew?interface=api).

```text
POST /{namespace}/domains/{domain}/renew
```

Path: `domain`. Body, as JSON: the other inputs. Emits [`Domain.renewed`](/business/events/Domain.renewed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The Domain to renew. |
| `years` | `integer` | No | Years to add. Defaults to the Domain’s tier in the renewal Setting. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `domain` | [Domain](/business/nouns/domain) | Yes | The Domain, with its new `expiresAt`. |

**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 POST https://api.sb/kilnbakery.com/domains/domain_VbYut4CTsH/renew \
  -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.renew",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```

### Domain.search
Search lists candidate names with availability, first-year price, renewal price and the rules of each extension. [Verb page](/business/nouns/domain/search?interface=api).

```text
POST /{namespace}/domains/search
```

Body, as JSON: the inputs. Emits [`Domain.searched`](/business/events/Domain.searched).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | `string` | Yes | A name, or a word to build names from. |
| `extensions` | `string[]` | No | Extensions to check, such as `com` or `ai`. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `candidates` | list of [Domain](/business/nouns/domain) | Yes | Candidate Domains, each with its prices, three-year cost and extension rules. |

**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 POST https://api.sb/kilnbakery.com/domains/search \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"Example query"}'
```

```json
{
  "api": "https://api.sb/kilnbakery.com",
  "candidates": [
    {
      "$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.search",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/kilnbakery.com/actions/act_0y76a1jB6k"
  }
}
```