cURL
curl --request GET 'https://api.integrateledger.com/v1/customers?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.get_customer(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.getCustomer({ customerId: "user_123" });const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.integrateledger.com/v1/customers', 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",
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"
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")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/customers")
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{
"customerId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"availableCredits": 123,
"currentPlan": {
"id": "<string>",
"name": "<string>",
"status": "active",
"currentPeriodStart": "2023-11-07T05:31:56Z",
"currentPeriodEnd": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Customers and usage
Get a customer
Read a customer’s current credit balance and plan in the API key’s environment.
GET
/
v1
/
customers
cURL
curl --request GET 'https://api.integrateledger.com/v1/customers?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.get_customer(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.getCustomer({ customerId: "user_123" });const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.integrateledger.com/v1/customers', 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",
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"
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")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/customers")
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{
"customerId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"availableCredits": 123,
"currentPlan": {
"id": "<string>",
"name": "<string>",
"status": "active",
"currentPeriodStart": "2023-11-07T05:31:56Z",
"currentPeriodEnd": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Pass the exact
customerId used when creating the customer. IDs can contain punctuation, spaces, or slashes; URL encode the query value. The response includes availableCredits from active plan and add-on grants and currentPlan when an active plan or pending Checkout exists. An active plan takes precedence over a pending Checkout. currentPlan is null when neither exists; this does not imply the balance is zero because add-on credits may remain.
Your API key selects the organization and Sandbox or Live environment. Unknown IDs return 404 customer_not_found. This operation does not create a customer or initiate Checkout. It may advance a due free-plan period before returning the balance, just as Check credits does.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Required string length:
1 - 255