Subscriptions
The subscription object
A subscription bills a customer for recurring prices every period, in advance. Paycose either runs the billing schedule itself and creates each period's invoice, or, when the subscription is routed to a provider that bills on its own side (such as Stripe), keeps this object in step with the provider's subscription and invoices.
Attributes
idstringRequiredUnique identifier for the object.
objectstringRequiredString naming the object's type.
livemodebooleanRequiredtruewhen the object exists in live mode,falsein test mode.createdtimestampRequiredTime the object was created, in Unix seconds.
updatedtimestampRequiredTime the object last changed, in Unix seconds.
numberstringRequiredSequential subscription number assigned when the subscription is created, for display on documents.
customer_idstringRequiredID of the customer being billed. Empty for a guest subscription created without a customer.
default_payment_method_idstringRequiredID of the saved payment method charged for each period. Empty when none is set, for example on a
send_invoicesubscription or one created withpayment_behavior=default_incompletebefore its first payment.customer_namestringRequiredCustomer name copied onto the subscription when it was created, falling back to the billing details collected at checkout.
customer_emailstringRequiredCustomer email copied onto the subscription when it was created, falling back to the billing details collected at checkout.
customer_phonestringRequiredCustomer phone number copied onto the subscription when it was created, falling back to the billing details collected at checkout.
billing_detailsobjectNullableBilling details the payer entered when the subscription was started from a checkout session. Absent for subscriptions created through the API.
Show child attributes
billing_details.namestringPayer's name, up to 255 characters. Omitted when not given.
Max length 255
billing_details.emailstringPayer's email address. Omitted when not given.
Max length 254 · Format
emailbilling_details.phonestringPayer's phone number, up to 64 characters. Omitted when not given.
Max length 64
billing_details.addressobjectNullablePayer's billing address. Omitted when not given.
Show child attributes
billing_details.address.line1stringFirst line of the address, such as street and house number. Up to 255 characters.
Max length 255
billing_details.address.line2stringSecond line of the address, such as building or unit. Up to 255 characters.
Max length 255
billing_details.address.citystringCity or district. Up to 255 characters.
Max length 255
billing_details.address.statestringState, province or region. Up to 255 characters.
Max length 255
billing_details.address.postal_codestringPostal code. Up to 32 characters.
Max length 32
billing_details.address.countrystringTwo-letter ISO 3166-1 country code, in uppercase.
Pattern
^[A-Z]{2}$
billing_details.business_namestringName of the payer's business, up to 255 characters. Omitted when not given.
Max length 255
billing_details.tax_idobjectNullablePayer's tax ID. Omitted when not given.
Show child attributes
billing_details.tax_id.typestringRequiredType of the tax ID, as a tax ID type code from
GET /tax_id_types. Up to 64 characters.Max length 64
billing_details.tax_id.valuestringRequiredThe tax ID number. Up to 255 characters; checked against the type's format.
Max length 255
line_itemsarray of objectsRequiredThe recurring items billed every period, followed by any fee lines added through
default_fees.Show child attributes
line_items.idstringRequiredUnique identifier for the object.
line_items.objectstringRequiredString naming the object's type,
line_item.line_items.product_idstringRequiredID of the product billed on this line. Empty on fee lines.
line_items.product_price_idstringRequiredID of the price billed on this line. Empty on fee lines.
line_items.sort_orderintegerRequiredPosition of the line on the subscription, starting at
0.line_items.typestringRequiredKind of line:
productfor a price you subscribed the customer to,feefor a fee line.productA price you subscribed the customer to.
feeA fee line added through
default_fees. Itsmetadatacarries the fee'sfee_idandfee_name.
line_items.descriptionstringRequiredText shown for the line, normally the product name.
line_items.product_namestringRequiredName of the product when the line was added, or the fee's name on a fee line.
line_items.product_descriptionstringRequiredDescription of the product when the line was added.
line_items.product_imagestringRequiredURL of the product's image when the line was added. Empty when the product has none.
line_items.product_typestringRequiredproducton product lines andfeeon fee lines.productA product line.
feeA fee line.
line_items.unit_amountintegerRequiredPrice of one unit for one period, in the smallest currency unit.
line_items.quantityintegerNumber of units billed each period. Absent on a metered line, which bills the usage reported during the period, as on a Stripe subscription item for a metered price; the upcoming invoice shows that usage.
line_items.amount_discountintegerRequiredDiscount applied to this line, in the smallest currency unit.
line_items.amount_subtotalintegerRequiredunit_amountmultiplied byquantity, before discount and tax, in the smallest currency unit.line_items.amount_taxintegerRequiredTax on this line, in the smallest currency unit. Inclusive tax is counted here but is already part of
amount_subtotal.line_items.amount_totalintegerRequiredAmount of the line after discount, with exclusive tax added, in the smallest currency unit (for example,
49900is 499.00 THB).line_items.currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
line_items.discountablebooleanRequiredtruewhen a coupon may discount this line.line_items.prorationbooleanRequiredtruewhen the line is a proration. Lines stored on a subscription are not prorations.line_items.period_starttimestampRequiredNullableStart of the period this line currently covers, in Unix seconds. Set from the provider for a provider-billed subscription and on usage-based lines when retrieved; otherwise null.
line_items.period_endtimestampRequiredNullableEnd of the period this line currently covers, in Unix seconds. Set from the provider for a provider-billed subscription and on usage-based lines when retrieved; otherwise null.
line_items.reference_idstringRequiredThe provider's ID for this line (for example a Stripe subscription item ID) when the provider bills the subscription. Empty when Paycose bills it.
line_items.metadataobjectRequiredKey-value pairs you attach to the object for your own use. Paycose never reads or changes them.
line_items.taxesarray of objectsRequiredThe tax rates applied to this line and the tax each one adds.
Show child attributes
line_items.taxes.idstringRequiredUnique identifier for the object.
line_items.taxes.tax_rate_idstringRequiredID of the tax rate applied.
line_items.taxes.taxable_amountintegerRequiredAmount the rate was applied to, in the smallest currency unit. For an inclusive rate this is the line amount with the tax taken out.
line_items.taxes.tax_amountintegerRequiredTax this rate adds to the line, in the smallest currency unit.
line_items.taxes.inclusivebooleanRequiredtruewhen the tax is already included in the line amount,falsewhen it is added on top.
discountsarray of objectsRequiredThe coupon applied to the subscription, as a list of at most one discount. Empty when no coupon is applied or the coupon's duration has run out.
Show child attributes
discounts.reference_idstringThe provider's ID for this discount when the provider bills the subscription. Absent when Paycose bills it.
discounts.coupon_idstringRequiredID of the coupon applied.
discounts.promotion_code_idstringRequiredID of the promotion code the coupon was applied through. Empty when the coupon was applied directly.
discounts.namestringRequiredName of the coupon.
discounts.amountintegerRequiredDiscount the coupon takes off one period, in the smallest currency unit.
discounts.durationstringHow long the coupon applies. Absent only on discounts recorded before durations were stored.
foreverThe coupon applies to every invoice.
onceThe coupon applies to the first invoice only, then is removed.
repeatingThe coupon applies for
duration_in_monthsmonths fromstarted_at, then is removed.
discounts.duration_in_monthsintegerNumber of months a
repeatingcoupon applies. Absent for other durations.discounts.percentagenumberPercentage the coupon takes off the discountable lines, e.g.
10for 10%. Absent for a fixed-amount coupon.discounts.fixed_amountintegerAmount the coupon takes off, in the smallest currency unit. Absent for a percentage coupon.
discounts.currencystringCurrency of
fixed_amount, in lowercase. Absent for a percentage coupon.discounts.started_attimestampNullableTime the discount started, in Unix seconds.
discounts.ends_attimestampNullableTime a
repeatingdiscount stops applying, in Unix seconds. Absent for other durations.discounts.applied_countintegerNumber of invoices the discount has been applied to so far. Absent until it has been applied once.
discounts.applies_to_productsarray of strings
subtotalintegerRequiredSum of the line items' amounts before discount and tax for one period, in the smallest currency unit.
taxintegerRequiredTotal tax on the line items for one period, in the smallest currency unit. Inclusive tax is counted here but is already part of the line amounts.
totalintegerRequiredAmount one period costs after discount, with exclusive tax added, in the smallest currency unit (for example,
49900is 499.00 THB).amount_discountintegerRequiredDiscount the current coupon takes off one period, in the smallest currency unit.
amount_dueintegerRequiredAmount the latest invoice asks for, in the smallest currency unit; also updated when the line items change.
0until the subscription's first invoice exists.amount_paidintegerRequiredAmount paid on the latest invoice, in the smallest currency unit, whichever provider bills the subscription.
currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
scaling_factorintegerRequiredNumber of smallest currency units in one unit of
currency(10 to the power of the currency's decimal places), e.g.100for THB. Divide an amount by it to get the value in major units.transfer_dataobjectRequiredNullableWhere the money collected by each period invoice settles: a
destinationand, optionally, abalance_id. Null when the subscription settles to your own balance.Show child attributes
transfer_data.destinationstringRequiredID of the connected account (
acct_…) the document is for.transfer_data.balance_idstringRequiredID of the balance the document's payments are booked to.
transfer_data.connectedbooleanRequiredTrue when the destination is a connected account paid under Connect: what you owe it and your application fee are recorded on your ledger. False for a legacy destination.
statusenumRequiredWhere the subscription is in its lifecycle. For a provider-billed subscription the status follows the provider's. A subscription whose collection is paused stays
activeand carriespause_collection.incompleteThe first payment has not succeeded yet. A new subscription Paycose bills with
charge_automaticallystarts here, as does one created withpayment_behavior=default_incomplete. It becomesactivewhen the first invoice is paid, or at once when that invoice has nothing to collect.incomplete_expiredThe first invoice was not paid within 23 hours, or the checkout session that created the subscription expired first, so the subscription expired and its open first invoice was voided. Final.
trialingIn a trial period. The first invoice is billed when the trial ends.
activeRunning and in good standing.
past_dueThe latest renewal payment failed or needs the customer to authenticate, or a
send_invoiceinvoice passed its due date unpaid. Anactiveortrialingsubscription can move here. It returns toactivewhen its latest invoice is paid.unpaidEvery payment retry for an invoice failed; only a
past_duesubscription moves here. The invoice stays open and can still be paid; renewal invoices are created but not collected automatically.pausedThe provider paused the subscription itself, for example when a trial ended without a payment method. No invoices are created until it is resumed. A subscription whose collection you paused reads
activewithpause_collection.canceledThe subscription has ended. Final; create a new subscription to bill the customer again.
providerstringRequiredName of the payment provider the subscription is routed to, e.g.
stripe. When that provider bills on its own side, it creates the invoices; otherwise Paycose runs the billing schedule and charges through it.reference_idstringRequiredThe provider's ID for this subscription (for example a Stripe
sub_ID) when the provider bills it. Empty when Paycose bills it.provider_connection_idstringID of the provider account the subscription lives on, for a provider-billed subscription. Returned by retrieve and list only; absent when Paycose bills the subscription.
provider_connection_statusstringState of the provider account in
provider_connection_id, so you can spot a subscription left on an account that was replaced. Returned withprovider_connection_id; absent when that account's state could not be read.stagedThe provider account is set up but not in use yet.
activeThe provider account is in use.
retiredThe provider account was replaced and no longer takes new payments.
purgedThe provider account's credentials were removed.
missingThe provider account no longer exists.
collection_methodenumRequiredHow each period invoice is paid:
charge_automaticallycharges the default payment method,send_invoicesends the invoice for the customer to pay.charge_automaticallyEach invoice is charged to the default payment method.
send_invoiceEach invoice is sent to the customer, who pays it by its due date.
payment_method_typesarray of stringsPayment method types the payer may use to pay this subscription's invoices. Absent when there is no restriction.
payment_method_providersarray of stringsPayment providers that may process payments for this subscription's invoices. Absent when there is no restriction.
auto_advancebooleanRequiredThe
auto_advancevalue sent when the subscription was created or last updated. Renewal invoices that Paycose bills are finalized and collected automatically regardless, except while the subscription isunpaid.due_datetimestampRequiredNullableFixed due date sent with a
send_invoicesubscription, in Unix seconds. It applies to the first invoice only; later invoices fall duedays_until_duedays after they are finalized. Null when not set.days_until_dueintegerRequiredNullableNumber of days a
send_invoicesubscription gives the customer to pay each invoice.30unless you set it or adue_date; null forcharge_automaticallysubscriptions.descriptionstringRequiredYour description of the subscription, up to 500 characters.
billing_thresholdsobjectRequiredNullableInvoices the subscription early once the period's amount due reaches
amount_gte. Null when no threshold is set.Show child attributes
billing_thresholds.amount_gteintegerRequiredNullableAmount due, in the smallest currency unit, at which the subscription is invoiced early.
billing_thresholds.reset_billing_cycle_anchorbooleanRequiredWhether a threshold invoice starts a new billing period. When false, the period's dates stay as they were.
failure_countintegerRequiredNumber of consecutive failed payments on the subscription's invoices. Reset to
0when a payment succeeds.billing_cycle_anchortimestampRequiredNullableTime the billing cycle is anchored to, in Unix seconds: periods start on this date and repeat at the price's interval.
current_period_starttimestampRequiredNullableStart of the current billing period, in Unix seconds.
current_period_endtimestampRequiredNullableEnd of the current billing period, in Unix seconds. The next renewal invoice is created at this time.
trial_starttimestampRequiredNullableStart of the trial, in Unix seconds. Null when the subscription had no trial.
trial_endtimestampRequiredNullableEnd of the trial, in Unix seconds; billing starts then. Null when the subscription had no trial.
cancel_at_period_endbooleanRequiredtruewhen the subscription is set to cancel at the end of the current period. Reactivating it, or canceling it at once, sets this back tofalse.cancel_attimestampRequiredNullableTime a scheduled cancellation takes effect, in Unix seconds. Null when no cancellation is scheduled, and after a cancellation that took effect at once.
canceled_attimestampRequiredNullableTime the cancellation was requested, in Unix seconds. For a cancellation at period end, this is earlier than
cancel_at; canceling at once after scheduling one keeps the time the scheduled one was requested. Null when the subscription has not been canceled.ended_attimestampRequiredNullableTime the subscription ended, in Unix seconds. Null while it is still running.
pause_collectionobjectRequiredNullableSet while collection is paused through the pause endpoint: no invoice is collected until the subscription is resumed, and
statusstaysactive. Null when collection is not paused.Show child attributes
pause_collection.behaviorstringRequiredHow invoices are treated while collection is paused, as sent to the pause endpoint (
voidby default).keep_as_draftInvoices created while paused stay as drafts.
mark_uncollectibleInvoices created while paused are marked uncollectible.
voidInvoices created while paused are voided.
pause_collection.resumes_attimestampRequiredNullableTime collection resumes, in Unix seconds, as sent to the pause endpoint. Null when no time was set; collection then resumes when you resume the subscription.
test_clock_idstringID of the test clock the subscription runs on. Absent for subscriptions not attached to a test clock.
ID of the most recent invoice billed for the subscription, or the invoice itself with
expand[]=latest_invoice. Absent until the first invoice exists.pending_setup_intentstringReserved for the ID of a setup intent collecting a payment method for the subscription. Paycose does not set it today, so it is always absent.
cancellation_detailsobjectRequiredNullableWhy the subscription was canceled, recorded when a cancellation is requested. Always returned; each member is null until recorded, and they are cleared when the subscription is reactivated.
Show child attributes
cancellation_details.commentstringRequiredNullableThe customer's free-text comment, as sent in
cancellation_details.comment. Null when none was given.cancellation_details.feedbackstringRequiredNullableThe customer's feedback category, as sent in
cancellation_details.feedback. Null when none was given.customer_serviceThe customer was unhappy with customer service.
low_qualityThe customer was unhappy with quality.
missing_featuresFeatures the customer needs are missing.
otherAnother reason.
switched_serviceThe customer switched to another service.
too_complexThe service was too complex to use.
too_expensiveThe service was too expensive.
unusedThe customer did not use the service enough.
cancellation_details.reasonstringRequiredNullableWhy the subscription was canceled. Null until a cancellation is requested or the subscription ends.
cancellation_requestedThe cancellation was requested through the cancel endpoint.
payment_failedThe last payment retry failed and the dunning setting canceled the subscription.
on_behalf_ofstringID of the connected account each period invoice's payment is made on behalf of. The invoices' fee lines and tax are then the application fee. Absent when not set.
metadataobjectRequiredKey-value pairs you attach to the object for your own use. Paycose never reads or changes them.
latest_next_actionarray of objectsActions the payer still has to take to pay the subscription's open invoice, such as authenticating a card payment or scanning a QR code. Returned by retrieve only, and only while that invoice has an unpaid charge that needs action.
Show child attributes
latest_next_action.typestringRequiredThe kind of step. It decides which of
url,client_secret,payment_method,qr_dataandqr_image_urlare set.redirectSend the payer to
urlto finish the payment.share_linkSend the hosted payment link in
urlto the customer so they can complete authentication themselves.confirm_inlineShow the card form in your page and confirm the payment with
client_secret.show_qrShow
qr_dataas a QR code, or the image atqr_image_url, for the payer to scan.qrShow
qr_dataas a QR code for the payer to scan.otpAsk the payer for the one-time password their bank sent and submit it to confirm the payment.
latest_next_action.titlestringRequiredShort heading for the step, in English, suitable to show the payer.
latest_next_action.descriptionstringRequiredOne-sentence explanation of the step, in English, suitable to show the payer.
latest_next_action.urlstringFor
redirect, the page to send the payer to: a 3-D Secure page, a wallet's approval page or a banking app link. Forshare_link, a hosted payment page you can send to the customer; the link is valid for 24 hours. Omitted for other types.latest_next_action.client_secretstringFor
confirm_inline, the provider's client secret the card form uses to confirm or authenticate the payment. Forotp, the provider's reference of the payment that the one-time password confirms. Omitted for other types.latest_next_action.payment_methodstringFor
confirm_inlineafter a payment was refused off-session, the provider's payment method to authenticate. Forshow_qr, the QR payment method the code is for, such asalipay,wechat_payorqr_cross_border. Omitted otherwise.latest_next_action.qr_datastringFor
show_qrandqr, the raw QR payload to render as a QR code for the payer to scan. Omitted for other types.latest_next_action.qr_image_urlstringFor
show_qr, a link to the provider's image of the QR code, for when the provider sends no raw payload (such as an Omise PromptPay charge): show the image for the payer to scan. Omitted when the provider sends none.latest_next_action.cryptoobjectNullableShow child attributes
latest_next_action.crypto.networkstringRequiredlatest_next_action.crypto.chain_idstringRequiredlatest_next_action.crypto.testnetbooleanRequiredlatest_next_action.crypto.deposit_addressstringRequiredlatest_next_action.crypto.token_currencystringRequiredlatest_next_action.crypto.token_contract_addressstringRequiredlatest_next_action.crypto.token_amountstringRequiredlatest_next_action.crypto.token_unitsintegerRequiredlatest_next_action.crypto.token_decimalsintegerRequiredlatest_next_action.crypto.exchange_ratestringlatest_next_action.crypto.explorer_urlstringlatest_next_action.crypto.expires_attimestampRequiredUnix timestamp in seconds.
The full customer object when you pass
expand[]=customer; otherwise absent — usecustomer_id.The full payment method object when you pass
expand[]=default_payment_method; otherwise absent — usedefault_payment_method_id.