# Domain

> Domains: buy one in your user's name, connect one they own, or transfer one in.

```python
[offer] = noclick.Domain.search("anasilva", tlds=["dev"], limit=1)
ana = noclick.DomainContact(name="Ana Silva", email="ana@example.com", phone="+14155550123",
                            address="500 Market St", city="San Francisco", region="CA", postal_code="94105",
                            country="US", agreement_accepted_at=accepted_at)   # when she accepted the agreement
with noclick.as_user("user_42"):
    bought = noclick.Domain.buy(offer, max_price_usd=20, registrant=ana).wait()   # Ana's, charged to you

owned = noclick.Domain.connect("acme.test")              # one they already own
for record in owned.records:
    print(record.type, record.name, record.value)       # add these where its DNS is hosted
inbox = noclick.Inbox.create(local_part="help", domain="mail.acme.test")   # its own mail stays put
```

A bought domain is registered to the person (you, or the user it's bought for) and
charged to your account in dollars, like everything else: NoClick never bills your users.
It's never deleted: turn off auto-renew to let it lapse, or `transfer_out()` to move it
to another registrar. One registered elsewhere moves here with `Domain.transfer_in`.

## Domain

```typescript
class Domain
```

A domain you bought through NoClick, transferred in, or connected from elsewhere, and what it serves.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` | The domain, like `acmebooking.com`. |
| `source` | `DomainSource` | `bought` (through NoClick), `transferred` (moved here from another registrar, then registered through NoClick like a bought one) or `connected` (owned elsewhere). |
| `noClickDns` | `boolean` | Whether NoClick hosts its DNS: a bought domain, or a transferred one after `useNoClickDns()`. When false, `records` are added where its DNS is hosted and `dns` throws `NotAvailable`. |
| `wildcard` | `boolean` | Whether its `*.<name>` records are set too, so every subdomain can serve. |
| `status` | `DomainStatus` | `awaiting_human` (its purchase held for your policy's approver), `registering`, `transferring_in` (moving here from another registrar), `pending_dns`, `active`, `registrant_unverified`, `expiring`, `expired`, `transferring_out` or `failed`. |
| `expiresAt` | `Date | null` | When the registration runs out (null for a connected domain). |
| `autoRenew` | `boolean | null` | Renews itself 30 days before `expiresAt` (null for a connected domain). |
| `renewableUntil` | `Date | null` | The end of the guaranteed renewal window after `expiresAt`: the last moment `renew()` works (null for a connected domain). |
| `renewalUsd` | `number | null` | What renewing for `renewalYears` costs, in US dollars. |
| `renewalYears` | `number | null` | The term `renewalUsd` buys, in years: the TLD's minimum (null for a connected domain). |
| `registrant` | `DomainContact | null` | The person it's registered to (null for a connected domain); `update({ registrant })` changes it. |
| `records` | `DnsRecord[]` | The records it needs for what it serves: to add at its DNS host (connected), or kept by NoClick (bought). |
| `setupUrl` | `string | null` | A connected domain's one-click setup, where its DNS host supports the open Domain Connect standard; the host's consent page names NoClick alongside your brand (null otherwise). |
| `serves` | `DomainService[]` | What it points at: each app and inbox. |
| `registrantEmail` | `string | null` | Where the link to confirm the registrant's address went, sent in your brand on ICANN's behalf (a bought domain). |
| `registrantVerifyBy` | `Date | null` | While `registrant_unverified`: the day (15 days on) the domain stops resolving unless the registrant has confirmed. |
| `transferLockedUntil` | `Date | null` | Until then `transferOut()` throws `NotAvailable`: the registry's transfer lock after a domain is registered, transferred in or its registrant changes. |
| `userId` | `string | null` |  |
| `createdAt` | `Date | null` |  |
| `dns` | `DomainDns` | The records of a bought domain. |

Types:

```typescript
/**
 * `bought` (through NoClick), `transferred` (moved here from another registrar, then
 * registered through NoClick like a bought one) or `connected` (owned elsewhere).
 */
type DomainSource = "bought" | "transferred" | "connected";

/**
 * `awaiting_human`: its purchase is held for your policy's approver. `transferring_in`: moving to
 * NoClick from another registrar (up to about 5 days).
 */
type DomainStatus =
  | "awaiting_human" | "registering" | "transferring_in" | "pending_dns" | "active" | "registrant_unverified"
  | "expiring" | "expired" | "transferring_out" | "failed";

/** Something a domain points at: an app (`project`), an inbox, or your brand's pages (`brand`). */
interface DomainService {
  kind: "project" | "inbox" | "brand";
  id: string;
  name: string;
  /** The domain's name that serves it (an app at a bought domain is served at its name and its `www`). */
  hostname: string;
}
```

### Domain.search

```typescript
static search(
  query: string,
  options?: CallOptions & { tlds?: string[]; limit?: number },
): Promise<DomainOffer[]>
```

Names for sale built from `query` (a word, or a whole name), in `tlds` or a common set,
with close alternatives: up to `limit` (10 by default, at most 50), exact matches first, each
priced for the TLD's shortest term (`minYears`), with any trademark `claimsNotice`.

Parameters:

- `query` (`string`, required)
- `options.tlds` (`string[]`)
- `options.limit` (`number`): Return at most this many.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Up to `limit` offers (10 by default, at most 50), exact matches first, each with its
price and renewal price for the TLD's shortest term (`min_years`), the longest it
allows (`max_years`), whether it's `available`, and any trademark `claims_notice`.
Names that imitate well-known brands or banks aren't offered.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.buy

```typescript
static buy(
  offer: string | DomainOffer,
  options: DomainBuyOptions,
): Promise<DomainPurchase>
```

Register `offer` in the person's name (yours, or inside `asUser` the user's) for `years`, the
TLD's minimum when omitted, charged to your account and never to the user, refused with
`PriceExceeded` above `maxPriceUsd`. A user's domain needs `registrant`, the person's details
with `agreementAcceptedAt` (`InvalidRequest` without it); one your account buys for itself,
outside `asUser`, uses the account's default registrant when you pass none (with none set, it
throws `ActionRequired` whose `nextStep` links to where it's set, and nothing is bought). A name
with a `claimsNotice` needs `acceptClaims`. NoClick checks your account can pay before
registering (`PaymentRequired` otherwise) and charges it when the registry confirms the
registration; one that fails is never charged. A policy hold waits in `awaiting_human` until the
approver answers; nobody answering within 24 hours expires it, and nothing is charged. The price
is checked against `maxPriceUsd` again when it runs.

Parameters:

- `offer` (`string | DomainOffer`, required)
- `options.maxPriceUsd` (`number`, required): The most it may cost now, in US dollars; above it the purchase throws `PriceExceeded`.
- `options.years` (`number`): The term, in years: between the offer's `minYears` and `maxYears`, the TLD's minimum when
omitted. One the TLD doesn't offer throws `InvalidRequest` naming `years`, with the terms it does.
- `options.registrant` (`DomainContact`): The person it's registered to. A user's domain (inside `asUser`, or with `user`) naming none
uses the user's registrant profile (`Domain.setDefaultRegistrant(contact, { user })`), and with
none on file throws `InvalidRequest` naming `registrant`. A domain your account buys for itself
uses the account's default registrant instead (`Domain.setDefaultRegistrant`), and with none set
throws `ActionRequired` whose `nextStep` links to the console page where it's set. A registrant
that is the one on file, without `agreementAcceptedAt`, takes its acceptance from there once it
accepted the agreement as it stands.
- `options.autoRenew` (`boolean`): Renew 30 days before expiry (true by default).
- `options.acceptClaims` (`boolean`): True once the registrant has been shown the offer's `claimsNotice` and still wants the name. A
name with a notice is refused without it (`ActionRequired` whose details carry
`claims_notice`), and nothing is bought.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The purchase: an operation whose `.wait()` gives the `Domain` once it's registered
and its DNS is set up.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.agreement

```typescript
static agreement(options?: { client?: NoClick }): Promise<DomainAgreement>
```

NoClick's domain registration agreement, which every registrant accepts:
its page names the sponsoring registrar, as ICANN requires, and carries the fee schedule
(registration, renewal, renewal after expiry, restore) and ICANN's registrant rights and
responsibilities. Show it to the person, and record when they accept it as `agreementAcceptedAt`
on their `DomainContact`: a registration needs it.

Parameters:

- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The agreement's `url` and `version`.

### Domain.defaultRegistrant

```typescript
static defaultRegistrant(
  options?: { client?: NoClick; user?: UserRef | null },
): Promise<DomainContact | null>
```

The registrant your account's own domains are registered to when a purchase names none (null until set); with
`user` (a `User` or your id for one), that user's registrant profile, which their domains use.

Parameters:

- `options.user` (`UserRef | null`, default `null`): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The contact, or `None` until you set one.

Types:

```typescript
/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.setDefaultRegistrant

```typescript
static setDefaultRegistrant(
  contact: DomainContact | null,
  options?: { client?: NoClick; user?: UserRef | null },
): Promise<DomainContact | null>
```

Set (or with `null` clear) the registrant your account's own domains use when a purchase names
none, so `Domain.buy` or `Domain.fromName(..., { createIfMissing })` outside `asUser` needs no
contact in code; until one is set, such a purchase throws `ActionRequired`. With `user` (a `User` or
your id for one) it's that user's registrant profile, with their own acceptance: their domains (`asUser`,
or an app of theirs) are registered to it when a purchase names none. Like any registrant, it needs
`agreementAcceptedAt`. It's a standing acceptance too: where your approval settings make `terms` and
`person_filing` standing (`ApprovalPolicy.set`), a purchase it covers, an app's code's included, runs with
no one asked.

Parameters:

- `contact` (`DomainContact | null`, required)
- `options.user` (`UserRef | null`, default `null`): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The contact now on file (`None` once cleared).

Types:

```typescript
/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.connect

```typescript
static connect(
  name: string,
  options?: CallOptions & { wildcard?: boolean },
): Promise<Domain>
```

Connect a domain the person owns (`acme.com`, or `book.acme.com`). It's `pendingDns` until
`records` are added where its DNS is hosted (`setupUrl` does it in one click where the host
supports it). On a bare domain `www` is primary and the bare name needs CNAME flattening or a forward.
`wildcard: true` adds the `*.<name>` records too, so every subdomain can serve an app or send an
app's email without a record of its own; each goes live once its certificate is issued, usually
within minutes of its first use.

Parameters:

- `name` (`string`, required)
- `options.wildcard` (`boolean`)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The domain, `pending_dns` until the records in `records` are added where its DNS is
hosted, with `setup_url` when that host can add them in one click (the open Domain
Connect standard; the host's consent page names NoClick alongside your brand).

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.transferQuote

```typescript
static transferQuote(
  name: string,
  options?: CallOptions,
): Promise<TransferQuote>
```

Whether `name` (registered elsewhere) can move to NoClick now, and what it
costs. Nothing is charged. NoClick works it out from the domain's public registration data (its
registrar lock, its transfer lock, whether NoClick registers the TLD) and the registrar's price, so
it's a best answer until `transferIn` is accepted.

Parameters:

- `name` (`string`, required)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The quote: `eligible` with the `price_usd` the transfer charges (it adds `years`
to the registration) and the `renewal_usd` after, or not eligible with the `reason`
and, inside the registry's transfer lock, `locked_until`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.transferIn

```typescript
static transferIn(
  name: string | TransferQuote | Domain,
  options: DomainTransferOptions,
): Promise<DomainTransfer>
```

Move `name` (a name, a `TransferQuote`, or a domain you connected) to
NoClick from its current registrar, with the `authCode` that registrar gives. It's charged to your
account like a purchase once the transfer completes (`PriceExceeded` above `maxPriceUsd`,
`awaiting_human` while your policy holds it), and registered to `registrant` on the same rule as
`Domain.buy`, `agreementAcceptedAt` included: required for a user's domain, else the account's
default registrant. One the registry won't move now throws
`NotAvailable` with the reason. Its nameservers don't change, so its DNS keeps working where it's
hosted; once it's `active`, `useNoClickDns()` moves the DNS to NoClick. A connected domain keeps its
id and what it serves; passed as a `Domain`, the transfer acts in that domain's own scope (its user,
else your account), while a name acts for the current user or `user`.

Parameters:

- `name` (`string | TransferQuote | Domain`, required)
- `options.authCode` (`string`, required): The code the current registrar gives to move the domain out (its EPP or auth code).
- `options.maxPriceUsd` (`number`, required): The most it may cost, in US dollars; above it the transfer throws `PriceExceeded`.
- `options.registrant` (`DomainContact`): The person it's registered to from now on: required for a user's domain, as in `Domain.buy`.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The transfer: an operation whose `.wait()` gives the `Domain` once it's moved,
`source` `transferred`. The domain is `transferring_in` meanwhile, up to about 5
days; the current owner may be emailed by their registrar to approve. If the registry
refuses (a wrong auth code is `noclick.InvalidRequest` naming `auth_code`), the
transfer fails with its reason and nothing is charged.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.fromName

```typescript
static fromName(
  name: string,
  options?: CallOptions & Partial<DomainBuyOptions> & {
    createIfMissing?: boolean;
  },
): Domain
```

A lazy reference to your domain called `name`; loading one that isn't yours throws `NotFound`. An
`autoRenew` you pass is set on it every run. With `createIfMissing` your code owns it idempotently:
the first time it's used with no such domain it's bought as `Domain.buy` would (`maxPriceUsd` is
required, `years` is the TLD's minimum when omitted, and a user's domain needs `registrant`).
`maxPriceUsd`, `years` and `registrant` say how to buy it, so they matter only then.

Parameters:

- `name` (`string`, required)
- `options.createIfMissing` (`boolean`)
- `options.maxPriceUsd` (`number`): The most it may cost now, in US dollars; above it the purchase throws `PriceExceeded`.
- `options.years` (`number`): The term, in years: between the offer's `minYears` and `maxYears`, the TLD's minimum when
omitted. One the TLD doesn't offer throws `InvalidRequest` naming `years`, with the terms it does.
- `options.registrant` (`DomainContact`): The person it's registered to. A user's domain (inside `asUser`, or with `user`) naming none
uses the user's registrant profile (`Domain.setDefaultRegistrant(contact, { user })`), and with
none on file throws `InvalidRequest` naming `registrant`. A domain your account buys for itself
uses the account's default registrant instead (`Domain.setDefaultRegistrant`), and with none set
throws `ActionRequired` whose `nextStep` links to the console page where it's set. A registrant
that is the one on file, without `agreementAcceptedAt`, takes its acceptance from there once it
accepted the agreement as it stands.
- `options.autoRenew` (`boolean`, default: unchanged): Renew 30 days before expiry (true by default).
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.acceptClaims` (`boolean`): True once the registrant has been shown the offer's `claimsNotice` and still wants the name. A
name with a notice is refused without it (`ActionRequired` whose details carry
`claims_notice`), and nothing is bought.

Returns: A domain that loads (or is bought) the first time you read a field; `noclick.NotFound`
then if there's none. A domain just bought is `registering` (`awaiting_human` while
your policy holds it) until the purchase finishes. Nothing is sent yet.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.fromId

```typescript
static fromId(domainId: string, options?: CallOptions): Domain
```

A lazy reference to a domain by id.

Parameters:

- `domainId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.

Returns: A domain that loads the first time you read a field. Nothing is sent yet.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.get

```typescript
static get(domainId: string, options?: CallOptions): Promise<Domain>
```

Load a domain by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `domainId` (`string`, required)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The domain, loaded.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Domain.list

```typescript
static list(options?: ReadOptions & { limit?: number }): Promise<Domain[]>
```

Your domains, bought and connected (the current user's inside `asUser`, or those `userFilter` covers).

Parameters:

- `options.limit` (`number`): Return at most this many.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Every matching domain, newest first, fetched page by page. A domain transferred out
or disconnected isn't listed.

Types:

```typescript
/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### Domain.listPage

```typescript
static listPage(options?: ReadOptions & PageOptions): Promise<Page<Domain>>
```

One page of domains; pass `nextCursor` back as `cursor`.

Parameters:

- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A page whose `data` holds the domains and whose `next_cursor` is `None` on the last page.

Types:

```typescript
/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### Domain.verify

```typescript
verify(): Promise<this>
```

Check the domain's DNS now; each record's `status` and the domain's own are as found.

Returns: This domain, with each record's `status` and the domain's own `status` as found.

### Domain.update

```typescript
update(
  changes: { autoRenew?: boolean; registrant?: DomainContact },
): Promise<this>
```

Change a bought domain's settings: `{ autoRenew: false }` lets it lapse at `expiresAt`, and
`registrant` replaces the details of the person it's registered to. ICANN requires accurate
details, so update them when the person's change. Changing the registrant's name, organization
or email asks the new registrant to confirm their email again (the domain is
`registrant_unverified` meanwhile) and may start the registry's transfer lock (see
`transferLockedUntil`).

Parameters:

- `changes` (`{ autoRenew?: boolean; registrant?: DomainContact }`, required)

Returns: This domain, updated.

### Domain.renew

```typescript
renew(options: { years?: number; maxPriceUsd: number }): Promise<DomainPurchase>
```

Extend a bought domain now by `years`, or the TLD's minimum term (`renewalYears`) when omitted,
charged to your account when the renewal lands; like a purchase it may wait in `awaiting_human`
for your policy's approver. After `renewableUntil` it throws `NotAvailable`: renewing past the
guaranteed renewal window, or restoring a domain the registry is about to delete, isn't an API
call (NoClick support may be able to restore it, at the registry's restore fee).

Parameters:

- `options.years` (`number`)
- `options.maxPriceUsd` (`number`, required)

Returns: The renewal: an operation whose `.wait()` gives the `Domain` with its later `expires_at`.

### Domain.useNoClickDns

```typescript
useNoClickDns(): Promise<DnsRecord[]>
```

Move a transferred domain's DNS hosting to NoClick: the records NoClick can
read where it's hosted now are copied first, then its nameservers change. Resolves to the records
copied, for review: add any it missed with `dns.set`. On a domain whose DNS NoClick already hosts it
copies nothing; a connected domain throws `NotAvailable` (transfer it in first).

Returns: The records it copied, for review: add any it couldn't read with `dns.set`.
The domain's `noclick_dns` is now True.

### Domain.transferOut

```typescript
transferOut(): Promise<TransferCode>
```

Unlock a bought or transferred domain for another registrar; inside the registry's transfer lock
(`transferLockedUntil`) it throws `NotAvailable`. The code works until its `expiresAt`.

Returns: The auth code to give the other registrar, until its `expires_at` (call
`transfer_out()` again for a fresh one). The domain shows `transferring_out`
until the move completes, then leaves your list.

### Domain.delete

```typescript
delete(): Promise<void>
```

Disconnect a connected domain (its DNS stays as it is where it's hosted). Throws `Conflict`
while an inbox uses it, and on a bought domain, which can only lapse or transfer out.

## DomainOffer

```typescript
interface DomainOffer
```

A name from `Domain.search`; buy it with `Domain.buy(offer, { maxPriceUsd })`.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `available` | `boolean` |  |
| `priceUsd` | `number | null` | What buying it charges now, for `minYears`, in US dollars. |
| `renewalUsd` | `number | null` | What each renewal of `minYears` costs. |
| `premium` | `boolean` | The registry prices this name above its usual rate, often far above. |
| `minYears` | `number | null` | The TLD's shortest term, in years (two for `.ai`): what `Domain.buy` registers when `years` is left out. |
| `maxYears` | `number | null` | The TLD's longest term, in years. |
| `claimsNotice` | `string | null` | During the TLD's trademark-claims period, for a name that matches a registered trademark: the Trademark Clearinghouse notice (Markdown) the registrant must be shown before buying it, with `acceptClaims: true` once they have (null otherwise). |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## DomainContact

```typescript
interface DomainContact
```

The registrant: the person a domain is registered to, as the registry records it. ICANN
requires real details, kept accurate (`domain.update({ registrant })` when they change), and
`email` is sent a link to confirm the address, in your brand on ICANN's behalf; a person
confirms once, for all their domains. Domains are registered through NoClick's registrar
partner, which the public registration record names; privacy protection keeps the
registrant's details out of it.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `email` | `string` |  |
| `phone` | `string` | E.164, like `+14155550123`. |
| `address` | `string` | A second street line follows a newline. |
| `city` | `string` |  |
| `postalCode` | `string` |  |
| `country` | `string` | Two letters, like `US`. |
| `region` | `string` | The state, province or region of the address; the registry requires one. |
| `organization` | `string` | When set, that organization is the legal owner (ICANN's "Registered Name Holder"): never put your company on a user's domain unless your company means to own it. |
| `agreementAcceptedAt` | `Date` | When this person explicitly accepted the domain registration agreement (`Domain.agreement()`'s `url`). A registration needs it: a registrant, or your account's default registrant, without it is refused with `InvalidRequest` naming `registrant.agreement_accepted_at`. |

## DomainPurchase

```typescript
class DomainPurchase extends Operation
```

A domain bought or renewed: the operation `Domain.buy` and
`domain.renew` return. It's charged to your account when the registry confirms it, and one that
fails is never charged; while your policy holds it for a person to approve, it waits in
`awaiting_human`. `wait()` resolves to the `Domain`.

| Attribute | Type | Description |
| --- | --- | --- |
| `priceUsd` | `number | null` | What it charges your account, in US dollars. |
| `domainId` | `string | null` | The domain being bought or renewed. |
| `domain` | `Domain` | The domain, already listed while it runs (its `status` follows it). |

### DomainPurchase.purchaseFromId

```typescript
static purchaseFromId(
  operationId: string,
  options?: CallOptions,
): DomainPurchase
```

A lazy reference to a purchase by operation id: resume it anywhere, price and domain included (`Operation.fromId` gives a plain operation).

Parameters:

- `operationId` (`string`, required)
- `options.client` (`NoClick`)
- `options.user` (`UserOption`): `undefined` = the ambient user (`asUser`), `null` = the account itself.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

## DomainTransfer

```typescript
class DomainTransfer extends Operation
```

A domain moving to NoClick from another registrar: the operation
`Domain.transferIn` returns, charged to your account like a purchase (the quote, which adds the
quote's `years` to the registration) once the transfer completes, with the same `priceUsd`,
`domainId` and `domain`. The domain is `transferring_in` while the registry and the current
registrar move it, up to about 5 days; `wait()` resolves to the `Domain` once it's `active`. If the
registry refuses (a wrong auth code is `InvalidRequest` naming `authCode`), it fails with the
registry's reason and nothing is charged.

### DomainTransfer.transferFromId

```typescript
static transferFromId(
  operationId: string,
  options?: CallOptions,
): DomainTransfer
```

A lazy reference to a transfer by operation id: resume it anywhere, price and domain included (`Operation.fromId` gives a plain operation).

Parameters:

- `operationId` (`string`, required)
- `options.client` (`NoClick`)
- `options.user` (`UserOption`): `undefined` = the ambient user (`asUser`), `null` = the account itself.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

## DnsRecord

```typescript
interface DnsRecord
```

One DNS record. `name` is `@` for the domain itself, or the label before it (`www`).
`required` is false for a record the domain works without (a connected domain's bare-name
`ALIAS`, which forwarding can replace); `managed` marks one NoClick keeps for what it serves.

| Attribute | Type | Description |
| --- | --- | --- |
| `type` | `string` |  |
| `name` | `string` |  |
| `value` | `string` |  |
| `status` | `string | null` | `verified` once public DNS answers with it, `pending` until then, `conflict` when another record is in the way. |
| `purpose` | `string | null` | What it's for, in a few words. |
| `required` | `boolean` |  |
| `managed` | `boolean` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## DomainDns

```typescript
class DomainDns
```

`domain.dns`: the records of a bought domain, whose DNS NoClick
hosts. A connected domain's DNS stays where it is (`domain.records` lists what to add
there), so these throw `NotAvailable` on one.

### DomainDns.records

```typescript
records(): Promise<DnsRecord[]>
```

Every record in the domain's DNS: yours, and the ones NoClick keeps (`managed`) for what it serves.

Returns: The records, each with its `status`; `managed` marks NoClick's.

### DomainDns.set

```typescript
set(type: string, name: string, value: string): Promise<DnsRecord>
```

Add a record, or keep it if the same one is there. A `CNAME` replaces the name's existing
`CNAME`; other types add alongside. One that clashes with a managed record throws `Conflict`.

Parameters:

- `type` (`string`, required)
- `name` (`string`, required)
- `value` (`string`, required)

Returns: The record as saved; its `status` turns `verified` once public DNS serves it,
usually within minutes.

### DomainDns.delete

```typescript
delete(record: DnsRecord): Promise<void>
```

Remove `record` (from `records()`); a managed one throws `Conflict`.

Parameters:

- `record` (`DnsRecord`, required)

## TransferCode

```typescript
class TransferCode
```

What `domain.transferOut()` gives; printing it never shows the code.

| Attribute | Type | Description |
| --- | --- | --- |
| `authCode` | `string` | Give it to the other registrar. |
| `unlockedAt` | `Date | null` |  |
| `expiresAt` | `Date | null` | When the code stops working, where the registry limits it (null otherwise); `transferOut()` again gives a fresh one. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## TransferQuote

```typescript
interface TransferQuote
```

What moving a domain to NoClick from its current registrar costs, and
whether the registry allows it now: `eligible` is false (with `reason`) while the domain is locked
at its registrar, inside the registry's transfer lock after a domain is registered, transferred in
or its registrant changes (`lockedUntil`), on a TLD NoClick doesn't register, or already with
NoClick's registrar under another account (moving it between accounts isn't supported yet).
NoClick works it out from the domain's public registration data and the registrar's price, so
it's a best answer until `Domain.transferIn` is accepted.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `eligible` | `boolean` |  |
| `reason` | `string | null` | Why it can't move now (null when it can). |
| `priceUsd` | `number | null` | What the transfer charges your account, in US dollars; it adds `years` to the registration. |
| `renewalUsd` | `number | null` | What each renewal of `years` costs after. |
| `years` | `number | null` | The term the transfer adds to the registration: the TLD's minimum, one year for most. |
| `lockedUntil` | `Date | null` | The end of the registry's transfer lock, while it applies. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## DomainAgreement

```typescript
interface DomainAgreement
```

NoClick's domain registration agreement, from `Domain.agreement()`. The
page at `url` is the agreement the registrant accepts (it names the sponsoring registrar, as ICANN
requires), the fee schedule (registration, renewal, renewal after expiry, restore) and ICANN's
registrant rights and responsibilities. Show it to the person and record when they accept it, as
`agreementAcceptedAt` on their `DomainContact`. `version` names the revision.

| Attribute | Type | Description |
| --- | --- | --- |
| `url` | `string` |  |
| `version` | `string` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```
