Docs
You are viewing:
Product Catalog 2.0
Scope
How to get the last subscription of each individual customer via API?
Is there any way to get the recent subscription using API?
What is the parameter to get each customer's subscription by month via API?
Summary
You can make use of the List Subscription API call and use the parameter 'sort_by[ ]' to filter the subscription by period.
Solution
Step 1: You can make use of this API call to list subscriptions.
Step 2: To filter the subscription by period.
sort_by[ ]
optional, string filter Sorts based on the specified attribute. Supported attributes: created_at, updated_at Supported sort-orders: asc, desc
Example → sort_by[asc] = "created_at" This will sort the result based on the 'created_at' attribute in ascending(earliest first) order.
Step 3: To filter the subscription by customer.
id[ ]
optional, string filter A unique and immutable identifier for the subscription. If not provided, it is autogenerated. Supported operators: is, is_not, starts_with, in, not_in
Example → id[is] = "8gsnbYfsMLds"
customer_id[ ]
optional, string filter Identifier of the customer with whom this subscription is associated. Supported operators: is, is_not, starts_with, in, not_in
Example → customer_id[is_not] = "8gsnbYfsMLds"
Step 4: To filter the subscription by Plan.
item_id[ ]
optional, string filter The plan item code. Supported operators: is, is_not, starts_with, in, not_in
Example → item_id[is] = "silver"
item_price_id[ ]
optional, string filter The plan item price code. Supported operators : is, is_not, starts_with, in, not_in
Example → item_price_id[is] = "silver-USD-monthly"
Step 5: To filter the subscription by subscription status.
status[ ]
optional, enumerated string filter The current state of the subscription. Possible values are: future, in_trial, active, non_renewing, paused, cancelled. Supported operators: is, is_not, in, not_in
Example → status[is] = "active"
Was this article helpful?