cURL
curl --request POST 'https://api.integrateledger.com/v1/plans/starter/migrations' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"fromVersion":1,"toVersion":2,"timing":"at_renewal"}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.createPlanMigration({ id: "starter", body: { fromVersion: 1, toVersion: 2, timing: "at_renewal" } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.create_plan_migration("starter", from_version=1, to_version=2, timing="at_renewal"){
"migrationId": 123,
"planId": "<string>",
"fromVersion": 123,
"toVersion": 123,
"timing": "now",
"status": "draft",
"customers": 1,
"byChange": {
"priceUp": 1,
"priceDown": 1,
"same": 1
},
"progress": {
"queued": 1,
"scheduled": 1,
"applied": 1
},
"skipped": [
{
"customerId": "<string>",
"reason": "pending_change"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Plans
Preview moving subscribers to another version
See who would move from one plan version to another, how their price changes, and who is skipped.
POST
/
v1
/
plans
/
{id}
/
migrations
cURL
curl --request POST 'https://api.integrateledger.com/v1/plans/starter/migrations' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"fromVersion":1,"toVersion":2,"timing":"at_renewal"}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.createPlanMigration({ id: "starter", body: { fromVersion: 1, toVersion: 2, timing: "at_renewal" } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.create_plan_migration("starter", from_version=1, to_version=2, timing="at_renewal"){
"migrationId": 123,
"planId": "<string>",
"fromVersion": 123,
"toVersion": 123,
"timing": "now",
"status": "draft",
"customers": 1,
"byChange": {
"priceUp": 1,
"priceDown": 1,
"same": 1
},
"progress": {
"queued": 1,
"scheduled": 1,
"applied": 1
},
"skipped": [
{
"customerId": "<string>",
"reason": "pending_change"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Previews moving the subscribers of one version (
fromVersion, by number or label) to another (toVersion). The answer is a draft migration: how many subscribers move, whether their price goes up, down or stays the same, and who is skipped and why. Nothing moves until you run it.
timing: "at_renewal"(the default): each subscriber keeps the version they paid for until their next renewal, which bills and grants the new one.timing: "now": the new version starts at once, with no proration and no charge. The customer gets its allowance less what they already used this period, and its price bills from the next renewal.
pending_change), when Stripe’s subscription can’t take the change or the versions are billed differently, free and paid or on another billing interval (stripe_state), when a payment is owed (past_due), or while on a trial (trialing).
Needs the Billing permission at Write.Authorizations
Path Parameters
Body
application/json
at_renewal (the default): each subscriber keeps the version they paid for until their next renewal, which bills the new one. now: the new version starts at once, with no proration; its allowance less what this period used is granted, and its price bills from the next renewal.
Available options:
now, at_renewal Response
The preview, a draft migration