# `PhoenixKitBilling.SubscriptionType`
[🔗](https://github.com/BeamLabEU/phoenix_kit_billing/blob/0.5.1/lib/phoenix_kit_billing/schemas/subscription_type.ex#L1)

Schema for subscription types (pricing tiers).

Subscription types define the pricing, billing interval, and features
available at each tier. Types are managed internally and used to
create subscriptions.

## Fields

- `name` - Display name (e.g., "Basic", "Pro", "Enterprise")
- `slug` - Unique identifier (e.g., "basic", "pro")
- `description` - Marketing description
- `price` - Price per billing period (Decimal)
- `currency` - Three-letter currency code (default: "EUR")
- `interval` - Billing interval: "day", "week", "month", "year"
- `interval_count` - Number of intervals (e.g., 3 months)
- `trial_days` - Free trial period in days (default: 0)
- `features` - JSON map of features included in this type
- `active` - Whether this type is available for new subscriptions
- `sort_order` - Display order in type listings

## Examples

    %SubscriptionType{
      name: "Professional",
      slug: "pro",
      price: Decimal.new("29.99"),
      currency: "EUR",
      interval: "month",
      interval_count: 1,
      trial_days: 14,
      features: %{"api_calls" => 10000, "storage_gb" => 50},
      active: true
    }

# `billing_period_days`

Returns the billing period in days for this subscription type.

# `changeset`

Creates a changeset for a subscription type.

## Required fields
- `name` - Display name
- `slug` - Unique identifier (URL-friendly)
- `price` - Price per period

## Optional fields
- `description`, `currency`, `interval`, `interval_count`
- `trial_days`, `features`, `active`, `sort_order`, `metadata`

# `formatted_price`

Returns the formatted price string with currency.

# `get_by_slug`

Gets a subscription type by its slug.

# `interval_description`

Returns the billing interval description (e.g., "monthly", "every 3 months").

# `list_active`

Lists all active subscription types ordered by sort_order.

# `next_billing_date`

Calculates the next billing date from a given start date.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
