---
title: "Add an environment domain"
method: POST
path: "/projects/{projectId}/environments/{environmentId}/domains"
tags: ["Domain Management"]
---

# Add an environment domain

`POST /projects/{projectId}/environments/{environmentId}/domains`

Add a single domain to an environment.
If the environment is not production, the `replacement_for` field
is required, which binds a new domain to an existing one from a
production environment.
If the `ssl` field is left blank without an object containing
a PEM-encoded SSL certificate, a certificate will
[be provisioned for you via Let's Encrypt](https://docs.upsun.com/anchors/routes/https/certificates/).

## Path parameters

- `projectId` string, required
- `environmentId` string, required

## Request body

- union
  - ProdDomainStorageCreateInput
    - `name` string, required
    - `attributes` object — Arbitrary attributes attached to this resource
    - `is_default` boolean — Is this domain default
  - ReplacementDomainStorageCreateInput
    - `name` string, required
    - `attributes` object — Arbitrary attributes attached to this resource
    - `replacement_for` string — Prod domain which will be replaced by this domain.

## Response `default`

- AcceptedResponse
  - `status` string, required — The status text of the response
  - `code` integer, required — The status code of the response

---

[API](https://skmtc.net/upsun/apis/upsun-com-rest-api.md) · [All operations](https://skmtc.net/upsun/apis/upsun-com-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/upsun/upsun-com-rest-api/revisions/6cc88fde6435/schema)
