cURL
curl --request POST 'https://api.integrateledger.com/v1/add-ons' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"id":"extra_credits","name":"Extra credits","type":"credit_pack","creditAmount":50,"priceCents":500}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.create_add_on(id="extra_credits", name="Extra credits", credit_amount=50, price_cents=500)import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.createAddOn({ id: "extra_credits", name: "Extra credits", type: "credit_pack", creditAmount: 50, priceCents: 500 });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '<string>',
name: '<string>',
type: 'credit_pack',
creditAmount: 123,
priceCents: 123
})
};
fetch('https://api.integrateledger.com/v1/add-ons', 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/add-ons",
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([
'id' => '<string>',
'name' => '<string>',
'type' => 'credit_pack',
'creditAmount' => 123,
'priceCents' => 123
]),
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/add-ons"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\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/add-ons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/add-ons")
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 \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\n}"
response = http.request(request)
puts response.read_body{
"item": {
"id": "extra_credits",
"name": "Extra credits",
"type": "credit_pack",
"creditAmount": 50,
"priceCents": 500
},
"changed": true
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Add-ons
Create an add-on
Create one credit pack without replacing other catalog items.
POST
/
v1
/
add-ons
cURL
curl --request POST 'https://api.integrateledger.com/v1/add-ons' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"id":"extra_credits","name":"Extra credits","type":"credit_pack","creditAmount":50,"priceCents":500}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.create_add_on(id="extra_credits", name="Extra credits", credit_amount=50, price_cents=500)import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.createAddOn({ id: "extra_credits", name: "Extra credits", type: "credit_pack", creditAmount: 50, priceCents: 500 });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '<string>',
name: '<string>',
type: 'credit_pack',
creditAmount: 123,
priceCents: 123
})
};
fetch('https://api.integrateledger.com/v1/add-ons', 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/add-ons",
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([
'id' => '<string>',
'name' => '<string>',
'type' => 'credit_pack',
'creditAmount' => 123,
'priceCents' => 123
]),
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/add-ons"
payload := strings.NewReader("{\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\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/add-ons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.integrateledger.com/v1/add-ons")
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 \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"credit_pack\",\n \"creditAmount\": 123,\n \"priceCents\": 123\n}"
response = http.request(request)
puts response.read_body{
"item": {
"id": "extra_credits",
"name": "Extra credits",
"type": "credit_pack",
"creditAmount": 50,
"priceCents": 500
},
"changed": true
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Create one credit pack without replacing other catalog items. An add-on is a one-time Stripe Checkout purchase that grants a fixed number of credits after payment. It can top up a customer who already has a plan.
Set the pack value
Settype to credit_pack, creditAmount to a positive integer, and priceCents to a positive integer in USD cents. For example, creditAmount: 50 and priceCents: 500 sells 50 credits for $5.00. The ID is a stable API identifier with letters, numbers, underscores, or hyphens (up to 100 characters); the name is a display label.
The response contains the created item and changed: true. Another active add-on with the same ID returns 409 already_exists. Credit-pack prices are created for each hosted Checkout session rather than synced as recurring Stripe catalog prices.
Sell a pack
Create or find the customer, then call Attach a plan or add-on withaddOnId and open its checkoutUrl. The purchase remains pending_checkout until Stripe confirms a paid session. Ledger grants the Checkout’s credit amount once and shows the purchase in the customer dashboard. Repeating the same attach request while Checkout is open returns the existing link; a different pack can return 409 purchase_pending.
The price and credit amount are fixed for an open Checkout. Update an add-on returns 409 purchase_pending if you try to change either value while a purchase is pending. When Stripe’s signed checkout.session.expired event reaches Ledger, the pending purchase is removed and the edit can be retried. A browser cancel redirect alone does not expire the Stripe session. Archive an add-on hides it from new purchases while keeping purchase history. See Customers for the complete top-up flow.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json