{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/appy-to/json-schema/appy-to-domain-schema.json",
  "title": "Domain",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/appy-to-openapi.yaml#/components/schemas/Domain",
  "type": "object",
  "required": [
    "id",
    "hostname",
    "status",
    "isDefault",
    "rootRedirectUrl",
    "appId",
    "dns",
    "verification",
    "lastError",
    "lastCheckedAt",
    "verifiedAt",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "hostname": {
      "type": "string",
      "description": "Lowercase ASCII hostname. Unicode names are stored as punycode."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "verifying",
        "active",
        "error"
      ],
      "description": "`pending`: waiting for the CNAME record. `verifying`: the record is correct and the certificate is being issued. `active`: live. `error`: see `lastError`."
    },
    "isDefault": {
      "type": "boolean",
      "description": "Link `url` fields, the dashboard and QR codes use this domain while it is active."
    },
    "rootRedirectUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Where the bare domain and unknown slugs go. Null shows a neutral not-found page."
    },
    "appId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Enterprise. The SDK app whose Universal Links and App Links this domain serves."
    },
    "dns": {
      "$ref": "#/$defs/DomainDNS"
    },
    "verification": {
      "type": "array",
      "description": "Extra records the certificate provider asks for, if any. Most domains only need the CNAME in `dns`.",
      "items": {
        "$ref": "#/$defs/DomainVerificationRecord"
      }
    },
    "lastError": {
      "type": [
        "string",
        "null"
      ],
      "description": "In `error`, what to fix. In `pending`, what the last check found (for example a CNAME that points elsewhere), or null when no record was found yet."
    },
    "lastCheckedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "verifiedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the domain first became active."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "DomainDNS": {
      "type": "object",
      "required": [
        "type",
        "name",
        "host",
        "value",
        "apex",
        "note"
      ],
      "description": "The record to create at the DNS provider.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "CNAME"
          ]
        },
        "name": {
          "type": "string",
          "description": "Record name relative to the registered domain; `@` for a root domain."
        },
        "host": {
          "type": "string",
          "description": "The full hostname the record is for."
        },
        "value": {
          "type": "string",
          "description": "The CNAME target."
        },
        "apex": {
          "type": "boolean",
          "description": "True for a root domain such as `acme.com`."
        },
        "note": {
          "type": [
            "string",
            "null"
          ],
          "description": "For root domains: explains that the DNS provider must support CNAME flattening or ALIAS/ANAME records."
        }
      }
    },
    "DomainVerificationRecord": {
      "type": "object",
      "required": [
        "type",
        "name",
        "value",
        "purpose"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "TXT",
            "CNAME"
          ]
        },
        "name": {
          "type": "string",
          "description": "Full record name."
        },
        "value": {
          "type": "string"
        },
        "purpose": {
          "type": "string",
          "enum": [
            "ownership",
            "certificate"
          ]
        }
      }
    }
  }
}