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

# Attach custom domain

> Attach a custom domain to an app or worker



## OpenAPI

````yaml https://api.getcargo.io/openapi.json post /hosting/custom-domains
openapi: 3.1.0
info:
  title: Cargo API
  version: 1.0.0
  description: Cargo Platform API v1
servers:
  - url: https://api.getcargo.io/v1
    description: Cargo API
security:
  - bearerAuth: []
paths:
  /hosting/custom-domains:
    post:
      tags:
        - Hosting - Custom Domains
      summary: Attach custom domain
      description: Attach a custom domain to an app or worker
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    kind:
                      type: string
                      const: app
                    appUuid:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                      title: App UUID
                      description: Identifier of the app this custom domain attaches to.
                    hostname:
                      title: Hostname
                      description: >-
                        Customer-controlled subdomain to attach (e.g.
                        app.example.com). Must be a valid FQDN with at least
                        three DNS labels, must not include a protocol or path,
                        and must not be under a Cargo-owned domain. Normalised
                        to lowercase.
                      type: string
                      minLength: 4
                      maxLength: 253
                  required:
                    - kind
                    - appUuid
                    - hostname
                  additionalProperties: false
                - type: object
                  properties:
                    kind:
                      type: string
                      const: worker
                    workerUuid:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
                      title: Worker UUID
                      description: Identifier of the worker this custom domain attaches to.
                    hostname:
                      title: Hostname
                      description: >-
                        Customer-controlled subdomain to attach (e.g.
                        app.example.com). Must be a valid FQDN with at least
                        three DNS labels, must not include a protocol or path,
                        and must not be under a Cargo-owned domain. Normalised
                        to lowercase.
                      type: string
                      minLength: 4
                      maxLength: 253
                  required:
                    - kind
                    - workerUuid
                    - hostname
                  additionalProperties: false
              title: Request body
              description: Request body schema.
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  customDomain:
                    oneOf:
                      - type: object
                        properties:
                          uuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          workspaceUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          hostname:
                            type: string
                          status:
                            type: string
                            enum:
                              - pending_verification
                              - verifying
                              - active
                              - failed
                              - deactivated
                          verifiedAt:
                            anyOf:
                              - type: string
                              - type: 'null'
                          verification:
                            type: array
                            items:
                              type: object
                              properties:
                                recordType:
                                  type: string
                                  enum:
                                    - CNAME
                                    - TXT
                                name:
                                  type: string
                                value:
                                  type: string
                              required:
                                - recordType
                                - name
                                - value
                              additionalProperties: false
                          cnameTarget:
                            anyOf:
                              - type: string
                              - type: 'null'
                          chargedUntil:
                            type: string
                          createdAt:
                            type: string
                          updatedAt:
                            type: string
                          kind:
                            type: string
                            const: app
                          appUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                        required:
                          - uuid
                          - workspaceUuid
                          - hostname
                          - status
                          - verifiedAt
                          - verification
                          - cnameTarget
                          - chargedUntil
                          - createdAt
                          - updatedAt
                          - kind
                          - appUuid
                        additionalProperties: false
                      - type: object
                        properties:
                          uuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          workspaceUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                          hostname:
                            type: string
                          status:
                            type: string
                            enum:
                              - pending_verification
                              - verifying
                              - active
                              - failed
                              - deactivated
                          verifiedAt:
                            anyOf:
                              - type: string
                              - type: 'null'
                          verification:
                            type: array
                            items:
                              type: object
                              properties:
                                recordType:
                                  type: string
                                  enum:
                                    - CNAME
                                    - TXT
                                name:
                                  type: string
                                value:
                                  type: string
                              required:
                                - recordType
                                - name
                                - value
                              additionalProperties: false
                          cnameTarget:
                            anyOf:
                              - type: string
                              - type: 'null'
                          chargedUntil:
                            type: string
                          createdAt:
                            type: string
                          updatedAt:
                            type: string
                          kind:
                            type: string
                            const: worker
                          workerUuid:
                            type: string
                            format: uuid
                            pattern: >-
                              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                        required:
                          - uuid
                          - workspaceUuid
                          - hostname
                          - status
                          - verifiedAt
                          - verification
                          - cnameTarget
                          - chargedUntil
                          - createdAt
                          - updatedAt
                          - kind
                          - workerUuid
                        additionalProperties: false
                    title: Custom domain
                    description: Newly attached custom domain.
                    type: object
                required:
                  - customDomain
                additionalProperties: false
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '404':
          description: Not found
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````