> ## Documentation Index
> Fetch the complete documentation index at: https://developer.transactbridge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Subscription

> This API is used to update a subscription. Partner can update the item values for the same frequency or change the frequency of the subscription or change the reattempt configuration of the subscription.



## OpenAPI

````yaml /api-reference/subscriptions/subs.json post /subscription/v1.0/updateSubscription
openapi: 3.0.3
info:
  title: Subscription API
  description: API for creating and managing subscription sessions and payments.
  version: 1.0.0
servers:
  - url: https://sandbox-api.transactbridge.com
    description: Sandbox Environment
  - url: https://api.transactbridge.com
    description: Production Environment
security:
  - ApiKeyAuth: []
    SignatureAuth: []
paths:
  /subscription/v1.0/updateSubscription:
    post:
      tags:
        - Subscription
      summary: Update Subscription
      description: >-
        This API is used to update a subscription. Partner can update the item
        values for the same frequency or change the frequency of the
        subscription or change the reattempt configuration of the subscription.
      operationId: UpdateSubscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                subscriptionId:
                  type: string
                  format: MongoId
                  description: >-
                    Subscription Id of the subscription for which update is
                    needed.
                  example: 65a1b2c3d4e5f67890123456
                items:
                  type: array
                  description: Items the customer wants to buy.
                  items:
                    type: object
                    required:
                      - name
                      - quantity
                      - amount
                    properties:
                      productReferenceId:
                        type: string
                        format: referenceId
                        description: >-
                          If the product is already created use the refereneId
                          of that product.
                      name:
                        type: string
                        description: Name of the product the customer wants to buy.
                      quantity:
                        type: number
                        description: Number of products the customer wants to buy.
                      amount:
                        type: number
                        description: Price of the product.
                      prorate:
                        type: number
                        description: >-
                          If the invoice needs to be partially paid the total
                          amount will be calculated using prorate on day
                          consumed basis.
                      description:
                        type: string
                        description: >-
                          Description of the product.


                          Description in the items object allows HTML syntax for
                          customer view. Use html syntax for code break so that
                          the description on the product page is better from a
                          UI perspective. We break and show the description like
                          unlisted items.
                      productId:
                        type: string
                        format: MongoId
                        description: >-
                          If product is already in the catelogue, Partner can
                          use that
                billTo:
                  type: object
                  description: Billing Details of the customer
                  properties:
                    name:
                      type: string
                      description: Name of the customer
                    line1:
                      type: string
                      description: Address Line 1 of the customer
                    line2:
                      type: string
                      description: Address Line 2 of the customer
                    city:
                      type: string
                      description: City of the customer
                    state:
                      type: string
                      description: State of the customer address
                    country:
                      type: string
                      description: >-
                        Country of the customer.[Enum for
                        country](/api-reference/validators-and-enum)
                    postalCode:
                      type: string
                      description: Pin code of the customer.
                reAttemptConfig:
                  type: array
                  description: >-
                    To configure how the reattempt for failed invoices be
                    processed.
                  items:
                    type: object
                    properties:
                      days:
                        type: string
                        description: >-
                          Number of days after which the reattempt is to be
                          made.
                        example: '3'
                      attemptType:
                        type: string
                        description: >-
                          Depending on the enum passed, the post-reattempt flow
                          is configured. `try_again` configures the system to
                          make a reattempt. Other values are terminal states
                          that change the status of the subscription and invoice
                          according to the configured enum.
                        enum:
                          - try_again
                          - subscription_active-invoice_unpaid
                          - subscription_paused-invoice_unpaid
                          - subscription_expire-invoice_unpaid
                          - subscription_expire-invoice_cancelled
                        example: try_again
                    required:
                      - days
                      - attemptType
                meta:
                  type: object
                  description: >-
                    To add meta params in the subscription. They will be passed
                    in the webhook and query API as well.
                  properties:
                    param1:
                      type: string
                      maxLength: 256
                    param2:
                      type: string
                      maxLength: 256
                    param3:
                      type: string
                      maxLength: 256
                couponDetails:
                  type: object
                  description: >-
                    To pass the coupon object and apply different coupons on the
                    subscription.
                  properties:
                    coupon:
                      type: string
                      description: String with max length of 256 characters.
                    applicable:
                      type: boolean
                      description: Always send true
                    discountType:
                      type: string
                      description: >-
                        Discount can be percentage based on the invoice value or
                        flat.
                      enum:
                        - PCNT
                        - FIX
                    discountPcnt:
                      type: string
                      description: If discountType is PCNT then this parameter is Mandatory
                    discountQuoteAmount:
                      type: string
                      description: If discountType is FIX then this parameter is Mandatory
                    durationType:
                      type: string
                      description: >-
                        The duration for which this coupon will be applicable on
                        the subscription.
                      enum:
                        - LIMITED_PERIOD
                        - FOREVER
                        - ONETIME
                    periodUnit:
                      type: string
                      description: >-
                        If durationType is LIMITED_PERIOD then this parameter is
                        Mandatory
                      enum:
                        - DAIL
                        - WEEK
                        - MNTH
                        - BIMN
                        - QURT
                        - MIAN
                        - YEAR
                        - ONDM
                    period:
                      type: number
                      description: >-
                        If durationType is LIMITED_PERIOD then this parameter is
                        Mandatory
                  required:
                    - coupon
                    - applicable
                    - discountType
                    - durationType
                frequency:
                  type: string
                  enum:
                    - DAIL
                    - WEEK
                    - MNTH
                    - BIMN
                    - QURT
                    - MIAN
                    - YEAR
                    - ONDM
                  description: >-
                    To update the frequency of a subscription. Only prepaid
                    subscriptions are allowed for frequency update.
                  example: MNTH
                maxUnpausedInvoiceDueCount:
                  type: object
                  description: >-
                    Maximum number of unpaid invoices count allowed after that
                    the subscription is PAUSED by the system. For example, if a
                    subscription has been paused due to 3 non-payment of
                    invoices and this parameter is set to 2, then once the
                    customer pays 1 invoice the subscription will be
                    reactivated.
                  example: 2
                maxQuoteAmount:
                  type: string
                  description: >-
                    Amount that can be auto-debited from the customer using the
                    existing mandate. Increasing this parameter might require a
                    new mandate setup.
                  example: 15000
              required:
                - subscriptionId
      responses:
        '200':
          description: Contains the updated subscription details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/updateSubscription'
components:
  schemas:
    updateSubscription:
      type: object
      properties:
        status:
          type: string
          description: The response from the API
        sub_status:
          type: string
          description: Used for internal purposes only
        data:
          type: object
          description: Contains the updated subscription details.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Merchant API Key
    SignatureAuth:
      type: apiKey
      in: header
      name: x-signature
      description: Generated request signature

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.