steampipe plugin install stripe

Table: stripe_subscription - Query Stripe Subscriptions using SQL

Stripe Subscriptions is a service within Stripe that allows businesses to manage recurring billing for their customers. It provides a simplified way to set up and manage subscriptions, including various billing models, prorations, and tax rates. Stripe Subscriptions helps businesses automate their recurring billing, stay informed about subscription changes, and take appropriate actions when predefined conditions are met.

Table Usage Guide

The stripe_subscription table provides insights into subscriptions within Stripe. As a financial analyst or a business owner, explore subscription-specific details through this table, including the status, items, and associated customer information. Utilize it to uncover information about subscriptions, such as those with upcoming invoices, the relationships between customers and their subscriptions, and the verification of billing details.

Examples

List all subscriptions

Explore all active subscriptions to understand the scope and scale of your service usage. This can aid in assessing revenue streams and identifying potential areas for growth or improvement.

select
*
from
stripe_subscription;
select
*
from
stripe_subscription;

Subscriptions currently in the trial period

Explore which subscriptions are presently in their trial period to manage customer engagement and retention strategies effectively. This allows for a timely review of customer behavior and interactions during the trial phase.

select
*
from
stripe_subscription
where
status = 'trialing'
order by
created desc;
select
*
from
stripe_subscription
where
status = 'trialing'
order by
created desc;

Subscriptions set to cancel at the end of this period

Identify the Stripe subscriptions that are scheduled to cancel at the end of the current billing period. This is useful for understanding your upcoming subscription churn and potentially reaching out to these customers to prevent cancellation.

select
*
from
stripe_subscription
where
cancel_at_period_end;
select
*
from
stripe_subscription
where
cancel_at_period_end = 1;

Subscriptions created in the last 7 days

Discover the segments that have newly subscribed to your service within the past week. This can be useful in understanding recent customer behavior and trends.

select
*
from
stripe_subscription
where
created > current_timestamp - interval '7 days'
order by
created;
select
*
from
stripe_subscription
where
created > datetime('now', '-7 days')
order by
created;

Schema for stripe_subscription

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
account_idtext=, !=, ~~, ~~*, !~~, !~~*The Stripe account ID.
application_fee_percentdouble precisionA non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account.
billing_cycle_anchortimestamp with time zoneDetermines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
billing_thresholdsjsonbDefine thresholds at which an invoice will be sent, and the subscription advanced to a new billing period.
cancel_attimestamp with time zoneA date in the future at which the subscription will automatically get canceled.
cancel_at_period_endbooleanIf the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.
canceled_attimestamp with time zoneIf the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.
collection_methodtext=Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
createdtimestamp with time zone>, >=, =, <, <=Time at which the subscription was created.
current_period_endtimestamp with time zone>, >=, =, <, <=End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.
current_period_starttimestamp with time zone>, >=, =, <, <=Start of the current period that the subscription has been invoiced for.
customer_idtext=ID of the customer who owns the subscription.
days_until_duebigintNumber of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically.
default_payment_methodjsonbID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source.
default_sourcejsonbID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If default_payment_method is also set, default_payment_method will take precedence. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source.
default_tax_ratesjsonbThe tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription.
discountjsonbDescribes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.
ended_attimestamp with time zoneIf the subscription has ended, the date the subscription ended.
idtext=Unique identifier for the subscription.
itemsjsonbList of subscription items, each with an attached price.
latest_invoice_idtextID of the most recent invoice this subscription has generated.
livemodebooleanHas the value true if the subscription exists in live mode or the value false if the subscription exists in test mode.
metadatajsonbSet of key-value pairs that you can attach to an subscription. This can be useful for storing additional information about the subscription in a structured format.
next_pending_invoice_item_invoicetimestamp with time zoneSpecifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval.
pause_collectionjsonbIf specified, payment collection for this subscription will be paused.
pending_invoice_item_intervaljsonbSpecifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval.
pending_setup_intenttextYou can use this SetupIntent to collect user authentication when creating a subscription without immediate payment or updating a subscription’s payment method, allowing you to optimize for off-session payments. Learn more in the SCA Migration Guide.
pending_updatejsonbIf specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.
schedulejsonbThe schedule attached to the subscription.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
start_datetimestamp with time zoneDate when the subscription was first created. The date might differ from the created date due to backdating.
statustext=Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid.
transfer_datajsonbThe account (if any) the subscription’s payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription’s invoices.
trial_endtimestamp with time zoneIf the subscription has a trial, the end of that trial.
trial_starttimestamp with time zoneIf the subscription has a trial, the start of that trial.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- stripe

You can pass the configuration to the command with the --config argument:

steampipe_export_stripe --config '<your_config>' stripe_subscription