> ## Documentation Index
> Fetch the complete documentation index at: https://docs.korve.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Add

> Add a custom domain to a project environment (production by default) and get the CNAME record to create.



## OpenAPI

````yaml /openapi.json post /v1/orgs/{orgId}/projects/{projectId}/domains
openapi: 3.1.0
info:
  title: Korve API
  version: 0.1.0
  description: >-
    Typed control plane for deploying applications and explicitly provisioning
    their managed infrastructure.
servers:
  - url: https://api.korve.dev
security: []
paths:
  /v1/orgs/{orgId}/projects/{projectId}/domains:
    post:
      tags:
        - domains
      summary: Add
      description: >-
        Add a custom domain to a project environment (production by default) and
        get the CNAME record to create.
      operationId: domains.add
      parameters:
        - name: orgId
          in: path
          required: true
          schema:
            type: string
          description: The organization's id (UUID) or slug — either form is accepted.
        - name: projectId
          in: path
          required: true
          schema:
            type: string
          description: The project's id (UUID) or slug — either form is accepted.
      requestBody:
        required: true
        x-korve-max-bytes: 1048576
        content:
          application/json:
            schema:
              type: object
              properties:
                hostname:
                  type: string
                  pattern: ^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$
                  description: Hostname you control, e.g. "app.acme.com".
                environment:
                  type: string
                  pattern: ^[a-z][a-z0-9-]{0,38}$
                  description: >-
                    Environment the domain routes to. Defaults to "production".
                    An environment that does not exist on the project answers
                    404. The preview environment answers 422: preview apps are
                    ephemeral per-pull-request deployments, so a stable hostname
                    can never attach to them.
              required:
                - hostname
      responses:
        '201':
          description: >-
            Domain registered. Create the CNAME from the instructions, then
            check the domain until it goes active.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  hostname:
                    type: string
                    pattern: ^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$
                  environment:
                    type: string
                    pattern: ^[a-z][a-z0-9-]{0,38}$
                    description: Slug of the environment this domain routes to.
                  status:
                    type: string
                    description: >-
                      Verification state: pending_dns until the CNAME points at
                      the platform, pending_ssl while the certificate is issued,
                      then active. failed is terminal.
                    enum:
                      - pending_dns
                      - pending_ssl
                      - active
                      - failed
                  verificationErrors:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Why verification is stuck, when the edge reported a
                      reason.
                  createdAt:
                    type: string
                    format: date-time
                  instructions:
                    type: string
                    description: >-
                      DNS setup step. Production domains target the project's
                      managed subdomain, e.g. "CNAME app.acme.com →
                      my-app.korve.app"; domains on other environments target
                      that environment's own subdomain, e.g. "CNAME
                      staging.acme.com → my-app-staging.korve.app".
                required:
                  - id
                  - hostname
                  - environment
                  - status
                  - verificationErrors
                  - instructions
        '402':
          description: Organization billing is not active.
        '404':
          description: No such project or environment in this organization.
        '409':
          description: That hostname is already in use on the platform.
        '422':
          description: >-
            Invalid hostname, a managed platform hostname, or the preview
            environment (preview apps are per-pull-request — domains cannot
            attach to them).
        '502':
          description: Registering the domain at the edge failed; nothing was added.
      security:
        - apiKey: []
        - session: []
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: korve_api_key
    session:
      type: apiKey
      in: cookie
      name: korve.session_token

````