---
title: "Domain Verification"
description: "Verify that you own a custom domain before routing it to a Freestyle VM."
url: "/docs/vms/domain-verification"
---

Before a custom domain can route to a Freestyle VM, verify that you own it. Verification creates a TXT record challenge for the domain.

You can verify domains in the [Freestyle Dashboard](https://dash.freestyle.sh/dashboard/domain-ownership) or through the SDK.


## Create A Verification

```ts
import { freestyle } from "freestyle";

const { verificationId, record, instructions } =
  await freestyle.domains.verifications.create({
    domain: "example.com",
  });

console.log(verificationId);
console.log(record);
console.log(instructions);
```

Freestyle returns a TXT record like this:

```ts
{
  type: "TXT",
  name: "_freestyle_custom_hostname.example.com",
  value: "<verification-code>",
}
```

Add that TXT record in your DNS provider. Some providers automatically append the domain name, so if `_freestyle_custom_hostname.example.com` does not verify, try `_freestyle_custom_hostname` as the record name.


## Complete Verification

After adding the TXT record, complete verification by domain:

```ts
await freestyle.domains.verifications.complete({
  domain: "example.com",
});
```

Or complete verification by ID:

```ts
await freestyle.domains.verifications.complete({
  verificationId,
});
```


## List Verifications

```ts
const verifications = await freestyle.domains.verifications.list();

for (const verification of verifications) {
  console.log(verification.domain, verification.verificationCode);
}
```


## Cancel A Verification

```ts
await freestyle.domains.verifications.cancel({
  domain: "example.com",
  verificationCode: "<verification-code>",
});
```


## List Verified Domains

```ts
const domains = await freestyle.domains.list({
  limit: 50,
});

for (const domain of domains) {
  console.log(domain.domain, domain.verifiedDns);
}
```

Verification proves ownership. It does not point the domain at Freestyle or route traffic to a VM. After verification, [configure DNS](https://www.freestyle.sh/docs/vms/domain-dns) and create a [domain mapping](https://www.freestyle.sh/docs/vms/domain-mappings).
