Display All Subscriptions for a Customer

Overview

This guide shows you how to implement Get Subscriptions for Customer endpoint to retrieve subscriptions for a customer.

Use Case

  1. An Accounts Manager enters a customer ID into your company's subscription management portal.
  2. The page uses the Get Subscriptions for Customer endpoint to obtain subscription details for the specified customer.
  3. The Accounts Manager selects a subscription from the list of returned subscriptions.
  4. The page displays the item details returned by the API response, including the product name, quantity, status, and deactivation date for deactivated items.

Implement Get Subscriptions for Customer endpoint

Before you start

Make sure that you have the following value available:

  • customerId
📘

Note

If your company provides its own unique customer identifier during checkout, Cleverbridge stores it as CustomerReferenceId.

You can then use this value instead of customerId when calling this endpoint.

We recommend storing customer and subscription data in your own system and using Cleverbridge notifications to keep it synchronized with subscription changes.

Parameters

Parameter

Type

Required

Example

Notes

customerId

str

Yes

64749867

The unique identifier of the customer.

subscriptionstatus

str

No

1

Filters subscriptions by status.
See the table below.

Subscription Status Parameter

The subscriptionstatus parameter is optional. If this parameter is omitted, the endpoint returns all subscriptions for the specified customer.

The subscriptionstatus parameter takes the following string values (and returns a corresponding integer in a JSON response):


#CodeStatus
1ACTActive
2DEADeactivated
3FINFinished
4GRAGrace
5HLDHold
6NEWNew
7HBCHandled by Client
8WNOAwaiting new order

Request

Call the Get Subscriptions for Customer endpoint.

curl --location 'https://rest.cleverbridge.com/subscription/getsubscriptionsforcustomer?customerId=159610858&subscriptionstatus=Active' \
--header 'Accept: application/json' \
--header 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS' \
import http.client

conn = http.client.HTTPSConnection("rest.cleverbridge.com")
payload = ''
headers = {
  'Accept': 'application/json',
  'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS'
}
conn.request("GET", "/subscription/getsubscriptionsforcustomer?customerId=159610858&subscriptionstatus=Active", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'GET',
  'hostname': 'rest.cleverbridge.com',
  'path': '/subscription/getsubscriptionsforcustomer?customerId=159610858&subscriptionstatus=Active',
  'headers': {
    'Accept': 'application/json',
    'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.get("https://rest.cleverbridge.com/subscription/getsubscriptionsforcustomer?customerId=159610858&subscriptionstatus=Active")
  .header("Accept", "application/json")
  .header("Authorization", "Basic YOUR_BASE64_ENCODED_CREDENTIALS")
  .asString();

Response

{
  "Subscriptions": [
    {
      "Id": 68841753,
      "Subscriptionstatus": 1,
      "RenewalType": "Automatic",
      "NextBillingDate": "2027-05-13T10:28:42.344357",
      "Items": [
        {
          "RunningNo": 1,
          "ProductName": "Cloudify Storage A",
          "ProductNameExtension": "Cloud Storage",
          "Quantity": 1,
          "Status": 1
        }
      ]
    }
  ],
  "ResultMessage": "OK"
}

The response returns all matching subscriptions. Each subscription includes its status, renewal type, next billing date, and the subscription items associated with it.