{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/recur-tw/json-schema/recur-tw-subscription-schema.json",
  "title": "Subscription",
  "description": "A subscription with its product, customer and 10 most recent invoices",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/recur-tw-openapi.json#/components/schemas/Subscription",
  "type": "object",
  "required": [
    "object",
    "id",
    "status",
    "product",
    "customer",
    "amount",
    "interval",
    "interval_count",
    "current_period_start",
    "current_period_end",
    "cancel_at_period_end",
    "created_at",
    "livemode"
  ],
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "subscription"
      ]
    },
    "id": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "PENDING",
        "TRIAL",
        "ACTIVE",
        "PAST_DUE",
        "CANCELED",
        "EXPIRED"
      ]
    },
    "product": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "slug": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": "string"
        },
        "price": {
          "type": "integer",
          "description": "TWD, a whole number (499 is NT$499)"
        },
        "interval": {
          "type": "string"
        },
        "interval_count": {
          "type": "integer"
        }
      }
    },
    "customer": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "external_id": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "amount": {
      "type": "integer",
      "description": "TWD, a whole number (499 is NT$499)"
    },
    "interval": {
      "type": "string"
    },
    "interval_count": {
      "type": "integer"
    },
    "current_period_start": {
      "type": "string",
      "format": "date-time"
    },
    "current_period_end": {
      "type": "string",
      "format": "date-time"
    },
    "cancel_at_period_end": {
      "type": "boolean"
    },
    "canceled_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "started_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "trial_start": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "trial_end": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "coupon": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "discount_type": {
          "type": "string"
        },
        "discount_amount": {
          "type": "integer"
        },
        "duration": {
          "type": "string"
        },
        "duration_months": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "promotion_code_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "discount_amount": {
      "type": "integer",
      "description": "Discount the coupon gives on the product price, in TWD"
    },
    "invoices": {
      "type": "array",
      "description": "The 10 most recent invoices",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "amount": {
            "type": "integer"
          },
          "period_start": {
            "type": "string",
            "format": "date-time"
          },
          "period_end": {
            "type": "string",
            "format": "date-time"
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      }
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "livemode": {
      "type": "boolean"
    }
  }
}