Skip to main content
Previews the pricing impact of creating or updating a subscription without making changes.

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

{
  "input": {
    "customerId": "customer-123",
    "subscriptionId": "sub-789",
    "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.