Skip to content
POST/v1/organizations/{organizationId}/billing/preview
Preview an organization billing change
curl --request POST \
  --url 'https://api.photon.codes/v1/organizations/{organizationId}/billing/preview' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "fixedCharge": {
    "fixedChargeCode": "<string>",
    "increment": -10000
  },
  "promotionCode": "<string>"
}'
{
  "balanceAfterCents": -9007199254740991,
  "change": {
    "quote": {
      "amount": "<string>",
      "currency": "<string>",
      "currentPeriodEnd": "<string>"
    },
    "type": "fixed_charge"
  },
  "dueLater": {
    "currency": "<string>",
    "lines": [
      {
        "amountCents": -9007199254740991,
        "code": "<string>",
        "discountCents": -9007199254740991,
        "kind": "fixed_charge",
        "name": "<string>",
        "periodEnd": "<string>",
        "periodStart": "<string>",
        "units": "<string>"
      }
    ],
    "totalCents": -9007199254740991
  },
  "dueNow": {
    "creditsCents": -9007199254740991,
    "currency": "<string>",
    "discountCents": -9007199254740991,
    "feesCents": -9007199254740991,
    "lines": [
      {
        "amountCents": -9007199254740991,
        "code": "<string>",
        "discountCents": -9007199254740991,
        "kind": "fixed_charge",
        "name": "<string>",
        "periodEnd": "<string>",
        "periodStart": "<string>",
        "units": "<string>"
      }
    ],
    "taxesCents": -9007199254740991,
    "totalCents": -9007199254740991
  },
  "nextCharge": {
    "amountCents": -9007199254740991,
    "at": "<string>",
    "currency": "<string>"
  },
  "nextInvoiceAt": "<string>",
  "timeZone": "<string>",
  "upcomingInvoices": [
    {
      "at": "<string>",
      "invoice": {
        "creditsCents": -9007199254740991,
        "currency": "<string>",
        "discountCents": -9007199254740991,
        "feesCents": -9007199254740991,
        "lines": [
          {
            "amountCents": -9007199254740991,
            "code": "<string>",
            "discountCents": -9007199254740991,
            "kind": "fixed_charge",
            "name": "<string>",
            "periodEnd": "<string>",
            "periodStart": "<string>",
            "units": "<string>"
          }
        ],
        "taxesCents": -9007199254740991,
        "totalCents": -9007199254740991
      }
    }
  ]
}

Authorizations

Authorizationstringheaderrequired

Account Service Key, prefixed with pho_ask_, sent as Authorization: Bearer <key>. Acts on behalf of its owning account, subject to the permissions and credential restrictions of each operation. Account access tokens and OAuth grants also use the Bearer header. In organizations that require SSO, Account Service Keys are not accepted for managing the organization's SSO settings, deleting the organization, or checking whether it can be deleted.

Scopes

billing:read

View invoices, usage, payment status.

Headers

Photon-Versionenum<string>

Selects the API contract date. Without it, the request is served as 2026-07-01.

Available options: "2026-07-01"

Path Parameters

organizationIdstringrequired

Body requiredapplication/json

fixedChargeobjectrequired

A quantity change made now, as a purchase or release makes it.

Show child attributes

A promotion code the customer entered, previewed as the purchase redeems it, on an increase only: dueNow and upcomingInvoices are discounted by it. Needs billing:manage. A refused code fails the preview with PROMOTION_CODE_REJECTED, its reason as a refused purchase's failure detail.

maxLength: 255
minLength: 1
Additional properties are not allowed.

Responseapplication/json

What the change would bill.

balanceAfterCentsinteger | nullrequired

The payer's credit balance once dueNow is charged: the credit the change issues included, less what dueNow uses. In dueNow's currency. Null when the change charges nothing now (a downgrade).

maximum: 9007199254740991
minimum: -9007199254740991
changeobjectrequired

What the change does beside what it bills, by the kind of change requested: fixed_charge for a fixed-charge change, plan_change for a plan change.

Show child attributes
dueLaterobjectrequired

Billed later rather than with dueNow: one line per plan change addition, billed when it is added and priced as if added now; or, for an organization that pays by invoice, what a fixed-charge change adds to its next invoice. After coupons, before taxes; the balance left after dueNow applies to it first. nextCharge already includes it. No lines when nothing is billed later.

Show child attributes
dueNowobjectrequired

An invoice priced by the billing engine as it would bill it: its lines, then what coupons, taxes and credits change, and what the payer is charged. No lines when it bills nothing.

Show child attributes
nextChargeobject | nullrequired

What is charged next for all that is held after the change: the first of upcomingInvoices, at its time and total, after coupons, with taxes, before credits. For a downgrade, the target plan's first charge at the period end. Usage and a minimum commitment are billed after the period. Null when nothing is charged, or the subscription ends first.

Show child attributes
nextInvoiceAtstring | nullrequired

ISO 8601.

timeZonestringrequired

The IANA time zone the payer is billed in, e.g. America/Los_Angeles. Billing periods start and end at its midnights, so read their calendar dates in it.

upcomingInvoicesarrayrequired

The invoices the subscription the change leaves issues in the following periods, assuming no later change: one, and another while a coupon with an end discounted the last, so the last listed is the price from then on. At most 24. For a change at the period end (a downgrade, or the held plan kept), the first is what the invoice due then bills for it.

Show child attributes
Additional properties are not allowed.

Response Headers

RFC 9745 structured-field Date at which the operation was or will be deprecated: @ followed by Unix seconds, for example @1767225599.

pattern: "^@-?[0-9]+$"

True when this response was replayed from an earlier attempt.

Photon-Versionenum<string>

The selected API contract date, also returned on errors after selection.

Available options: "2026-07-01"
RateLimitstring

Current rate-limit state.

Rate-limit policy applied by the gateway.

Delay before retrying, in seconds or as an HTTP date.

Sunsetstring

RFC 8594 HTTP-date (IMF-fixdate) after which the operation may become unavailable, for example Thu, 31 Dec 2026 23:59:59 GMT.

pattern: "^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-9]{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT$"

Identifier for this HTTP attempt.

Trace ID of this request. Sent alongside X-Request-ID when a middleware published a trace ID for the request.

pattern: "^(?!0{32}$)[0-9a-f]{32}$"