Subscriptions
Use the subscriptions API to fetch information about an account's commerce subscriptions. This is a read-only API, so it cannot be used for creating new or managing existing subscriptions. If you're looking to manage marketing email subscriptions instead, check out the subscription preferences API.
For example, use this API to fetch all currently active subscriptions.
To use this API, the account must be set up to collect payments through either HubSpot payments or Stripe payment processing.
Depending on the information you need, there are a few ways to retrieve subscriptions:
- To retrieve all subscriptions, make a
GET
request tocrm/v3/objects/subscriptions
. - To retrieve a specific subscription, make a
GET
request to the above URL and specify a subscription ID. For example:crm/v3/objects/subscriptions/41112146008
. - To retrieve subscriptions that meet a specific set of criteria, you can make a
POST
request to the search endpoint and include filters in the request body. See an example of using the search endpoint below.
The response will include a few default properties, including the create date, last modified date.
To return specific properties, include a properties
query parameter in the request URL along with comma-separated property names. For example, making a GET
request to the following URL would result in the response below:
crm/v3/objects/subscriptions?properties=hs_status,hs_last_payment_amount
To view all available subscription properties, make a GET
request to crm/v3/properties/subscriptions
. Learn more about using the properties API.
Below are some common subscription properties that you may want to query.
Property name | Label in UI | Description |
---|---|---|
hs_status |
The current status of the subscription. Values include:
|
|
hs_recurring_billing_start_date |
The date that the subscription is scheduled to start. |
|
hs_last_payment_amount |
The amount that was charged during the most recent billing period. |
|
hs_next_payment_amount |
The amount that will be charged at the start of the next billing period. |
|
hs_next_payment_due_date |
The date that the next payment is due. |
You can use the search endpoint to retrieve subscriptions that meet a specific set of filter criteria. This will be a POST
request that includes your filter criteria in the request body.
For example, to search for all currently active subscriptions, you would make a POST
request to crm/v3/objects/subscriptions/search
with the following request body:
Note that the filters
array specifies the search criteria, while the properties
array specifies which properties to return.
While you cannot set associations using this API, you can retrieve association information by making a GET request to the following URL:
crm/v3/objects/subscriptions/{subscriptionId}/associations/{associatedObjectName}
Associated objects can include contacts, companies, deals, quotes, line items, payments, discounts, fees, and taxes. These associations are typically set by the payment link or quote associated with the initial subscription payment. To manage these associations, you can update the subscription in HubSpot.
Below is an example of how you might use this API combined with another API to get a specific set of association information.
To retrieve a subscription and the line items associated with it, make a GET
request to:
crm/v3/objects/subscription/{subscriptionId}/associations/line_items
This will return the IDs of the currently associated line items, along with meta information about the association type.
You can then use the returned IDs to request more information about the line items through the line items API. For example, you could batch retrieve line items by ID with the following POST
request:
crm/v3/objects/line_items/batch/read
The response would be formatted as follows:
Thank you for your feedback, it means a lot to us.