> ## Documentation Index
> Fetch the complete documentation index at: https://dodopayments-mintlify-external-integration-datafast-autosen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Subscription

> Update a subscription's details.



## OpenAPI

````yaml patch /subscriptions/{subscription_id}
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.61.5
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /subscriptions/{subscription_id}:
    patch:
      tags:
        - Subscriptions
      operationId: patch_subscription_handler
      parameters:
        - name: subscription_id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchSubscriptionRequest'
        required: true
      responses:
        '200':
          description: Subscription successfully updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionResponse'
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


            const client = new DodoPayments({
              bearerToken: 'My Bearer Token',
            });


            const subscription = await
            client.subscriptions.update('subscription_id');


            console.log(subscription.product_id);
        - lang: Python
          source: |-
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token="My Bearer Token",
            )
            subscription = client.subscriptions.update(
                subscription_id="subscription_id",
            )
            print(subscription.product_id)
        - lang: Go
          source: |
            package main

            import (
              "context"
              "fmt"

              "github.com/dodopayments/dodopayments-go"
              "github.com/dodopayments/dodopayments-go/option"
            )

            func main() {
              client := dodopayments.NewClient(
                option.WithBearerToken("My Bearer Token"),
              )
              subscription, err := client.Subscriptions.Update(
                context.TODO(),
                "subscription_id",
                dodopayments.SubscriptionUpdateParams{

                },
              )
              if err != nil {
                panic(err.Error())
              }
              fmt.Printf("%+v\n", subscription.ProductID)
            }
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import com.dodopayments.api.models.subscriptions.Subscription;

            import
            com.dodopayments.api.models.subscriptions.SubscriptionUpdateParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    Subscription subscription = client.subscriptions().update("subscription_id");
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import com.dodopayments.api.models.subscriptions.Subscription

            import
            com.dodopayments.api.models.subscriptions.SubscriptionUpdateParams


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val subscription: Subscription = client.subscriptions().update("subscription_id")
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )

            subscription = dodo_payments.subscriptions.update("subscription_id")

            puts(subscription)
components:
  schemas:
    PatchSubscriptionRequest:
      type: object
      properties:
        billing:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/BillingAddress'
        cancel_at_next_billing_date:
          type:
            - boolean
            - 'null'
          description: >-
            When set, the subscription will remain active until the end of
            billing period
        customer_name:
          type:
            - string
            - 'null'
        disable_on_demand:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DisableOnDemandReq'
        metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Metadata'
        next_billing_date:
          type:
            - string
            - 'null'
          format: date-time
        status:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SubscriptionStatus'
        tax_id:
          type:
            - string
            - 'null'
    SubscriptionResponse:
      type: object
      description: Response struct representing subscription details
      required:
        - subscription_id
        - recurring_pre_tax_amount
        - tax_inclusive
        - currency
        - status
        - created_at
        - product_id
        - quantity
        - trial_period_days
        - subscription_period_interval
        - payment_frequency_interval
        - subscription_period_count
        - payment_frequency_count
        - next_billing_date
        - previous_billing_date
        - customer
        - metadata
        - cancel_at_next_billing_date
        - billing
        - on_demand
        - addons
        - meters
      properties:
        addons:
          type: array
          items:
            $ref: '#/components/schemas/AddonCartResponseItem'
          description: Addons associated with this subscription
        billing:
          $ref: '#/components/schemas/BillingAddress'
          description: Billing address details for payments
        cancel_at_next_billing_date:
          type: boolean
          description: Indicates if the subscription will cancel at the next billing date
        cancelled_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Cancelled timestamp if the subscription is cancelled
        created_at:
          type: string
          format: date-time
          description: Timestamp when the subscription was created
        currency:
          $ref: '#/components/schemas/Currency'
          description: Currency used for the subscription payments
        customer:
          $ref: '#/components/schemas/CustomerLimitedDetailsResponse'
          description: Customer details associated with the subscription
        discount_cycles_remaining:
          type:
            - integer
            - 'null'
          format: int32
          description: Number of remaining discount cycles if discount is applied
        discount_id:
          type:
            - string
            - 'null'
          description: The discount id if discount is applied
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Timestamp when the subscription will expire
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional custom data associated with the subscription
        meters:
          type: array
          items:
            $ref: '#/components/schemas/MeterCartResponseItem'
          description: Meters associated with this subscription (for usage-based billing)
        next_billing_date:
          type: string
          format: date-time
          description: >-
            Timestamp of the next scheduled billing. Indicates the end of
            current billing period
        on_demand:
          type: boolean
          description: Wether the subscription is on-demand or not
        payment_frequency_count:
          type: integer
          format: int32
          description: Number of payment frequency intervals
        payment_frequency_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: Time interval for payment frequency (e.g. month, year)
        payment_method_id:
          type:
            - string
            - 'null'
          description: Saved payment method id used for recurring charges
        previous_billing_date:
          type: string
          format: date-time
          description: >-
            Timestamp of the last payment. Indicates the start of current
            billing period
        product_id:
          type: string
          description: Identifier of the product associated with this subscription
        quantity:
          type: integer
          format: int32
          description: Number of units/items included in the subscription
        recurring_pre_tax_amount:
          type: integer
          format: int32
          description: >-
            Amount charged before tax for each recurring payment in smallest
            currency unit (e.g. cents)
        status:
          $ref: '#/components/schemas/SubscriptionStatus'
          description: Current status of the subscription
        subscription_id:
          type: string
          description: Unique identifier for the subscription
        subscription_period_count:
          type: integer
          format: int32
          description: Number of subscription period intervals
        subscription_period_interval:
          $ref: '#/components/schemas/TimeInterval'
          description: Time interval for the subscription period (e.g. month, year)
        tax_id:
          type:
            - string
            - 'null'
          description: Tax identifier provided for this subscription (if applicable)
        tax_inclusive:
          type: boolean
          description: Indicates if the recurring_pre_tax_amount is tax inclusive
        trial_period_days:
          type: integer
          format: int32
          description: Number of days in the trial period (0 if no trial)
    BillingAddress:
      type: object
      required:
        - country
        - state
        - city
        - street
        - zipcode
      properties:
        city:
          type: string
          description: City name
        country:
          $ref: '#/components/schemas/CountryCodeAlpha2'
          description: Two-letter ISO country code (ISO 3166-1 alpha-2)
        state:
          type: string
          description: State or province name
        street:
          type: string
          description: >-
            Street address including house number and unit/apartment if
            applicable
        zipcode:
          type: string
          description: Postal code or ZIP code
    DisableOnDemandReq:
      type: object
      title: Disable On Demand Request
      required:
        - next_billing_date
      properties:
        next_billing_date:
          type: string
          format: date-time
    Metadata:
      type: object
      additionalProperties:
        type: string
      propertyNames:
        type: string
    SubscriptionStatus:
      type: string
      enum:
        - pending
        - active
        - on_hold
        - cancelled
        - failed
        - expired
    AddonCartResponseItem:
      type: object
      title: Addon Cart Response Item
      description: Response struct representing subscription details
      required:
        - addon_id
        - quantity
      properties:
        addon_id:
          type: string
        quantity:
          type: integer
          format: int32
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
    CustomerLimitedDetailsResponse:
      type: object
      required:
        - customer_id
        - name
        - email
      properties:
        customer_id:
          type: string
          description: Unique identifier for the customer
        email:
          type: string
          description: Email address of the customer
        metadata:
          $ref: '#/components/schemas/Metadata'
          description: Additional metadata associated with the customer
        name:
          type: string
          description: Full name of the customer
        phone_number:
          type:
            - string
            - 'null'
          description: Phone number of the customer
    MeterCartResponseItem:
      type: object
      description: >-
        Response struct representing usage-based meter cart details for a
        subscription
      required:
        - meter_id
        - price_per_unit
        - free_threshold
        - currency
        - name
        - measurement_unit
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
        description:
          type:
            - string
            - 'null'
        free_threshold:
          type: integer
          format: int64
        measurement_unit:
          type: string
        meter_id:
          type: string
        name:
          type: string
        price_per_unit:
          type: string
          example: '10.50'
    TimeInterval:
      type: string
      enum:
        - Day
        - Week
        - Month
        - Year
    CountryCodeAlpha2:
      type: string
      description: ISO country code alpha2 variant
      enum:
        - AF
        - AX
        - AL
        - DZ
        - AS
        - AD
        - AO
        - AI
        - AQ
        - AG
        - AR
        - AM
        - AW
        - AU
        - AT
        - AZ
        - BS
        - BH
        - BD
        - BB
        - BY
        - BE
        - BZ
        - BJ
        - BM
        - BT
        - BO
        - BQ
        - BA
        - BW
        - BV
        - BR
        - IO
        - BN
        - BG
        - BF
        - BI
        - KH
        - CM
        - CA
        - CV
        - KY
        - CF
        - TD
        - CL
        - CN
        - CX
        - CC
        - CO
        - KM
        - CG
        - CD
        - CK
        - CR
        - CI
        - HR
        - CU
        - CW
        - CY
        - CZ
        - DK
        - DJ
        - DM
        - DO
        - EC
        - EG
        - SV
        - GQ
        - ER
        - EE
        - ET
        - FK
        - FO
        - FJ
        - FI
        - FR
        - GF
        - PF
        - TF
        - GA
        - GM
        - GE
        - DE
        - GH
        - GI
        - GR
        - GL
        - GD
        - GP
        - GU
        - GT
        - GG
        - GN
        - GW
        - GY
        - HT
        - HM
        - VA
        - HN
        - HK
        - HU
        - IS
        - IN
        - ID
        - IR
        - IQ
        - IE
        - IM
        - IL
        - IT
        - JM
        - JP
        - JE
        - JO
        - KZ
        - KE
        - KI
        - KP
        - KR
        - KW
        - KG
        - LA
        - LV
        - LB
        - LS
        - LR
        - LY
        - LI
        - LT
        - LU
        - MO
        - MK
        - MG
        - MW
        - MY
        - MV
        - ML
        - MT
        - MH
        - MQ
        - MR
        - MU
        - YT
        - MX
        - FM
        - MD
        - MC
        - MN
        - ME
        - MS
        - MA
        - MZ
        - MM
        - NA
        - NR
        - NP
        - NL
        - NC
        - NZ
        - NI
        - NE
        - NG
        - NU
        - NF
        - MP
        - 'NO'
        - OM
        - PK
        - PW
        - PS
        - PA
        - PG
        - PY
        - PE
        - PH
        - PN
        - PL
        - PT
        - PR
        - QA
        - RE
        - RO
        - RU
        - RW
        - BL
        - SH
        - KN
        - LC
        - MF
        - PM
        - VC
        - WS
        - SM
        - ST
        - SA
        - SN
        - RS
        - SC
        - SL
        - SG
        - SX
        - SK
        - SI
        - SB
        - SO
        - ZA
        - GS
        - SS
        - ES
        - LK
        - SD
        - SR
        - SJ
        - SZ
        - SE
        - CH
        - SY
        - TW
        - TJ
        - TZ
        - TH
        - TL
        - TG
        - TK
        - TO
        - TT
        - TN
        - TR
        - TM
        - TC
        - TV
        - UG
        - UA
        - AE
        - GB
        - UM
        - US
        - UY
        - UZ
        - VU
        - VE
        - VN
        - VG
        - VI
        - WF
        - EH
        - YE
        - ZM
        - ZW
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````