Setup Subscription
This API is used to set up a subscription for a customer.
Environment
| Environment | HTTP Method | API |
| Sandbox | POST | https://api-preprod.phonepe.com/apis/pg-sandbox/subscriptions/v2/setup |
| Production | POST | https://api.phonepe.com/apis/pg/subscriptions/v2/setup |
Request
| Header Name | Header Value | Description |
| Content-Type | application/json | |
| Authorization | O-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 Name | Data Type | Description | Constraints |
merchantOrderId | String | Merchant’s unique identifier for the order | Max Length = 63 characters No Special characters are allowed except underscore “_” and hyphen “-“ |
amount | Long | Initial setup amount in paisa | |
paymentFlow.type | String | Type of flow (e.g., SUBSCRIPTION_SETUP) | |
paymentFlow.merchantSubscriptionId | String | Merchant’s unique identifier for the subscription | |
paymentFlow.authWorkflowType | String | Authentication method (e.g., ZERO) | |
paymentFlow.amountType | String | Type of recurring charge (e.g., FIXED or VARIABLE) | |
paymentFlow.maxAmount | Long | Maximum limit for recurring debits in paisa | |
paymentFlow.frequency | String | Frequency of debit (e.g., ON_DEMAND, MONTHLY) | |
paymentFlow.expireAt | Long | Mandate expiry timestamp in epoch | |
paymentFlow.paymentMode.type | String | Payment method (e.g., ENACH_ACCOUNT) | |
paymentFlow.paymentMode.authInstrumentType | String | Auth channel (e.g., NET_BANKING) | |
paymentFlow.merchantUrls.redirectUrl | String | Success redirect URL | |
paymentFlow.merchantUrls.cancelRedirectUrl | String | Failure/Cancel redirect URL | |
constraints[].type | String | Type of account constraint (e.g., ENACH_ACCOUNT) | |
constraints[].accountNumber | String | Customer bank account number | Account number length should be min = 8, max = 20 |
constraints[].ifsc | String | Bank IFSC code | |
constraints[].accountType | String | Account type (e.g., SAVINGS) | |
constraints[].bankCustomerName | String | Name as per bank records | |
metaInfo.udf1 | String | User Defined Field 1 | |
metaInfo.udf2 | String | User Defined Field 2 |
Response
Sample Response
{
"orderId" : "OMO123",
"state" : "PENDING",
"redirectUrl" : "http-redirect-url",
}Response Parameters
| Parameter Name | Data Type | Description |
orderId | String | PG generated internal order ID |
state | String | Current state (e.g., PENDING) |
redirectUrl | String | URL to redirect user for bank authentication |