{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "distinct": {
            "type": "string"
          },
          "attempt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "occurredAt": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "recordedAt": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "window": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["counted", "late", "future", "excluded"]
          },
          "achievement": {
            "anyOf": [
              {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "ordinal": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "achievedAt": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "window": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "const": "revoked"
                      },
                      "completion": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "revokedAt": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "id",
                      "ordinal",
                      "achievedAt",
                      "window",
                      "status",
                      "completion",
                      "revokedAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "ordinal": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "achievedAt": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "window": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "const": "awarded"
                      },
                      "completion": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      }
                    },
                    "required": [
                      "id",
                      "ordinal",
                      "achievedAt",
                      "window",
                      "status",
                      "completion"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      },
                      "ordinal": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "achievedAt": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "window": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "const": "budget-exhausted"
                      },
                      "budget": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100,
                        "pattern": "^[a-zA-Z0-9_-]+$"
                      }
                    },
                    "required": [
                      "id",
                      "ordinal",
                      "achievedAt",
                      "window",
                      "status",
                      "budget"
                    ],
                    "additionalProperties": false
                  }
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "distinct",
          "attempt",
          "occurredAt",
          "recordedAt",
          "window",
          "status",
          "achievement",
          "reason"
        ]
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": ["items", "nextCursor"]
}
