# Subscriptions/Recurring Payments

Following are the APIs that are required to create, debit, and cancel a subscription.

1. Create subscription - You can refer to the link given below to know the parameters required for creating a subscription:\
   \
   <https://docs.rocketfuel.inc/developer-guides/api-reference/generate-invoice-link><br>
2. Request a debit of funds for the subscription&#x20;

{% hint style="info" %}
Reminder emails are sent to the shoppers to make the pre-payment for the subscriptions with the invoice link or maintain the exchange balance equal to the bill amount.&#x20;
{% endhint %}

<mark style="color:green;">`POST`</mark> `/subscription/debit`

#### Request Body

| Name                                             | Type   | Description |
| ------------------------------------------------ | ------ | ----------- |
| merchantAuth<mark style="color:red;">\*</mark>   | String |             |
| merchantId<mark style="color:red;">\*</mark>     | String |             |
| orderId                                          | String |             |
| items                                            | Array  |             |
| subscriptionId<mark style="color:red;">\*</mark> | String |             |
| amount<mark style="color:red;">\*</mark>         | Number |             |
| currency<mark style="color:red;">\*</mark>       | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{

status: 200,

result: {

data: [{

      transactionId: response.id,

      amount: response.localAmount,

      currency: response.localCurrency,

      rateDivisor: response.rateDivisor,

      orderId: response.meta.offerId,

      status: response.status,

      userId,

      merchantId,

subscriptionId

}],

errors: [],

}
```

{% endtab %}
{% endtabs %}

3\. To cancel a subscription

<mark style="color:green;">`POST`</mark> `/subscription/cancel`

#### Request Body

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| merchantId     | String |             |
| merchantAuth   | String |             |
| subscriptionId | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{

status: 200,

result: { success: true }

}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{

  "ok": false,

  "statusCode": 400,

  "data": {

}

"message": "Subscription not found"

}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
  "ok": false,

  "statusCode": 500,
  "data": {

}

"message": "Internal server error"

  }
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rocketfuel.inc/developer-guides/api-reference/payins/utility-apis/subscriptions-recurring-payments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
