{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "lifecycle": {
      "type": "object",
      "properties": {
        "watchId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "projectId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "revision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Optimistic concurrency revision; supply it as expectedRevision on the next write."
        },
        "deal": {
          "type": "object",
          "properties": {
            "costMinor": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                {
                  "type": "null"
                }
              ]
            },
            "currency": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "USD",
                    "EUR",
                    "GBP",
                    "JPY",
                    "CAD",
                    "AUD",
                    "NZD",
                    "CHF",
                    "CNY",
                    "HKD",
                    "SGD",
                    "INR",
                    "KRW",
                    "BRL",
                    "MXN",
                    "SEK",
                    "NOK",
                    "DKK",
                    "PLN",
                    "CZK",
                    "HUF",
                    "ZAR",
                    "AED",
                    "SAR",
                    "ILS",
                    "THB",
                    "TRY",
                    "IDR",
                    "MYR",
                    "PHP",
                    "VND",
                    "KWD",
                    "BHD",
                    "OMR"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "acquiredOn": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "expiresOn": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "renewalWindowDays": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 365
                },
                {
                  "type": "null"
                }
              ]
            },
            "contactRef": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,119}$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "contactLabel": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 120
                },
                {
                  "type": "null"
                }
              ]
            },
            "dealNote": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 1000
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "costMinor",
            "currency",
            "acquiredOn",
            "expiresOn",
            "renewalWindowDays",
            "contactRef",
            "contactLabel",
            "dealNote"
          ],
          "additionalProperties": false
        },
        "createdAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "updatedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "watchId",
        "projectId",
        "revision",
        "deal",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": false
    },
    "schema_version": {
      "type": "number",
      "const": 1
    },
    "workspace_id": {
      "type": "string",
      "description": "Workspace that owns this record."
    },
    "project_id": {
      "type": "string",
      "description": "Project that owns this record."
    },
    "verification_job_id": {
      "type": "string"
    },
    "watch_id": {
      "type": "string"
    },
    "run_id": {
      "type": "string"
    },
    "candidate_id": {
      "type": "string"
    },
    "observation_id": {
      "type": "string"
    },
    "local_reference": {
      "anyOf": [
        {
          "type": "string",
          "description": "Customer reference for joining this record to a local ledger entry."
        },
        {
          "type": "null"
        }
      ],
      "description": "Customer reference for joining this record to a local ledger entry."
    },
    "created_at": {
      "type": "string",
      "description": "UTC timestamp when the record was created."
    },
    "watch": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Resource identifier returned by the operation."
        },
        "workspace_id": {
          "type": "string",
          "description": "Workspace that owns this record."
        },
        "project_id": {
          "type": "string",
          "description": "Project that owns this record."
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "paused"
          ],
          "description": "Resource lifecycle status."
        },
        "cadence_seconds": {
          "type": "number"
        },
        "state": {
          "type": "string",
          "description": "Saved lifecycle or evidence state, as enumerated for this record."
        },
        "observation_state": {
          "type": "object",
          "properties": {
            "state": {
              "description": "Saved lifecycle or evidence state, as enumerated for this record.",
              "type": "string"
            },
            "uncertain": {
              "type": "boolean"
            },
            "checked_at": {
              "description": "UTC timestamp of the saved check.",
              "type": "string"
            },
            "lastChangedAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "firstAbsentAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "consecutiveAbsent": {
              "type": "number"
            },
            "nextCheckAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "reason": {
              "description": "Recorded explanation; null when no explanation applies.",
              "anyOf": [
                {
                  "type": "string",
                  "description": "Recorded explanation; null when no explanation applies."
                },
                {
                  "type": "null"
                }
              ]
            },
            "latestAttempt": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "description": "Saved lifecycle or evidence state, as enumerated for this record.",
                      "type": "string"
                    },
                    "reason": {
                      "description": "Recorded explanation; null when no explanation applies.",
                      "anyOf": [
                        {
                          "type": "string",
                          "description": "Recorded explanation; null when no explanation applies."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "checkedAt": {
                      "type": "string"
                    },
                    "httpStatus": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "occurrenceCount": {
                      "type": "number"
                    },
                    "occurrences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "href": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "targetUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "anchor": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "rel": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "context": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "locator": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "line": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "column": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "offset": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "additionalProperties": {}
                      }
                    },
                    "checkerVersion": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": {}
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastSuccessfulObservation": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "description": "Saved lifecycle or evidence state, as enumerated for this record.",
                      "type": "string"
                    },
                    "reason": {
                      "description": "Recorded explanation; null when no explanation applies.",
                      "anyOf": [
                        {
                          "type": "string",
                          "description": "Recorded explanation; null when no explanation applies."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "checkedAt": {
                      "type": "string"
                    },
                    "httpStatus": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "occurrenceCount": {
                      "type": "number"
                    },
                    "occurrences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "href": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "targetUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "anchor": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "rel": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "context": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "locator": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "line": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "column": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "offset": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "additionalProperties": {}
                      }
                    },
                    "checkerVersion": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": {}
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastSuccessfulObservationSameAsLatestAttempt": {
              "type": "boolean"
            },
            "confirmedState": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastSuccessfulAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "lastHealthyAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "firstUnavailableAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "unavailableCount": {
              "type": "number"
            },
            "wasEverHealthy": {
              "type": "boolean"
            },
            "retryNotBefore": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "ignored": {
              "type": "boolean"
            }
          },
          "additionalProperties": {},
          "description": "Saved observation state. Before the first check, this object can be empty."
        },
        "created_at": {
          "type": "string",
          "description": "UTC timestamp when the record was created."
        },
        "updated_at": {
          "type": "string",
          "description": "UTC timestamp of the last record update."
        },
        "last_attempt_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "last_success_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "last_observation_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "next_check_at": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "overdue_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "source_url": {
          "type": "string",
          "description": "Publisher page URL recorded in this evidence."
        },
        "target_url": {
          "type": "string",
          "description": "Destination URL recorded in this evidence."
        },
        "target_scope": {
          "type": "string"
        },
        "expected_anchor": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "expected_rel": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "local_reference": {
          "anyOf": [
            {
              "type": "string",
              "description": "Customer reference for joining this record to a local ledger entry."
            },
            {
              "type": "null"
            }
          ],
          "description": "Customer reference for joining this record to a local ledger entry."
        },
        "last_successful_observation_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "history_compacted_before": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "created": {
          "description": "True when this request created the record; false when an existing record was reused.",
          "type": "boolean"
        },
        "detail": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "workspace_id",
        "project_id",
        "status",
        "cadence_seconds",
        "state",
        "observation_state",
        "created_at",
        "updated_at",
        "last_attempt_at",
        "last_success_at",
        "last_observation_id",
        "next_check_at",
        "overdue_reason",
        "source_url",
        "target_url",
        "target_scope",
        "expected_anchor",
        "expected_rel",
        "local_reference",
        "last_successful_observation_id"
      ],
      "additionalProperties": {}
    },
    "replayed": {
      "type": "boolean",
      "description": "True when the response reuses an earlier request with the same idempotency value."
    },
    "recurring_monitoring_created": {
      "type": "boolean",
      "const": true,
      "description": "Whether this operation enrolled recurring monitoring."
    }
  },
  "required": [
    "schema_version",
    "workspace_id",
    "project_id",
    "verification_job_id",
    "watch_id",
    "run_id",
    "candidate_id",
    "observation_id",
    "local_reference",
    "created_at",
    "watch",
    "replayed",
    "recurring_monitoring_created"
  ],
  "additionalProperties": {}
}
