cURL
curl --request POST 'https://api.integrateledger.com/v1/customers/stripe-customer?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"stripeCustomerId":"cus_123"}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.linkStripeCustomer({ customerId: "user_123", body: { stripeCustomerId: "cus_123" } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.link_stripe_customer(customer_id="user_123", stripe_customer_id="cus_123"){
"customerId": "<string>",
"stripeCustomerId": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "payload_too_large"
}{
"error": "rate_limited"
}{
"error": "internal_error",
"request_id": "<string>"
}{
"error": "<string>"
}Customers
Link a Stripe customer
Link a customer to the Stripe customer you already bill them with.
POST
/
v1
/
customers
/
stripe-customer
cURL
curl --request POST 'https://api.integrateledger.com/v1/customers/stripe-customer?customerId=user_123' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"stripeCustomerId":"cus_123"}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.linkStripeCustomer({ customerId: "user_123", body: { stripeCustomerId: "cus_123" } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.link_stripe_customer(customer_id="user_123", stripe_customer_id="cus_123"){
"customerId": "<string>",
"stripeCustomerId": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "payload_too_large"
}{
"error": "rate_limited"
}{
"error": "internal_error",
"request_id": "<string>"
}{
"error": "<string>"
}Use this when you move existing Stripe billing to Ledger: it’s the first step of Migrate from Stripe Billing. Pass the exact
customerId as a URL-encoded query value and the customer’s stripeCustomerId from your Stripe account. Create the customer first with Create or get a customer.
Ledger checks that the Stripe customer exists in the Stripe account connected for the key’s environment (Sandbox or Live), adds ledger_organization_id, ledger_customer_id and ledger_env to its metadata, and saves the link. It changes nothing else on the Stripe customer and charges nothing. After linking, Checkout and upgrades use this Stripe customer and its saved cards. A Sandbox customer on a test clock brings the clock’s time with it.
Linking the same Stripe customer again changes nothing. The call returns 409 stripe_customer_already_linked when the customer is linked to a different Stripe customer, 409 stripe_customer_linked_elsewhere when another of your customers has this one, and 409 stripe_customer_owned_elsewhere when its metadata names another Ledger workspace or environment. Unknown customers return 404 customer_not_found; a Stripe customer that doesn’t exist or was deleted returns 404 stripe_customer_not_found. The key needs the customers:write permission.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Required string length:
1 - 255Body
application/json
The customer's existing Stripe customer, in the Stripe account connected for this environment.
Maximum string length:
255