# Add a domain

Serve an [environment](/docs/concepts/project-lifecycle.md#environments) on your own domain, beside the Veryfront address it already has, such as `support-site.production.veryfront.com`.

## Before you start

You need a published project. See [Publish](/docs/deployment/publish.md).

## Add a domain

**Studio**

Custom domains need the Pro plan. First, at your DNS provider, add a CNAME record for `support.example.com` pointing to `cname.veryfront.com`. Studio refuses a domain that has none.

1. In your project, open **Runtime** > **Environments**.
2. Click **Production**.
3. Under **Domains**, click **Add domain**.
4. Enter `support.example.com` as the **Domain**.
5. Click **Add domain**. Studio says "Domain added" and lists it under **Domains**.
6. Click **Open** beside `support.example.com`. You should now see your Production site on your own domain. A **Private** environment asks you to sign in first.

**API**

Custom domains need the Pro plan. First, add the CNAME record for `support.example.com` pointing to `cname.veryfront.com` at your DNS provider.

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Get the project with your [API key](/docs/authentication/api-keys.md):

```bash
curl https://api.veryfront.com/projects/$PROJECT \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

3. Set `ENVIRONMENT_ID` to the `id` of the entry named `production` in its `environments`: `export ENVIRONMENT_ID=<id>`.
4. Add the domain:

```bash
curl -X POST https://api.veryfront.com/projects/$PROJECT/environments/$ENVIRONMENT_ID/domains \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "support.example.com"}'
```

5. List the environment's domains. You should now see `support.example.com` beside its Veryfront address:

```bash
curl https://api.veryfront.com/projects/$PROJECT/environments/$ENVIRONMENT_ID/domains \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

## Troubleshooting

**If Studio says "Could not add domain. Try again." and a message reads "No DNS records found for support.example.com. Please add a CNAME record pointing to cname.veryfront.com"**, the record is missing. Add it at your DNS provider, then click **Add domain** again. The API answers `400` with the same `detail`.

## With MCP

1. Call `veryfront__list_environments` with `{ "project_reference": "my-project" }`, and take the `id` of `production`.
2. Add the CNAME record for `support.example.com` at your DNS provider, then call `veryfront__create_domain` with `{ "project_reference": "my-project", "environment_id": "<the id>", "domain": "support.example.com" }`. This needs the Pro plan.
3. Call `veryfront__list_domains` with `{ "project_reference": "my-project", "environment_id": "<the id>" }`. It worked when `support.example.com` is listed.

## Next steps

* [Add a server](/docs/runtime/servers.md)
* [Add an environment](/docs/runtime/add-environment.md)
