Purchase API List

Overview

This guide shows you how to retrieve a list of purchases for a time period using the Get Purchase List endpoint.

Use case

Cloudify sells cloud backup subscriptions through Cleverbridge. Each night, Cloudify revokes the license keys of refunded purchases.

  1. Cloudify's license service sends a request to the Get Purchase List endpoint with the previous day as the time period.
  2. The request filters the list by the purchase status PNP_RFD (Refunded).
  3. Cleverbridge returns the IDs of all purchases that match the filter.
  4. The license service revokes the license keys of these purchases.

Result

Customers with a refund can't use Cloudify Backup Pro. No one at Cloudify checks refunds manually.

Implement Get Purchase List

To get the list, send one GET request with a start date, an end date, and an optional status filter. The response contains purchase IDs and status codes, not full purchase details.

Before you start

Make sure that:

  • Your Cleverbridge user has the API User privilege. For more information, see Authentication.
  • You replace YOUR_BASE64_ENCODED_CREDENTIALS with your base64-encoded username:password.
  • You write dates in the format YYYY-MM-DDThh:mm:ss, for example 2026-11-18T00:00:00.
  • You test with a test user. The endpoint returns production data. To get a test user, contact your Client Experience Manager.
  • You run the Node.js sample on Node.js 18 or later and the Java sample on Java 11 or later. These versions include the built-in HTTP clients that the samples use.

The endpoint is read-only. It doesn't change purchases or send notifications.

Parameters

The request uses these query and header parameters:

ParameterTypeRequiredExampleNotes
startDateTimestringYes2026-11-18T00:00:00Query parameter. The start of the time period.
endDateTimestringYes2026-11-19T00:00:00Query parameter. The end of the time period.
purchasestatusIdsstringNoPNP_RFDQuery parameter. Filters the list by purchase status code. For all codes, see Purchase Status.
AcceptstringNoapplication/jsonHeader. The response format: application/json or application/xml. Default: application/json.
AuthorizationstringYesBasic YOUR_BASE64_ENCODED_CREDENTIALSHeader. HTTP Basic authentication with your base64-encoded username:password.

Request

Send a GET request to the following endpoint:

GET https://rest.cleverbridge.com/purchase/getpurchaselist?startDateTime={startDateTime}&endDateTime={endDateTime}&purchasestatusIds={purchasestatusIds}

The following samples retrieve all refunded purchases from November 18, 2026:

curl --request GET \
  --url 'https://rest.cleverbridge.com/purchase/getpurchaselist?startDateTime=2026-11-18T00:00:00&endDateTime=2026-11-19T00:00:00&purchasestatusIds=PNP_RFD' \
  --header 'Accept: application/json' \
  --header 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS'
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({
    "startDateTime": "2026-11-18T00:00:00",
    "endDateTime": "2026-11-19T00:00:00",
    "purchasestatusIds": "PNP_RFD",
})
url = f"https://rest.cleverbridge.com/purchase/getpurchaselist?{params}"

request = urllib.request.Request(
    url,
    method="GET",
    headers={
        "Accept": "application/json",
        "Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS",
    },
)

with urllib.request.urlopen(request) as response:
    print(response.status)
    print(response.read().decode("utf-8"))
const params = new URLSearchParams({
  startDateTime: "2026-11-18T00:00:00",
  endDateTime: "2026-11-19T00:00:00",
  purchasestatusIds: "PNP_RFD",
});
const url = `https://rest.cleverbridge.com/purchase/getpurchaselist?${params}`;

async function getPurchaseList() {
  const response = await fetch(url, {
    method: "GET",
    headers: {
      Accept: "application/json",
      Authorization: "Basic YOUR_BASE64_ENCODED_CREDENTIALS",
    },
  });

  console.log(response.status);
  console.log(await response.text());
}

getPurchaseList();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetPurchaseList {
    public static void main(String[] args) throws Exception {
        String url = "https://rest.cleverbridge.com/purchase/getpurchaselist"
                + "?startDateTime=2026-11-18T00:00:00"
                + "&endDateTime=2026-11-19T00:00:00"
                + "&purchasestatusIds=PNP_RFD";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Accept", "application/json")
                .header("Authorization", "Basic YOUR_BASE64_ENCODED_CREDENTIALS")
                .GET()
                .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
                .send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}

Response

A successful call returns HTTP status 200 OK:

{
  "Purchases": [
    {
      "PurchaseId": 115515453,
      "PurchasestatusId": "PNP_RFD",
      "ReimbursementId": 0,
      "ReimbursementtypeId": null
    },
    {
      "PurchaseId": 115515453,
      "PurchasestatusId": "PNP_RFD",
      "ReimbursementId": 2137154,
      "ReimbursementtypeId": "FUL"
    },
    {
      "PurchaseId": 115523981,
      "PurchasestatusId": "PNP_RFD",
      "ReimbursementId": 0,
      "ReimbursementtypeId": null
    },
    {
      "PurchaseId": 115523981,
      "PurchasestatusId": "PNP_RFD",
      "ReimbursementId": 2137201,
      "ReimbursementtypeId": "FUL"
    }
  ],
  "ResultMessage": "OK"
}

The response contains these fields:

FieldDescription
PurchasesThe list of entries that match the request. One purchase can have more than one entry.
Purchases[].PurchaseIdThe ID of the purchase. Use it with the Get Purchase endpoint to get the full purchase details.
Purchases[].PurchasestatusIdThe purchase status code, for example PNP_RFD. These codes are more detailed than the statusId codes in purchase notifications.
Purchases[].ReimbursementIdThe ID of the reimbursement. 0 means that the entry is the purchase itself, not a reimbursement.
Purchases[].ReimbursementtypeIdThe reimbursement type, for example FUL (refund of the full amount). For all codes, see Reimbursement Type.
ResultMessageThe result of the call. OK means that the call is successful.

To process each purchase one time, group the entries by PurchaseId.

Errors

If Cleverbridge can't process the request, the endpoint returns HTTP status 500 Internal Server Error. Send the request again later.

{
  "Id": null,
  "Message": "An error has occured processing your request.",
  "Status": 500
}

Did this page help you?