cURL
curl --request GET 'https://api.integrateledger.com/v1/customers/purchases?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY"import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.list_customer_purchases(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.listCustomerPurchases({ customerId: "user_123" });const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.integrateledger.com/v1/customers/purchases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.integrateledger.com/v1/customers/purchases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.integrateledger.com/v1/customers/purchases"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.integrateledger.com/v1/customers/purchases")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/customers/purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 123,
"addOnId": "<string>",
"name": "<string>",
"creditAmount": 123,
"status": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"hasMore": true,
"nextCursor": 123
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Customers and usage
List customer purchases
Read a customer’s credit-pack purchase history in the API key’s environment.
GET
/
v1
/
customers
/
purchases
cURL
curl --request GET 'https://api.integrateledger.com/v1/customers/purchases?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY"import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.list_customer_purchases(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.listCustomerPurchases({ customerId: "user_123" });const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.integrateledger.com/v1/customers/purchases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.integrateledger.com/v1/customers/purchases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.integrateledger.com/v1/customers/purchases"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.integrateledger.com/v1/customers/purchases")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/customers/purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 123,
"addOnId": "<string>",
"name": "<string>",
"creditAmount": 123,
"status": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"hasMore": true,
"nextCursor": 123
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Pass the exact opaque
customerId as a URL-encoded query value. Results are ordered newest first and can be paged with limit and nextCursor. Each item shows the add-on ID, name, confirmed credit amount, status, and creation time. A pending_checkout purchase has not granted credits, so creditAmount is null. Once Checkout grants credits, creditAmount shows the immutable amount actually granted. It is also null for any legacy paid row with no linked grant. Multiple purchases of the same pack appear as separate items.
The API key scopes the result to its organization and Sandbox or Live environment. Use Get a customer for the current balance, which can also include plan credits. Stripe invoice and Checkout payment documents are available from the dashboard’s customer billing panels when the connected Stripe account can verify them.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Required string length:
1 - 255Required range:
1 <= x <= 100Required range:
x <= 2147483647