python - v0.31.0 - 2026-03-27 09:23:19
polar-sdk 0.31.0 — Breaking Changes
Customer Type Discrimination
Customer, CustomerCreate, and CustomerState are now discriminated unions based on a type field ("individual" or "team"), instead of single flat models.
Migration Guide
Model replacements
| Before | After |
|---|---|
Customer(...) |
CustomerIndividual(...) or CustomerTeam(...) |
CustomerCreate(...) |
CustomerIndividualCreate(...) or CustomerTeamCreate(...) |
CustomerState(...) |
CustomerStateIndividual(...) or CustomerStateTeam(...) |
Type checking
isinstance(x, Customer) no longer works — Customer is now a Union type alias, not a class. Use the type field to discriminate:
# Before
if isinstance(customer, Customer):
...
# After
if customer.type == "individual":
# customer is CustomerIndividual
...
elif customer.type == "team":
# customer is CustomerTeam
...Field changes
emailis now optional/nullable onOrderCustomer,SubscriptionCustomer,LicenseKeyCustomer,CustomerPortalCustomertypeis now required onOrderCustomer,SubscriptionCustomer,LicenseKeyCustomer
Removed exports (replaced by individual/team variants)
| Removed | Replaced by |
|---|---|
OwnerCreate |
MemberOwnerCreate |
CustomerTaxID |
CustomerIndividualTaxID / CustomerTeamTaxID |
CustomerStateTaxID |
CustomerStateIndividualTaxID / CustomerStateTeamTaxID |
CustomerCreateMetadata |
CustomerIndividualCreateMetadata / CustomerTeamCreateMetadata |
ListResourceCustomer |
Inline union type |
Webhook payloads affected
All customer-related webhook events (customer_created, customer_updated, customer_deleted, customer_state_changed) and any webhook carrying a customer field (orders, subscriptions, benefit grants) now use the discriminated union types.