{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cooperemail-com/json-schema/cooperemail-com-domain-schema.json",
  "title": "Domain",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cooperemail-com-openapi.yml#/components/schemas/Domain",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "const": "domain"
    },
    "id": {
      "type": "string"
    },
    "domain": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "verified",
        "cleanup_failed"
      ]
    },
    "status_detail": {
      "type": "string"
    },
    "mail": {
      "type": "object",
      "properties": {
        "receiving": {
          "type": "boolean"
        },
        "sending": {
          "type": "boolean"
        },
        "inboxes": {
          "type": "boolean"
        }
      },
      "required": [
        "receiving",
        "sending",
        "inboxes"
      ]
    },
    "records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DomainRecord"
      }
    },
    "warnings": {
      "type": "array",
      "description": "Empty when nothing else is wrong. existing_mail_provider means this hostname already has MX records that are not the records in this response. spf_dash_all means an SPF record ends in -all and does not name the sender. dmarc_reject means DMARC p=reject will block mail until alignment succeeds. multiple_spf means more than one SPF TXT is published on that host.",
      "items": {
        "$ref": "#/$defs/DomainWarning"
      }
    },
    "zone_status": {
      "type": "string",
      "enum": [
        "onboarded",
        "domain_zone_not_onboarded",
        "external"
      ],
      "description": "Present when custom-domain mail is on for this account."
    },
    "nameservers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "nameserver_instructions": {
      "type": [
        "string",
        "null"
      ]
    },
    "dns": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "manual",
            "automatic",
            "external"
          ]
        },
        "zone_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "written": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "present": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "conflicts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "error": {
          "type": "string"
        }
      },
      "required": [
        "mode"
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "verified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_checked_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "domain",
    "status",
    "status_detail",
    "mail",
    "records",
    "warnings"
  ],
  "$defs": {
    "DomainRecord": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "mx",
            "spf",
            "dkim",
            "dmarc",
            "verify",
            "cf_bounce_mx",
            "cf_bounce_spf",
            "cf_bounce_dkim",
            "return_path_mx",
            "return_path_spf",
            "return_path_cname"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "MX",
            "TXT",
            "CNAME"
          ]
        },
        "host": {
          "type": "string"
        },
        "value": {
          "type": "string"
        },
        "priority": {
          "type": "integer",
          "description": "MX priority. Copy this with the host and value."
        },
        "ttl": {
          "type": "integer",
          "description": "Suggested TTL in seconds. Present on external-DNS records."
        },
        "status": {
          "type": "string",
          "enum": [
            "valid",
            "missing",
            "invalid"
          ]
        },
        "found": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "hint": {
          "description": "Null when this record is valid or no specific mistake was found. Otherwise what to change. Validity is unchanged.",
          "oneOf": [
            {
              "$ref": "#/$defs/DomainRecordHint"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "role",
        "type",
        "host",
        "value",
        "status",
        "found",
        "hint"
      ]
    },
    "DomainRecordHint": {
      "type": "object",
      "description": "What to change for a record that is missing or invalid. Null on the record when it is valid or no specific mistake was found.",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "duplicated_suffix",
            "wrong_host",
            "wrong_type",
            "wrong_token",
            "value_typo",
            "multiple_spf",
            "mx_priority",
            "other_provider_mx"
          ]
        },
        "message": {
          "type": "string",
          "description": "One short sentence describing what to change."
        },
        "found_at": {
          "type": "string",
          "description": "Host where the value was found, when that host is not the one Cooper asked for."
        }
      },
      "required": [
        "code",
        "message"
      ]
    },
    "DomainWarning": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "existing_mail_provider",
            "spf_dash_all",
            "dmarc_reject",
            "multiple_spf"
          ]
        },
        "message": {
          "type": "string"
        },
        "provider": {
          "type": "string",
          "description": "Present when the existing MX host is a recognized provider."
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  }
}