cURL
curl --request POST 'https://api.integrateledger.com/v1/customers' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"customerId":"user_123"}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.create_or_get_customer(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.createOrGetCustomer({ customerId: "user_123" });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>'})
};
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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<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/customers"
payload := strings.NewReader("{\n \"customerId\": \"<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/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\"\n}")
.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::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"customerId": "<string>",
"created": true
}{
"error": "<string>"
}{
"error": "<string>"
}Customers and usage
Create or get a customer
Create a customer from an application ID in the selected environment, or return the existing customer.
POST
/
v1
/
customers
cURL
curl --request POST 'https://api.integrateledger.com/v1/customers' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"customerId":"user_123"}'import os
from ledger_sdk import Ledger
ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
ledger.create_or_get_customer(customer_id="user_123")import { Ledger } from "@ledger/sdk";
const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await ledger.createOrGetCustomer({ customerId: "user_123" });const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>'})
};
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 => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<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/customers"
payload := strings.NewReader("{\n \"customerId\": \"<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/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\"\n}")
.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::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"customerId": "<string>",
"created": true
}{
"error": "<string>"
}{
"error": "<string>"
}Creates a customer using your application’s stable user ID in the environment selected by your API key, or returns the customer already associated with that ID. Send a nonempty
customerId of at most 255 characters. The response echoes it with created: true for a new record or created: false for a repeat call.
This operation is safe to retry and does not attach a plan, create a Stripe customer, or grant credits by itself. The API key scopes the ID to your organization; another organization can use the same customer ID independently. After creation, use Attach a plan or add-on to start billing, then Check credits to read the balance.
Invalid input returns 400 invalid_request; a missing or invalid key returns 401 unauthorized. See Customers for the complete lifecycle.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Required string length:
1 - 255