List Subscriptions
Retrieve a list of subscriptions.
You can filter the list with query parameters.
billing
Method of billing. One of the following:
pay_automatically
send_invoice
customer
ID of the customer. String starting with cus_.
ending_before
The ID of a record in the list. The list ends with the last record that was created before the record with this ID. Use this filter to get the previous page of results.
limit
The maximum number of subscriptions to return. Range: 1-100.
10
product
ID of a
product
object. The product must havetype
set to service. String starting with product_. Filter for one product at a time.
starting_after
The ID of a record in the list. The list begins with the record that was created next after the record with this ID. Use this filter to get the next page of results. Relevant when
ending_before
is not used.
status
Status of the subscription. One of the following:
active
canceled
trialing
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { string customer = "cus_494eae8b99f697107d7384c2c6862166"; int limit = 1; string result = RapydApiRequestSample.Utilities.MakeRequest("GET", $"/v1/payments/subscriptions?customer={customer}&limit={limit}"); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const result = await makeRequest( 'GET', '/v1/payments/subscriptions?customer=cus_f3923ec56a56578b6a18df24d4f32d54&limit=1' ); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); try { $object = make_request('get', '/v1/payments/subscriptions?customer=cus_494eae8b99f697107d7384c2c6862166&limit=1'); var_dump($object); } catch(Exception $e) { echo "Error: $e"; } ?>
Python
from pprint import pprint from utilities import make_request result = make_request(method='get', path='/v1/payments/subscriptions?customer=cus_494eae8b99f697107d7384c2c6862166&limit=1') pprint(result)
/v1/payments/subscriptions
List Subscriptions by Customer
curl -X get https://sandboxapi.rapyd.net/v1/payments/subscriptions?customer=cus_494eae8b99f697107d7384c2c6862166&limit=1 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "c03a32f6-5023-4577-b2b3-4442df616d4a" }, "data": [ { "id": "sub_db73da2fc2a7a3b8451fed8afdbaf46c", "billing": "pay_automatically", "billing_cycle_anchor": 1700140716, "created_at": 1700140716, "customer_token": "cus_b306773fc73d23e5a9b4347984606cf7", "days_until_due": 30, "metadata": {}, "tax_percent": 0, "cancel_at_period_end": false, "canceled_at": null, "current_period_end": 1702732716, "current_period_start": 1700140716, "discount": null, "ended_at": null, "subscription_items": { "data": [ { "id": "subi_e3cec118feec75e0f270d888a053a410", "created": 1700140716, "metadata": null, "quantity": 5, "plan": { "id": "plan_4feb4cf48e807cd142d7759a58a55d2f", "aggregate_usage": "sum", "amount": 9.99, "billing_scheme": "per_unit", "created_at": 1700140529, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": { "id": "product_4ba001c7655c4a0ee4f471dbaccaa305", "active": true, "attributes": [ "location", "size" ], "created_at": 1673932995, "description": "Unlimited music streaming", "images": [ "64bit-encoded-image-1", "64bit-encoded-image-2" ], "metadata": {}, "name": "Unlimited Music", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "Music streaming", "type": "services", "unit_label": "month", "updated_at": 1673932995 }, "nickname": "Unlimited Plan", "tiers": [], "tiers_mode": "", "transform_usage": { "divide_by": 1, "round": "up" }, "trial_period_days": 7, "usage_type": "licensed", "active": true } }, { "id": "subi_f0d375617a093d30307adec9ea246b44", "created": 1700140716, "metadata": null, "quantity": 3, "plan": { "id": "plan_26aabd1d48bcfec1ff05dc2bed772aa3", "aggregate_usage": "sum", "amount": 10.99, "billing_scheme": "per_unit", "created_at": 1700140584, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": { "id": "product_4ba001c7655c4a0ee4f471dbaccaa305", "active": true, "attributes": [ "location", "size" ], "created_at": 1673932995, "description": "Unlimited music streaming", "images": [ "64bit-encoded-image-1", "64bit-encoded-image-2" ], "metadata": {}, "name": "Unlimited Music", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "Music streaming", "type": "services", "unit_label": "month", "updated_at": 1673932995 }, "nickname": "Unlimited Plan plus", "tiers": [], "tiers_mode": "", "transform_usage": { "divide_by": 1, "round": "up" }, "trial_period_days": 7, "usage_type": "licensed", "active": true } } ], "has_more": false, "total_count": 2, "url": "/v1/subscription_items?subscription=sub_db73da2fc2a7a3b8451fed8afdbaf46c" }, "status": "unpaid", "trial_end": null, "trial_start": null, "payment_method": "card_3c000ae5db06762a2c8a00ca514fa336", "payment_fields": null, "payout_fields": null, "type": "payment", "simultaneous_invoice": false } ] }
List Subscriptions by Product
curl -X get https://sandboxapi.rapyd.net/v1/payments/subscriptions?product=product_4ba001c7655c4a0ee4f471dbaccaa305&limit=1 -H 'access_key: your-access-key-here' -H 'Content-Type: application/json' -H 'idempotency: your-idempotency-parameter-here' -H 'salt: your-random-string-here' -H 'signature: your-calculated-signature-here' -H 'timestamp: your-unix-timestamp-here'
{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "90944be7-447f-4875-ac63-f1a9f970b613" }, "data": [ { "id": "sub_db73da2fc2a7a3b8451fed8afdbaf46c", "billing": "pay_automatically", "billing_cycle_anchor": 1700140716, "created_at": 1700140716, "customer_token": "cus_b306773fc73d23e5a9b4347984606cf7", "days_until_due": 30, "metadata": {}, "tax_percent": 0, "cancel_at_period_end": false, "canceled_at": null, "current_period_end": 1702732716, "current_period_start": 1700140716, "discount": null, "ended_at": null, "subscription_items": { "data": [ { "id": "subi_e3cec118feec75e0f270d888a053a410", "created": 1700140716, "metadata": null, "quantity": 5, "plan": { "id": "plan_4feb4cf48e807cd142d7759a58a55d2f", "aggregate_usage": "sum", "amount": 9.99, "billing_scheme": "per_unit", "created_at": 1700140529, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": { "id": "product_4ba001c7655c4a0ee4f471dbaccaa305", "active": true, "attributes": [ "location", "size" ], "created_at": 1673932995, "description": "Unlimited music streaming", "images": [ "64bit-encoded-image-1", "64bit-encoded-image-2" ], "metadata": {}, "name": "Unlimited Music", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "Music streaming", "type": "services", "unit_label": "month", "updated_at": 1673932995 }, "nickname": "Unlimited Plan", "tiers": [], "tiers_mode": "", "transform_usage": { "divide_by": 1, "round": "up" }, "trial_period_days": 7, "usage_type": "licensed", "active": true } }, { "id": "subi_f0d375617a093d30307adec9ea246b44", "created": 1700140716, "metadata": null, "quantity": 3, "plan": { "id": "plan_26aabd1d48bcfec1ff05dc2bed772aa3", "aggregate_usage": "sum", "amount": 10.99, "billing_scheme": "per_unit", "created_at": 1700140584, "currency": "USD", "interval": "month", "interval_count": 1, "metadata": {}, "product": { "id": "product_4ba001c7655c4a0ee4f471dbaccaa305", "active": true, "attributes": [ "location", "size" ], "created_at": 1673932995, "description": "Unlimited music streaming", "images": [ "64bit-encoded-image-1", "64bit-encoded-image-2" ], "metadata": {}, "name": "Unlimited Music", "package_dimensions": { "height": 0, "length": 0, "weight": 0, "width": 0 }, "shippable": false, "skus": [], "statement_descriptor": "Music streaming", "type": "services", "unit_label": "month", "updated_at": 1673932995 }, "nickname": "Unlimited Plan plus", "tiers": [], "tiers_mode": "", "transform_usage": { "divide_by": 1, "round": "up" }, "trial_period_days": 7, "usage_type": "licensed", "active": true } } ], "has_more": false, "total_count": 2, "url": "/v1/subscription_items?subscription=sub_db73da2fc2a7a3b8451fed8afdbaf46c" }, "status": "unpaid", "trial_end": null, "trial_start": null, "payment_method": "card_3c000ae5db06762a2c8a00ca514fa336", "payment_fields": null, "payout_fields": null, "type": "payment", "simultaneous_invoice": false } ] }