> ## Documentation Index
> Fetch the complete documentation index at: https://www.cashfree.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoPay Mandates for Wallet Recharge

> Set up a UPI AutoPay mandate with AgentPay MCP so your AI agent can recharge a customer's Cashfree wallet on demand, without payment links.

AutoPay mandates let your AI agent recharge a customer's Cashfree AgentPay wallet whenever it runs low, without sending a payment link each time. The customer approves a UPI AutoPay mandate once. After that, your agent raises a charge for the amount it needs, up to a limit the customer agreed to.

> [!WARNING]
>
> **AutoPay mandates are in beta.** The tools, arguments and responses on this page may change before general availability. Contact the Cashfree sales team to enable them for your account before you build on them.

This feature is currently limited to the following options:

* **Plan type:** `ON_DEMAND`. Your agent raises every charge. There's no fixed charge schedule.
* **Payment method:** UPI AutoPay (`upi`).

## What your customer experiences

From the customer's side, setting up AutoPay is a short chat. The following example shows a customer whose wallet balance is too low to pay a bill:

| Speaker | Message |
| - | - |
| **Customer** | Pay my electricity bill. |
| **Agent** | Your BESCOM bill is ₹1,350.00, but your wallet has ₹200.00. Do you want me to recharge your wallet automatically when it runs low? You approve UPI AutoPay once, for up to ₹2,000 per recharge. |
| **Customer** | Yes, set it up. |
| **Agent** | Which email address should I use for AutoPay updates? |
| **Customer** | [rahul@example.com](mailto:rahul@example.com) |
| **Agent** | Please approve UPI AutoPay in your UPI app using this link: \<link>. Tell me when you're done. |
| **Customer** | Done. |
| **Agent** | AutoPay is active. I've scheduled a ₹1,200.00 recharge. You'll get a notice from your bank before the debit, and the money reaches your wallet after that, usually within a day. I'll pay your bill once it arrives. |

The next time the wallet runs low, the agent tells the customer the amount and recharges the wallet without a new approval.

## Key concepts

Keep these concepts in mind as you build your integration:

* **Consent comes first.** Every AutoPay tool needs the customer's `access_token` from the AgentPay consent step. See [Get the customer's consent](https://www.cashfree.com/docs/tools-ai/agentpay-mcp/integration-guide.md#pay-a-bill-step-by-step).
* **A subscription holds the mandate.** You create one subscription for each customer. It carries the plan, which sets `plan_max_amount`, the most any single recharge can be.
* **The customer authorises once.** An `AUTH` payment returns a UPI AutoPay link. After the customer approves it, the subscription becomes `ACTIVE`.
* **Every recharge is a charge.** A `CHARGE` payment debits the customer's UPI account through the mandate. A charge isn't instant. Cashfree sends the customer a pre-debit notification and debits their account at least 24 hours later, on or after the `payment_schedule_date`. The charge stays `PENDING` until then, and becomes `SUCCESS` or `FAILED` after the debit.
* **You choose the IDs.** `subscription_id` and `payment_id` are your own references. They belong to this customer only, so a token for another customer can't see or change them.
* **The phone number comes from the consent.** Never ask the customer for it.
* **Ask the customer for their email address.** `create_subscription` needs it, and it doesn't come from the consent.

## Set up AutoPay and recharge the wallet

> [!NOTE]
>
> **Before you start, make sure you have:**
>
> * The AgentPay MCP server connected to your agent. See [Connect your agent](https://www.cashfree.com/docs/tools-ai/agentpay-mcp/integration-guide.md#connect-your-agent).
> * A valid `access_token` for the customer from the AgentPay consent flow.
> * AutoPay mandates enabled for your account.

Here is the whole journey at a glance. The approval happens only once for each customer:

```mermaid theme={"dark"}
flowchart LR
    A[1. Create the<br/>subscription] --> B[2. Request UPI<br/>AutoPay approval]
    B --> C[3. Customer<br/>approves]
    C --> D[4. Confirm it<br/>is active]
    D --> E[5. Raise a<br/>recharge]
    E --> F[6. Check the<br/>result]
```

**1. Create the subscription**

Ask the customer for their email address, then call `create_subscription` with an `ON_DEMAND` plan. Set `plan_max_amount` to the largest recharge you expect to need:

```json Arguments theme={"dark"}
{
  "subscription_id": "wallet_recharge_9999999999",
  "customer_details": { "customer_name": "Rahul Sharma", "customer_email": "rahul@example.com" },
  "plan_details": { "plan_type": "ON_DEMAND", "plan_name": "Wallet recharge", "plan_max_amount": 2000 },
  "authorization_details": { "authorization_amount": 1, "authorization_amount_refund": true, "payment_methods": ["upi"] },
  "access_token": "<ACCESS_TOKEN>"
}
```

The subscription starts as `INITIALIZED`. Save the `subscription_session_id` for the next step.

**2. Request UPI AutoPay approval**

Call `raise_subscription_charge` with `payment_type` set to `AUTH`:

```json Arguments theme={"dark"}
{
  "subscription_id": "wallet_recharge_9999999999",
  "payment_id": "auth_9999999999",
  "payment_type": "AUTH",
  "subscription_session_id": "sub_session_5611257126",
  "payment_method": { "upi": { "channel": "link" } },
  "access_token": "<ACCESS_TOKEN>"
}
```

The response contains UPI app links in `data.payload`. Send the customer the `default` link, or the link for their UPI app.

**3. Wait for the customer to approve**

The customer opens the link and approves the AutoPay mandate in their UPI app with their UPI PIN. Ask them to tell you when they're done.

**4. Confirm the subscription is active**

Call `get_subscription` until `subscription_status` is `ACTIVE` and `authorisation_details.authorization_status` is `ACTIVE`. If the authorisation fails, tell the customer and send a new `AUTH` request with a new `payment_id`.

Stop polling if the subscription reaches one of these statuses:

* `LINK_EXPIRED`: the customer didn't approve in time. Create a new subscription with a new `subscription_id`.
* `CUSTOMER_CANCELLED` or `CANCELLED`: the subscription has ended. Create a new one only if the customer asks.

See [Subscription statuses](#subscription-statuses) for every status.

**5. Raise a recharge**

When the wallet balance can't cover what the customer wants to pay, tell the customer the amount, then call `raise_subscription_charge` with `payment_type` set to `CHARGE`:

```json Arguments theme={"dark"}
{
  "subscription_id": "wallet_recharge_9999999999",
  "payment_id": "recharge_9999999999_1761120000",
  "payment_type": "CHARGE",
  "payment_amount": 1200,
  "payment_schedule_date": "2026-11-12T00:00:00+05:30",
  "payment_remarks": "Wallet recharge",
  "access_token": "<ACCESS_TOKEN>"
}
```

`payment_amount` can't exceed the plan's `plan_max_amount`. Use a new `payment_id` for every recharge.

The debit happens at least 24 hours after Cashfree notifies the customer, so tell the customer when to expect the money.

**6. Check the result**

After the scheduled debit, call `get_subscription_payments` and find your `payment_id`. When `payment_status` is `SUCCESS`, check the balance with `get_wallet_balance` and continue with the bill payment. If the bill's `ref_id` is more than 15 minutes old by then, fetch the bill again before you debit the wallet. If it's `FAILED`, read `failure_details.failure_reason` and tell the customer.

## Manage the mandate

After setup, you can change the subscription or a single recharge. Always confirm with the customer before you cancel anything.

The following actions are available:

| Task | Tool | Action |
| - | - | - |
| Stop all future recharges | `manage_subscription` | `CANCEL` |
| Retry a failed recharge | `manage_subscription_payment` | `RETRY`, with `next_scheduled_time` |
| Cancel a pending recharge | `manage_subscription_payment` | `CANCEL` |

> [!WARNING]
>
> **Cancel the subscription before you revoke consent.** Revoking the customer's AgentPay consent doesn't cancel their UPI AutoPay mandate. After revocation, your agent can't call the AutoPay tools for that customer. If the customer wants to stop using your agent, call `manage_subscription` with `CANCEL` first, then call `revoke_consent`.

## Tool reference

AutoPay mandates add six tools to the AgentPay MCP server. Every tool needs the customer's `access_token`. Tools that create or change something also accept an optional `idempotency_key`. Send the same key when you retry the same request, so Cashfree doesn't process it twice.

| Tool | What it does |
| - | - |
| `create_subscription` | Creates an on-demand subscription for the customer. |
| `get_subscription` | Returns the subscription's status and mandate details. |
| `manage_subscription` | Cancels the subscription. |
| `raise_subscription_charge` | Requests UPI AutoPay approval (`AUTH`) or raises a recharge (`CHARGE`). |
| `get_subscription_payments` | Lists every approval and recharge for the subscription. |
| `manage_subscription_payment` | Retries or cancels a single recharge. |

Send dates in ISO 8601 format with a time zone offset, for example `2026-11-12T00:00:00+05:30`. Send all amounts in rupees, not paise. IDs can contain up to 200 letters, digits, dots, underscores or hyphens.

### create\_subscription

Creates an on-demand subscription for the consented customer.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | Your unique reference for this subscription. |
| `customer_details` | object | Yes | `customer_email` (required) and `customer_name` (optional, letters and spaces only). Don't send the phone number. |
| `plan_details` | object | Yes | `plan_type` set to `ON_DEMAND`, plus either an existing `plan_id`, or `plan_name` (up to 40 characters) and `plan_max_amount` for a new plan. Optional: `plan_max_cycles`, `plan_currency` (default `INR`) and `plan_note`. |
| `authorization_details` | object | No | `authorization_amount` (at least 1 for UPI), `authorization_amount_refund`, and `payment_methods` (`["upi"]`, the default). |
| `subscription_meta` | object | No | `return_url` for after approval, and `notification_channel` (`SMS`, `EMAIL`). |
| `subscription_expiry_time` | string | No | When the subscription ends. |
| `subscription_tags` | object | No | Up to 10 key and value pairs for your reference. |
| `access_token` | string | Yes | From the consent step. |
| `idempotency_key` | string | No | Reuse it when you retry the same request. |

```json Response theme={"dark"}
{
  "cf_subscription_id": "4835078261",
  "subscription_id": "wallet_recharge_9999999999",
  "subscription_status": "INITIALIZED",
  "subscription_session_id": "sub_session_5611257126",
  "next_schedule_date": null,
  "customer_details": { "customer_name": "Rahul Sharma", "customer_email": "rahul@example.com", "customer_phone": "9999999999" },
  "plan_details": {
    "plan_id": "plan_8823",
    "plan_name": "Wallet recharge",
    "plan_type": "ON_DEMAND",
    "plan_currency": "INR",
    "plan_max_amount": 2000,
    "plan_status": "ACTIVE"
  },
  "authorisation_details": { "authorization_amount": 1, "authorization_amount_refund": true, "authorization_status": "INITIALIZED" }
}
```

### get\_subscription

Returns the subscription's current status and mandate details.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | From `create_subscription`. |
| `access_token` | string | Yes | From the consent step. |

```json Response (excerpt) theme={"dark"}
{
  "subscription_id": "wallet_recharge_9999999999",
  "subscription_status": "ACTIVE",
  "plan_details": { "plan_type": "ON_DEMAND", "plan_max_amount": 2000 },
  "authorisation_details": {
    "authorization_status": "ACTIVE",
    "authorization_time": "2026-11-12T12:04:33+05:30",
    "payment_id": "auth_9999999999",
    "payment_method": { "upi": { "upi_id": "success@upi" } }
  }
}
```

#### Subscription statuses

A subscription can have the following statuses:

| Status | Meaning | What your agent does |
| - | - | - |
| `INITIALIZED` | The subscription is created and waiting for the customer's approval. | Keep polling. |
| `ACTIVE` | The customer approved the mandate. | Raise recharges as needed. |
| `LINK_EXPIRED` | The approval link expired before the customer approved it. | Create a new subscription with a new `subscription_id`. |
| `CUSTOMER_PAUSED` | The customer paused the mandate in their UPI app. Only the customer can resume it. | Tell the customer that recharges stay paused until they resume AutoPay in their UPI app. |
| `CUSTOMER_CANCELLED` | The customer cancelled the mandate in their UPI app. | Tell the customer that AutoPay is off. Create a new subscription only if they ask. |
| `CANCELLED` | Your agent cancelled the subscription. | Create a new subscription only if the customer asks. |
| `COMPLETED` | The subscription reached `plan_max_cycles`. | Create a new subscription if the customer wants to continue. |
| `EXPIRED` | The subscription reached `subscription_expiry_time`. | Create a new subscription if the customer wants to continue. |

When a customer pauses or cancels the mandate in their UPI app, the status changes within 30 to 45 minutes.

### manage\_subscription

Cancels the subscription.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | From `create_subscription`. |
| `action` | string | Yes | `CANCEL`. |
| `access_token` | string | Yes | From the consent step. |
| `idempotency_key` | string | No | Reuse it when you retry the same request. |

The response is the updated subscription, in the same format as `get_subscription`. `CANCEL` can't be undone.

### raise\_subscription\_charge

Requests UPI AutoPay approval, or raises a recharge on an active subscription.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | From `create_subscription`. |
| `payment_id` | string | Yes | Your unique reference for this payment. |
| `payment_type` | string | No | `AUTH` for approval, or `CHARGE` for a recharge. Default is `CHARGE`. |
| `subscription_session_id` | string | For `AUTH` | From `create_subscription`. |
| `payment_method` | object | For `AUTH` | `{ "upi": { "channel": "link" } }`. |
| `payment_amount` | number | For `CHARGE` | The recharge amount. It can't exceed `plan_max_amount`. |
| `payment_schedule_date` | string | For `CHARGE` | The date to debit the customer. |
| `payment_remarks` | string | No | A short description of the charge. |
| `access_token` | string | Yes | From the consent step. |
| `idempotency_key` | string | No | Reuse it when you retry the same request. |

```json Response (AUTH) theme={"dark"}
{
  "cf_payment_id": "8563578087",
  "subscription_id": "wallet_recharge_9999999999",
  "payment_id": "auth_9999999999",
  "payment_amount": 1,
  "payment_status": "PENDING",
  "payment_type": "AUTH",
  "payment_method": "UPI",
  "action": "custom",
  "channel": "link",
  "data": {
    "payload": {
      "default": "upi://mandate?...",
      "gpay": "tez://upi/mandate?...",
      "phonepe": "phonepe://mandate?...",
      "paytm": "paytmmp://mandate?..."
    }
  }
}
```

```json Response (CHARGE) theme={"dark"}
{
  "cf_payment_id": "6255515658",
  "subscription_id": "wallet_recharge_9999999999",
  "payment_id": "recharge_9999999999_1761120000",
  "payment_amount": 1200,
  "payment_status": "PENDING",
  "payment_type": "CHARGE",
  "payment_method": "UPI",
  "failure_details": null,
  "data": {}
}
```

A `CHARGE` response isn't the final result. Check `get_subscription_payments` until the payment is `SUCCESS` or `FAILED`.

### get\_subscription\_payments

Lists every approval and recharge for the subscription.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | From `create_subscription`. |
| `access_token` | string | Yes | From the consent step. |

```json Response theme={"dark"}
[
  {
    "cf_payment_id": "8563578087",
    "subscription_id": "wallet_recharge_9999999999",
    "payment_id": "auth_9999999999",
    "payment_type": "AUTH",
    "payment_amount": 1,
    "payment_status": "SUCCESS",
    "retry_attempts": 0,
    "failure_details": null
  },
  {
    "cf_payment_id": "6255515658",
    "subscription_id": "wallet_recharge_9999999999",
    "payment_id": "recharge_9999999999_1761120000",
    "payment_type": "CHARGE",
    "payment_amount": 1200,
    "payment_status": "FAILED",
    "payment_schedule_date": "2026-11-12T00:00:00+05:30",
    "retry_attempts": 1,
    "failure_details": { "failure_reason": "INSUFFICIENT_FUNDS" }
  }
]
```

A payment moves from `PENDING` to `SUCCESS`, `FAILED` or `CANCELLED`.

### manage\_subscription\_payment

Retries or cancels a single recharge.

| Argument | Type | Required | Description |
| - | - | - | - |
| `subscription_id` | string | Yes | From `create_subscription`. |
| `payment_id` | string | Yes | The recharge to change. |
| `action` | string | Yes | `RETRY` for a failed recharge, or `CANCEL` for a pending one. |
| `next_scheduled_time` | string | For `RETRY` | The date to try the debit again. |
| `access_token` | string | Yes | From the consent step. |
| `idempotency_key` | string | No | Reuse it when you retry the same request. |

The response is the updated payment, in the same format as an item from `get_subscription_payments`.

## Troubleshooting

The following table lists common errors and how to fix them:

| Error | Cause | Fix |
| - | - | - |
| `Invalid enum value. Expected 'ON_DEMAND'` | You sent another plan type. | Use `ON_DEMAND`. |
| `Invalid enum value. Expected 'upi'` or `payment_method must have exactly one of: upi` | You sent another payment method. | Use `{ "upi": { "channel": "link" } }`. |
| `Invalid enum value. Expected 'CANCEL'` | You sent an unsupported action, such as `PAUSE`. | Use `CANCEL`. |
| `plan_details needs plan_id, or plan_name and plan_max_amount for a new plan` | The plan is incomplete. | Send an existing `plan_id`, or `plan_name` and `plan_max_amount`. |
| `payment_amount is required for CHARGE` | The recharge has no amount. | Add `payment_amount`. |
| `payment_schedule_date is required for CHARGE` | The recharge has no debit date. | Add `payment_schedule_date`. |
| `subscription_session_id and payment_method are required for AUTH` | The approval request is incomplete. | Use the `subscription_session_id` from `create_subscription` and the UPI payment method. |
| `next_scheduled_time is required for RETRY` | The date is missing. | Add `next_scheduled_time`. |
| Input validation error on `subscription_id` or `payment_id` | The ID has spaces or other characters, or is longer than 200 characters. | Use only letters, digits, dots, underscores and hyphens. |
| HTTP 401 or 403 | The `access_token` has expired, or the customer revoked consent. | Call `refresh_access_token`. If the customer revoked consent, start the consent flow again before you manage their subscription. |

## Talk to the customer

Your agent talks to the customer in plain terms. Follow these practices:

* Explain what AutoPay is for and the maximum amount per recharge before you send the approval link.
* Tell the customer the amount before every recharge.
* Confirm before you cancel a subscription or a recharge.
* If the customer wants your agent to stop, cancel their subscription before you revoke consent.
* Don't mention tokens, session IDs, payment IDs or tool names.
* Don't ask for the customer's phone number. It comes from their consent.

## Test in sandbox

Use the same sandbox server URL, API key and consent OTP as in [Test in sandbox](https://www.cashfree.com/docs/tools-ai/agentpay-mcp/integration-guide.md#test-in-sandbox), then complete the following checks:

1. **Setup.** Create a subscription, request approval and confirm it becomes `ACTIVE`.
2. **Recharge.** Raise a `CHARGE` and confirm it appears in `get_subscription_payments`.
3. **Limits.** Raise a `CHARGE` above `plan_max_amount` and check that your agent handles the error.
4. **Retry.** Retry a failed recharge with `manage_subscription_payment`.
5. **Cancel.** Cancel the subscription and check that Cashfree refuses new recharges.

> [!NOTE]
>
> In beta, sandbox responses for AutoPay mandates are sample data. Statuses don't change over time, so use them to check your request format and agent flow, not real payment outcomes.

Related topics

<ul>
  <li>[AgentPay MCP Integration Guide](https://www.cashfree.com/docs/tools-ai/agentpay-mcp/integration-guide.md)</li>
  <li>[AgentPay MCP Tool Reference](https://www.cashfree.com/docs/tools-ai/agentpay-mcp/tool-reference.md)</li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.