{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/payments-ai/json-schema/payments-ai-public-api-subscription-response-schema.json",
  "title": "PublicApiSubscriptionResponse",
  "description": "Subscription read. Every id is a Payments AI id.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/payments-ai-mor-openapi.json#/components/schemas/PublicApiSubscriptionResponse",
  "type": "object",
  "required": [
    "id",
    "status",
    "customerId",
    "planId",
    "productId",
    "orderId",
    "currentPeriodStart",
    "currentPeriodEnd",
    "nextChargeAt",
    "trialEndsAt",
    "cancelAtPeriodEnd",
    "createdAt"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "status": {
      "$ref": "#/$defs/PublicApiSubscriptionStatus"
    },
    "customerId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Null when the buyer could not be linked to a customer."
    },
    "planId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Null when the subscription is not on a catalogue plan."
    },
    "productId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Null when the subscription is not on a catalogue product."
    },
    "orderId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Order that started the subscription. Null for a plan checkout without an order."
    },
    "currentPeriodStart": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Start of the current billing period. Null on a subscription that has not renewed or changed since this field was added."
    },
    "currentPeriodEnd": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "End of the current billing period. During a trial, the trial end."
    },
    "nextChargeAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the next renewal charge is due. Null when no charge is scheduled: a pending cancellation, an ended subscription, or a one-time purchase."
    },
    "trialEndsAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "End of the free trial. Null when the subscription is not in a trial."
    },
    "cancelAtPeriodEnd": {
      "type": "boolean",
      "description": "True when the subscription ends at the end of the current period instead of renewing."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "PublicApiSubscriptionStatus": {
      "type": "string",
      "enum": [
        "active",
        "trialing",
        "canceling",
        "inactive"
      ],
      "description": "`active` renews at the period end. `trialing` is in a free trial. `canceling` keeps access until the period end and then ends. `inactive` has ended."
    }
  }
}