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
    }
  }
}
{
  "input": {
    "customerId": "customer-123",
    "planId": "plan-enterprise",
    "billingPeriod": "ANNUAL",
    "addons": [
      { "addonId": "addon-seats", "quantity": 10 }
    ]
  }
}
{
  "data": {
    "previewSubscription": {
      "immediateInvoice": {
        "subtotal": {
          "amount": 3990,
          "currency": "USD"
        },
        "discount": {
          "amount": 0,
          "currency": "USD"
        },
        "tax": {
          "amount": 319.2,
          "currency": "USD"
        },
        "total": {
          "amount": 4309.2,
          "currency": "USD"
        },
        "lineItems": [
          {
            "description": "Enterprise Plan (Annual)",
            "quantity": 1,
            "unitPrice": {
              "amount": 2990,
              "currency": "USD"
            },
            "total": {
              "amount": 2990,
              "currency": "USD"
            }
          },
          {
            "description": "Extra Seats x 10",
            "quantity": 10,
            "unitPrice": {
              "amount": 100,
              "currency": "USD"
            },
            "total": {
              "amount": 1000,
              "currency": "USD"
            }
          }
        ]
      },
      "recurringInvoice": {
        "subtotal": {
          "amount": 3990,
          "currency": "USD"
        },
        "total": {
          "amount": 4309.2,
          "currency": "USD"
        }
      },
      "credits": null,
      "proration": null
    }
  }
}

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.