{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dotsy-ai/json-schema/dotsy-ai-add-custom-domain-response-schema.json",
  "title": "AddCustomDomainResponse",
  "description": "`domain` is the first host added. For an external add, `domains` lists every host and `connect` says how to finish connecting.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dotsy-ai-domains-api-openapi.yml#/components/schemas/AddCustomDomainResponse",
  "type": "object",
  "properties": {
    "domain": {
      "$ref": "#/$defs/CustomDomain"
    },
    "domains": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CustomDomain"
      },
      "description": "Every host added (external adds only)."
    },
    "connect": {
      "$ref": "#/$defs/DomainConnect"
    }
  },
  "required": [
    "domain"
  ],
  "$defs": {
    "CustomDomain": {
      "type": "object",
      "properties": {
        "host": {
          "type": "string"
        },
        "slug": {
          "type": "string",
          "description": "The site this hostname serves."
        },
        "kind": {
          "type": "string",
          "enum": [
            "internal",
            "external"
          ],
          "description": "`internal`: a nested subdomain of the platform's own site domain, connected at once with no DNS. `external`: a domain you own, which needs DNS records and a certificate."
        },
        "status": {
          "type": "string",
          "enum": [
            "pending_dns",
            "pending_cert",
            "connected",
            "error"
          ],
          "description": "`pending_dns`: waiting for the DNS records. `pending_cert`: DNS is right, the HTTPS certificate is being issued. `connected`: live. `error`: Cloudflare could not set the hostname up (see `lastError`); it no longer holds a hostname slot."
        },
        "isPrimary": {
          "type": "boolean",
          "description": "The primary host is the canonical address: the site's other connected hosts redirect (301) to it."
        },
        "lastError": {
          "type": [
            "string",
            "null"
          ],
          "description": "Why setup failed or stalled, or null (Cloudflare's own words when it gave any)."
        },
        "cfVerification": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string",
              "enum": [
                "does_not_cname",
                "using_cloudflare",
                "ownership_missing",
                "dcv_failed",
                "moved_never_connected",
                "moved_after_connected",
                "cf_not_found",
                "prevalidated"
              ],
              "description": "A stable code for what Cloudflare reports. `prevalidated` is not an error: the certificate is ready, DNS doesn't point at dotsy yet."
            },
            "message": {
              "type": "string",
              "description": "The same in plain words, for people."
            }
          },
          "required": [
            "code",
            "message"
          ],
          "description": "External hosts only, when Cloudflare reports something to act on. `cf_not_found`: Cloudflare deleted the hostname — remove the domain and add it again. `prevalidated`: Cloudflare is ready but DNS still points at the old host, so the domain stays `pending_dns` until it points here."
        },
        "createdAt": {
          "type": "number",
          "description": "When the hostname was added, Unix ms."
        },
        "verifiedAt": {
          "type": "number",
          "description": "When the hostname was last verified, Unix ms."
        },
        "connectSessionId": {
          "type": [
            "string",
            "null"
          ],
          "description": "The connect session (`cs_…`) this host belongs to, or null (internal hosts, expired sessions)."
        },
        "lastCheckedAt": {
          "type": "number",
          "description": "When Cloudflare was last asked about this hostname, Unix ms."
        },
        "dnsRecords": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DnsRecord"
          },
          "description": "The records to create. Empty for internal hosts. For a connected host they are all `found`; otherwise each carries a live `recordStatus`."
        },
        "apexForwarding": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "description": "The bare domain."
            },
            "to": {
              "type": "string",
              "description": "Where it should forward."
            },
            "providerForwards": {
              "type": "boolean",
              "description": "False when the provider has no forwarding service: moving DNS to Cloudflare is the only way to serve the bare domain."
            },
            "helpUrl": {
              "type": "string",
              "description": "The provider's help article on forwarding a domain."
            },
            "setUp": {
              "type": "boolean",
              "description": "dotsy set the forward up through the provider's API (GoDaddy)."
            },
            "provider": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "label"
              ],
              "description": "The DNS provider detected from the nameservers."
            }
          },
          "required": [
            "from",
            "to",
            "providerForwards",
            "provider"
          ],
          "description": "Only on a `www.<domain>` host with no bare-domain host on the site, when the DNS provider can't point the bare domain at a hostname: forward the bare domain to this host at the provider. Returned by listCustomDomains, refreshCustomDomain and connectCustomDomainProvider, from cached nameservers (absent until they're cached)."
        }
      },
      "required": [
        "host",
        "slug",
        "kind",
        "status",
        "isPrimary",
        "lastError",
        "createdAt",
        "verifiedAt",
        "connectSessionId",
        "lastCheckedAt",
        "dnsRecords"
      ]
    },
    "DnsRecord": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "DNS record type, e.g. `CNAME`, `TXT` or `A`."
        },
        "name": {
          "type": "string",
          "description": "The record name to enter at the DNS provider (relative to the zone, e.g. `www` or `_acme-challenge.www`)."
        },
        "value": {
          "type": "string",
          "description": "The record value to enter."
        },
        "purpose": {
          "type": "string",
          "enum": [
            "routing",
            "dcv",
            "apex"
          ],
          "description": "`routing`: points the hostname at dotsy. `apex`: the same for a bare domain. `dcv`: proves you control the domain so the certificate can be issued."
        },
        "host": {
          "type": "string",
          "description": "On `connect` records only: the session host this row belongs to."
        },
        "recordStatus": {
          "type": "string",
          "enum": [
            "found",
            "missing",
            "mismatch",
            "waiting",
            "duplicate",
            "blocked"
          ],
          "description": "A live DNS check of this record. Absent when no check has run. `duplicate` means extra TXT records at this name are blocking the certificate. `found` means the value Cloudflare wants now is in DNS — never an old certificate token. `blocked`: a bare-domain (`@`) row at a DNS provider that only offers ANAME/ALIAS there — Cloudflare can't verify the bare domain that way, so leave the `@` records as they are (`action: none`)."
        },
        "action": {
          "type": "string",
          "enum": [
            "add",
            "change",
            "delete",
            "keep",
            "none"
          ],
          "description": "What to do with this row: `add` it, `change` the record at this name to `value`, `delete` it (an old value still in DNS — `value` is the one to remove), `keep` it as it is, or `none` (a `blocked` row). Absent when the live check couldn't tell (`waiting`). A routing `change` row for a name still serving the old site is listed after the certificate rows: change it last."
        },
        "liveValues": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What public DNS answers at this name right now (on `change`, `delete` and mixed rows)."
        },
        "nameError": {
          "type": "string",
          "enum": [
            "doubled_suffix"
          ],
          "description": "The name looks like it was pasted as a full hostname and the provider appended the zone to it."
        },
        "useInstead": {
          "type": "string",
          "description": "With `nameError`: the relative name to enter instead."
        },
        "dnsTxtCount": {
          "type": "number",
          "description": "With `recordStatus: duplicate`: how many TXT answers exist at this name."
        },
        "dcvExpectedValues": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "No longer returned: only Cloudflare's current certificate token is valid; old ones come back as `action: delete` rows.",
          "deprecated": true
        },
        "enterAs": {
          "type": "string",
          "enum": [
            "ANAME",
            "ALIAS"
          ],
          "description": "No longer returned. At a DNS provider that only offers ANAME/ALIAS on `@` the bare-domain row is `recordStatus: blocked` with no `enterAs`: Cloudflare can't verify a bare domain through a flattened record outside Cloudflare DNS.",
          "deprecated": true
        },
        "matchedVia": {
          "type": "string",
          "enum": [
            "flattened"
          ],
          "description": "With `recordStatus: found` on a `CNAME` on `@` (Cloudflare DNS only): there was no CNAME answer, but the bare domain's A/AAAA addresses are among the target's (a flattened CNAME). Shared Cloudflare addresses mean this can't prove the domain points here — the hostname `status` is the final word."
        }
      },
      "required": [
        "type",
        "name",
        "value",
        "purpose"
      ]
    },
    "DomainConnect": {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "description": "The connect session. Pass it as `sessionId` to getCustomDomainConnect to resume."
        },
        "kind": {
          "type": "string",
          "enum": [
            "oauth",
            "redirect",
            "widget",
            "manual",
            "wait",
            "done"
          ],
          "description": "What to do next. `oauth` / `redirect` / `widget`: open `openUrl` in a browser. `manual`: follow `instructions` and enter `records`. `wait`: nothing to do, DNS or the certificate is propagating — poll again. `done`: every host is connected."
        },
        "summary": {
          "type": "string",
          "description": "One line to tell the user."
        },
        "openUrl": {
          "type": "string",
          "description": "A URL to open in a browser (OAuth start, Domain Connect apply)."
        },
        "openUrlLabel": {
          "type": "string"
        },
        "oauthLastError": {
          "type": "string",
          "description": "Last Cloudflare OAuth error code (`access_denied`, `exchange_failed`, …) while still on the OAuth lane."
        },
        "instructions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Numbered steps when `kind` is `manual`."
        },
        "records": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DnsRecord"
          },
          "description": "Copy-paste DNS rows for the session's hosts. `host` says which host each row belongs to."
        },
        "registrarDeepLink": {
          "type": "string",
          "description": "A link to the DNS page at the detected provider."
        },
        "provider": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "label": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "label"
          ],
          "description": "The DNS provider detected from the domain's nameservers."
        },
        "fieldHints": {
          "type": "object",
          "properties": {
            "hostField": {
              "type": "string",
              "description": "The label of the name box in the provider's DNS form."
            },
            "appendsZone": {
              "type": "boolean",
              "description": "The provider adds the domain itself: enter the relative `name`, never the full hostname."
            },
            "pasteWithoutQuotes": {
              "type": "boolean",
              "description": "Enter TXT values without quotes."
            }
          },
          "required": [
            "hostField",
            "appendsZone",
            "pasteWithoutQuotes"
          ],
          "description": "Manual lane: how the detected provider's DNS form names its fields. Absent for providers we haven't checked."
        },
        "apexSupport": {
          "type": "string",
          "enum": [
            "cname",
            "alias",
            "none",
            "unknown"
          ],
          "description": "Manual lane: what the detected provider accepts on the bare domain (`@`) when the target is a hostname. `cname`: a CNAME on `@` works. `alias`: the provider only offers ANAME/ALIAS, which Cloudflare can't verify — the `@` row is `recordStatus: blocked`; leave `@` as it is and connect www. `none`: the provider can't point `@` at a hostname — use www and forward the bare domain to it, or move DNS to Cloudflare. `unknown`: the provider wasn't recognised."
        },
        "apexForwarding": {
          "type": "object",
          "properties": {
            "from": {
              "type": "string",
              "description": "The bare domain."
            },
            "to": {
              "type": "string",
              "description": "Where to forward it."
            },
            "providerForwards": {
              "type": "boolean",
              "description": "False when the provider has no forwarding service: moving DNS to Cloudflare is the only way to serve the bare domain."
            },
            "helpUrl": {
              "type": "string",
              "description": "The provider's help article on forwarding a domain."
            },
            "replacesApex": {
              "type": "boolean",
              "description": "The session still holds the bare domain, which can never connect at this provider. Remove it (removeCustomDomain) and add the www host instead."
            },
            "setUp": {
              "type": "boolean",
              "description": "dotsy set this forward up through the provider's API (GoDaddy, via connectCustomDomainProvider) and read it back. Nothing to do at the provider."
            }
          },
          "required": [
            "from",
            "to",
            "providerForwards"
          ],
          "description": "The DNS provider can't point the bare domain at a hostname (`apexSupport: none`), so the site is connected on www and the bare domain should be forwarded to it at the provider. Adding a bare domain at such a provider connects the www host instead."
        },
        "nameServers": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The domain's nameservers, when the provider was not recognised."
        },
        "providerApi": {
          "type": "object",
          "properties": {
            "fields": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "secret": {
                    "type": "boolean"
                  },
                  "optional": {
                    "type": "boolean",
                    "description": "May be left out (GoDaddy's customer number)."
                  },
                  "placeholder": {
                    "type": "string"
                  }
                },
                "required": [
                  "key",
                  "label"
                ]
              }
            },
            "helpUrl": {
              "type": "string"
            },
            "helpLabel": {
              "type": "string"
            },
            "hasSavedCredentials": {
              "type": "boolean"
            }
          },
          "required": [
            "fields",
            "helpUrl",
            "helpLabel",
            "hasSavedCredentials"
          ],
          "description": "The paste-credentials lane (Name.com, GoDaddy): send the listed `fields` as `credentials` to connectCustomDomainProvider."
        },
        "entriAvailable": {
          "type": "boolean"
        },
        "lane": {
          "type": "string",
          "enum": [
            "cloudflare_oauth",
            "domain_connect",
            "entri",
            "manual"
          ],
          "description": "How the DNS records get applied: `cloudflare_oauth` (Cloudflare DNS, with the user's grant), `domain_connect`, `entri`, or `manual` (the user pastes records at their provider)."
        },
        "sessionStatus": {
          "type": "string",
          "enum": [
            "in_progress",
            "partial",
            "complete"
          ]
        },
        "hosts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "host": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending_dns",
                  "pending_cert",
                  "connected",
                  "error"
                ],
                "description": "`pending_dns`: waiting for the DNS records. `pending_cert`: DNS is right, the HTTPS certificate is being issued. `connected`: live. `error`: Cloudflare could not set the hostname up (see `lastError`); it no longer holds a hostname slot."
              },
              "isPrimary": {
                "type": "boolean"
              }
            },
            "required": [
              "host",
              "status",
              "isPrimary"
            ]
          }
        },
        "canReapplyOauth": {
          "type": "boolean",
          "description": "A stored Cloudflare OAuth grant exists, so reapplyCustomDomainOauth can fix the records without a browser."
        }
      },
      "required": [
        "sessionId",
        "kind",
        "summary",
        "entriAvailable",
        "lane",
        "sessionStatus",
        "hosts"
      ],
      "description": "What to do next to connect the pending hosts: the next action plus the connect session id."
    }
  }
}