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

# Create a Subscription

> Use this API to create a subscription by specifying the plan ID or plan Info and customer details.You can also specify the bank account information when you create the subscription to ensure that mandates are created via the specified bank account only. TPV is applicable only for eNACH and UPI Autopay. The Auth Link received in the response will be redirected to a link hosted on cashfree.com. Once the authorization is complete, your customer will be redirected to returnUrl. Store the subReferenceId as this is the unique ID generated by Cashfree Payments for the subscription and will be required for subsequent operations.



## OpenAPI

````yaml post /api/v2/subscriptions/nonSeamless/subscription
openapi: 3.0.0
info:
  title: Cashfree Subscription API
  description: >-
    Create and manage subscriptions and collect recurring payments from
    customers easily with Cashfree Subscriptions.
  version: v2
servers:
  - url: https://sandbox.cashfree.com
    description: Sandbox server
  - url: https://api.cashfree.com
    description: Production server
security: []
externalDocs:
  url: https://docs.cashfree.com/reference/postman-collection-1
  description: This url will have the information of all the APIs.
paths:
  /api/v2/subscriptions/nonSeamless/subscription:
    post:
      tags:
        - Subscription
      summary: Create a Subscription
      description: >-
        Use this API to create a subscription by specifying the plan ID or plan
        Info and customer details.You can also specify the bank account
        information when you create the subscription to ensure that mandates are
        created via the specified bank account only. TPV is applicable only for
        eNACH and UPI Autopay. The Auth Link received in the response will be
        redirected to a link hosted on cashfree.com. Once the authorization is
        complete, your customer will be redirected to returnUrl. Store the
        subReferenceId as this is the unique ID generated by Cashfree Payments
        for the subscription and will be required for subsequent operations.
      operationId: createSubscription
      parameters:
        - name: X-Client-Id
          in: header
          required: true
          schema:
            type: string
            description: Client ID provided by Cashfree.
            example: '14443641'
        - name: X-Client-Secret
          in: header
          required: true
          schema:
            type: string
            description: Client Secret provided by Cashfree.
            example: a477ed7e
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                subscriptionId:
                  type: string
                  description: Unique ID for the subscription.
                  example: DemoSubscriptionq
                customerName:
                  type: string
                  description: Customer's name for the subscription.
                  example: John Doe
                customerPhone:
                  type: string
                  description: Customer's phone number.
                  example: '9999900000'
                customerEmail:
                  type: string
                  description: Customer's email address.
                  example: john@gmail.com
                returnUrl:
                  type: string
                  description: >-
                    URL to which the customer is redirected after the
                    subscription process.
                  example: www.google.com
                authAmount:
                  type: number
                  description: Authorization amount for subscription.
                  example: 10
                expiresOn:
                  type: string
                  description: Expiry date of the subscription.
                  example: '2024-12-02 09:20:12'
                tpvEnabled:
                  type: boolean
                  description: Flag to enable TPV (Third Party Verification).
                  example: true
                payerAccountDetails:
                  type: object
                  description: Details of the payer's account if TPV is enabled.
                  properties:
                    accountNumber:
                      type: string
                      description: Account number of the payer.
                      example: '0123456789'
                    accountHolderName:
                      type: string
                      description: Account holder's name.
                      example: John Doe
                    bankId:
                      type: string
                      description: Bank identifier for the payer's bank.
                      example: ICIC
                    accountType:
                      type: string
                      description: Type of the bank account (e.g., SAVINGS).
                      example: SAVINGS
                    ifsc:
                      type: string
                      description: IFSC code of the bank.
                      example: ICIC0000001
                planInfo:
                  type: object
                  description: Information regarding the plan.
                  properties:
                    type:
                      type: string
                      description: Type of subscription plan.
                      enum:
                        - PERIODIC
                        - ON_DEMAND
                      example: ON_DEMAND
                    planName:
                      type: string
                      description: Name of the subscription plan.
                      example: abcede
                    maxAmount:
                      type: number
                      description: Maximum amount for the subscription plan.
                      example: 1000
                    maxCycles:
                      type: integer
                      description: Maximum number of cycles for the subscription.
                      example: 10
                    linkExpiry:
                      type: integer
                      description: Number of days after which the link expires.
                      example: 5
                    intervalType:
                      type: string
                      description: Interval type for periodic subscriptions (e.g., MONTH).
                      example: MONTH
                    recurringAmount:
                      type: number
                      description: Recurring amount for periodic subscriptions.
                      example: 100
                    intervals:
                      type: integer
                      description: Number of intervals for periodic subscriptions.
                      example: 2
                notificationChannels:
                  type: array
                  items:
                    type: string
                  description: Notification channels for updates.
                  example:
                    - EMAIL
                    - SMS
                splitDetails:
                  type: object
                  description: Details regarding payment split between different vendors.
                  properties:
                    scheme:
                      type: array
                      items:
                        type: object
                        properties:
                          merchantVendorId:
                            type: string
                            description: ID of the vendor.
                            example: test-vendor-1
                          percentage:
                            type: integer
                            description: Percentage of payment to be split.
                            example: 10
            examples:
              CreateSubscriptionWithoutTPV:
                summary: Create On-Demand Subscription without TPV Enabled
                value:
                  subscriptionId: DemoSubscriptionq
                  customerName: John Doe
                  customerPhone: '9999900000'
                  customerEmail: john@gmail.com
                  returnUrl: www.google.com
                  authAmount: 10
                  expiresOn: '2024-12-02 09:20:12'
                  planInfo:
                    type: ON_DEMAND
                    planName: abcede
                    maxAmount: 1000
                    maxCycles: 10
                    linkExpiry: 5
                  notificationChannels:
                    - EMAIL
                    - SMS
              CreateSubscriptionWithTPV:
                summary: Create On-Demand Subscription with TPV Enabled
                value:
                  subscriptionId: DemoSubscriptionq
                  customerName: John Doe
                  customerPhone: '9999900000'
                  customerEmail: john@gmail.com
                  returnUrl: www.google.com
                  authAmount: 10
                  expiresOn: '2024-12-02 09:20:12'
                  tpvEnabled: true
                  payerAccountDetails:
                    accountNumber: '0123456789'
                    accountHolderName: John Doe
                    bankId: ICIC
                    accountType: SAVINGS
                    ifsc: ICIC0000001
                  planInfo:
                    type: ON_DEMAND
                    planName: abcede
                    maxAmount: 1000
                    maxCycles: 10
                    linkExpiry: 5
                  notificationChannels:
                    - EMAIL
                    - SMS
              CreateSubscriptionWithSplitDetails:
                summary: Create On-Demand Subscription with Split Details
                value:
                  subscriptionId: DemoSubscriptionq
                  customerName: John Doe
                  customerPhone: '9999900000'
                  customerEmail: john@gmail.com
                  returnUrl: www.google.com
                  authAmount: 10
                  expiresOn: '2024-12-02 09:20:12'
                  planInfo:
                    type: ON_DEMAND
                    planName: abcede
                    maxAmount: 1000
                    maxCycles: 10
                    linkExpiry: 5
                  notificationChannels:
                    - EMAIL
                    - SMS
                  splitDetails:
                    scheme:
                      - merchantVendorId: test-vendor-1
                        percentage: 10
                      - merchantVendorId: test-vendor-2
                        percentage: 10
              CreatePeriodicSubscriptionWithoutTPV:
                summary: Create Periodic Subscription without TPV Enabled
                value:
                  subscriptionId: DemoSubscription
                  customerName: John Doe
                  customerPhone: '9999900000'
                  customerEmail: john@gmail.com
                  returnUrl: www.google.com
                  authAmount: 10
                  expiresOn: '2024-12-02 09:20:12'
                  firstChargeDate: '2023-12-02'
                  planInfo:
                    type: PERIODIC
                    intervalType: MONTH
                    planName: abcede
                    maxAmount: 1000
                    intervals: 2
                    recurringAmount: 100
                    maxCycles: 10
                    linkExpiry: 5
                  notificationChannels:
                    - EMAIL
                    - SMS
              CreatePeriodicSubscriptionWithTPV:
                summary: Create Periodic Subscription with TPV Enabled
                value:
                  subscriptionId: DemoSubscription
                  customerName: John Doe
                  customerPhone: '9999900000'
                  customerEmail: john@gmail.com
                  returnUrl: www.google.com
                  authAmount: 10
                  expiresOn: '2024-12-02 09:20:12'
                  firstChargeDate: '2023-12-02'
                  tpvEnabled: true
                  payerAccountDetails:
                    accountNumber: '0123456789'
                    accountHolderName: John Doe
                    bankId: ICIC
                    accountType: SAVINGS
                    ifsc: ICIC0000001
                  planInfo:
                    type: PERIODIC
                    intervalType: MONTH
                    planName: abcede
                    maxAmount: 1000
                    intervals: 2
                    recurringAmount: 100
                    maxCycles: 10
                  notificationChannels:
                    - EMAIL
                    - SMS
      responses:
        '200':
          description: Subscription created successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: HTTP response status.
                    example: 200
                  message:
                    type: string
                    description: >-
                      Message indicating the status of the subscription
                      creation.
                    example: Subscription Created
                  data:
                    type: object
                    properties:
                      subReferenceId:
                        type: integer
                        description: Reference ID for the subscription.
                        example: 1234
                      authLink:
                        type: string
                        description: Authorization link for the subscription.
                        example: https://cfre.in/wjnwdj3
        '400':
          description: Bad request due to invalid parameters or validation issues.
          content:
            application/json:
              examples:
                RecurringAmountError:
                  summary: Recurring Amount Error
                  value:
                    status: ERROR
                    subCode: '400'
                    message: Recurring amount cannot be greater than mandate amount
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the API call.
                    example: ERROR
                  message:
                    type: string
                    description: Error message.
                    example: Server encountered an unexpected condition.

````