{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getmattered/json-schema/getmattered-get-subscription-response-schema.json",
  "title": "GetSubscriptionResponse",
  "description": "Successful API response",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getmattered-billing-api-openapi.yml#/components/schemas/GetSubscriptionResponse",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/GetSubscriptionPayload"
    },
    "meta": {
      "$ref": "#/$defs/ResponseMetadata"
    },
    "success": {
      "type": "boolean",
      "enum": [
        true
      ]
    }
  },
  "required": [
    "data",
    "success"
  ],
  "additionalProperties": false,
  "$defs": {
    "GetSubscriptionPayload": {
      "type": "object",
      "properties": {
        "checkoutOffer": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "billingInterval": {
              "type": "string",
              "enum": [
                "month"
              ]
            },
            "percentOff": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10
            },
            "duration": {
              "type": "string",
              "enum": [
                "once"
              ]
            },
            "appliesTo": {
              "type": "string",
              "enum": [
                "subscription"
              ]
            }
          },
          "required": [
            "percentOff",
            "duration",
            "appliesTo"
          ],
          "additionalProperties": false,
          "description": "Account-only discount on the first subscription invoice. Renewals use the regular price."
        },
        "subscription": {
          "allOf": [
            {
              "$ref": "#/$defs/SubscriptionPayload"
            },
            {
              "description": "Subscription details if user has an active subscription"
            }
          ]
        },
        "tokensBalance": {
          "type": "integer",
          "minimum": 0,
          "description": "Current token balance"
        }
      },
      "required": [
        "subscription",
        "tokensBalance"
      ]
    },
    "ResponseMetadata": {
      "type": "object",
      "properties": {
        "duration": {
          "type": "number",
          "minimum": 0,
          "description": "Request duration in milliseconds"
        },
        "performance": {
          "type": "object",
          "properties": {
            "dbQueries": {
              "type": "integer",
              "minimum": 0
            },
            "totalDbTime": {
              "type": "number",
              "minimum": 0
            }
          },
          "description": "Performance metrics (preview/local only)"
        },
        "requestId": {
          "type": "string",
          "description": "Unique request identifier"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp"
        },
        "version": {
          "type": "string",
          "description": "API version"
        }
      }
    },
    "SubscriptionPayload": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "cancelAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the subscription is scheduled to end, or null when it is not scheduled to end"
        },
        "cancelAtPeriodEnd": {
          "type": "boolean",
          "description": "Provider flag for \"will not renew\". FALSE on a Stripe portal cancellation - read cancelAt as well"
        },
        "canceledAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the customer requested the cancellation, or null when they have not"
        },
        "currentPeriodEnd": {
          "type": "string",
          "format": "date-time",
          "description": "End of the current billing period"
        },
        "currentPeriodStart": {
          "type": "string",
          "format": "date-time",
          "description": "Start of the current billing period"
        },
        "interval": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "month",
            "year",
            "week",
            "day",
            null
          ],
          "description": "Billing interval for the subscription"
        },
        "planName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display name of the plan the billed price belongs to, from the synced plan row"
        },
        "planTier": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "job_seeker",
            "hired_in_30",
            "hired_yesterday",
            null
          ],
          "description": "Tier of the plan the billed price belongs to"
        },
        "priceId": {
          "type": "string",
          "description": "Stripe price ID"
        },
        "productName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Name of the subscribed product"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "trialing",
            "past_due",
            "unpaid",
            "canceled",
            "incomplete",
            "incomplete_expired",
            "paused"
          ],
          "description": "Current subscription status"
        },
        "subscriptionId": {
          "type": "string",
          "description": "Stripe subscription ID"
        },
        "tokensPerPeriod": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Tokens granted per billing cycle for this plan at this interval"
        }
      },
      "required": [
        "cancelAt",
        "cancelAtPeriodEnd",
        "canceledAt",
        "currentPeriodEnd",
        "currentPeriodStart",
        "interval",
        "planName",
        "planTier",
        "priceId",
        "productName",
        "status",
        "subscriptionId",
        "tokensPerPeriod"
      ],
      "additionalProperties": false,
      "description": "Subscription details if synced"
    }
  }
}