> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-60c89f9a-mintlify-audit-missing-sections-1778528421.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a subscription

> Creates a new subscription for a customer based on an existing plan.



## OpenAPI

````yaml /openapi/products.json post /subscriptions
openapi: 3.1.0
info:
  title: Razorpay Products API
  description: >-
    API specification for Razorpay Payment Links, Subscriptions, and QR Codes
    products.
  version: 1.0.0
  contact:
    name: Razorpay Support
    url: https://razorpay.com/support
servers:
  - url: https://api.razorpay.com/v1
    description: Razorpay Production API
security:
  - basicAuth: []
tags:
  - name: Payment Links
    description: >-
      Create and manage payment links to collect payments from customers without
      building a checkout flow.
  - name: Plans
    description: >-
      Create and manage plans that define the billing period and amount for
      subscriptions.
  - name: Subscriptions
    description: >-
      Create and manage recurring subscriptions for customers based on defined
      plans.
  - name: QR Codes
    description: Create and manage QR codes for accepting UPI payments in-store or online.
  - name: Invoices
    description: Create and manage invoices to bill customers for products and services.
paths:
  /subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create a subscription
      description: Creates a new subscription for a customer based on an existing plan.
      operationId: createSubscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSubscriptionRequest'
            example:
              plan_id: plan_00000000000001
              total_count: 6
              customer_notify: 1
              start_at: 1580453311
              quantity: 1
              addons: []
              notes:
                notes_key_1: Tea, Earl Grey, Hot
                notes_key_2: Tea, Earl Grey… decaf.
      responses:
        '200':
          description: Subscription created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
              example:
                id: sub_00000000000001
                entity: subscription
                plan_id: plan_00000000000001
                status: created
                total_count: 6
                paid_count: 0
                remaining_count: 6
                customer_notify: 1
                start_at: 1580453311
                end_at: null
                charge_at: 1580453311
                created_at: 1580453311
        '400':
          description: >-
            Bad request. The request body is missing required fields or contains
            invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized. Invalid or missing API credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateSubscriptionRequest:
      type: object
      required:
        - plan_id
        - total_count
      properties:
        plan_id:
          type: string
          description: Unique identifier of the plan to subscribe to.
          example: plan_00000000000001
        total_count:
          type: integer
          description: Total number of billing cycles for the subscription.
          example: 6
        customer_notify:
          type: integer
          description: >-
            Set to `1` to notify the customer via email and SMS, `0` to suppress
            notifications.
          enum:
            - 0
            - 1
          example: 1
        start_at:
          type: integer
          description: >-
            Unix timestamp at which the subscription should start. Defaults to
            the current time if not provided.
          example: 1580453311
        quantity:
          type: integer
          description: Number of subscriptions to be charged on a single charge.
          example: 1
        addons:
          type: array
          description: List of add-ons to include with the subscription.
          items:
            type: object
          example: []
        notes:
          type: object
          description: >-
            Key-value pairs for storing additional information. Maximum 15
            pairs, each key up to 40 characters and value up to 256 characters.
          additionalProperties:
            type: string
          example:
            notes_key_1: Tea, Earl Grey, Hot
            notes_key_2: Tea, Earl Grey… decaf.
    Subscription:
      type: object
      description: A Razorpay Subscription object.
      properties:
        id:
          type: string
          description: Unique identifier of the subscription.
          example: sub_00000000000001
        entity:
          type: string
          description: Entity type. Always `subscription`.
          example: subscription
        plan_id:
          type: string
          description: Unique identifier of the plan associated with this subscription.
          example: plan_00000000000001
        status:
          type: string
          description: Current status of the subscription.
          enum:
            - created
            - authenticated
            - active
            - pending
            - halted
            - cancelled
            - completed
            - expired
          example: created
        total_count:
          type: integer
          description: Total number of billing cycles in the subscription.
          example: 6
        paid_count:
          type: integer
          description: Number of billing cycles that have been successfully paid.
          example: 0
        remaining_count:
          type: integer
          description: Number of billing cycles remaining.
          example: 6
        customer_notify:
          type: integer
          description: >-
            Indicates whether the customer should be notified. `1` for yes, `0`
            for no.
          enum:
            - 0
            - 1
          example: 1
        start_at:
          type: integer
          description: Unix timestamp at which the subscription starts billing.
          example: 1580453311
          nullable: true
        end_at:
          type: integer
          description: Unix timestamp at which the subscription ends.
          example: null
          nullable: true
        charge_at:
          type: integer
          description: Unix timestamp of the next scheduled charge.
          example: 1580453311
          nullable: true
        created_at:
          type: integer
          description: Unix timestamp at which the subscription was created.
          example: 1580453311
    ErrorResponse:
      type: object
      description: Standard error response from the Razorpay API.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code.
              example: BAD_REQUEST_ERROR
            description:
              type: string
              description: Human-readable description of the error.
              example: The amount must be greater than 0.
            field:
              type: string
              description: The field that caused the error, if applicable.
              example: amount
              nullable: true
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Use your Razorpay Key ID as the username and Key Secret as the password.

````