# Buy a domain name with an API or one command

> Buy and configure a domain name via the CLI or HTTP API using thelastapi credits, with automatic DNS and SSL for your apps.

**You can buy and configure a domain name with a single terminal command or a single HTTP request using thelastapi.** When you buy a domain through thelastapi, it is paid from your account credits, registered to your saved owner details, and held on the platform's nameservers. That means the domain—and any subdomain under it—can immediately attach to any project with HTTPS enabled and zero manual DNS configuration required.

Here is how domain purchases work, how to execute them via the CLI and HTTP API, how agent permissions function, and how to manage the DNS records afterwards.

## How domain registration works

Every project hosted on thelastapi answers out of the box at `https://<slug>.vibiz.app`. When you are ready for custom branding, buying a domain directly gives you several operational advantages over third-party registrars:

- **Unified credits:** The registration fee is deducted directly from your account's credit balance. There are no secondary billing portals or separate cards to manage.
- **Zero DNS configuration on local hosting:** Because thelastapi hosts the domain's DNS zone, the domain attaches directly to your project. Its status is never stuck on `pending_dns`, `records_to_set` remains empty, and `dns_by_vibiz` is set to `true`.
- **Reusable across projects:** Domains belong to your account rather than a single project. You can route `example.com` to your main app and `api.example.com` to a backend service in separate projects with one command.

If you already own an address elsewhere, you can [connect a domain you already own](https://thelastapi.dev/blog/connect-domain-you-own) instead of purchasing a new one.

## Searching and quoting from the CLI

To find an available name, run `vibiz domains search`:

```bash
vibiz domains search sellshelf
```

The search output returns available options across endings, the first-year purchase price, and the annual renewal price in USD. Prices are charged in USD cents with no hidden fees added at checkout.

Before buying, the CLI checks that your account balance covers the cost and that your legal registrant details are present. You can view your current portfolio at any time:

```bash
vibiz domains owned
```

This lists all domains purchased by the account, showing their expiration dates, auto-renewal settings, and which projects currently serve traffic on them.

## Purchasing a domain

To purchase a domain using the CLI, run `vibiz domains buy`. This command requires a full-access key (or a Limited key within the owner's configured budget):

```bash
vibiz domains buy sellshelf.app
```

The CLI displays the price, shows your remaining balance after the deduction, and prompts for confirmation. To skip confirmation prompts in automated scripts, pass `--yes` (and optionally specify `--years` up to 10):

```bash
vibiz domains buy sellshelf.app --years 1 --yes
```

The registration runs immediately. Within a minute or two, the domain moves to `active` status and begins serving your project, with the `www` subdomain automatically included. 

### Purchasing via HTTP API

You can also run searches, request quotes, and register names directly over HTTP:

```bash
# 1. Search availability
curl "https://thelastapi.dev/v1/domains/search?q=sellshelf" \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

# 2. Get an exact quote
curl "https://thelastapi.dev/v1/domains/quote?domain=sellshelf.app" \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

# 3. Buy the domain
curl -X POST "https://thelastapi.dev/v1/domains/buy" \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "sellshelf.app",
    "years": 1,
    "expected_price_cents": 1200
  }'
```

Every purchase request carries `expected_price_cents`. If the registry price changed between your quote and registration call, the API charges nothing and returns `409 Conflict` with `reason: price_changed` alongside an updated quote. If your account lacks funds, the call returns `402 payment_required`. If the underlying registry fails to complete the registration, credits are instantly refunded via a `domain_refund` entry in your Billing history.

For complete field structures, inspect the [Domains docs](https://thelastapi.dev/docs/domains).

## Owner details and ICANN verification

Domain registries require accurate registrant contact information for legal ownership. With thelastapi, you configure this contact once:

- **Saved once:** The first time you purchase a domain, you enter your contact information (name, email, phone with `+` country code, and address with two-letter ISO country code). This is encrypted at rest and automatically applied to future domain orders.
- **Privacy:** Personal details are masked on public WHOIS directories wherever the registry allows it.
- **ICANN verification:** ICANN mandates that owner contact details be confirmed within 15 days of registration. thelastapi handles the inbound registry communication for you. The account owner receives an email titled **Confirm your domain <domain>**, containing a link to verify the contact details inside the console with a single click.

You can inspect or update these details using:

```bash
vibiz domains owner --open
```

Or pass a JSON payload directly via `vibiz domains owner --input '<json>'` or `PUT /v1/domains/owner`.

## Attaching bought domains to projects

Because the DNS zone is hosted on thelastapi's infrastructure, assigning names to apps does not require touching external DNS control panels.

### Serving a thelastapi project

To attach your apex domain and `www` to a specific project:

```bash
vibiz domains use sellshelf.app --project shop
```

To route a subdomain to another project, specify the name:

```bash
vibiz domains use sellshelf.app --project docs --name docs
```

The platform provisions an SSL certificate automatically. If you later rewrite the application and [deploy a static site with one command](https://thelastapi.dev/blog/deploy-static-site-one-command) onto a fresh project called `shop-v2`, switch traffic over cleanly using `vibiz domains move`:

```bash
vibiz domains move sellshelf.app --to shop-v2
```

### Pointing to external hosting

If you run your primary application on another server while using thelastapi for analytics or sign-in, you can still manage the domain here. Pass `--points-to` with an IP address or hostname:

```bash
vibiz domains point app.sellshelf.app cname.yourhost.com
```

This writes the necessary `CNAME` or `ALIAS`/`A` records into the domain's DNS zone automatically.

## Managing DNS records

When external tools require domain verification, you can inspect and manipulate records directly without logging into another service. This is particularly common when you need to [add a DNS TXT record to verify your domain](https://thelastapi.dev/blog/add-dns-txt-record-verification) for identity verification or search tooling.

List all active records on the domain:

```bash
vibiz domains records sellshelf.app
```

Records labeled `managed` are maintained automatically by thelastapi for hosting, email routing, and certificate issuance (CAA records). To append custom DNS records, specify the record type, name, and target value:

```bash
# Add a TXT verification record
vibiz domains records add sellshelf.app TXT openai-business-profile "openai-business-profile=abc123xyz"

# Add an external MX record
vibiz domains records add sellshelf.app MX @ mx.mailhost.com --priority 10 --ttl 3600
```

Names are relative to the domain (using `@` for the root apex). Supported record types include `A`, `AAAA`, `CNAME`, `MX`, `TXT`, and `CAA`. Adding records is idempotent: re-submitting an identical type, name, and value returns `200` with `created: false` rather than creating duplicates.

To delete a record, provide its ID:

```bash
vibiz domains records remove sellshelf.app rec_123
```

Attempting to delete a system-maintained record returns `409 managed_record` unless explicitly overridden using `--force`.

## Enabling agent automation

Autonomous AI agents (such as Claude Code or Cursor) can discover and quote domains by default using the `GET /v1/domains/search` and `GET /v1/domains/quote` endpoints.

However, to prevent unauthorized spending, domain purchases and renewals default to human owners: a quote provides a `buy_url` link where an owner confirms the checkout.

If you want your agent to handle end-to-end setups autonomously, you can set an agent spend ceiling. In Billing, or via the API:

```bash
curl -X PATCH "https://thelastapi.dev/v1/billing" \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_domain_limit_cents": 3000}'
```

When an `agent_domain_limit_cents` budget is configured, agents holding Limited keys can complete registrations up to that price threshold. The domain will automatically be registered using the owner's pre-saved contact details.

If you are setting up an entire legal entity alongside your web infrastructure, review the guide on how to [form a US LLC or C-Corp from your terminal](https://thelastapi.dev/blog/form-us-llc-c-corp-terminal) or explore the [company formation documentation](https://thelastapi.dev/docs/company).

## Next step

Run `vibiz domains search <name>` in your terminal to see pricing and availability for your project's custom domain, or open your project in the console and select **Buy a domain**.

## Frequently asked questions

### How does domain auto-renewal work?

Auto-renewal is enabled by default on all purchased domains; approximately 30 days before expiration, the renewal fee is deducted from your credit balance and the domain is renewed. You can disable this anytime with `vibiz domains auto-renew <domain> off`.

### What happens if an automated domain registration fails?

If the registry rejects the registration call, credits are returned to your account balance immediately as a `domain_refund` entry in your Billing history.

### Can an AI agent send its own contact information when buying a domain?

No, agents cannot provide custom registration details; they can only purchase domains using the verified legal contact information previously saved by the human account owner.

### How do I transfer a bought domain out to another registrar?

Run `vibiz domains transfer-code <domain>` using a full-access key to generate the authorization code required by your new registrar, keeping in mind that registry rules lock new domains for 60 days post-registration.

---

Published 2026-11-15 · https://thelastapi.dev/blog/buy-domain-name-api
