Manage Subscriptions Using the Subscriptions API
After setting up a subscription plan (see Set up and Manage a Subscription Plan), you can use the Subscriptions API to create and manage subscriptions.
On this page
The Subscription API provides the Subscription type that represents a subscription. In addition to storing basic subscription information (customer ID and associated plan ID), the type provides fields that you can optionally customize including:
Payment source information (
card_id
). By default, when you create a subscription, Square sends an invoice to the customer's email address. Optionally, a card on file can be linked with the subscription so that Square can charge the card and email a receipt for the invoice. ACH payments are not possible through the Subscriptions API because bank account sources cannot be stored on file and charged later.Subscription start date (
start_date
). By default, the subscription starts as soon as you create a subscription. You can optionally configure a start date to start the subscription some time in future. Initially, these subscriptions have a status of PENDING and become ACTIVE on the start date. The start date is effective at midnight for the specifiedtimezone
.Tax percentage (
tax_percentage
). By default, taxes are not added to the subscription invoice. You can optionally specify a tax percentage when creating individual subscriptions. For example, depending on the business location you might configure different tax rates. Square then bills the customer for both the subscription and taxes.Override subscription price (
price_override_money
). By default, the subscription plan determines the subscription price (see Set up and Manage a Subscription Plan). However, individual subscriptions can optionally override that amount. For more information, see Subscription price override.Subscription cancellation date (
canceled_date
). By default, the subscription plan dictates if and when a subscription ends. You also have the option to callCancelSubscription
to cancel a subscription.Note
If you set the
canceled_date
, the subscription cancels on the specified date and the final bill is prorated accordingly. However, if you callCancelSubscription
, the subscriptions cancels at the end of the current billing cycle.
You use the Subscriptions API to create and manage subscriptions.
You call CreateSubscription to enroll a customer in a subscription plan. In the request, you provide a customer ID, a plan ID, and a location ID to associate with the subscription. The customer ID refers to the customer profile in the seller's Customer Directory (see Customers API Overview).
Note
The customer profiles must include a valid email address. Square emails the subscription invoices and the receipts to this email address.
You can also customize individual subscriptions.
The following are example CreateSubscription
requests:
Example 1: Create a subscription. The following
CreateSubscription
request specifies the minimum required fields:The following is an example response:
Note the following:
The request does not specify
card_id
, the customer's card on file; therefore, Square sends the invoice to the customer's email address.The request does not specify
start_date
; therefore, the subscription starts immediately.If the plan offers a free phase, Square bills the subscription only after the free phase; otherwise, billing occurs immediately.
To test an end-to-end experience, see Walkthrough: Create a Subscription Plan and Manage Subscriptions.
Example 2: Create subscriptions with customization. The following
CreateSubscription
call specifies optional configurations:start_date
of the subscription, some future date (YYYY-MM-DD).card_id
identifies the card on file to charge.price_override_money
specifies a custom price ($5) for the subscription. The price overrides the price configured in the plan (see Set up and Manage a Subscription Plan).tax_percentage
to add to the invoice. The example shows a 5% tax.timezone
indicates that the subscription date is relative to the "America/Los_Angeles" timezone. The timezone is the IANA Timezone Database identifier for the timezone (for example, America/Los_Angeles). For more information, see List of tz database time zones.The following is an example response:
The response shows the
subscription_status
as PENDING. When the start date arrives, the status changes to ACTIVE. Square charges the card on file based on the subscription plan and sends an invoice receipt to the customer's email address. For example, if the subscription plan offers an initial free phase, the customer is billed (invoiced or charged) only after the free phase.The amount charged for this subscription is $5.25, which is the price override amount plus the 5% tax the example uses.
Note
Application fees, as currently supported in the Payments API, are not supported in the Subscriptions API and desirable fees should be negotiated with the seller and included in the subscription price to be presented to the user.
Example 3: Create subscriptions with an explicit source name.
A subscription can be created using Seller Dashboard, Square Point of Sales, or an application using the Subscription API. The resulting subscription has a source name to indicate what tool it was created with.
For example, if you use the Square API Explorer with the credentials of one of your Square applications, the default source name of the created subscription is the name of the application registered with the Square Developer Dashboard.
When creating a subscription using the API, you can explicitly specify a source name to override the default source name. This is useful to categorize your subscriptions by their sources of creation and then to facilitate querying for subscriptions by specified source names.
The following
CreateSubscription
example shows how to create a subscription with an explicit source name.An example response to this request is shows as follows:
Suppose that you registered your Square application as "My Square App" and that you use this application's credentials to call the Square API. If you do not explicitly specify the source in the previous request, the response contains the registered Square application name as the default source name:
When an order is placed on a subscription, the subscription source name, if any, is propagated to the order's source name.
You can modify or clear Subscription
field values by calling UpdateSubscription. For example, use this endpoint to update the tax_percentage
configured for a subscription, update a card_id
on file, or clear an upcoming canceled_date
.
In the request body, include the Subscription
object with only the fields you want to update. To clear a field, set the field value to null
.
Example 1: Update a subscription field. The following request updates the tax_percentage
of the subscription, either by adding a new tax or updating the existing tax_percentage
, if previously set:
Example 2: Update and clear subscription fields. The following request updates the price_override_money
field and clears the tax_percentage
and canceled_date
fields:
Note
The canceled_date
of a subscription can only be removed to undo a future scheduled cancellation. Clearing the canceled_date
field removes the pending cancellation from the subscription.
The following is an example response:
Because the tax_percentage
and canceled_date
fields are cleared, they are not returned in the response.
If you know the ID of a subscription to retrieve, call RetrieveSubscription and provide the subscription_id
in the endpoint URL as shown:
The following is an example response:
Use the SearchSubscriptions endpoint to retrieve a list of all subscriptions. In addition, you can find subscriptions created at specific locations or optionally provide customer IDs to retrieve subscriptions purchased by a specific customer. These search results are grouped by location, within each location by customer, and then sorted in created_at
order.
In the response, you get the specified customer subscriptions associated with the locations specified. When working with a large number of Subscription
objects, it might be helpful to paginate the response.
With the Square API 2021-10-20 or later, you can search for subscriptions by source name. To do so, set the source_names
filter in the SearchSubscription
request, as shown in the following code example:
The response contains all subscriptions created with a source name matching "iOS App" as a substring. An example of such a response is shown as follows:
The same subscription is returned if the request's source_names
filter contains a query string of "My iOS", "My", "iOS", or "App". However, the response does not contain this subscription if the query string is "My App". Notice that matching is case sensitive.
To view upcoming actions for each subscription in the response, set the include
parameter to actions
as shown:
A subscription can be paused for a number of billing cycles without being canceled. Call PauseSubscription and include the id
of the subscription to pause. Optionally, you can include a pause_reason
and, if you know how long the subscription should be paused before being resumed, you can include either a pause_cycle_duration
(the number of billing cycles to pause) or a resume_effective_date
in the request. When called, a PAUSE
action is scheduled and the subscription is paused at the end of the current billing period. At this time, the subscription's status
is set to PAUSED.
For example, a gym might allow athletes to pause their monthly membership for up to 3 months in the event of an injury:
The following is an example response:
There are some restrictions on pausing a subscription:
Subscriptions cannot be paused during a free trial phase.
Subscriptions can be paused for any number of billing cycles within a single phase. For example, if a subscription has two billing cycles left in the current phase, it can be paused for up to two cycles only. If the
pause_cycle_duration
is set beyond the current phase, the request fails and the subscription is not paused.
To manually resume a paused or deactivated subscription, call ResumeSubscription with the desired subscription ID
, resume_effective_date
, and resume_change_timing
to indicate whether the subscription should resume immediately on the resume_effective_date
or at the end of the billing cycle for that date.
Prior to version 2021-11-17, ResumeSubscription was only used to resume deactivated subscriptions and only required a subscription_id
. Now the endpoint has expanded to allow resuming paused subscriptions as well.
The following is an example response:
When called, a RESUME
action is scheduled. Note that if a RESUME
action is already scheduled, you must first cancel the pending action and then call ResumeSubscription to schedule a new one.
When you cancel a subscription, the canceled_date
field is set to the end of the active billing cycle and a CANCEL action is scheduled for the same date. After this date, the status
changes from ACTIVE to CANCELED. For example, if the subscription is in a phase with a monthly cadence, the canceled_date
is set depending on when the phase started:
If the phase started on the first of the month, the
canceled_date
is set to the end of the month.If the phase started on March 5, the
canceled_date
is set to April 5.
The following is an example response. The subscription_status
remains ACTIVE; however, the canceled_date
is set to end of the current billing period.
You can swap the subscription plan associated with a customer. For example, to upgrade a customer to a new premium plan or change a plan without altering the original plan for other subscribers. To do so, call the SwapPlan endpoint, including the subscription_id
to update in the path and the new_plan_id
in the request body as shown:
SwapPlan replaces the original plan with the new subscription plan at the end of the current billing cycle. This means that the original plan is still in effective until the end of the current billing cycle. When SwapPlan is called and the start of the new plan is pending, the subscription has a SWAP_PLAN action associated with it.
For a gym membership subscription plan, you might offer a 50% off summer special. Subscriptions created during this period override the plan price by adding
price_override_money
in the request.A subscription plan created for charitable causes might offer free subscriptions, hoping that subscribers give donations. These subscribers can set the price for their subscriptions.
In these cases, the price_override_money
field is set on the individual subscription. This price override does not apply to the free-trial phase in a subscription (see About the free-trial phase in a plan).
Important
The price_override_money
overrides the recurring_price_money
of all the subscription phases (except the initial free-trial phase, if present) regardless of the phase cadence
.
When setting the subscription price override, see the related Requirements and limitations.
Consider a gym membership subscription plan defined as having two phases:
Phase 1: Six-week free membership. For this phase, the
cadence
is weekly,recurring_price_money
is 0, andperiod
is 6.Phase 2: A monthly price of $60, after the initial phase. For this phase,
cadence
is monthly,recurring_price_money
is $60, and you do not specify theperiod
(to indicate the never ending phase).
Now suppose you offer a 50% summer special for gym memberships. For subscriptions created during the summer, you include price_override_money
in the CreateSubscription
request and set it to $30.
Phase 1: The price has no effect. It remains a free phase.
Phase 2: The monthly price changes to $30.
Consider another fictitious subscription plan defined as having two phases:
Phase 1: A one-year phase price at $500. For this phase, the
cadence
is yearly,recurring_price_money
is $500, andperiod
is 1.Phase 2: A monthly price of $50, after the initial phase. For this phase,
cadence
is monthly,recurring_price_money
is $50, and you do not specify theperiod
(to indicate the never ending phase).
Now suppose you create a subscription that specifies price_override_money
of $1 in the CreateSubscription
request:
Phase 1: The price changes to $1 (for the entire year).
Phase 2: The price also changes to $1 (monthly).
The price_override_money
applies to all phases (except the initial free phase, if any) regardless of the phase cadence
(monthly and yearly, in this example).
Consider another fictitious subscription plan for charitable causes, where the subscribers specify the amount they want to donate every year.
In this case, you define a plan as having one phase with the yearly price set at $0. Because this plan has only one phase, even though the price is $0, it is not a free-trial phase (see About the free-trial phase in a plan).
So when you create a subscription that specifies price_override_money
(for example, a $10 donation every year), the phase price changes to $10 per year.
The minimum amount you can charge for a subscription is $1. A subscription can have a free trial which you indicate by setting a $0 price for the first phase. You configure the subscription price in two places:
On the subscription plan. For more information, see Set up a subscription plan.
With a subscription price override. For more information, see Subscription object.
ACH payments are not possible through the Subscriptions API because bank account sources cannot be stored on file and charged later.
For OAuth flow, the Subscriptions API requires OAuth credentials and permissions. For more information about credentials, see Square API Access Tokens. In addition, the Subscriptions API requires these permissions:
SUBSCRIPTIONS_READ
andSUBSCRIPTIONS_WRITE.
ORDERS_READ
andORDERS_WRITE.
These permissions are required to create invoices.PAYMENTS_READ
andPAYMENTS_WRITE.
When you charge a card on file for the subscription, these permissions are required.CUSTOMERS_READ
. The subscription is associated with a customer profile in the seller's Customer Directory. Therefore, to create or manage subscriptions, you need this permission.
A webhook is a subscription that notifies you when a Square event occurs. For more information about using webhooks, see Square Webhooks Overview.
The Subscriptions API uses the following webhook events:
Event | Permission | Description |
---|---|---|
subscription.created | SUBSCRIPTIONS_READ | A Subscription object was created. |
subscription.updated | SUBSCRIPTIONS_READ | A Subscription object was updated. |
For a complete list of webhook events, see V2 Webhook Events Reference.
The following sections provide additional information.
Square bills the subscriptions in advance. At the start of a billing period, customers receive an emailed invoice, or if there is a card_id
on file, the card is automatically charged. The billing cycle starts on the subscription start date and repeats per the plan cadence (see Set up and Manage a Subscription Plan.
For a plan with a monthly cadence (including multiple months, such as every three months), if the billing date is after the end of a given month, Square bills the subscription on the last day of that month. For example, if the subscription starts on May 31, Square sends the next bill on June 30.
In addition, note the following:
If a subscription has a
card_id
set and Square's attempt to charge the card fails, Square sends the invoice to the customer's email address with a link to follow for making a payment.Square does not receive complete information from credit card providers about why payments fail. Therefore, if a customer's card fails or is declined, they should reach out to the card provider for more information.
As long as the subscription is active, Square sends invoices regardless of whether the customer paid the invoices previously billed. Each invoice amount remains specific to the billing period (individual invoices do not show any accumulation of the outstanding balance).
Both the customer and seller receive emails for each invoice billed. The email includes a URL to Square-hosted invoice page for the customer to pay the invoice. If Square charged the customer's card on file, the email provides the receipt.
All invoices that the Subscriptions API creates are available in the Seller Dashboard. You can also use the Invoices API to manage them. For more information, see Invoices API Overview. Invoices that are created by the Subscriptions API include a
subscription_id
field.Subscription payment status can be tracked by subscribing to the payment_made webhook event of the Invoices API or by calling the ListPayments or GetPayment endpoint of the Payments API to retrieve payment objects and inspect the payment status.
Subscription payments incur seller transaction fees , as do all card payments made through Square APIs. These fees vary by country.
Under specific conditions, Square might deactivate a subscription. For more information, see Deactivated subscriptions.
Actions are scheduled, future changes to subscriptions. When calling RetrieveSubscription or SearchSubscriptions, you can set the include
query parameter to actions
as shown to include the actions associated with the subscription in the response:
The following is an example response:
The possible actions associated with subscriptions are PAUSE, RESUME, SWAP_PLAN, and CANCEL. These actions can be scheduled by calling PauseSubscription, ResumeSubscription, SwapSubscription, or CancelSubscription, respectively.
When the action occurs, it becomes an event and can be accessed by calling ListSubscriptionEvents.
If you want to cancel an action before it occurs (for example, if a PAUSE
action had been scheduled but is no longer necessary), call DeleteSubscriptionAction with the subscription_id
and action_id
to cancel.
Events represent past subscription changes. Use ListSubscriptionEvents to retrieve events for a subscription. The events associated with subscriptions are START_SUBSCRIPTION
, STOP_SUBSCRIPTION
(when the subscription is canceled), PLAN_CHANGE
(swapping subscriptions), RESUME_SUBSCRIPTION
, PAUSE_SUBSCRIPTION
, and DEACTIVATE_SUBSCRIPTION
. You provide the subscription ID in the endpoint URL as shown:
The following is an example response:
After a subscription is created, there are events that can make a subscription non-billable, causing Square to deactivate the subscription. Some of the reasons include:
The customer's email address is deleted from the profile in the seller's Customer Directory.
The customer's email is no longer valid in the profile in the seller's Customer Directory.
The customer's name is deleted from the profile in the seller's Customer Directory.
The location is deactivated by the seller.
The location is not allowed to accept payments by the Square risk department.
Note
Customer profile deletion is an irreversible action. Therefore, if a customer profile is deleted, Square cancels the subscription.
The following is an example subscription with the status
set to DEACTIVATED.
Note that Square deactivates a subscription only at the end of the billing cycle. For example, consider a monthly billing cycle starting on the first day of the month. Now consider the following example sequence:
On January 1, a monthly subscription is created for a customer.
On January 15, the customer's email is deleted.
On February 1, Square discovers that the subscription is non-billable and deactivates the subscription. Square does not send any new invoices.
Applications can subscribe to the subscription.updated
webhook to receive subscription deactivation notifications (when the subscription's status
changes to DEACTIVATED). A seller can also use the Seller Dashboard to find deactivated subscriptions.
There are two ways to resume a deactivated subscription:
A seller can resume a deactivated subscription in the Seller Dashboard.
If subscriptions are managed programmatically, applications can call ResumeSubscription as shown:
ResumeSubscription
sets the subscriptionstatus
to ACTIVE.The resumption of a deactivated subscription fails unless all issues are resolved.
After a subscription is resumed in the middle of the billing cycle, Square sends a prorated invoice for the remaining billing cycle. For example, consider a monthly billing cycle starting on the first day of the month. Now consider the following example sequence:
On January 1, a subscription is created for a customer.
On January 15, the customer's email was deleted.
On February 1, Square discovers that the subscription is non-billable and deactivates the subscription.
On February 15, the customer's email is added back to the profile.
On February 15, the application called
ResumeSubscription
.On February 15, Square sends a prorated invoice for the rest of February.
Applications can call ListSubscriptionEvents as shown to determine why a subscription was deactivated by Square.
The following is an example response. It shows a list of events, one of which is an event of the type DEACTIVATE_SUBSCRIPTION
. The info
object provides the reason
code
and details why the subscription was deactivated.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.