---
title: "Create Razorpay Subscription"
method: POST
path: "/api/payments/razorpay/{environment}/subscriptions"
tags: ["Razorpay Payments"]
---

# Create Razorpay Subscription

`POST /api/payments/razorpay/{environment}/subscriptions`

Create a Razorpay Subscription and mirror it locally, then return Checkout options for authorization. The backend first evaluates the caller's INSERT policy on payments.razorpay_subscriptions so apps can restrict which subjects can start subscriptions.

## Path parameters

- `environment` 'test' | 'live', required

## Request body

- union — Notes keys starting with insforge_ are reserved and rejected. Either totalCount or endAt is required.
  - object
    - `planId` string, required
    - `totalCount` integer, required
    - `endAt` integer — Unix timestamp in seconds.
    - `quantity` integer
    - `startAt` integer — Unix timestamp in seconds.
    - `expireBy` integer — Unix timestamp in seconds.
    - `customerNotify` boolean
    - `offerId` string, nullable
    - `description` string, nullable
    - `subject` BillingSubject, required
      - `type` string, required
      - `id` string, required
    - `customerName` string, nullable
    - `customerEmail` string, email, nullable
    - `customerContact` string, nullable
    - `callbackUrl` string, uri, nullable
    - `notes` Metadata
  - object
    - `planId` string, required
    - `totalCount` integer
    - `endAt` integer, required — Unix timestamp in seconds.
    - `quantity` integer
    - `startAt` integer — Unix timestamp in seconds.
    - `expireBy` integer — Unix timestamp in seconds.
    - `customerNotify` boolean
    - `offerId` string, nullable
    - `description` string, nullable
    - `subject` BillingSubject, required
      - `type` string, required
      - `id` string, required
    - `customerName` string, nullable
    - `customerEmail` string, email, nullable
    - `customerContact` string, nullable
    - `callbackUrl` string, uri, nullable
    - `notes` Metadata

## Response `201`

Razorpay subscription created

- CreateRazorpaySubscriptionResponse
  - `subscription` RazorpaySubscription, required
    - `environment` 'test' | 'live', required
    - `subscriptionId` string, required
    - `planId` string, required
    - `customerId` string, nullable, required
    - `subjectType` string, nullable, required
    - `subjectId` string, nullable, required
    - `status` 'created' | 'authenticated' | 'active' | 'pending' | 'halted' | 'cancelled' | 'completed' | 'expired' | 'paused', required
    - `currentStart` string, date-time, nullable, required
    - `currentEnd` string, date-time, nullable, required
    - `endedAt` string, date-time, nullable, required
    - `quantity` integer, nullable, required
    - `chargeAt` string, date-time, nullable, required
    - `startAt` string, date-time, nullable, required
    - `endAt` string, date-time, nullable, required
    - `totalCount` integer, nullable, required
    - `authAttempts` integer, nullable, required
    - `paidCount` integer, nullable, required
    - `remainingCount` integer, nullable, required
    - `shortUrl` string, nullable, required
    - `hasScheduledChanges` boolean, required
    - `changeScheduledAt` string, date-time, nullable, required
    - `offerId` string, nullable, required
    - `authorizationPaymentId` string, nullable, required
    - `authorizationVerifiedAt` string, date-time, nullable, required
    - `notes` Metadata, required
    - `providerCreatedAt` string, date-time, nullable, required
    - `syncedAt` string, date-time, required
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required
  - `checkoutOptions` object, required
    - `key` string, required
    - `subscription_id` string, required
    - `name` string, nullable
    - `description` string, nullable
    - `callback_url` string, nullable
    - `prefill` RazorpayCheckoutPrefill, required
      - `name` string, nullable
      - `email` string, email, nullable
      - `contact` string, nullable

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `403` — Forbidden
- `500` — Internal server error

---

[API](https://skmtc.dev/insforge/apis/insforge-authentication-api.md) · [All operations](https://skmtc.dev/insforge/apis/insforge-authentication-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/insforge/insforge-authentication-api/revisions/a935bb49f932/schema)
