Skip to content
Indiana
Dashboard
Docs
Browse docs / Preview an Invoice

Preview an Invoice

POST/api/v1/invoices/preview

Calculate Product charges, custom lines, discounts and tax without creating an Invoice or granting access.

API v1Updated

Make the request

Calculate Product charges, custom lines, discounts and tax without creating an Invoice or granting access.

Credential
Server API key only. Call from your trusted backend.
Permission
billing:write
Set the base URL and App ID from SDK setup. These examples use placeholders and do not execute requests. Never put a server key in browser code.
For this Web Beta, configure the Stripe Sandbox test account and fixed Product Prices before checkout. Redirects do not confirm payment.
request.shShell
curl -X POST "$INDIANA_BASE_URL/api/v1/invoices/preview" \  -H "Authorization: Bearer $INDIANA_SECRET_KEY" \  -H "X-Indiana-Project: $INDIANA_PROJECT_ID" \  -H "X-Indiana-Protocol: 0.5" \  -H "X-Indiana-Environment: sandbox" \  -H "Content-Type: application/json" \  -d '{  "customerId": "00000000-0000-4000-8000-000000000001",  "params": {    "customer_id": "00000000-0000-4000-8000-000000000001",    "custom_line_items": [      {        "amount": 10,        "description": "Service"      }    ]  }}'

The response tab lists field types, not an example payload. Actual values depend on customer state.

Request parameters

JSON body

customerIduuidRequired

Indiana customer ID mapped from a verified identity on the server. Omit for customer-token calls, which use the token-bound customer.

paramsobjectRequired

The params value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
customer_idstringRequired

The customer_id value for this operation. Its accepted type and constraints are listed above and below.

plansarrayOptional

The plans value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
plan_idstringRequired

The plan_id value for this operation. Its accepted type and constraints are listed above and below.

versionnumberOptional

The version value for this operation. Its accepted type and constraints are listed above and below.

customizeobjectOptional

The customize value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
priceobject | nullOptional

Price in the requested or existing billing currency; null when unavailable, without currency substitution.

itemsarrayOptional

The items value for this operation. Its accepted type and constraints are listed above and below.

feature_quantitiesarrayOptional

The feature_quantities value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
feature_idstringRequired

The feature_id value for this operation. Its accepted type and constraints are listed above and below.

billing_behaviorenumRequired

The billing_behavior value for this operation. Its accepted type and constraints are listed above and below.

Show allowed values

"prepaid""usage_based"

quantitynumberOptional

Use the declared field type for business quantity. Credit operations use decimal strings to avoid floating-point error. quote/reserve/confirm/refund require positive quantities; consume can record zero-cost events.

min: 0

usagearrayOptional

The usage value for this operation. Its accepted type and constraints are listed above and below.

proratebooleanOptional

The prorate value for this operation. Its accepted type and constraints are listed above and below.

license_quantitiesarrayOptional

The license_quantities value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
license_plan_idstringRequired

The license_plan_id value for this operation. Its accepted type and constraints are listed above and below.

quantityintegerRequired

Use the declared field type for business quantity. Credit operations use decimal strings to avoid floating-point error. quote/reserve/confirm/refund require positive quantities; consume can record zero-cost events.

min: 0 · max: 9007199254740991

customizeobjectOptional

The customize value for this operation. Its accepted type and constraints are listed above and below.

feature_quantitiesarrayOptional

The feature_quantities value for this operation. Its accepted type and constraints are listed above and below.

proratebooleanOptional

The prorate value for this operation. Its accepted type and constraints are listed above and below.

discountsarrayOptional

The discounts value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
reward_idstringOptional

The reward_id value for this operation. Its accepted type and constraints are listed above and below.

promotion_codestringOptional

The promotion_code value for this operation. Its accepted type and constraints are listed above and below.

proratebooleanOptional

The prorate value for this operation. Its accepted type and constraints are listed above and below.

custom_line_itemsarrayOptional

The custom_line_items value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
amountnumberRequired

Credit or ledger amount, using the field’s decimal-string or integer type.

descriptionstringRequired

The description value for this operation. Its accepted type and constraints are listed above and below.

discountsarrayOptional

The discounts value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
reward_idstringOptional

The reward_id value for this operation. Its accepted type and constraints are listed above and below.

promotion_codestringOptional

The promotion_code value for this operation. Its accepted type and constraints are listed above and below.

invoice_template_idstringOptional

The invoice_template_id value for this operation. Its accepted type and constraints are listed above and below.

net_terms_daysintegerOptional

The net_terms_days value for this operation. Its accepted type and constraints are listed above and below.

max: 9007199254740991

tax_rate_idstringOptional

The tax_rate_id value for this operation. Its accepted type and constraints are listed above and below.

period_startintegerOptional

The period_start value for this operation. Its accepted type and constraints are listed above and below.

min: 0 · max: 9007199254740991

period_endintegerOptional

The period_end value for this operation. Its accepted type and constraints are listed above and below.

min: 0 · max: 9007199254740991

previewbooleanOptional

The preview value for this operation. Its accepted type and constraints are listed above and below.

Response fields

Successful responses include requestId and scope. Use the actual business status or accepted field to determine the result. Optional fields are omitted when unavailable.

HTTP 200 · application/json

requestIduuidRequired

Server-generated HTTP request UUID. Include it when reporting a failed request.

scopeobjectRequired

The App and environment of this response. Headers only verify scope; they cannot switch key scope.

Show child fields
projectIdstringRequired

App ID bound to the credential.

minLength: 1

environmentenumRequired

Separate data scope: sandbox or live.

Show allowed values

"sandbox""live"

previewobjectRequired

The preview value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
currencystringRequired

Currency code supported by the published price.

linesarrayRequired

The lines value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
plan_idstring | nullRequired

The plan_id value for this operation. Its accepted type and constraints are listed above and below.

feature_idstring | nullRequired

The feature_id value for this operation. Its accepted type and constraints are listed above and below.

descriptionstringRequired

The description value for this operation. Its accepted type and constraints are listed above and below.

amountnumberRequired

Credit or ledger amount, using the field’s decimal-string or integer type.

amount_after_discountsnumberRequired

The amount_after_discounts value for this operation. Its accepted type and constraints are listed above and below.

quantitynumber | nullRequired

Use the declared field type for business quantity. Credit operations use decimal strings to avoid floating-point error. quote/reserve/confirm/refund require positive quantities; consume can record zero-cost events.

proratedbooleanRequired

The prorated value for this operation. Its accepted type and constraints are listed above and below.

period_startnumber | nullRequired

The period_start value for this operation. Its accepted type and constraints are listed above and below.

period_endnumber | nullRequired

The period_end value for this operation. Its accepted type and constraints are listed above and below.

subtotalnumberRequired

The subtotal value for this operation. Its accepted type and constraints are listed above and below.

discount_totalnumberRequired

The discount_total value for this operation. Its accepted type and constraints are listed above and below.

taxobject | nullRequired

The tax value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
totalnumberRequired

The total value for this operation. Its accepted type and constraints are listed above and below.

amount_inclusivenumberRequired

The amount_inclusive value for this operation. Its accepted type and constraints are listed above and below.

amount_exclusivenumberRequired

The amount_exclusive value for this operation. Its accepted type and constraints are listed above and below.

statusenumRequired

The status value for this operation. Its accepted type and constraints are listed above and below.

Show allowed values

"complete""incomplete"

totalnumberRequired

The total value for this operation. Its accepted type and constraints are listed above and below.

due_datenumber | nullRequired

The due_date value for this operation. Its accepted type and constraints are listed above and below.

Handle errors

Common failures
CodeRecovery
UNAUTHENTICATEDVerify the key or refresh the expired customer token once.
FORBIDDENCheck current key permissions and customer access.
INVALID_REQUESTCheck field types, UUIDs, decimal strings and mutually exclusive fields.
SCOPE_MISMATCHUse the App and environment bound to the credential.

Common failures

  • UNAUTHENTICATED

    Recovery
    Verify the key or refresh the expired customer token once.
  • FORBIDDEN

    Recovery
    Check current key permissions and customer access.
  • INVALID_REQUEST

    Recovery
    Check field types, UUIDs, decimal strings and mutually exclusive fields.
  • SCOPE_MISMATCH

    Recovery
    Use the App and environment bound to the credential.

Related:All request and error conventions·Back to endpoint index