# `mix ash_billing.reconcile`
[🔗](https://github.com/sfelixalejandro/ash_billing/blob/v0.7.0/lib/mix/tasks/ash_billing.reconcile.ex#L1)

Inspects financial drift or reconciles one or more subscriptions against the authoritative
billing provider using `AshBilling.Reconciler` and `AshBilling.reconcile_subscription/2`.

**Read-only by default (`--dry-run`).** Writes to PostgreSQL require `--execute` together
with explicit confirmation (`--confirm` or interactive prompt confirmation).

## Usage

    # Dry-run single subscription
    mix ash_billing.reconcile \
      --domain MyApp.Billing \
      --subscription-resource MyApp.Billing.Subscription \
      --subscription-id sub_123 \
      --system

    # Execute bulk reconciliation for subscriptions not reconciled in 24h
    mix ash_billing.reconcile \
      --domain MyApp.Billing \
      --subscription-resource MyApp.Billing.Subscription \
      --older-than-hours 24 \
      --concurrency 2 \
      --rate-limit-ms 100 \
      --system \
      --execute \
      --confirm

## Options

  * `--domain` - Ash domain module (required unless configured under `:ash_billing`).
  * `--subscription-resource` - Ash subscription resource module (required unless configured).
  * `--customer-resource` - Optional Ash customer resource module override.
  * `--subscription-id` - Reconcile a single subscription by `provider_subscription_id`.
  * `--id` - Reconcile a single subscription by local primary key.
  * `--older-than-hours` - Bulk filter: select records with `last_reconciled_at` `nil` or older than `N` hours.
  * `--status` - Comma-separated status filter (e.g. `active,past_due`).
  * `--missing-quantity` - Bulk filter: select subscriptions with `quantity IS NULL`.
  * `--all` - Explicit opt-in to scan all subscriptions without a narrower filter.
  * `--dry-run` - Inspect drift without writing to PostgreSQL (default).
  * `--execute` - Perform transactional reconciliation writes (requires `--confirm` or interactive confirmation).
  * `--confirm` - Explicit confirmation for `--execute` in non-interactive environments.
  * `--system` - Run with `authorize?: false` for trusted CLI system maintenance (without `--system`, Ash authorization remains enabled).
  * `--tenant` - Scope reads and writes to a specific tenant (required on multitenant resources).
  * `--stripe-account` - Scope provider requests (and database filtering) to a Stripe Connect account ID.
  * `--stripe-account-attribute` - Subscription attribute storing the Stripe Connect account ID (auto-detected if `:stripe_account_id` or `:stripe_account` exists).
  * `--stripe-account-scope` - Pass `tenant` for bulk Connect runs on multitenant resources with 1:1 tenant-to-account mapping and no per-row Connect column.
  * `--reset-event-cursor` - Pass `reset_event_cursor?: true` during `--execute`.
  * `--page-size` - Keyset pagination batch size (`1..500`, default `50`).
  * `--limit` - Maximum subscriptions to process.
  * `--concurrency` - Max concurrent workers per batch (`1..10`, default `2`).
  * `--rate-limit-ms` - Global minimum interval in milliseconds between provider requests across all workers (default `0`).
  * `--format` - `text` (default) or `json`.
  * `--json` - Shorthand for `--format json`.
  * `--no-start` - Do not start the application before running.

---

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