@usebillow/sdk 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,11 +1,13 @@
1
- import { c as TaxBehavior, d as Customer, U as UnappliedPaymentReason, S as SavedPaymentMethod, e as CreateChargeInput, R as RequestOptions, f as Charge, g as CreateMerchantInitiatedChargeInput, I as IdempotentRequestOptions, h as CallOptions, i as PayInvoiceInput, C as CreateProductInput, j as UpdateProductInput, k as MigrationResult, l as CreateSubscriptionInput, B as BillowOptions, a as CreateCouponInput, m as Coupon, F as FeatureKind, M as MeterConfig, n as Feature, o as UpdateFeatureInput, p as UsageAlert, q as CreateUsageAlertInput, b as CheckResult, T as TrackResult, E as EntitlementView, A as AttachResult } from './billing-DZ4rIyg7.cjs';
2
- export { r as ActivatedSubscriptionResult, s as BillingInterval, t as ContractAddSubscriptionItemInput, u as ContractApplySubscriptionCouponInput, v as ContractCancelSubscriptionInput, w as ContractChangeSubscriptionPlanInput, x as ContractCreateChargeInput, y as ContractCreateCustomerInput, z as ContractCreateMerchantInitiatedChargeInput, D as ContractCreatePortalSessionInput, G as ContractCreateProductInput, H as ContractCreateSubscriptionInput, J as ContractCreateWebhookEndpointInput, K as ContractMigrateSubscribersInput, L as ContractRefundChargeInput, N as ContractResolveRefundInput, O as ContractUpdateProductInput, Q as ContractUpdateSubscriptionItemInput, V as ContractUpdateWebhookEndpointInput, W as CouponDuration, X as CouponKind, Y as CreateSubscriptionResult, Z as EntitlementInput, _ as InvoicePaymentResult, $ as MeterAggregation, a0 as MeterFilter, a1 as MeterRoundingMode, a2 as PendingSubscriptionCheckoutResult, a3 as PriceInput, P as Product, a4 as ProductEntitlement, a5 as ProductPrice, a6 as Subscription, a7 as SubscriptionDetail, a8 as SubscriptionItem, a9 as UpdatePriceInput, aa as UsageAlertKind, ab as UsageAlertMetric, ac as UsageModel, ad as UsageTier } from './billing-DZ4rIyg7.cjs';
1
+ import { f as SavedPaymentMethod, g as CreateHostedDomainInput, h as PayInvoiceInput } from './index.d-CKQAhQfJ.cjs';
2
+ export { i as ContractAddSubscriptionItemInput, j as ContractApplySubscriptionCouponInput, k as ContractCancelSubscriptionInput, l as ContractChangeSubscriptionPlanInput, m as ContractCreateChargeInput, n as ContractCreateCustomerInput, o as ContractCreateMerchantInitiatedChargeInput, p as ContractCreatePortalSessionInput, q as ContractCreateProductInput, r as ContractCreateSubscriptionInput, s as ContractCreateWebhookEndpointInput, M as ContractMigrateSubscribersInput, R as ContractRefundChargeInput, t as ContractResolveRefundInput, U as ContractUpdateProductInput, u as ContractUpdateSubscriptionItemInput, v as ContractUpdateWebhookEndpointInput, H as HostedDomain, w as HostedDomainList, I as InvoicePaymentResult } from './index.d-CKQAhQfJ.cjs';
3
3
  import { C as ChargeStatus, P as PaymentMethodStatus, I as InvoiceStatus, R as RefundStatus, W as WebhookDeliveryStatus } from './billing-status-BZQN_gm7.cjs';
4
4
  export { a as CHARGE_STATUSES, b as INVOICE_STATUSES, c as PAYMENT_METHOD_STATUSES, d as REFUND_STATUSES, e as WEBHOOK_DELIVERY_STATUSES } from './billing-status-BZQN_gm7.cjs';
5
5
  import { SubscriptionStatus } from './status.cjs';
6
6
  export { ACTIVE_SUBSCRIPTION_STATUSES, NEVER_ACTIVATED_SUBSCRIPTION_STATUSES, SUBSCRIPTION_STATUSES, TERMINAL_SUBSCRIPTION_STATUSES, grantsAccess, isTerminal } from './status.cjs';
7
- import { a as CreditThresholdLevel, b as CreditGrant, c as CreditTopUp, d as CreateCreditGrantInput, e as CreditGrantRequestResult, f as CreditPacks, g as CreateCreditPackInput, h as CreditPack, U as UpdateCreditPackInput, i as CreateCreditTopUpInput, j as CreditTopUpRequestResult, k as CreditTopUpListParams, l as CreditBalance, m as CreditLedgerEntry, n as CreditUsageParams, o as CreditUsage } from './credits-C3Fe3TO0.cjs';
8
- export { p as CreditAccountStatus, C as CreditGrantKind, q as CreditMoney, r as CreditPackListItem, s as CreditTopUpStatus, t as CreditTransactionType, u as CreditUsageGroupBy } from './credits-C3Fe3TO0.cjs';
7
+ import { c as TaxBehavior, d as Customer, U as UnappliedPaymentReason, e as CreateChargeInput, R as RequestOptions, f as Charge, g as CreateMerchantInitiatedChargeInput, I as IdempotentRequestOptions, h as CallOptions, C as CreateProductInput, i as UpdateProductInput, j as MigrationResult, k as CreateSubscriptionInput, B as BillowOptions, a as CreateCouponInput, l as Coupon, F as FeatureKind, M as MeterConfig, m as Feature, n as UpdateFeatureInput, o as UsageAlert, p as CreateUsageAlertInput, b as CheckResult, T as TrackResult, E as EntitlementView, A as AttachResult } from './billing-B-VyZCXV.cjs';
8
+ export { q as ActivatedSubscriptionResult, r as BillingInterval, s as CouponDuration, t as CouponKind, u as CreateSubscriptionResult, v as EntitlementInput, w as MeterAggregation, x as MeterFilter, y as MeterRoundingMode, z as PendingSubscriptionCheckoutResult, D as PriceInput, P as Product, G as ProductEntitlement, H as ProductPrice, S as Subscription, J as SubscriptionDetail, K as SubscriptionItem, L as UpdatePriceInput, N as UsageAlertKind, O as UsageAlertMetric, Q as UsageModel, V as UsageTier } from './billing-B-VyZCXV.cjs';
9
+ import { a as CreditThresholdLevel, e as CreditGrant, f as CreditTopUp, g as CreateCreditGrantInput, h as CreditGrantRequestResult, i as CreditPacks, j as CreateCreditPackInput, k as CreditPack, U as UpdateCreditPackInput, l as CreateCreditTopUpInput, m as CreditTopUpRequestResult, n as CreditTopUpListParams, o as CreditBalance, p as CreditLedgerEntry, q as CreditUsageParams, r as CreditUsage } from './hosted-domains-BYYl2DSa.cjs';
10
+ export { s as CreditAccountStatus, C as CreditGrantKind, t as CreditMoney, u as CreditPackBreakdown, v as CreditPackListItem, w as CreditTopUpStatus, x as CreditTransactionType, y as CreditUsageGroupBy, H as HostedDomainActivatedData, d as HostedDomainDisabledData, b as HostedDomainDnsFailingData, z as HostedDomainEventBase, c as HostedDomainReassignmentPendingData, A as HostedDomainStatus, B as HostedDomainStatusReason } from './hosted-domains-BYYl2DSa.cjs';
9
11
  import 'zod';
10
12
 
11
13
  /**
@@ -703,6 +705,192 @@ interface Whoami {
703
705
  /** Currencies configured for this Project (payment credential sets). */
704
706
  currencies: string[];
705
707
  defaultCurrency: string;
708
+ /** Whether the Project's custom-domain endpoints (`hostedDomains`) are open: live only, behind a rollout flag. */
709
+ hostedDomainsEnabled: boolean;
710
+ }
711
+
712
+ /**
713
+ * Public SDK types for Rate Cards, quotes, credit reservations and consumption reversals.
714
+ * Re-exported by ../types.ts.
715
+ *
716
+ * Every credit quantity - and every count of units - is a `string` of a whole number, e.g.
717
+ * `"5000000"` for 5 credits: never a `number`, which would silently round past 2^53.
718
+ */
719
+ /** One Credit Action's price in a Rate Card version: `ceil(units * unitPrice / perUnits)` a line. */
720
+ interface CreditRateCardItem {
721
+ /** The Credit Action key, e.g. `send_message`. */
722
+ action: string;
723
+ /** The category it is spent from: a reservation holds one category. */
724
+ category: string;
725
+ /** Microcredits per `perUnits` units. */
726
+ unitPrice: string;
727
+ /** How many units `unitPrice` buys. */
728
+ perUnits: string;
729
+ }
730
+ /** An immutable Rate Card version: a price change is a new version. */
731
+ interface CreditRateCard {
732
+ id: string;
733
+ /** 1, 2, 3... in the order versions were published (and take effect). */
734
+ version: number;
735
+ /** From when it prices new quotes and reservations made from items. */
736
+ effectiveAt: string;
737
+ /** Its prices, by action. */
738
+ items: CreditRateCardItem[];
739
+ createdAt: string;
740
+ }
741
+ /** Publish a new Rate Card version: every Credit Action it prices, once each. */
742
+ interface PublishCreditRateCardInput {
743
+ /**
744
+ * When it takes effect (ISO 8601 with a timezone): now when omitted; never in the past, nor
745
+ * before the version before it takes effect.
746
+ */
747
+ effectiveAt?: string;
748
+ items: Array<{
749
+ /** 1-100 lowercase letters, digits, dots, hyphens or underscores. */
750
+ action: string;
751
+ category: string;
752
+ /** Whole microcredits as a decimal string; "0" for an action that costs nothing. */
753
+ unitPrice: string;
754
+ /** Whole units as a decimal string; "1" when omitted. */
755
+ perUnits?: string;
756
+ }>;
757
+ }
758
+ /** Opaque context on a line (e.g. a model name), unpriced: a JSON object of at most 4 KiB. */
759
+ type CreditDimensions = Record<string, unknown>;
760
+ /** One line of a quote or a commit: a Credit Action and how many units of it. */
761
+ interface CreditLineItem {
762
+ action: string;
763
+ /** Whole units as a decimal string, positive. */
764
+ units: string;
765
+ /** Never personal data: what a commit records stays with the ledger for good. */
766
+ dimensions?: CreditDimensions | null;
767
+ }
768
+ /** A line as priced, with the terms it was priced on. */
769
+ interface CreditPricedLine {
770
+ action: string;
771
+ units: string;
772
+ unitPrice: string;
773
+ perUnits: string;
774
+ /** `ceil(units * unitPrice / perUnits)` microcredits. */
775
+ amount: string;
776
+ dimensions: CreditDimensions | null;
777
+ }
778
+ /** Price a customer's Credit Actions (all of one category) at the current Rate Card version. */
779
+ interface CreateCreditQuoteInput {
780
+ /** The customer's external id. */
781
+ customerId: string;
782
+ /** 1 to 100 lines. */
783
+ items: CreditLineItem[];
784
+ }
785
+ /** A quote: what the lines cost at the version it pins, reservable until `expiresAt` (15 minutes). */
786
+ interface CreditQuote {
787
+ id: string;
788
+ /** The customer's external id. */
789
+ customerId: string;
790
+ rateCardVersion: number;
791
+ category: string;
792
+ /** What the lines cost in all: what a reservation over the quote holds. */
793
+ amount: string;
794
+ items: CreditPricedLine[];
795
+ expiresAt: string;
796
+ createdAt: string;
797
+ }
798
+ /**
799
+ * A credit reservation's state: `held` until committed, released or expired; `protected` (paid
800
+ * for, still being fulfilled) never expires; `committed`, `released` and `expired` are final.
801
+ */
802
+ type CreditReservationStatus = "held" | "protected" | "committed" | "released" | "expired";
803
+ /** Credits held for one operation. */
804
+ interface CreditReservation {
805
+ id: string;
806
+ /** The customer's external id. */
807
+ customerId: string;
808
+ /** Your own id for the operation, unique per customer. */
809
+ operationKey: string;
810
+ category: string;
811
+ /** Microcredits held when it was made. */
812
+ amount: string;
813
+ /** Microcredits its commit consumed (the rest was released with it). */
814
+ consumed: string;
815
+ status: CreditReservationStatus;
816
+ /** The quote it was made over; null when made from items. */
817
+ quoteId: string | null;
818
+ /** The Rate Card version its commit prices at. */
819
+ rateCardVersion: number;
820
+ /** When it is released if still `held`. */
821
+ expiresAt: string;
822
+ protectedAt: string | null;
823
+ settledAt: string | null;
824
+ /**
825
+ * The commit's consumption: what `credits.consumptions.reverse` names. Null until committed, and
826
+ * for a commit that cost nothing (it consumed nothing).
827
+ */
828
+ consumptionId: string | null;
829
+ metadata: Record<string, string> | null;
830
+ createdAt: string;
831
+ }
832
+ /** What a reservation holds for and how it is identified; give `quoteId` or `items`. */
833
+ interface CreateCreditReservationBase {
834
+ /** The customer's external id. */
835
+ customerId: string;
836
+ /**
837
+ * Your own id for the operation (1-255 characters), unique per customer. Never personal data:
838
+ * erasure replaces it with `erased_<reservation id>`, a prefix you may not use.
839
+ */
840
+ operationKey: string;
841
+ /** How long the hold lasts unsettled; your project's default when omitted, up to its maximum. */
842
+ ttlSeconds?: number;
843
+ /** At most 20 keys (40 characters) and values (500 characters). Never personal data. */
844
+ metadata?: Record<string, string>;
845
+ }
846
+ /** Hold credits over a quote (its amount, at the version it pins), or over Credit Actions. */
847
+ type CreateCreditReservationInput = CreateCreditReservationBase & ({
848
+ quoteId: string;
849
+ items?: never;
850
+ } | {
851
+ /** Priced at the current version, all of one category; 1 to 100 lines. */
852
+ items: Array<{
853
+ action: string;
854
+ units: string;
855
+ }>;
856
+ quoteId?: never;
857
+ });
858
+ /** What `credits.reservations.create` answers: the reservation its idempotency key stands for. */
859
+ interface CreditReservationRequestResult extends CreditReservation {
860
+ /**
861
+ * `true` when the idempotency key was already used: this is the reservation that earlier request
862
+ * made, as it was made, and nothing new was held. `false` when this call made it.
863
+ */
864
+ replayed: boolean;
865
+ }
866
+ /** Give back part or all of what a commit consumed. */
867
+ interface ReverseCreditConsumptionInput {
868
+ /** Positive whole microcredits as a decimal string. */
869
+ amount: string;
870
+ /** Why (at most 500 characters), kept on the reversal and cleared on erasure. */
871
+ reason?: string;
872
+ /** At most 20 keys (40 characters) and values (500 characters). Never personal data. */
873
+ metadata?: Record<string, string>;
874
+ }
875
+ /** A consumption reversal. */
876
+ interface CreditReversal {
877
+ id: string;
878
+ /** The customer's external id. */
879
+ customerId: string;
880
+ consumptionId: string;
881
+ /** The `reverse` ledger transaction. */
882
+ transactionId: string;
883
+ amount: string;
884
+ /** Of `amount`, what came back to a grant past its expiry and expired again at once. */
885
+ forfeited: string;
886
+ reason: string | null;
887
+ metadata: Record<string, string> | null;
888
+ createdAt: string;
889
+ }
890
+ /** What `credits.consumptions.reverse` answers: the reversal its idempotency key stands for. */
891
+ interface CreditReversalRequestResult extends CreditReversal {
892
+ /** `true` when an earlier request under the key made it, and nothing was given back again. */
893
+ replayed: boolean;
706
894
  }
707
895
 
708
896
  /** What surface a portal session lands the Customer on. */
@@ -714,10 +902,18 @@ interface CreatePortalSessionInput {
714
902
  flow?: PortalSessionFlow;
715
903
  /** Product slug to subscribe to — required when `flow` is `checkout`. */
716
904
  productId?: string;
717
- /** Where the surface returns the Customer when they finish or exit. */
905
+ /**
906
+ * Where the surface returns the Customer when they finish or exit: an absolute `https` URL
907
+ * without credentials (and, in live, without a port other than 443). A loopback host such as
908
+ * `localhost` is also accepted over `http`, on any port, in either environment.
909
+ */
718
910
  returnUrl?: string;
719
911
  }
720
- /** The minted portal session: redirect the Customer to `url` (it carries the bearer). */
912
+ /**
913
+ * The minted portal session: redirect the Customer to `url` at once. Its token is a single-use
914
+ * entry token - Billow's hosted portal exchanges it on first open, after which the link works
915
+ * only for the browser that opened it.
916
+ */
721
917
  interface PortalSession {
722
918
  id: string;
723
919
  url: string;
@@ -725,6 +921,21 @@ interface PortalSession {
725
921
  /** ISO-8601 expiry — the session (and its URL) stop working after this. */
726
922
  expiresAt: string;
727
923
  }
924
+ /** The single-use entry exchange's input (`BillowPortal.exchange`). */
925
+ interface PortalSessionExchangeInput {
926
+ /** The `Host` the link was opened on: it must be the host the session is bound to. */
927
+ host: string;
928
+ /** The session token the browser already holds, if any: a revisit by the browser that
929
+ * exchanged the link lands on its own session, and only that browser's. */
930
+ sessionToken?: string;
931
+ }
932
+ /** What the exchange returns: the session's bearer from now on, and its unchanged expiry. */
933
+ interface PortalSessionExchange {
934
+ sessionToken: string;
935
+ flow: PortalSessionFlow;
936
+ /** ISO-8601 expiry of the session, set when it was minted. */
937
+ expiresAt: string;
938
+ }
728
939
  /**
729
940
  * The portal shell: the session's flow + return URL, the merchant's
730
941
  * customer-facing brand, and the Customer's identity. The lightweight payload a
@@ -944,41 +1155,13 @@ interface CustomerCreditsExport {
944
1155
  updatedAt: string;
945
1156
  } | null;
946
1157
  grants: CreditGrant[];
947
- reservations: Array<{
948
- id: string;
949
- /** The customer's external id. */
950
- customerId: string;
951
- operationKey: string;
952
- category: string;
953
- amount: string;
954
- consumed: string;
955
- status: "held" | "protected" | "committed" | "released" | "expired";
956
- expiresAt: string;
957
- protectedAt: string | null;
958
- settledAt: string | null;
959
- /** The commit's `consume` ledger transaction. */
960
- consumptionId: string | null;
961
- metadata: Record<string, string> | null;
962
- createdAt: string;
963
- }>;
1158
+ reservations: CreditReservation[];
964
1159
  /** Every credit top-up, as it now stands. */
965
1160
  topUps: CreditTopUp[];
966
1161
  /** Every consumption reversal, with your own reason and metadata (cleared on erasure). */
967
- reversals: Array<{
968
- id: string;
969
- /** The customer's external id. */
970
- customerId: string;
971
- /** The consumption reversed: its commit's `consume` ledger transaction. */
972
- consumptionId: string;
973
- /** The `reverse` ledger transaction. */
974
- transactionId: string;
975
- amount: string;
976
- /** Of `amount`, what came back to an expired grant and expired again at once. */
977
- forfeited: string;
978
- reason: string | null;
979
- metadata: Record<string, string> | null;
980
- createdAt: string;
981
- }>;
1162
+ reversals: CreditReversal[];
1163
+ /** Every quote made for the customer (even with no credit account), with its priced lines. */
1164
+ quotes: CreditQuote[];
982
1165
  /** Every ledger transaction, in the order it was written, with its postings. */
983
1166
  ledger: Array<{
984
1167
  id: string;
@@ -1268,11 +1451,14 @@ declare function createCreditsResource(ctx: RequestContext): {
1268
1451
  * checkout to send the buyer to. Credits are granted when the payment succeeds (listen for
1269
1452
  * `credit_top_up.succeeded`). The `idempotencyKey` is required and must identify this one
1270
1453
  * purchase: a retry under it answers the same top-up as it now stands (`replayed: true`) and
1271
- * buys nothing again; reusing it for another purchase throws `idempotency_conflict` (409).
1272
- * A retry can also throw `conflict` (409), with `details.reason`: `checkout_in_progress` -
1273
- * the first request is still opening the checkout, so retry the same key shortly - or
1274
- * `checkout_unavailable` - its checkout could not be opened and never will be, so buy again
1275
- * under a new key.
1454
+ * buys nothing again - asking the payment provider again for a checkout the first attempt
1455
+ * could not open, within its page's 40 minutes (Stripe only in the first 10, while 30
1456
+ * remain: it answers a timed-out first attempt with the checkout it made, or makes one never
1457
+ * made; Paymob only if the first attempt never made one); reusing it for another purchase
1458
+ * throws `idempotency_conflict` (409). A retry can also throw `conflict` (409), with
1459
+ * `details.reason`: `checkout_in_progress` - another request is still opening the
1460
+ * checkout, so retry the same key shortly - or `checkout_unavailable` - its checkout could
1461
+ * not be opened and never will be, so buy again under a new key.
1276
1462
  */
1277
1463
  create: (input: CreateCreditTopUpInput, options: IdempotentRequestOptions) => Promise<CreditTopUpRequestResult>;
1278
1464
  /** A top-up as it now stands: status, checkout, grants, and what refunds revoked. */
@@ -1307,6 +1493,80 @@ declare function createCreditsResource(ctx: RequestContext): {
1307
1493
  */
1308
1494
  get: (customer: string, params?: CreditUsageParams, options?: CallOptions) => Promise<CreditUsage>;
1309
1495
  };
1496
+ rateCards: {
1497
+ /**
1498
+ * Publish a new Rate Card version: what each Credit Action costs, as
1499
+ * `ceil(units * unitPrice / perUnits)` microcredits a line. Versions are immutable - a price
1500
+ * change is a new version - and take effect in order, at `effectiveAt` (now when omitted).
1501
+ */
1502
+ publish: (input: PublishCreditRateCardInput, options?: CallOptions) => Promise<CreditRateCard>;
1503
+ /** The version in effect now (`not_found` before the first takes effect). */
1504
+ current: (options?: CallOptions) => Promise<CreditRateCard>;
1505
+ /** One version, by its number. */
1506
+ get: (version: number, options?: CallOptions) => Promise<CreditRateCard>;
1507
+ /**
1508
+ * The published versions, newest first. Auto-paginating by cursor: `await` the first page,
1509
+ * `for await (…)` every version, or `.listAll()` to collect them.
1510
+ */
1511
+ list: (params?: CursorListParams, options?: CallOptions) => CursorListPromise<CreditRateCard>;
1512
+ };
1513
+ quotes: {
1514
+ /**
1515
+ * Price a customer's Credit Actions (all of one category) at the current Rate Card version
1516
+ * and keep the price for 15 minutes: a reservation over the quote holds exactly its
1517
+ * `amount`, and its commit prices at the version the quote pinned. A quote holds nothing.
1518
+ */
1519
+ create: (input: CreateCreditQuoteInput, options?: CallOptions) => Promise<CreditQuote>;
1520
+ /** A quote as it was made. */
1521
+ get: (quoteId: string, options?: CallOptions) => Promise<CreditQuote>;
1522
+ };
1523
+ reservations: {
1524
+ /**
1525
+ * Hold credits for one operation: over a `quoteId`, or over `items` priced at the current
1526
+ * Rate Card version. The `idempotencyKey` is required: a retry under it - after a lost
1527
+ * reply, even once the quote expired - answers the same reservation (`replayed: true`) and
1528
+ * holds nothing again. Reusing it for another request, or a new key with an `operationKey`
1529
+ * the customer already used (`details.reason: "operation_key_used"`), throws
1530
+ * `idempotency_conflict` (409). Throws `insufficient_credits` (402), `account_frozen`
1531
+ * (423), `account_closed` (409), `conflict` (409, `details.reason: "quote_expired"`), or
1532
+ * `validation_error` (422) - e.g. `details.reason: "zero_amount"` when the items cost nothing.
1533
+ * The `operationKey` is an operation id, never personal data: erasure replaces it.
1534
+ */
1535
+ create: (input: CreateCreditReservationInput, options: IdempotentRequestOptions) => Promise<CreditReservationRequestResult>;
1536
+ /** A reservation as it now stands. */
1537
+ get: (reservationId: string, options?: CallOptions) => Promise<CreditReservation>;
1538
+ /**
1539
+ * A customer's reservation (by external id) made with `operationKey` - how to find one whose
1540
+ * reply was lost. Throws `not_found` (404) when there is none.
1541
+ */
1542
+ findByOperationKey: (customer: string, operationKey: string, options?: CallOptions) => Promise<CreditReservation>;
1543
+ /**
1544
+ * Commit what the operation used: lines priced at the reservation's Rate Card version,
1545
+ * consuming at most what it holds (`commit_exceeds_hold`, 409) and releasing the rest; lines
1546
+ * that cost nothing in all consume nothing (`consumed: "0"`, `consumptionId: null`). The
1547
+ * same commit again answers it again, so it is safe to retry; anything else after it throws
1548
+ * `invalid_state_transition` (409) with the reservation in `details` - with
1549
+ * `details.reason: "reservation_expired"` once the hold is past its `expiresAt`.
1550
+ */
1551
+ commit: (reservationId: string, items: CreditLineItem[], options?: CallOptions) => Promise<CreditReservation>;
1552
+ /** Release the whole hold. Safe to retry; after a commit it throws (409). */
1553
+ release: (reservationId: string, options?: CallOptions) => Promise<CreditReservation>;
1554
+ /**
1555
+ * Protect a held reservation whose operation was paid for and is still being fulfilled: it
1556
+ * never expires (commit or release it when done). Safe to retry. A hold already past its
1557
+ * `expiresAt` throws `invalid_state_transition` (409, `details.reason: "reservation_expired"`).
1558
+ */
1559
+ protect: (reservationId: string, options?: CallOptions) => Promise<CreditReservation>;
1560
+ };
1561
+ consumptions: {
1562
+ /**
1563
+ * Give back part or all of a commit's consumption (`consumptionId` on the committed
1564
+ * reservation), never more than is left (`reversal_exceeds_consumption`, 409). The
1565
+ * `idempotencyKey` is required: a retry under it answers the same reversal
1566
+ * (`replayed: true`) and gives nothing back again.
1567
+ */
1568
+ reverse: (consumptionId: string, input: ReverseCreditConsumptionInput, options: IdempotentRequestOptions) => Promise<CreditReversalRequestResult>;
1569
+ };
1310
1570
  };
1311
1571
 
1312
1572
  declare function createCustomersResource(ctx: RequestContext): {
@@ -1376,6 +1636,272 @@ declare function createDeliverabilityResource(ctx: RequestContext): {
1376
1636
  inbound: (params?: InboundWebhookListParams, options?: CallOptions) => ListPromise<InboundWebhookListItem>;
1377
1637
  };
1378
1638
 
1639
+ /**
1640
+ * Custom domains for the hosted customer portal (live keys only, behind a per-Project rollout
1641
+ * flag). Add a hostname, create the two DNS records it answers, and Billow verifies them.
1642
+ */
1643
+ declare function createHostedDomainsResource(ctx: RequestContext): {
1644
+ /** The Project's domains, and whether its plan allows adding more (`whiteLabel`). */
1645
+ list: (options?: CallOptions) => Promise<{
1646
+ data: {
1647
+ id: string;
1648
+ hostname: string;
1649
+ hostnameUnicode: string;
1650
+ environment: "live";
1651
+ status: "failed" | "active" | "pending_verification" | "verified" | "disabled";
1652
+ statusReason: "verification_expired" | "tls_unavailable" | "edge_blocked" | "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended" | null;
1653
+ isPrimary: boolean;
1654
+ records: {
1655
+ type: "TXT" | "CNAME";
1656
+ name: string;
1657
+ value: string;
1658
+ }[];
1659
+ dns: {
1660
+ checkedAt: string | null;
1661
+ failingSince: string | null;
1662
+ graceEndsAt: string | null;
1663
+ txt: {
1664
+ status: "found" | "missing" | "inconclusive" | null;
1665
+ values: string[];
1666
+ };
1667
+ cname: {
1668
+ status: "found" | "missing" | "inconclusive" | "wrong" | null;
1669
+ chain: string[];
1670
+ };
1671
+ };
1672
+ edge: {
1673
+ status: string | null;
1674
+ sslStatus: string | null;
1675
+ errors: string[];
1676
+ certificateExpiresAt: string | null;
1677
+ checkedAt: string | null;
1678
+ };
1679
+ reassignment: {
1680
+ role: "owner" | "claimant";
1681
+ dueAt: string;
1682
+ } | null;
1683
+ entitlementLapse: {
1684
+ lapsedAt: string;
1685
+ servingEndsAt: string;
1686
+ disablesAt: string;
1687
+ } | null;
1688
+ verificationExpiresAt: string | null;
1689
+ verifiedAt: string | null;
1690
+ activatedAt: string | null;
1691
+ createdAt: string;
1692
+ updatedAt: string;
1693
+ }[];
1694
+ whiteLabel: {
1695
+ entitled: boolean;
1696
+ requiredPlan: string;
1697
+ };
1698
+ }>;
1699
+ /**
1700
+ * Add a subdomain such as `billing.example.com`. Answers the domain with the TXT and CNAME
1701
+ * `records` to create. Needs a plan with white-label branding (`permission_denied` otherwise).
1702
+ */
1703
+ create: (input: CreateHostedDomainInput, options?: CallOptions) => Promise<{
1704
+ id: string;
1705
+ hostname: string;
1706
+ hostnameUnicode: string;
1707
+ environment: "live";
1708
+ status: "failed" | "active" | "pending_verification" | "verified" | "disabled";
1709
+ statusReason: "verification_expired" | "tls_unavailable" | "edge_blocked" | "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended" | null;
1710
+ isPrimary: boolean;
1711
+ records: {
1712
+ type: "TXT" | "CNAME";
1713
+ name: string;
1714
+ value: string;
1715
+ }[];
1716
+ dns: {
1717
+ checkedAt: string | null;
1718
+ failingSince: string | null;
1719
+ graceEndsAt: string | null;
1720
+ txt: {
1721
+ status: "found" | "missing" | "inconclusive" | null;
1722
+ values: string[];
1723
+ };
1724
+ cname: {
1725
+ status: "found" | "missing" | "inconclusive" | "wrong" | null;
1726
+ chain: string[];
1727
+ };
1728
+ };
1729
+ edge: {
1730
+ status: string | null;
1731
+ sslStatus: string | null;
1732
+ errors: string[];
1733
+ certificateExpiresAt: string | null;
1734
+ checkedAt: string | null;
1735
+ };
1736
+ reassignment: {
1737
+ role: "owner" | "claimant";
1738
+ dueAt: string;
1739
+ } | null;
1740
+ entitlementLapse: {
1741
+ lapsedAt: string;
1742
+ servingEndsAt: string;
1743
+ disablesAt: string;
1744
+ } | null;
1745
+ verificationExpiresAt: string | null;
1746
+ verifiedAt: string | null;
1747
+ activatedAt: string | null;
1748
+ createdAt: string;
1749
+ updatedAt: string;
1750
+ }>;
1751
+ get: (id: string, options?: CallOptions) => Promise<{
1752
+ id: string;
1753
+ hostname: string;
1754
+ hostnameUnicode: string;
1755
+ environment: "live";
1756
+ status: "failed" | "active" | "pending_verification" | "verified" | "disabled";
1757
+ statusReason: "verification_expired" | "tls_unavailable" | "edge_blocked" | "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended" | null;
1758
+ isPrimary: boolean;
1759
+ records: {
1760
+ type: "TXT" | "CNAME";
1761
+ name: string;
1762
+ value: string;
1763
+ }[];
1764
+ dns: {
1765
+ checkedAt: string | null;
1766
+ failingSince: string | null;
1767
+ graceEndsAt: string | null;
1768
+ txt: {
1769
+ status: "found" | "missing" | "inconclusive" | null;
1770
+ values: string[];
1771
+ };
1772
+ cname: {
1773
+ status: "found" | "missing" | "inconclusive" | "wrong" | null;
1774
+ chain: string[];
1775
+ };
1776
+ };
1777
+ edge: {
1778
+ status: string | null;
1779
+ sslStatus: string | null;
1780
+ errors: string[];
1781
+ certificateExpiresAt: string | null;
1782
+ checkedAt: string | null;
1783
+ };
1784
+ reassignment: {
1785
+ role: "owner" | "claimant";
1786
+ dueAt: string;
1787
+ } | null;
1788
+ entitlementLapse: {
1789
+ lapsedAt: string;
1790
+ servingEndsAt: string;
1791
+ disablesAt: string;
1792
+ } | null;
1793
+ verificationExpiresAt: string | null;
1794
+ verifiedAt: string | null;
1795
+ activatedAt: string | null;
1796
+ createdAt: string;
1797
+ updatedAt: string;
1798
+ }>;
1799
+ /** Check the DNS records now (2 per minute per domain); answers the refreshed domain. */
1800
+ verify: (id: string, options?: CallOptions) => Promise<{
1801
+ id: string;
1802
+ hostname: string;
1803
+ hostnameUnicode: string;
1804
+ environment: "live";
1805
+ status: "failed" | "active" | "pending_verification" | "verified" | "disabled";
1806
+ statusReason: "verification_expired" | "tls_unavailable" | "edge_blocked" | "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended" | null;
1807
+ isPrimary: boolean;
1808
+ records: {
1809
+ type: "TXT" | "CNAME";
1810
+ name: string;
1811
+ value: string;
1812
+ }[];
1813
+ dns: {
1814
+ checkedAt: string | null;
1815
+ failingSince: string | null;
1816
+ graceEndsAt: string | null;
1817
+ txt: {
1818
+ status: "found" | "missing" | "inconclusive" | null;
1819
+ values: string[];
1820
+ };
1821
+ cname: {
1822
+ status: "found" | "missing" | "inconclusive" | "wrong" | null;
1823
+ chain: string[];
1824
+ };
1825
+ };
1826
+ edge: {
1827
+ status: string | null;
1828
+ sslStatus: string | null;
1829
+ errors: string[];
1830
+ certificateExpiresAt: string | null;
1831
+ checkedAt: string | null;
1832
+ };
1833
+ reassignment: {
1834
+ role: "owner" | "claimant";
1835
+ dueAt: string;
1836
+ } | null;
1837
+ entitlementLapse: {
1838
+ lapsedAt: string;
1839
+ servingEndsAt: string;
1840
+ disablesAt: string;
1841
+ } | null;
1842
+ verificationExpiresAt: string | null;
1843
+ verifiedAt: string | null;
1844
+ activatedAt: string | null;
1845
+ createdAt: string;
1846
+ updatedAt: string;
1847
+ }>;
1848
+ /** Make an active domain the default host for new portal sessions. */
1849
+ makePrimary: (id: string, options?: CallOptions) => Promise<{
1850
+ id: string;
1851
+ hostname: string;
1852
+ hostnameUnicode: string;
1853
+ environment: "live";
1854
+ status: "failed" | "active" | "pending_verification" | "verified" | "disabled";
1855
+ statusReason: "verification_expired" | "tls_unavailable" | "edge_blocked" | "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended" | null;
1856
+ isPrimary: boolean;
1857
+ records: {
1858
+ type: "TXT" | "CNAME";
1859
+ name: string;
1860
+ value: string;
1861
+ }[];
1862
+ dns: {
1863
+ checkedAt: string | null;
1864
+ failingSince: string | null;
1865
+ graceEndsAt: string | null;
1866
+ txt: {
1867
+ status: "found" | "missing" | "inconclusive" | null;
1868
+ values: string[];
1869
+ };
1870
+ cname: {
1871
+ status: "found" | "missing" | "inconclusive" | "wrong" | null;
1872
+ chain: string[];
1873
+ };
1874
+ };
1875
+ edge: {
1876
+ status: string | null;
1877
+ sslStatus: string | null;
1878
+ errors: string[];
1879
+ certificateExpiresAt: string | null;
1880
+ checkedAt: string | null;
1881
+ };
1882
+ reassignment: {
1883
+ role: "owner" | "claimant";
1884
+ dueAt: string;
1885
+ } | null;
1886
+ entitlementLapse: {
1887
+ lapsedAt: string;
1888
+ servingEndsAt: string;
1889
+ disablesAt: string;
1890
+ } | null;
1891
+ verificationExpiresAt: string | null;
1892
+ verifiedAt: string | null;
1893
+ activatedAt: string | null;
1894
+ createdAt: string;
1895
+ updatedAt: string;
1896
+ }>;
1897
+ /** Remove a domain; the portal sessions on it end immediately. */
1898
+ remove: (id: string, options?: CallOptions) => Promise<{
1899
+ id: string;
1900
+ hostname: string;
1901
+ removed: true;
1902
+ }>;
1903
+ };
1904
+
1379
1905
  declare function createInvoicesResource(ctx: RequestContext): {
1380
1906
  /** List invoices. Filters: status, customer (external id), from, to. Auto-paginating. */
1381
1907
  list: (params?: InvoiceListParams, options?: CallOptions) => ListPromise<InvoiceListItem>;
@@ -2066,6 +2592,8 @@ declare class Billow {
2066
2592
  portalSessions: ReturnType<typeof createPortalSessionsResource>;
2067
2593
  deliverability: ReturnType<typeof createDeliverabilityResource>;
2068
2594
  marketplace: ReturnType<typeof createMarketplaceResource>;
2595
+ /** Custom domains for the hosted customer portal (live keys, behind a rollout flag). */
2596
+ hostedDomains: ReturnType<typeof createHostedDomainsResource>;
2069
2597
  /**
2070
2598
  * Organization settings (Phase D3, F) — the configurable dunning schedule, usage settlement grace,
2071
2599
  * and the cross-currency reporting currency + FX-rate registry (ADR-0013).
@@ -2298,6 +2826,13 @@ declare class BillowPortal {
2298
2826
  * the lightweight payload the hosting app frames every page with, and the
2299
2827
  * validate-and-route check at login. */
2300
2828
  session(options?: CallOptions): Promise<PortalSessionInfo>;
2829
+ /**
2830
+ * The single-use entry exchange (ADR-0039): on a client built with a minted link's entry
2831
+ * token, trade it for the session token to use from now on. Succeeds once per link, and
2832
+ * afterwards only for the browser presenting that exchange's `sessionToken`; anything else is
2833
+ * a 401. For a hosted surface; an integrator's own surface may keep using the entry token.
2834
+ */
2835
+ exchange(input: PortalSessionExchangeInput, options?: CallOptions): Promise<PortalSessionExchange>;
2301
2836
  /** The self-serve home payload: identity + subscriptions + usage + saved cards. */
2302
2837
  me(options?: CallOptions): Promise<PortalView>;
2303
2838
  invoices: {
@@ -2305,6 +2840,8 @@ declare class BillowPortal {
2305
2840
  list: (params?: ListParams & {
2306
2841
  status?: InvoiceListItem["status"];
2307
2842
  }, options?: CallOptions) => ListPromise<InvoiceListItem>;
2843
+ /** One of the Customer's invoices, in the list's shape. */
2844
+ get: (id: string, options?: CallOptions) => Promise<InvoiceListItem>;
2308
2845
  /** Open or resume checkout for this customer's outstanding invoice. */
2309
2846
  pay: (id: string, input?: PayInvoiceInput, options?: CallOptions) => Promise<{
2310
2847
  invoiceId: string;
@@ -2376,4 +2913,4 @@ declare class BillowPortal {
2376
2913
  };
2377
2914
  }
2378
2915
 
2379
- export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditPackInput, CreateCreditTopUpInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, CreditGrant, CreditGrantRequestResult, CreditLedgerEntry, CreditPack, CreditPacks, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };
2916
+ export { AttachResult, BILLOW_ERROR_CODES, Billow, BillowApiError, type BillowErrorCode, BillowOptions, BillowPortal, BillowPublishable, type BusinessProfile, CallOptions, type CatalogItem, Charge, type ChargeListItem, type ChargeListParams, type ChargeSearchHit, ChargeStatus, CheckResult, type CheckoutMethodInfo, type ConfigField, type ConfigFieldOption, type ConfigFieldType, Coupon, CreateChargeInput, CreateCouponInput, CreateCreditGrantInput, CreateCreditPackInput, type CreateCreditQuoteInput, type CreateCreditReservationInput, CreateCreditTopUpInput, CreateHostedDomainInput, CreateMerchantInitiatedChargeInput, type CreatePortalSessionInput, CreateProductInput, CreateSubscriptionInput, CreateUsageAlertInput, type CreateWebhookEndpointInput, type CredentialSet, CreditBalance, type CreditDimensions, CreditGrant, CreditGrantRequestResult, CreditLedgerEntry, type CreditLineItem, CreditPack, CreditPacks, type CreditPricedLine, type CreditQuote, type CreditRateCard, type CreditRateCardItem, type CreditReservation, type CreditReservationRequestResult, type CreditReservationStatus, type CreditReversal, type CreditReversalRequestResult, CreditThresholdLevel, CreditTopUp, CreditTopUpListParams, CreditTopUpRequestResult, CreditUsage, CreditUsageParams, type CursorListParams, type CursorListPromise, type CursorPaginated, Customer, type CustomerAnonymizationResult, type CustomerCreditsExport, type CustomerDataExport, type CustomerListItem, type CustomerListParams, type CustomerOverview, type CustomerSearchHit, type CustomerUsage, type CustomerUsageDetail, type EmailDeliveryListItem, type EmailDeliveryListParams, type EmailDeliveryStatus, type EmailTemplateSetting, EntitlementView, type ExchangeRate, type ExportJsonValue, type ExternalPaymentMethod, type ExternalPaymentResult, Feature, FeatureKind, IdempotentRequestOptions, type InboundWebhookListItem, type InboundWebhookListParams, type InboundWebhookOutcome, type IntegrationDefinition, type IntegrationKind, type IntegrationTier, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListItem, type InvoiceListParams, type InvoiceSearchHit, InvoiceStatus, type ListParams, type ListPromise, MeterConfig, type MetricsOverview, type MetricsParams, type MetricsRollup, MigrationResult, type OutboxEventListItem, type OutboxEventListParams, type OutboxEventStatus, type Paginated, PayInvoiceInput, type PaymentMethod, PaymentMethodStatus, type PaymentProviderDefinition, type PortalCardSetupResult, type PortalCheckout, type PortalPlanChange, type PortalSession, type PortalSessionExchange, type PortalSessionExchangeInput, type PortalSessionFlow, type PortalSessionInfo, type PortalSubscriptionStatus, type PortalView, type ProviderCredentialSummary, type ProviderVerifyResult, type ProviderVerifyTarget, type ProviderVerifyTargetResult, type PublishCreditRateCardInput, type RecordExternalPaymentInput, type Refund, type RefundChargeInput, type RefundRequestResult, type RefundReviewReason, RefundStatus, RequestOptions, type ResolveRefundInput, type ReverseCreditConsumptionInput, SavedPaymentMethod, type ScheduledSubscriptionChange, type SearchResults, type SubscriptionListItem, type SubscriptionListParams, type SubscriptionSearchHit, SubscriptionStatus, TaxBehavior, type TimeseriesInterval, type TimeseriesMetric, type TimeseriesParams, type TimeseriesPoint, type TimeseriesResult, TrackResult, UnappliedPaymentReason, type UpdateBusinessProfileInput, UpdateCreditPackInput, type UpdateEmailTemplateInput, UpdateFeatureInput, UpdateProductInput, type UpdateWebhookEndpointInput, type UpsertCredentialsInput, UsageAlert, type WebhookDelivery, WebhookDeliveryStatus, type WebhookEndpoint, type WebhookEndpointWithSecret, type Whoami, currencyExponent, formatMoney, isSecretField, toMajorUnits, toMinorUnits };