Setup Subscription


This API is used to set up a subscription for a customer. You will have to configure UPI Intent and UPI Collect. For UPI Collect, the customer’s UPI VPA (Virtual Payment Address) must be validated before initiating the UPI Collect request.

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
Request Parameters
Parameter NameData TypeDescriptionMandatoryConstraints
merchantOrderIdStringUnique merchant order id generated by merchant.YesMax Length = 63 characters.
No Special characters allowed except underscore “_” and hyphen “-“
amountLongMin Value = 100 (in Paise)Yes
The amount is in Paise.

Note:
For PENNY_DROP flow, the amount should be equal to 200 (In Paise)

For TRANSACTION flow, the amount should be greater than or equal to 100 and the first debit amount(In Paise)
expireAtDateTime(in milliseconds)NoDefault value – 10 minutes
metaInfoObjectMerchant defined meta info to store additional information.
Same data will be returned in status and callback response.
NoFor udf1 to udf10, there is no constraint.
For udf11 to udf15, alphanumeric values with _-+@. are allowed.
paymentFlowObjectAdditional details required by this flowYes
deviceContext.deviceOSStringThe type of device OS.YesPossible values
Android
• iOS

The metaInfo object contains additional parameters, which are explained in the table below.

Request Parameters of metoInfo Object:
Parameter NameData TypeDescriptionMandatory (Yes/No)Constraints
metaInfo.udf1-15StringOptional details you can add for more informationNoMaximum length for Udf1-10 = 256 characters
Maximum length for Udf11-15 = 50 characters

⚠️ Do Not Rename metainfo Parameters!


It is mandatory to keep the parameter names udf1, udf2, etc., exactly as they are in the metainfo block. Renaming these key values will result in a production error.

The paymentFlow object contains additional parameters, which are explained in the table below.

Request Parameters of paymentFlow Object:
Parameter NameData TypeDescriptionMandatoryConstraints
paymentFlow.typeStringType of payment flow.YesValues Allowed: [SUBSCRIPTION_SETUP]
paymentFlow.merchantSubscriptionIdStringUnique merchant reference subscription ID – used for subscription status.Yes
paymentFlow.authWorkflowTypeStringType of setup workflow.YesSubscription auth type.
Values:
PENNY_DROP
TRANSACTION
paymentFlow.amountTypeStringNature of redemption amount.YesPossible Values :
FIXED
VARIABLE
paymentFlow.maxAmountLongMax amount upto which redemptions will be allowed.YesThe MAXIMUM debit/redemption amount for the mandate.
The amount is in Paise.

Note:
For VARIABLE recurring debit, this amount would be considered as Max Cap Amount
paymentFlow.frequencyStringSubscription frequency.YesPossible Values :
DAILY
WEEKLY
MONTHLY
YEARLY
FORTNIGHTLY
BIMONTHLY
ON_DEMAND
QUARTERLY
HALFYEARLY
paymentFlow.expireAtDateTimeSubscription cycle expiry. No operation allowed after subscription expires.
(in milliseconds)
NoDefault Value : 30 years
paymentFlow.paymentMode
ObjectPayment mode details for setup.YesPossible Values :
{
    “type”: “UPI_INTENT”,
    “targetApp”: “com.phonepe.app”
}
{
    “type”: “UPI_COLLECT”,
    “details”: {
        “type”: “VPA”,
        “vpa”: “1234567890@ybl”
    }
}
paymentFlow.paymentMode.targetAppStringTarget app for intent payment mode.Yes• Android: Package Name of the UPI app

• iOS: Static Values like [PHONEPE, GPAY, PAYTM, CRED, SUPERMONEY, BHIM, AMAZON]
Sample Request
{
    "merchantOrderId": "MO1709025658932",
    "amount": 200,
    "expireAt": 1709058548000,
    "metaInfo": {
        "udf1": "some meta info of max length 256",
        "udf2": "some meta info of max length 256",
        "udf3": "some meta info of max length 256",
        "udf4": "some meta info of max length 256",
        "udf5": "some meta info of max length 256",
        "udf6": "some meta info of max length 256",
        "udf7": "some meta info of max length 256",
        "udf8": "some meta info of max length 256",
        "udf10": "some meta info of max length 256",
        "udf11": "some meta info of max length 50",
        "udf12": "some meta info of max length 50",
        "udf13": "some meta info of max length 50",
        "udf14": "some meta info of max length 50",
        "udf15": "some meta info of max length 50"
    },
    "paymentFlow": {
        "type": "SUBSCRIPTION_SETUP",
        "merchantSubscriptionId": "MS1709025658932",
        "authWorkflowType": "TRANSACTION",
        "amountType": "FIXED",
        "maxAmount": 200,
        "frequency": "ON_DEMAND",
        "expireAt": 1737278524000,
        "paymentMode": {
            "type": "UPI_INTENT",
            "targetApp": "com.phonepe.app"
        }
    },
    "deviceContext": {
        "deviceOS": "ANDROID"
    }
}
Sample Request in CURL
curl --location 'https://api-preprod.phonepe.com/apis/pg-sandbox/subscriptions/v2/setup' \
--header 'Accept: application/json' \
--header 'Authorization: O-Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MTIyNTM2MjU2NDQsIm1lcmNoYW50SWQiOiJWMlNVQlVBVCJ9.7aVzYI_f_77-bBicEcRNuYx093b2wCsgl_WFNkKqAPY' \
--header 'Content-Type: application/json' \
--data '{
   "merchantOrderId": "MO1443709025658932",
   "amount": 200,
   "expireAt": 1709058548000,
   "paymentFlow": {
       "type": "SUBSCRIPTION_SETUP",
       "merchantSubscriptionId": "MS1709025658932",
       "authWorkflowType": "TRANSACTION",
       "amountType": "FIXED",
       "maxAmount": 200,
       "frequency": "ON_DEMAND",
       "expireAt": 1737278524000,
       "paymentMode": {
           "type": "UPI_INTENT",
           "targetApp": "com.phonepe.app"
       }
   },
    "deviceContext" : {
        "deviceOS" : "ANDROID"
    }
}'
Sample Response
{
    "orderId" : "OMO2408072246197375675282",
    "state" : "PENDING",
    "intentUrl" : "ppesim://mandate?pa=VRUAT@ybl&pn=SUBSCRIBEMID&am=300&mam=&tr=OM2408072246197385675168&utm_campaign=SUBSCRIBE_AUTH&utm_medium=VRUAT&utm_source=OM2408072246197385675168"
}

Use this API to validate the customer’s UPI VPA. This verification must be completed before initiating a UPI Collect transaction.

EnvironmentHTTP MethodAPI
SandboxPOSThttps://api-preprod.phonepe.com/apis/pg-sandbox/v2/validate/upi
ProductionPOSThttps://api.phonepe.com/apis/pg/v2/validate/upi
Request Headers
Header NameHeader Value
Content-Typeapplication/json
AuthorizationO-Bearer <access_token>
Request Parameters
Parameter NameData TypeDescriptionMandatory (Yes/No)Constraints
typeStringType of UPI Payment Address.YesValues allowed: [VPA]
vpaStringVPA of user to validate.YesMax Length: 255
Sample Request
{
    "type": "VPA",
    "vpa": "****@ybl" //add success@ybl/failure@ybl/pending@ybl here.
}

📘 Simulating PhonePe Mandate Responses!


In the UAT environment, you will not receive an actual collect request. The system provides a mocked API response that is simulated based on the VPA address you enter.

To test the different scenarios, please follow these steps:

  1. In the VPA Address field, enter one of the following test VPAs:
    • Success@ybl (Simulates a successful validation and mandate creation)
    • Failure@ybl (Simulates a failed validation)
    • Pending@ybl (Simulates a pending or in-progress response)
  2. After submitting, the API will return a corresponding response based on the VPA you entered.
  3. Please verify that the subscription status correctly reflects that API response.
Case 1: Sample Response for VPA is Valid
{
    "valid": true,
    "name": "<Name of User>"
}
Case 2: Sample Response for Invalid VPA
{    
    "valid": false
}
Response Parameters
Parameter NameData TypeDescriptionMandatoryConstraints
typeStringType of UPI Payment AddressYesClient ID shared by PhonePe PG
vpaStringVPA of user to validateYesMax Length: 255
Sample Request
{
    "merchantOrderId": "MO1709025691805",
    "amount": 200,
    "expireAt": 1709058548000,
    "metaInfo": {
        "udf1": "some meta info of max length 256",
        "udf2": "some meta info of max length 256",
        "udf3": "some meta info of max length 256",
        "udf4": "some meta info of max length 256",
        "udf5": "some meta info of max length 256",
        "udf6": "additional-information-6",
        "udf7": "additional-information-7",
        "udf8": "additional-information-8",
        "udf9": "additional-information-9",
        "udf10": "additional-information-10",
        "udf11": "additional-information-11",
        "udf12": "additional-information-12",
        "udf13": "additional-information-13",
        "udf14": "additional-information-14",
        "udf15": "additional-information-15"
    },
    "paymentFlow": {
        "type": "SUBSCRIPTION_SETUP",
        "merchantSubscriptionId": "MS1709025691805",
        "authWorkflowType": "TRANSACTION",
        "amountType": "VARIABLE",
        "maxAmount": 2000,
        "frequency": "ON_DEMAND",
        "expireAt": 1737278524000,
        "paymentMode": {
            "type": "UPI_COLLECT",
            "details": {
                "type": "VPA",
                "vpa": "****@ybl" //add success@ybl/failure@ybl/pending@ybl here.
            }
        }
    }
}
Sample Request in CURL
curl --location 'https://api-preprod.phonepe.com/apis/pg-sandbox/subscriptions/v2/setup' \
--header 'Accept: application/json' \
--header 'Authorization: O-Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MTIyNTM2MjU2NDQsIm1lcmNoYW50SWQiOiJWMlNVQlVBVCJ9.7aVzYI_f_77-bBicEcRNuYx093b2wCsgl_WFNkKqAPY' \
--header 'Content-Type: application/json' \
--data-raw '{
   "merchantOrderId": "MO1709025691805",
   "amount": 200,
   "expireAt": 1709058548000,
   "paymentFlow": {
       "type": "SUBSCRIPTION_SETUP",
       "merchantSubscriptionId": "MS1709025691805",
       "authWorkflowType": "TRANSACTION",
       "amountType": "VARIABLE",
       "maxAmount": 2000,
       "frequency": "ON_DEMAND",
       "expireAt": 1737278524000,
       "paymentMode": {
           "type": "UPI_COLLECT",
           "details": {
               "type": "VPA",
                "vpa": "****@ybl" //add success@ybl/failure@ybl/pending@ybl here.
           }
       }
   }
}
Sample Response
{
    "orderId" : "OMO2408072246197375675282",
    "state" : "PENDING"
}

You can also test this API request directly in Postman for a quick and easy integration check.

In the next section, you will learn about the two types of order status APIs provided by PhonePe to track subscription actions. These will help you monitor the progress of both subscription setup and redemption requests in real time.

Is this article helpful?