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

# Attach a custom domain

> Domain must already be pointed at the platform (CNAME to the platform's edge).



## OpenAPI

````yaml /api-reference/openapi.json post /apps/{app_id}/domains
openapi: 3.0.0
info:
  title: Shard Cloud API
  description: >-
    API reference for Shard Cloud's authenticated management endpoints — Apps,
    Databases, VMs, Custom Docker Images, and project-level Alerts & Backups.
    Every endpoint on this page requires a JWT bearer token (see Authentication
    below). CDN endpoints have their own reference under the CDN tab.
  version: 2.0.0
servers:
  - url: https://shardcloud.app/api
    description: API base path
security: []
tags:
  - name: Databases
    description: PostgreSQL, MySQL, MongoDB, and Redis database services.
  - name: Apps
    description: Web application deployment, files, domains, and configuration.
  - name: VMs
    description: Full Linux virtual machines with SSH access.
  - name: Custom Images
    description: User-built Docker images, deployable straight to an App.
  - name: Project
    description: >-
      Resource alerts and backups — shared across App, Database, and VM
      projects.
paths:
  /apps/{app_id}/domains:
    post:
      tags:
        - Apps
      summary: Attach a custom domain
      description: >-
        Domain must already be pointed at the platform (CNAME to the platform's
        edge).
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCustomDomainRequest'
      responses:
        '200':
          description: Custom domain added successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  custom_hostname:
                    $ref: '#/components/schemas/CustomHostname'
                  cname:
                    type: string
                    description: The platform hostname to CNAME your domain to.
        '400':
          description: Bad request or validation error
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ValidationError'
        '403':
          description: No valid subscription, or app is not a public web app
      security:
        - JWTAuth: []
components:
  schemas:
    UpdateCustomDomainRequest:
      type: object
      required:
        - custom_domain
      properties:
        custom_domain:
          type: string
    CustomHostname:
      type: object
      description: Cloudflare's custom hostname object for one app custom domain.
      properties:
        id:
          type: string
        hostname:
          type: string
        status:
          type: string
        ssl:
          $ref: '#/components/schemas/SSL'
        ownership_verification:
          $ref: '#/components/schemas/ValidationRecord'
    Error:
      type: object
      properties:
        error:
          type: string
    ValidationError:
      type: object
      properties:
        error:
          type: string
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              message:
                type: string
    SSL:
      type: object
      properties:
        method:
          type: string
        type:
          type: string
        status:
          type: string
        validation_records:
          type: array
          items:
            $ref: '#/components/schemas/ValidationRecord'
    ValidationRecord:
      type: object
      properties:
        type:
          type: string
        name:
          type: string
        value:
          type: string
        txt_name:
          type: string
        txt_value:
          type: string
  securitySchemes:
    JWTAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Send your API token (Dashboard → Settings → API Token) as
        `Authorization: Bearer <token>`.

````