{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/siteqwality-com/json-schema/siteqwality-com-dns-job-schema.json",
  "title": "DnsJob",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/siteqwality-com-openapi-openapi.json#/components/schemas/DnsJob",
  "type": "object",
  "required": [
    "id",
    "account_id",
    "http_job_id",
    "current_status",
    "domain",
    "created_at",
    "grace_states",
    "registry_publishes_expiry"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "account_id": {
      "type": "string",
      "format": "uuid"
    },
    "http_job_id": {
      "type": "string",
      "format": "uuid"
    },
    "current_status": {
      "$ref": "#/$defs/DnsJobStatus"
    },
    "domain": {
      "type": "string"
    },
    "expiry_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_run_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "last_status_change_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "domain_status": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "EPP status codes from the last check, RFC 8056 form\n(`auto renew period`, not `autoRenewPeriod`)."
    },
    "grace_states": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Registry states that mean the registration is in trouble regardless of\nwhat `expiry_date` says.\n\nDerived from `domain_status` rather than stored, so a client never has to\ncarry its own copy of which EPP codes matter. It is the field a UI should\nkey \"needs attention\" off: a domain in `auto renew period` reports an\nexpiry date up to two years out while sitting in a 45-day window in which\nthe registrar can hand it back."
    },
    "registrar": {
      "type": [
        "string",
        "null"
      ],
      "description": "Sponsoring registrar as of the last check."
    },
    "nameservers": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "Nameservers as of the last check, lowercased and sorted."
    },
    "manual_expiry_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "The renewal date the customer entered themselves.\n\nFor the TLDs in [`crate::domain_expiry::NO_EXPIRY_TLDS`], whose\nregistries publish no date under any protocol, this is the only date\nthere can be, and the normal 90/60/30/7/0 ladder runs against it.\n\n**When a registry date also exists, the registry wins** and this stays\nvisible beside it rather than being discarded. A stale manual date is\nexactly the silent wrongness domain monitoring exists to remove, so it\nnever overrides the authority; but dropping it would leave the customer\nbelieving they had entered a date that was doing something. Seeing the\ntwo disagree is the information. `expiry_source` says which of them\n`expiry_date` currently is."
    },
    "expiry_source": {
      "type": [
        "string",
        "null"
      ],
      "description": "Where the current `expiry_date` came from: `rdap`, `whois`, `whoxy` or\n`manual`. Null when there is no date at all."
    },
    "registry_publishes_expiry": {
      "type": "boolean",
      "description": "Whether this TLD's registry publishes an expiry date.\n\nDERIVED from the domain, never stored, so it can never go stale against\nthe curated list. `false` for the eleven TLDs measured as publishing\nnothing, and that is the flag a UI keys \"offer the manual entry field\"\noff. It is `true` for every TLD not positively established otherwise,\nincluding every TLD nobody has looked at, which is what makes the default\nsafe: being wrong in this direction costs three failed lookups, and being\nwrong the other way silently removes a customer's check."
    },
    "last_failure_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the last check could not read the registry, if it could not.\n\nOne of `no_rdap_endpoint`, `registry_no_record`, `no_whois_server`,\n`whois_no_record`, `whois_access_denied`, `rate_limited`,\n`transport_error`, `malformed_response`, `no_source_has_a_record`, or\n`registry_publishes_no_expiry`.\n\n**`registry_publishes_no_expiry` is a STATE, not a failure**, and a UI\nmust not present it as a broken check. It means the chain was never run\nbecause this registry publishes nothing, and the customer's next move is\nto enter a date, not to open a support ticket. `registry_publishes_expiry`\nabove is the same fact in the form a client can branch on.\n\nA failed check DELIBERATELY leaves `expiry_date`, `domain_status`,\n`registrar` and `nameservers` untouched: it learned nothing, and clearing\nthem would erase a good date over a transient blip and re-arm every alert\nrung. So a non-null value here means the sibling fields are LAST KNOWN\nrather than current, and a UI should say so. Cleared on the next\nsuccessful check."
    },
    "last_failure_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "$defs": {
    "DnsJobStatus": {
      "type": "string",
      "enum": [
        "good",
        "expired",
        "unknown"
      ]
    }
  }
}