{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/audiopod-ai/json-schema/audiopod-ai-session-validation-response-schema.json",
  "title": "SessionValidationResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/audiopod-ai-auth-api-openapi.yml#/components/schemas/SessionValidationResponse",
  "properties": {
    "is_valid": {
      "type": "boolean",
      "title": "Is Valid"
    },
    "session_info": {
      "anyOf": [
        {
          "$ref": "#/$defs/SessionInfo"
        },
        {
          "type": "null"
        }
      ]
    },
    "user": {
      "anyOf": [
        {
          "$ref": "#/$defs/User"
        },
        {
          "type": "null"
        }
      ]
    },
    "expires_in": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expires In"
    },
    "needs_refresh": {
      "type": "boolean",
      "title": "Needs Refresh",
      "default": false
    },
    "session_extended": {
      "type": "boolean",
      "title": "Session Extended",
      "default": false
    },
    "grace_period_used": {
      "type": "boolean",
      "title": "Grace Period Used",
      "default": false
    },
    "auto_refresh_recommended": {
      "type": "boolean",
      "title": "Auto Refresh Recommended",
      "default": false
    },
    "refresh_threshold_seconds": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Refresh Threshold Seconds"
    },
    "session_max_age_seconds": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Session Max Age Seconds"
    }
  },
  "type": "object",
  "required": [
    "is_valid"
  ],
  "$defs": {
    "AutoRefillState": {
      "properties": {
        "enabled": {
          "type": "boolean",
          "title": "Enabled",
          "default": false
        },
        "target": {
          "type": "string",
          "const": "payg",
          "title": "Target",
          "default": "payg"
        },
        "threshold_credits": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Threshold Credits"
        },
        "last_attempt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Attempt"
        }
      },
      "type": "object",
      "title": "AutoRefillState",
      "description": "Status of automatic credit top-up for this account."
    },
    "CreditInfo": {
      "properties": {
        "credits_balance": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Credits Balance"
        },
        "payg_balance": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Payg Balance",
          "default": 0
        },
        "total_available_credits": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Total Available Credits"
        },
        "last_reset_at": {
          "type": "string",
          "format": "date-time",
          "title": "Last Reset At"
        },
        "total_credits_used": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Total Credits Used"
        },
        "total_payg_credits_purchased": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Total Payg Credits Purchased",
          "default": 0
        },
        "next_reset_date": {
          "type": "string",
          "format": "date-time",
          "title": "Next Reset Date"
        },
        "credits_per_month": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Credits Per Month"
        },
        "cycle_allotment": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Cycle Allotment"
        },
        "rolled_over": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Rolled Over",
          "default": 0
        },
        "held_until": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Held Until"
        },
        "auto_refill_state": {
          "anyOf": [
            {
              "$ref": "#/$defs/AutoRefillState"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "credits_balance",
        "total_available_credits",
        "last_reset_at",
        "total_credits_used",
        "next_reset_date",
        "credits_per_month"
      ],
      "title": "CreditInfo"
    },
    "EntitlementInfo": {
      "properties": {
        "tier": {
          "type": "string",
          "title": "Tier"
        },
        "tier_source": {
          "type": "string",
          "title": "Tier Source"
        },
        "expires_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expires At"
        },
        "web_subscription_active": {
          "type": "boolean",
          "title": "Web Subscription Active",
          "default": false
        },
        "iap_active": {
          "type": "boolean",
          "title": "Iap Active",
          "default": false
        },
        "web_tier": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Web Tier"
        },
        "iap_tiers": {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array",
          "title": "Iap Tiers"
        }
      },
      "type": "object",
      "required": [
        "tier",
        "tier_source"
      ],
      "title": "EntitlementInfo",
      "description": "Cross-platform entitlement snapshot — highest active tier across\nweb Stripe subscription and mobile IAP rows. See\n``app.services.entitlement_service`` for resolution logic."
    },
    "PaymentRecoveryInfo": {
      "properties": {
        "status": {
          "type": "string",
          "title": "Status"
        },
        "plan_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Plan Name"
        },
        "current_period_end": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current Period End"
        }
      },
      "type": "object",
      "required": [
        "status"
      ],
      "title": "PaymentRecoveryInfo",
      "description": "A recoverable-but-not-active subscription (payment failed at renewal).\n\nSurfaced SEPARATELY from ``subscription`` (which stays null for non-active\nsubs) so the dashboard can show a \"your payment failed — update your card to\nrestore your plan\" banner WITHOUT feature-gating code that reads\n``subscription.plan_name`` accidentally re-granting paid features to a user\nwhose plan has lapsed. Only populated when there is no active subscription\nand the most recent subscription is ``past_due`` or ``unpaid``."
    },
    "SessionInfo": {
      "properties": {
        "session_id": {
          "type": "string",
          "title": "Session Id"
        },
        "user_id": {
          "type": "string",
          "title": "User Id"
        },
        "device_info": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Device Info"
        },
        "ip_address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ip Address"
        },
        "user_agent": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "User Agent"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At"
        },
        "last_active": {
          "type": "string",
          "format": "date-time",
          "title": "Last Active"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "title": "Expires At"
        },
        "is_current": {
          "type": "boolean",
          "title": "Is Current",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "session_id",
        "user_id",
        "created_at",
        "last_active",
        "expires_at"
      ],
      "title": "SessionInfo"
    },
    "SubscriptionInfo": {
      "properties": {
        "plan_id": {
          "type": "string",
          "title": "Plan Id"
        },
        "plan_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Plan Name"
        },
        "is_free_plan": {
          "type": "boolean",
          "title": "Is Free Plan",
          "default": false
        },
        "status": {
          "type": "string",
          "title": "Status"
        },
        "current_period_start": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current Period Start"
        },
        "current_period_end": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Current Period End"
        },
        "cancel_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cancel At"
        },
        "retention_offer_used_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Retention Offer Used At"
        },
        "next_invoice_amount_cents": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Next Invoice Amount Cents"
        },
        "next_invoice_currency": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Next Invoice Currency"
        },
        "provider": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Provider"
        },
        "auto_renews": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Auto Renews"
        }
      },
      "type": "object",
      "required": [
        "plan_id",
        "status"
      ],
      "title": "SubscriptionInfo"
    },
    "User": {
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "title": "Email"
        },
        "full_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Full Name"
        },
        "is_active": {
          "type": "boolean",
          "title": "Is Active",
          "default": true
        },
        "is_superuser": {
          "type": "boolean",
          "title": "Is Superuser",
          "default": false
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At"
        },
        "updated_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Updated At"
        },
        "image": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Image"
        },
        "id": {
          "type": "string",
          "format": "uuid4",
          "title": "Id"
        },
        "google_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Google Id"
        },
        "stripe_customer_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Stripe Customer Id"
        },
        "is_verified": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Is Verified"
        },
        "user_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "User Type"
        },
        "audio_usage": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Audio Usage"
        },
        "onboarding_completed": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Onboarding Completed"
        },
        "referral_source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Referral Source"
        },
        "phone_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone Number"
        },
        "country_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Country Code"
        },
        "phone_verified": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone Verified"
        },
        "referral_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Referral Code"
        },
        "referred_by": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Referred By"
        },
        "onboarding_stage": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Onboarding Stage"
        },
        "onboarding_stage_updated_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Onboarding Stage Updated At"
        },
        "onboarding_started_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Onboarding Started At"
        },
        "phone_added_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone Added At"
        },
        "payment_method_added_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Payment Method Added At"
        },
        "first_subscription_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Subscription At"
        },
        "credits": {
          "anyOf": [
            {
              "$ref": "#/$defs/CreditInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "subscription": {
          "anyOf": [
            {
              "$ref": "#/$defs/SubscriptionInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "payment_recovery": {
          "anyOf": [
            {
              "$ref": "#/$defs/PaymentRecoveryInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "entitlement": {
          "anyOf": [
            {
              "$ref": "#/$defs/EntitlementInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "plan_tier": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Plan Tier"
        }
      },
      "type": "object",
      "required": [
        "email",
        "created_at",
        "id"
      ],
      "title": "User"
    }
  }
}