Create Plan
Endpoint for creating a Plan.
info
Please be aware that this endpoint requires a Manage Transactions API Key.
POST /api/v1/groups/{group_id}/revere_pay/{linked_account_id}/recurring/plans
info
Retry logic applies to subscriptions paid by credit card. Due to the nature and timeline of ACH payments, it is not relevant for the ACH payment method.
Request Parameters
| Name | Description | Type | Required |
|---|---|---|---|
| amount | The amount of the plan. | uint64 | Required |
| initial_amount | The initial amount of the plan. This amount is only used for the first transaction of the plan, and then the amount will be used. | uint64 | |
| billing_cycle | Billing cycle of the plan. It can be daily, weekly, monthly, quarterly, semiannual or annual. | string | Required |
| billing_factor | Billing factor of the Billing Cycle. For daily Billing Cycles, it represents the interval in days (e.g. 7 runs every 7 days). For weekly, monthly, quarterly, semiannual and annual Billing Cycles, it must be 1. | uint64 | |
| description | Description of the Plan. Will be seen by end-users, make sure it is recognizable. | string | |
| duration | Number of cycles the plan will run for. 6 means that the plan will run for 6 cycles. Use 0 for endless plans. | string | Required |
| name | Name of the Plan. Will be seen by end-users, make sure it is recognizable. | string | Required |
| proration_behavior | Controls how mid-cycle billing adjustments are handled when subscriptions on this plan are changed. Possible values: none, create_prorations, immediate_action. | string | |
| tax | The amount of tax included in the Plan. | uint64 | |
| shipping_amount | The amount of shipping included in the Plan. | uint64 | |
| trial_period_days | Number of days of the trial period. | uint64 | |
| trial_amount | The trial amount charged for the Plan at the beginning of the Trial period. Requires trial_period_days. | uint64 | |
| max_retry_count | Number of times the subscription should be tried to run. After the maximum retries, the subscription status will change to failed. Maximum value: 5 | uint64 | |
| retry_policy | Array of objects containing a custom retry schedule used when retrying a subscription's charge after a failed card payment. | object | |
| retry_policy.steps | Ordered list of retry steps, one entry per retry attempt. The number of steps must match max_retry_count. | object array | |
| retry_policy.steps[].delay_days | Number of days to wait before the next retry attempt runs. Must be greater than 0 and no more than 30. The sum of delay_days across all steps must not exceed 30. | uint64 |
Response
| Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request / Validation error |
| 500 | Internal Error |
Example Usage
- JavaScript
- Python
- Go
plans.js
var headers = new Headers();
headers.append('Authorization', 'API_KEY');
var requestOptions = {
method: 'POST',
headers: headers,
redirect: 'follow',
body: {
// request body data
}
};
const group_id = '';
const linked_account_id = '';
const url = `https://api.reverepayments.dev/api/v1/groups/${group_id}/revere_pay/${linked_account_id}/recurring/plans`;
fetch(url, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
plans.py
import requests
group_id = ""
linked_account_id = ""
url = "https://api.reverepayments.dev/api/v1/groups/"+group_id+"/revere_pay/"+linked_account_id+"/recurring/plans"
headers = {
'Authorization': 'API_KEY'
}
response = requests.request("POST", url, headers=headers, json={
// request body data
})
print(response.text)
plans.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
const group_id = ""
const linked_account_id = ""
url := "https://api.reverepayments.dev/api/v1/groups/" + group_id + "/revere_pay/" + linked_account_id + "/recurring/plans"
client := &http.Client{}
body := bytes.NewBuffer(nil)
_ = json.NewEncoder(body).Encode(map[string]any{
// body data
})
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Authorization", "API_KEY")
res, _ := client.Do(req)
defer res.Body.Close()
bytes, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(string(bytes))
}
Example Request
{
"name": "Monthly Plan",
"amount": 10000,
"initial_amount": 5000,
"billing_factor": 1,
"billing_cycle": "monthly",
"duration": 12,
"description": "Cover support for a year",
"proration_behavior": "none",
"tax": 1000,
"shipping_amount": 2000,
"trial_amount": 1000,
"trial_period_days": 7,
"max_retry_count": 3,
"retry_policy": {
"steps": [{ "delay_days": 1 }, { "delay_days": 3 }, { "delay_days": 5 }]
}
}
Example Success Response
{
"id": "0204ea34-6c93-4990-9a9b-dfb372006ad6",
"name": "Monthly Plan",
"duration": 12,
"amount": 10000,
"initial_amount": 5000,
"trial_amount": 1000,
"billing_cycle": "monthly",
"billing_factor": 1,
"linked_account_id": "<linked_account_id>",
"description": "Cover support for a year",
"tax": 1000,
"shipping_amount": 2000,
"custom_fields": null,
"created_at": "2024-04-11T15:11:16.975339432Z",
"updated_at": "2024-04-11T15:11:16.975339432Z",
"trial_period_days": 7,
"max_retry_count": 3,
"retry_policy": {
"steps": [{ "delay_days": 1 }, { "delay_days": 3 }, { "delay_days": 5 }]
},
"proration_behavior": "none"
}