Files
cfw-autumn/packages/sdk/.speakeasy/code-samples.overlay.yaml
Owen Greenhalgh 596a9bb7db regen sdk
2026-05-28 15:03:10 +01:00

1035 lines
28 KiB
YAML

overlay: 1.0.0
info:
title: CodeSamples overlay for typescript target
version: 0.0.0
actions:
- target: $["paths"]["/v1/balances.batch_track"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.batchTrack([
{
customerId: "cus_123",
featureId: "messages",
value: 1,
},
{
customerId: "cus_123",
eventName: "message.sent",
value: 1,
},
]);
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.check"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.check({
customerId: "cus_123",
featureId: "messages",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.create"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.balances.create({
customerId: "cus_123",
featureId: "api_calls",
reset: {
interval: "month",
},
});
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.delete"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.balances.delete({
customerId: "cus_123",
featureId: "api_calls",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.finalize"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.balances.finalize({
lockId: "lock_abc123",
action: "confirm",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.track"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.track({
customerId: "cus_123",
featureId: "messages",
value: 1,
});
console.log(result);
}
run();
- target: $["paths"]["/v1/balances.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.balances.update({
customerId: "cus_123",
featureId: "api_calls",
remaining: 5,
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.attach"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.attach({
customerId: "cus_123",
planId: "pro_plan",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.create_schedule"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.createSchedule({
customerId: "cus_123",
phases: [
{
startsAt: 1735689600000,
plans: [
{
planId: "trial_plan",
},
],
},
{
startsAt: 1736899200000,
plans: [
{
planId: "pro_plan",
},
],
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.multi_attach"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.multiAttach({
customerId: "cus_123",
plans: [
{
planId: "pro_plan",
},
{
planId: "addon_seats",
featureQuantities: [
{
featureId: "seats",
quantity: 5,
},
],
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.open_customer_portal"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.openCustomerPortal({
customerId: "cus_123",
returnUrl: "https://useautumn.com",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.preview_attach"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.previewAttach({
customerId: "cus_123",
planId: "pro_plan",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.preview_multi_attach"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.previewMultiAttach({
customerId: "cus_123",
plans: [
{
planId: "pro_plan",
},
{
planId: "addon_seats",
featureQuantities: [
{
featureId: "seats",
quantity: 5,
},
],
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.preview_update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.previewUpdate({
customerId: "cus_123",
planId: "pro_plan",
featureQuantities: [
{
featureId: "seats",
quantity: 15,
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.setup_payment"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.setupPayment({
customerId: "cus_123",
successUrl: "https://example.com/account/billing",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/billing.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.billing.update({
customerId: "cus_123",
planId: "pro_plan",
featureQuantities: [
{
featureId: "seats",
quantity: 10,
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/customers.delete"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.customers.delete({
customerId: "cus_123",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/customers.get"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.customers.get({
customerId: "cus_123",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/customers.get_or_create"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.customers.getOrCreate({
customerId: "cus_123",
name: "John Doe",
email: "john@example.com",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/customers.list"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.customers.list({
limit: 10,
});
console.log(result);
}
run();
- target: $["paths"]["/v1/customers.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.customers.update({
customerId: "cus_123",
name: "Jane Doe",
email: "jane@example.com",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/entities.create"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.entities.create({
name: "Seat 42",
featureId: "seats",
customerId: "cus_123",
entityId: "seat_42",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/entities.delete"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.entities.delete({
customerId: "cus_123",
entityId: "seat_42",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/entities.get"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.entities.get({
entityId: "seat_42",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/entities.list"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.entities.list({
limit: 10,
});
console.log(result);
}
run();
- target: $["paths"]["/v1/entities.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.entities.update({
customerId: "cus_123",
entityId: "seat_42",
billingControls: {
spendLimits: [
{
featureId: "messages",
enabled: true,
overageLimit: 25,
},
],
},
});
console.log(result);
}
run();
- target: $["paths"]["/v1/events.aggregate"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.events.aggregate({
customerId: "cus_123",
featureId: "api_calls",
range: "30d",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/events.list"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.events.list({
customerId: "cus_123",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/features.create"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.features.create({
name: "API Calls",
type: "metered",
consumable: true,
featureId: "api-calls",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/features.delete"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.features.delete({
featureId: "old-feature",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/features.get"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.features.get({
featureId: "api-calls",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/features.list"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.features.list();
console.log(result);
}
run();
- target: $["paths"]["/v1/features.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.features.update({
name: "API Requests",
display: {
singular: "API request",
plural: "API requests",
},
featureId: "api-calls",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/plans.create"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.plans.create({
planId: "free_plan",
name: "Free",
autoEnable: true,
items: [
{
featureId: "messages",
included: 100,
reset: {
interval: "month",
},
},
],
});
console.log(result);
}
run();
- target: $["paths"]["/v1/plans.delete"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.plans.delete({
planId: "unused_plan",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/plans.get"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.plans.get({
planId: "pro_plan",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/plans.list"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.plans.list({});
console.log(result);
}
run();
- target: $["paths"]["/v1/plans.update"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.plans.update({
planId: "pro_plan",
name: "Pro Plan (Updated)",
price: {
amount: 15,
interval: "month",
},
});
console.log(result);
}
run();
- target: $["paths"]["/v1/referrals.create_code"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.referrals.createCode({
customerId: "cus_123",
programId: "prog_123",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/referrals.redeem_code"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.referrals.redeemCode({
code: "REF123",
customerId: "cus_456",
});
console.log(result);
}
run();
- target: $["paths"]["/v1/rewards.redeem"]["post"]
update:
x-codeSamples:
- lang: typescript
label: Typescript (SDK)
source: |-
import { Autumn } from "@useautumn/sdk";
const autumn = new Autumn({
xApiVersion: "2.3.0",
secretKey: process.env["AUTUMN_SECRET_KEY"] ?? "",
});
async function run() {
const result = await autumn.rewards.redeemCode({
code: "REWARD10",
customerId: "cus_456",
});
console.log(result);
}
run();