Setup Subscription


This API is used to set up a subscription for a customer.

EnvironmentHTTP MethodAPI
SandboxPOSThttps://api-preprod.phonepe.com/apis/pg-sandbox/subscriptions/v2/setup
ProductionPOSThttps://api.phonepe.com/apis/pg/subscriptions/v2/setup
Header NameHeader ValueDescription
Content-Typeapplication/json
AuthorizationO-Bearer <access_token>Pass access_token received in Authorization call
Sample Request
{
    "merchantOrderId": "MO1769085791683",
    "amount": 200,
    "paymentFlow": {
        "type": "SUBSCRIPTION_SETUP",
        "merchantSubscriptionId": "MS1769085791683",
        "authWorkflowType": "ZERO",
        "amountType": "FIXED",
        "maxAmount": 20000000,
        "frequency": "MONTHLY",
        "expireAt": 1769341171278,
        "paymentMode": {
            "type": "ENACH_ACCOUNT",
            "authInstrumentType": "NET_BANKING"
        },
        "merchantUrls": {
                "redirectUrl": "https://www.google.com",
                "cancelRedirectUrl": "https://www.google.com"
                }
        },
    "constraints": [
        {   "type":"ENACH_ACCOUNT",
            "accountNumber": "XXXXXXXX0223",
            "ifsc": "HDFC0000523",
            "accountType": "SAVINGS",
            "bankCustomerName": "Davneet"
        }
        ],
    "metaInfo": {
        "udf1": "udf1",
        "udf2": "udf2"
    }
}
Request Parameter
Parameter NameData TypeDescriptionConstraints
merchantOrderIdStringMerchant’s unique identifier for the orderMax Length = 63 characters
No Special characters are allowed except underscore “_” and hyphen “-“
amountLongInitial setup amount in paisa
paymentFlow.typeStringType of flow (e.g., SUBSCRIPTION_SETUP)
paymentFlow.merchantSubscriptionIdStringMerchant’s unique identifier for the subscription
paymentFlow.authWorkflowTypeStringAuthentication method (e.g., ZERO)
paymentFlow.amountTypeStringType of recurring charge (e.g., FIXED or VARIABLE)
paymentFlow.maxAmountLongMaximum limit for recurring debits in paisa
paymentFlow.frequencyStringFrequency of debit (e.g., ON_DEMAND, MONTHLY)
paymentFlow.expireAtLongMandate expiry timestamp in epoch
paymentFlow.paymentMode.typeStringPayment method (e.g., ENACH_ACCOUNT)
paymentFlow.paymentMode.authInstrumentTypeStringAuth channel (e.g., NET_BANKING)
paymentFlow.merchantUrls.redirectUrlStringSuccess redirect URL
paymentFlow.merchantUrls.cancelRedirectUrlStringFailure/Cancel redirect URL
constraints[].typeStringType of account constraint (e.g., ENACH_ACCOUNT)
constraints[].accountNumberStringCustomer bank account numberAccount number length should be
min = 8, max = 20
constraints[].ifscStringBank IFSC code
constraints[].accountTypeStringAccount type (e.g., SAVINGS)
constraints[].bankCustomerNameStringName as per bank records
metaInfo.udf1StringUser Defined Field 1
metaInfo.udf2StringUser Defined Field 2
Sample Response
{
    "orderId" : "OMO123",
    "state" : "PENDING",
    "redirectUrl" : "http-redirect-url",
}
Response Parameters
Parameter NameData TypeDescription
orderIdStringPG generated internal order ID
stateStringCurrent state (e.g., PENDING)
redirectUrlStringURL to redirect user for bank authentication
Is this article helpful?