# `PaperTiger.Resources.Plan`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.2/lib/paper_tiger/resources/plan.ex#L1)

Handles Plan resource endpoints.

## Endpoints

- POST   /v1/plans      - Create plan
- GET    /v1/plans/:id  - Retrieve plan
- POST   /v1/plans/:id  - Update plan
- DELETE /v1/plans/:id  - Delete plan
- GET    /v1/plans      - List plans

## Plan Object

Note: Plans are DEPRECATED in favor of Prices but still supported.

    %{
      id: "plan_...",
      object: "plan",
      created: 1234567890,
      active: true,
      amount: 2000,  # in cents
      currency: "usd",
      interval: "month",
      interval_count: 1,
      product: "prod_...",
      nickname: "Premium Plan",
      metadata: %{},
      # ... other fields
    }

# `create`

```elixir
@spec create(Plug.Conn.t()) :: Plug.Conn.t()
```

Creates a new plan.

## Required Parameters

- currency - Three-letter ISO currency code (e.g., "usd")
- interval - Billing interval ("day", "week", "month", or "year")
- amount - Price in cents (e.g., 2000 for $20.00)

## Optional Parameters

- id - Custom plan ID (if not provided, auto-generated as "plan_...")
- active - Whether plan is active (default: true)
- interval_count - Number of intervals between billings (default: 1)
- product - Product ID this plan belongs to
- nickname - Plan nickname
- metadata - Key-value metadata

# `delete`

```elixir
@spec delete(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
```

Deletes a plan.

Returns a deletion confirmation object.

# `list`

```elixir
@spec list(Plug.Conn.t()) :: Plug.Conn.t()
```

Lists all plans with pagination.

## Parameters

- limit - Number of items (default: 10, max: 100)
- starting_after - Cursor for pagination
- ending_before - Reverse cursor
- active - Filter by active status

# `retrieve`

```elixir
@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
```

Retrieves a plan by ID.

# `update`

```elixir
@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()
```

Updates a plan.

Note: Plans have limited fields that can be updated.

## Updatable Fields

- active
- metadata
- nickname

---

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