Files
cfw-autumn/others/python-sdk/.speakeasy/code-samples.overlay.yaml
2026-06-04 15:39:06 +01:00

889 lines
25 KiB
YAML

overlay: 1.0.0
info:
title: CodeSamples overlay for python target
version: 0.0.0
actions:
- target: $["paths"]["/v1/balances.batch_track"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.batch_track(request=[
{
"customer_id": "cus_123",
"feature_id": "messages",
"value": 1,
},
{
"customer_id": "cus_123",
"event_name": "message.sent",
"value": 1,
},
])
# Handle response
print(res)
- target: $["paths"]["/v1/balances.check"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.check(customer_id="cus_123", feature_id="messages")
# Handle response
print(res)
- target: $["paths"]["/v1/balances.create"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.balances.create(customer_id="cus_123", feature_id="api_calls", reset={
"interval": "month",
})
# Handle response
print(res)
- target: $["paths"]["/v1/balances.delete"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.balances.delete(customer_id="cus_123", feature_id="api_calls")
# Handle response
print(res)
- target: $["paths"]["/v1/balances.finalize"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.balances.finalize(lock_id="lock_abc123", action="confirm")
# Handle response
print(res)
- target: $["paths"]["/v1/balances.track"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.track(customer_id="cus_123", feature_id="messages", value=1)
# Handle response
print(res)
- target: $["paths"]["/v1/balances.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.balances.update(customer_id="cus_123", feature_id="api_calls", remaining=5)
# Handle response
print(res)
- target: $["paths"]["/v1/billing.attach"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.attach(customer_id="cus_123", plan_id="pro_plan", redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.create_schedule"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.create_schedule(customer_id="cus_123", phases=[
{
"starts_at": 1735689600000,
"plans": [
{
"plan_id": "trial_plan",
},
],
},
{
"starts_at": 1736899200000,
"plans": [
{
"plan_id": "pro_plan",
},
],
},
], redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.multi_attach"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.multi_attach(customer_id="cus_123", plans=[
{
"plan_id": "pro_plan",
},
{
"plan_id": "addon_seats",
"feature_quantities": [
{
"feature_id": "seats",
"quantity": 5,
},
],
},
], redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.open_customer_portal"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.open_customer_portal(customer_id="cus_123", return_url="https://useautumn.com")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.preview_attach"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.preview_attach(customer_id="cus_123", plan_id="pro_plan", redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.preview_multi_attach"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.preview_multi_attach(customer_id="cus_123", plans=[
{
"plan_id": "pro_plan",
},
{
"plan_id": "addon_seats",
"feature_quantities": [
{
"feature_id": "seats",
"quantity": 5,
},
],
},
], redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.preview_update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.preview_update(customer_id="cus_123", plan_id="pro_plan", feature_quantities=[
{
"feature_id": "seats",
"quantity": 15,
},
], redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.setup_payment"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.setup_payment(customer_id="cus_123", success_url="https://example.com/account/billing")
# Handle response
print(res)
- target: $["paths"]["/v1/billing.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.billing.update(customer_id="cus_123", plan_id="pro_plan", feature_quantities=[
{
"feature_id": "seats",
"quantity": 10,
},
], redirect_mode="if_required")
# Handle response
print(res)
- target: $["paths"]["/v1/customers.delete"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.customers.delete(customer_id="cus_123", delete_in_stripe=False)
# Handle response
print(res)
- target: $["paths"]["/v1/customers.get"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.customers.get(customer_id="cus_123")
# Handle response
print(res)
- target: $["paths"]["/v1/customers.get_or_create"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.customers.get_or_create(customer_id="cus_123", name="John Doe", email="john@example.com")
# Handle response
print(res)
- target: $["paths"]["/v1/customers.list"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.customers.list(start_cursor="", limit=10)
# Handle response
print(res)
- target: $["paths"]["/v1/customers.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.customers.update(customer_id="cus_123", name="Jane Doe", email="jane@example.com")
# Handle response
print(res)
- target: $["paths"]["/v1/entities.create"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.entities.create(feature_id="seats", customer_id="cus_123", entity_id="seat_42", name="Seat 42")
# Handle response
print(res)
- target: $["paths"]["/v1/entities.delete"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.entities.delete(entity_id="seat_42", customer_id="cus_123")
# Handle response
print(res)
- target: $["paths"]["/v1/entities.get"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.entities.get(entity_id="seat_42")
# Handle response
print(res)
- target: $["paths"]["/v1/entities.list"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.entities.list(start_cursor="", limit=10)
# Handle response
print(res)
- target: $["paths"]["/v1/entities.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.entities.update(entity_id="seat_42", customer_id="cus_123", billing_controls={
"spend_limits": [
{
"feature_id": "messages",
"enabled": True,
"overage_limit": 25,
},
],
})
# Handle response
print(res)
- target: $["paths"]["/v1/events.aggregate"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.events.aggregate(feature_id="api_calls", customer_id="cus_123", range="30d", bin_size="day")
# Handle response
print(res)
- target: $["paths"]["/v1/events.list"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.events.list(start_cursor="", limit=50, customer_id="cus_123")
# Handle response
print(res)
- target: $["paths"]["/v1/features.create"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.features.create(name="API Calls", type_="metered", feature_id="api-calls", consumable=True)
# Handle response
print(res)
- target: $["paths"]["/v1/features.delete"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.features.delete(feature_id="old-feature")
# Handle response
print(res)
- target: $["paths"]["/v1/features.get"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.features.get(feature_id="api-calls")
# Handle response
print(res)
- target: $["paths"]["/v1/features.list"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.features.list()
# Handle response
print(res)
- target: $["paths"]["/v1/features.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.features.update(feature_id="api-calls", name="API Requests", display={
"singular": "API request",
"plural": "API requests",
})
# Handle response
print(res)
- target: $["paths"]["/v1/plans.create"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.plans.create(plan_id="free_plan", name="Free", group="", add_on=False, auto_enable=True, items=[
{
"feature_id": "messages",
"included": 100,
"reset": {
"interval": "month",
},
},
], create_in_stripe=True)
# Handle response
print(res)
- target: $["paths"]["/v1/plans.delete"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.plans.delete(plan_id="unused_plan", all_versions=False)
# Handle response
print(res)
- target: $["paths"]["/v1/plans.get"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.plans.get(plan_id="pro_plan")
# Handle response
print(res)
- target: $["paths"]["/v1/plans.list"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.plans.list(request={})
# Handle response
print(res)
- target: $["paths"]["/v1/plans.update"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.plans.update(plan_id="pro_plan", group="", name="Pro Plan (Updated)", price={
"amount": 15,
"interval": "month",
}, create_in_stripe=True, archived=False)
# Handle response
print(res)
- target: $["paths"]["/v1/platform.get_revenuecat_keys"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.platform.get_revenue_cat_keys(organization_slug="acme", env="test")
# Handle response
print(res)
- target: $["paths"]["/v1/platform.link_revenuecat"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.platform.link_revenue_cat(organization_slug="acme", env="test", project_name="acme-mobile", redirect_url="https://dashboard.useautumn.com/dev?tab=revenuecat")
# Handle response
print(res)
- target: $["paths"]["/v1/platform.sync_revenuecat"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.platform.sync_revenue_cat(organization_slug="acme", env="test", product_ids=[
"pro",
"premium",
])
# Handle response
print(res)
- target: $["paths"]["/v1/referrals.create_code"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.referrals.create_code(customer_id="cus_123", program_id="prog_123")
# Handle response
print(res)
- target: $["paths"]["/v1/referrals.redeem_code"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.referrals.redeem_code(code="REF123", customer_id="cus_456")
# Handle response
print(res)
- target: $["paths"]["/v1/rewards.redeem"]["post"]
update:
x-codeSamples:
- lang: python
label: Python (SDK)
source: |-
from autumn_sdk import Autumn
with Autumn(
x_api_version="2.3.0",
secret_key="<YOUR_BEARER_TOKEN_HERE>",
) as autumn:
res = autumn.rewards.redeem_code(code="REWARD10", customer_id="cus_456")
# Handle response
print(res)