{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "plan": {
      "type": "string"
    },
    "source": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "live": {
      "type": "object",
      "properties": {
        "allowed": {
          "type": "boolean"
        },
        "reason": {
          "type": "string"
        },
        "until": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": ["allowed", "reason", "until"]
    },
    "liveState": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "state": {
              "type": "string"
            },
            "reason": {
              "type": "string"
            },
            "since": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "until": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": ["state", "reason", "since", "until"]
        },
        {
          "type": "null"
        }
      ]
    },
    "trial": {
      "type": "object",
      "properties": {
        "state": {
          "type": "string"
        },
        "project": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "startedAt": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "endsAt": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": ["state", "project", "startedAt", "endsAt"]
    },
    "customDomain": {
      "type": "boolean"
    },
    "ai": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string"
        },
        "allowanceUsdPerMonth": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "pools": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "pool": {
                "type": "string"
              },
              "capacity": {
                "type": "number"
              },
              "used": {
                "type": "number"
              },
              "remaining": {
                "type": "number"
              }
            },
            "required": ["pool", "capacity", "used", "remaining"]
          }
        },
        "remaining": {
          "type": "number"
        },
        "renewsAt": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "source",
        "allowanceUsdPerMonth",
        "pools",
        "remaining",
        "renewsAt"
      ]
    },
    "subscription": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "plan": {
              "type": "string",
              "enum": ["launch", "growth", "scale"]
            },
            "interval": {
              "type": "string",
              "enum": ["month", "year"]
            },
            "status": {
              "type": "string"
            },
            "currentPeriodEnd": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            },
            "cancelAtPeriodEnd": {
              "type": "boolean"
            },
            "lastInvoice": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": ["paid", "failed"]
                },
                {
                  "type": "null"
                }
              ]
            },
            "livemode": {
              "type": "boolean"
            },
            "scheduledChange": {
              "default": null,
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "plan": {
                      "type": "string",
                      "enum": ["launch", "growth", "scale"]
                    },
                    "interval": {
                      "type": "string",
                      "enum": ["month", "year"]
                    },
                    "at": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["plan", "interval", "at"]
                },
                {
                  "type": "null"
                }
              ]
            },
            "endedFor": {
              "default": null,
              "anyOf": [
                {
                  "type": "string",
                  "enum": ["project-deleted", "project-transferred"]
                },
                {
                  "type": "null"
                }
              ]
            },
            "unpaid": {
              "default": null,
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "since": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "promotionsRefusedAt": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "offlineAt": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["since", "promotionsRefusedAt", "offlineAt"]
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "plan",
            "interval",
            "status",
            "currentPeriodEnd",
            "cancelAtPeriodEnd",
            "lastInvoice",
            "livemode",
            "scheduledChange",
            "endedFor",
            "unpaid"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "enforcement": {
      "type": "boolean"
    }
  },
  "required": [
    "plan",
    "source",
    "live",
    "liveState",
    "trial",
    "customDomain",
    "ai",
    "subscription",
    "enforcement"
  ]
}
