Update Subscription

Update a subscription's details.

Request

use dodopayments_rust::{
    models::PatchSubscriptionRequest, to_pretty_json, DodoPaymentsClientBuilder,
};

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = std::env::var("DODO_API_KEY")?;

    let client = DodoPaymentsClientBuilder::new()
        .bearer_token(&api_key)
        .enviroment("test_mode")
        .build()?;

    let subscription_id = "sub_xxxxxxxxxx";

    let resp = client
        .subscriptions()
        .id(subscription_id)
        .update()
        .body(PatchSubscriptionRequest {
            ..Default::default()
        })
        .send()
        .await?;

    println!("{}", to_pretty_json(&resp)?);

    Ok(())
}

Path Parameters

ParameterTypeDescription
subscription_idstringSubscription Id

Body

FieldTypeDescription
billingobject
cancel_at_next_billing_dateobjectWhen set, the subscription will remain active until the end of billing period
credit_entitlement_cartobjectUpdate credit entitlement cart settings
customer_nameobject
disable_on_demandobject
metadataobject
next_billing_dateobject
statusobject
tax_idobject

Responses

200 Status

FieldTypeDescription
addonsarray<AddonCartResponseItem>Addons associated with this subscription
billingBillingAddressBilling address details for payments
cancel_at_next_billing_datebooleanIndicates if the subscription will cancel at the next billing date
cancelled_atobjectCancelled timestamp if the subscription is cancelled
created_atstringTimestamp when the subscription was created
credit_entitlement_cartarray<CreditEntitlementCartResponse>Credit entitlement cart settings for this subscription
currencyCurrencyCurrency used for the subscription payments
custom_field_responsesobjectCustomer's responses to custom fields collected during checkout
customerCustomerLimitedDetailsResponseCustomer details associated with the subscription
discount_cycles_remainingobjectNumber of remaining discount cycles if discount is applied
discount_idobjectThe discount id if discount is applied
expires_atobjectTimestamp when the subscription will expire
metadataMetadataAdditional custom data associated with the subscription
meter_credit_entitlement_cartarray<MeterCreditEntitlementCartResponse>Meter credit entitlement cart settings for this subscription
metersarray<MeterCartResponseItem>Meters associated with this subscription (for usage-based billing)
next_billing_datestringTimestamp of the next scheduled billing. Indicates the end of current billing period
on_demandbooleanWether the subscription is on-demand or not
payment_frequency_countintegerNumber of payment frequency intervals
payment_frequency_intervalTimeIntervalTime interval for payment frequency (e.g. month, year)
payment_method_idobjectSaved payment method id used for recurring charges
previous_billing_datestringTimestamp of the last payment. Indicates the start of current billing period
product_idstringIdentifier of the product associated with this subscription
quantityintegerNumber of units/items included in the subscription
recurring_pre_tax_amountintegerAmount charged before tax for each recurring payment in smallest currency unit (e.g. cents)
scheduled_changeobject
statusSubscriptionStatusCurrent status of the subscription
subscription_idstringUnique identifier for the subscription
subscription_period_countintegerNumber of subscription period intervals
subscription_period_intervalTimeIntervalTime interval for the subscription period (e.g. month, year)
tax_idobjectTax identifier provided for this subscription (if applicable)
tax_inclusivebooleanIndicates if the recurring_pre_tax_amount is tax inclusive
trial_period_daysintegerNumber of days in the trial period (0 if no trial)

Subscription successfully updated

422 Status

Invalid Request Object or Parameters

500 Status

Something went wrong :(