{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/curlec/json-schema/curlec-subscription-schema.json",
  "title": "Subscription",
  "description": "A recurring billing subscription linking a customer to a plan. Requires customer mandate authorization via short_url before charges can be collected.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/curlec-subscriptions-api-openapi.yml#/components/schemas/Subscription",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Subscription ID. Prefix: sub_"
    },
    "entity": {
      "type": "string",
      "enum": [
        "subscription"
      ]
    },
    "plan_id": {
      "type": "string",
      "description": "Associated plan ID (plan_*)."
    },
    "status": {
      "type": "string",
      "enum": [
        "created",
        "authenticated",
        "active",
        "pending",
        "halted",
        "cancelled",
        "completed",
        "expired",
        "paused"
      ],
      "description": "Subscription lifecycle status. created→authenticated (mandate authorized)→active→completed/cancelled/expired. pending=charge retry scheduled; halted=multiple failures; paused=temporarily stopped."
    },
    "current_start": {
      "type": "integer",
      "description": "Unix timestamp of current billing cycle start."
    },
    "current_end": {
      "type": "integer",
      "description": "Unix timestamp of current billing cycle end."
    },
    "ended_at": {
      "type": "integer",
      "description": "Unix timestamp when subscription ended (cancelled/completed/expired)."
    },
    "quantity": {
      "type": "integer",
      "default": 1,
      "description": "Number of plan units billed per cycle."
    },
    "notes": {
      "$ref": "#/$defs/Notes"
    },
    "charge_at": {
      "type": "integer",
      "description": "Unix timestamp of next scheduled charge attempt."
    },
    "start_at": {
      "type": "integer",
      "description": "Unix timestamp of first charge. Defaults to subscription creation time."
    },
    "end_at": {
      "type": "integer",
      "description": "Unix timestamp after which no more charges will be attempted."
    },
    "auth_attempts": {
      "type": "integer",
      "description": "Number of mandate authorization attempts."
    },
    "total_count": {
      "type": "integer",
      "description": "Total billing cycles. 0 = indefinite."
    },
    "paid_count": {
      "type": "integer",
      "description": "Number of billing cycles successfully charged."
    },
    "remaining_count": {
      "type": "integer",
      "description": "Remaining billing cycles."
    },
    "customer_notify": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "1 = Razorpay sends SMS/email notifications to customer on each charge."
    },
    "short_url": {
      "type": "string",
      "description": "Mandate authorization URL. Must be sent to the customer to activate the subscription."
    },
    "has_scheduled_changes": {
      "type": "boolean",
      "description": "True if a plan/quantity change is scheduled for the next cycle."
    },
    "change_scheduled_at": {
      "type": "string",
      "enum": [
        "now",
        "cycle_end"
      ],
      "description": "When scheduled changes take effect."
    },
    "source": {
      "type": "string",
      "description": "Source that created the subscription (e.g., api, dashboard)."
    },
    "offer_id": {
      "type": "string",
      "description": "Offer/coupon applied to the subscription."
    },
    "expire_by": {
      "type": "integer",
      "description": "Unix timestamp by which the customer must authorize the mandate."
    },
    "created_at": {
      "type": "integer"
    }
  },
  "$defs": {
    "Notes": {
      "type": "object",
      "description": "Key-value pairs for storing custom metadata. Maximum 15 pairs. Each key and value must not exceed 256 characters.",
      "additionalProperties": {
        "type": "string"
      },
      "maxProperties": 15
    }
  }
}