---
title: "Create a custom domain for a project"
method: POST
path: "/projects/{project_id}/custom-domains"
tags: ["Custom Domains"]
---

# Create a custom domain for a project

`POST /projects/{project_id}/custom-domains`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/custom-domains`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required

## Request body

- CustomDomainRequest
  - `branch` string, nullable
  - `domain` string, required
  - `environment_id` integer, required
  - `redirect_to` string, nullable
  - `service_name` string, nullable: Docker Compose service name this domain routes to (only for docker-compose projects)
  - `status_code` integer, nullable

## Response `201`

Custom domain created successfully

- CustomDomainResponse
  - `branch` string, nullable
  - `created_at` string, date-time, required
  - `domain` string, required
  - `domain_id` integer, nullable
  - `environment` DomainEnvironmentResponse, nullable
    - `id` integer, required
    - `name` string, required
    - `slug` string, required
  - `expiration_time` string, date-time, nullable
  - `id` integer, required
  - `last_renewed` string, date-time, nullable
  - `message` string, nullable
  - `project_id` integer, required
  - `redirect_to` string, nullable
  - `service_name` string, nullable: Docker Compose service name this domain routes to
  - `status` string, required
  - `status_code` integer, nullable
  - `updated_at` string, date-time, required

## Other responses

- `400`: Invalid input
- `401`: Unauthorized
- `409`: Domain already exists
- `500`: Internal server error

## Changes

- **2026-11-26** `e1864d950604`: 4 breaking
  - the `created_at` response's property type changed from `integer` to `string`, and format from `int64` to `date-time` for status `201`
  - the `expiration_time` response's property type changed from `integer, null` to `string, null`, and format from `int64` to `date-time` for status `201`
  - the `last_renewed` response's property type changed from `integer, null` to `string, null`, and format from `int64` to `date-time` for status `201`
  - the `updated_at` response's property type changed from `integer` to `string`, and format from `int64` to `date-time` for status `201`
- **2026-04-25** `774be20905f2`: 2 info
  - added the new optional request property `service_name`
  - added the optional property `service_name` to the response with the `201` status

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/custom-domains/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
