cURL
curl --request POST 'https://api.integrateledger.com/v1/check' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"customerId":"user_123","featureId":"api_call"}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.check_credits(customer_id="user_123", feature_id="api_call")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.checkCredits({ customerId: "user_123", featureId: "api_call" });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', featureId: '<string>'})
};
fetch('https://api.integrateledger.com/v1/check', 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/check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'featureId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.integrateledger.com/v1/check"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.integrateledger.com/v1/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/check")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"allowed": true,
"availableCredits": 1,
"creditCost": 123
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Customers and usage
Check a customer's available credits
Check available credits for one customer and feature without consuming any.
POST
/
v1
/
check
cURL
curl --request POST 'https://api.integrateledger.com/v1/check' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"customerId":"user_123","featureId":"api_call"}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.check_credits(customer_id="user_123", feature_id="api_call")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.checkCredits({ customerId: "user_123", featureId: "api_call" });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', featureId: '<string>'})
};
fetch('https://api.integrateledger.com/v1/check', 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/check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'featureId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.integrateledger.com/v1/check"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.integrateledger.com/v1/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/check")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\",\n \"featureId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"allowed": true,
"availableCredits": 1,
"creditCost": 123
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Reads the current balance for a customer and active feature without consuming credits. Send the stable
customerId and featureId. The response includes allowed, availableCredits, and that feature’s creditCost; an insufficient balance returns 200 with allowed: false.
A check does not reserve credits. Other usage may occur before you record this action, so Record usage makes a fresh decision and may return 409 insufficient_credits even after allowed: true. Call from your backend before performing the feature, then track only a successful action.
An unknown customer or archived/unknown feature returns 404 customer_not_found or 404 feature_not_found. See Credits and usage for balance order and concurrency behavior.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json