Skip to main content
Previews the pricing impact of creating or updating a subscription without making changes. When a customer already has an active subscription, Stigg automatically detects it and calculates proration — no subscriptionId is needed.

Mutation

mutation PreviewSubscription($input: PreviewSubscriptionInput!) {
  previewSubscription(input: $input) {
    immediateInvoice {
      subtotal {
        amount
        currency
      }
      discount {
        amount
        currency
      }
      tax {
        amount
        currency
      }
      total {
        amount
        currency
      }
      lineItems {
        description
        quantity
        unitPrice {
          amount
          currency
        }
        total {
          amount
          currency
        }
      }
    }
    recurringInvoice {
      subtotal {
        amount
        currency
      }
      total {
        amount
        currency
      }
    }
    credits {
      amount
      currency
    }
    proration {
      amount
      currency
    }
  }
}

Parameters

input
PreviewSubscriptionInput
required
Input for previewing subscription

Return Type

Returns a SubscriptionPreviewV2 with:
FieldTypeDescription
immediateInvoiceInvoicePreviewCharges due immediately
recurringInvoiceInvoicePreviewFuture recurring charges
creditsMoneyCredits to be applied
prorationMoneyProration amount

InvoicePreview Fields

FieldTypeDescription
subtotalMoneyBefore tax/discount
discountMoneyDiscount amount
taxMoneyTax amount
totalMoneyFinal amount
lineItems[LineItem]Itemized charges

Examples

Preview New Subscription

{
  "input": {
    "customerId": "customer-123",
    "planId": "plan-pro",
    "billingPeriod": "MONTHLY"
  }
}

Preview Upgrade

Pass the customer’s ID and the target planId. The backend automatically detects the customer’s active subscription and calculates proration.
{
  "input": {
    "customerId": "customer-123",
    "planId": "plan-enterprise"
  }
}

Preview with Coupon

{
  "input": {
    "customerId": "customer-123",
    "planId": "plan-pro",
    "couponId": "SAVE20"
  }
}

Common Use Cases

Show pricing before customer confirms purchase.
Show pricing impact of upgrading to a higher plan.
Show discount amount before applying coupon.