{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layers-com/json-schema/layers-com-partner-credits-schema-schema.json",
  "title": "PartnerCreditsSchema",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layers-com-openapi.json#/components/schemas/PartnerCreditsSchema",
  "type": "object",
  "properties": {
    "organizationId": {
      "description": "Organization the wallet belongs to.",
      "$ref": "#/$defs/OrganizationId"
    },
    "balance": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Total credits available — included credits remaining plus prepaid balance (gross, before reservations)."
    },
    "available": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Credits spendable on new work right now — balance minus credits reserved for in-flight work, floored at 0."
    },
    "includedRemaining": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Credits remaining from your plan's monthly included allowance."
    },
    "prepaidBalance": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Prepaid credits purchased on top of your plan allowance."
    },
    "reservedCredits": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Credits committed to in-flight work and not yet spendable."
    },
    "includedThisPeriod": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Total included credits granted for the current billing period."
    },
    "usedThisPeriod": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "Credits used so far in the current billing period."
    },
    "currentPeriod": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "start": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Billing period start, ISO-8601 UTC, or null if no active period."
            },
            "end": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Billing period end, ISO-8601 UTC, or null if no active period."
            },
            "usedCredits": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Credits used within this billing period."
            }
          },
          "required": [
            "start",
            "end",
            "usedCredits"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Current billing period window and usage, or null if no active period."
    },
    "subscriptionTier": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "free",
            "payg",
            "starter",
            "pro",
            "ultra",
            "scale",
            "enterprise"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Subscription plan tier, or null if no active plan. `payg` is pay as you go: $0 per month, no included credits, credits bought in packs. `scale` is the former name of `ultra` and appears only in historical records."
    },
    "billingStatus": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "active",
            "paused",
            "delinquent",
            "canceled",
            "trialing"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Current billing status of the subscription, or null if no active plan."
    },
    "estimatedCreditsPerFormat": {
      "type": "object",
      "properties": {
        "slideshow_builder": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Estimated upper-bound credit cost to generate one slideshow-builder content item."
        },
        "slideshow_remix": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Estimated upper-bound credit cost to generate one slideshow-remix content item."
        },
        "video_remix": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Estimated upper-bound credit cost to generate one video-remix content item."
        },
        "ugc_remix": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Estimated upper-bound credit cost to generate one UGC-remix content item."
        },
        "auto": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Estimated upper-bound credit cost when the format is chosen automatically."
        }
      },
      "required": [
        "slideshow_builder",
        "slideshow_remix",
        "video_remix",
        "ugc_remix",
        "auto"
      ],
      "additionalProperties": false,
      "description": "Defensive upper-bound credit estimate per output format, for client-side pre-flight checks."
    },
    "ingestCostsBilled": {
      "type": "object",
      "properties": {
        "github": {
          "type": "boolean",
          "const": false,
          "description": "Whether GitHub source ingestion is billed to your credits — always false."
        },
        "website": {
          "type": "boolean",
          "const": false,
          "description": "Whether website source ingestion is billed to your credits — always false."
        },
        "appstore": {
          "type": "boolean",
          "const": false,
          "description": "Whether App Store source ingestion is billed to your credits — always false."
        }
      },
      "required": [
        "github",
        "website",
        "appstore"
      ],
      "additionalProperties": false,
      "description": "Which source-ingestion costs are billed to your credits today; all currently absorbed by Layers."
    }
  },
  "required": [
    "organizationId",
    "balance",
    "available",
    "includedRemaining",
    "prepaidBalance",
    "reservedCredits",
    "includedThisPeriod",
    "usedThisPeriod",
    "currentPeriod",
    "subscriptionTier",
    "billingStatus",
    "estimatedCreditsPerFormat",
    "ingestCostsBilled"
  ],
  "additionalProperties": false,
  "$defs": {
    "OrganizationId": {
      "type": "string",
      "minLength": 5,
      "maxLength": 64,
      "pattern": "^org_[A-Za-z0-9-]+$"
    }
  }
}