{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "billing": {
      "type": "object",
      "properties": {
        "available": {
          "type": "boolean"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": ["admin-required", "staff-only", "not-configured"]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": ["available", "reason"]
    },
    "freeProjects": {
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "limit": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": ["count", "limit"]
    },
    "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"]
    },
    "freeAi": {
      "type": "object",
      "properties": {
        "usdPerMonth": {
          "type": "number"
        },
        "oneTimeUsd": {
          "type": "number"
        },
        "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": [
        "usdPerMonth",
        "oneTimeUsd",
        "pools",
        "remaining",
        "renewsAt"
      ]
    },
    "aiAllowanceUsdPerMonth": {
      "type": "number"
    },
    "enforcement": {
      "type": "boolean"
    },
    "projects": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "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"
              }
            ]
          },
          "subscription": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "string",
                    "minLength": 1
                  },
                  "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",
                            "minLength": 1
                          },
                          "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"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "plan",
          "source",
          "live",
          "liveState",
          "subscription"
        ]
      }
    }
  },
  "required": [
    "billing",
    "freeProjects",
    "trial",
    "freeAi",
    "aiAllowanceUsdPerMonth",
    "enforcement",
    "projects"
  ]
}
