{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layerhop-com/json-schema/layerhop-com-subscription-schema.json",
  "title": "Subscription",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layerhop-com-openapi.yaml#/components/schemas/Subscription",
  "type": "object",
  "required": [
    "id",
    "object",
    "livemode",
    "status",
    "customerEmail",
    "description",
    "amount",
    "settlement",
    "recipient",
    "interval",
    "intervalCount",
    "daysUntilDue",
    "cancelAtPeriodEnd",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^sub_"
    },
    "object": {
      "type": "string",
      "const": "subscription"
    },
    "livemode": {
      "type": "boolean"
    },
    "status": {
      "$ref": "#/$defs/SubscriptionStatus"
    },
    "customerEmail": {
      "type": "string"
    },
    "customerName": {
      "type": [
        "string",
        "null"
      ]
    },
    "merchantName": {
      "type": [
        "string",
        "null"
      ]
    },
    "description": {
      "type": "string"
    },
    "memo": {
      "type": [
        "string",
        "null"
      ]
    },
    "productId": {
      "type": [
        "string",
        "null"
      ]
    },
    "amount": {
      "type": "string",
      "pattern": "^\\d+$",
      "description": "Price per period in base units of the settlement token."
    },
    "settlement": {
      "$ref": "#/$defs/CheckoutSettlement"
    },
    "recipient": {
      "type": "string",
      "description": "Your payout address."
    },
    "interval": {
      "$ref": "#/$defs/SubscriptionInterval"
    },
    "intervalCount": {
      "type": "integer"
    },
    "daysUntilDue": {
      "type": "integer"
    },
    "currentPeriodStart": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Start of the period last invoiced (null before the first invoice)."
    },
    "currentPeriodEnd": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "nextInvoiceAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the next invoice is issued (null when paused or canceled)."
    },
    "cancelAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Scheduled cancel (the end of the current period)."
    },
    "cancelAtPeriodEnd": {
      "type": "boolean"
    },
    "canceledAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "cancellationReason": {
      "type": [
        "string",
        "null"
      ],
      "description": "`requested` (you canceled) or `unpaid` (past due for 7 days)."
    },
    "pausedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "latestInvoiceId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The invoice of the current period."
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "CheckoutSettlement": {
      "type": "object",
      "required": [
        "chainId",
        "token",
        "symbol",
        "decimals"
      ],
      "properties": {
        "chainId": {
          "type": "integer"
        },
        "token": {
          "type": "string"
        },
        "symbol": {
          "type": "string"
        },
        "decimals": {
          "type": "integer"
        }
      }
    },
    "SubscriptionInterval": {
      "type": "string",
      "description": "The billing period unit. Months and years keep the start's day of month (clamped to short months).",
      "enum": [
        "day",
        "week",
        "month",
        "year"
      ]
    },
    "SubscriptionStatus": {
      "type": "string",
      "description": "`active` (billing each period), `past_due` (an invoice is unpaid past its due date; reminders\nare being sent and renewals wait), `paused` (no invoices or reminders), `canceled` (for good:\nby you, or after 7 days past due).\n",
      "enum": [
        "active",
        "past_due",
        "canceled",
        "paused"
      ]
    }
  }
}