Dunning Campaigns
Create Dunning Campaign
Create a new dunning campaign for recovering failed payments.
POST
/
v1
/
dunning-campaigns
Create a dunning campaign
curl --request POST \
--url https://billing.example.com/v1/dunning-campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"trigger_event": "payment_failed"
}
'import requests
url = "https://billing.example.com/v1/dunning-campaigns"
payload = {
"name": "<string>",
"trigger_event": "payment_failed"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', trigger_event: 'payment_failed'})
};
fetch('https://billing.example.com/v1/dunning-campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/dunning-campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'trigger_event' => 'payment_failed'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/dunning-campaigns"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/dunning-campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/dunning-campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"is_active": true,
"trigger_event": "payment_failed",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"steps": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"campaign_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"step_order": 123,
"channel": "email",
"delay_hours": 123,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": true,
"created_at": "2023-11-07T05:31:56Z"
}
]
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A human-readable name for the campaign. |
description | string | No | A longer description of the campaign’s purpose. |
is_default | boolean | No | Whether this campaign should be the default for all subscriptions. Default false. |
payment_wall_enabled | boolean | No | If true, blocks product access after the grace period expires. Default false. |
payment_wall_grace_days | integer | No | Number of days before the payment wall takes effect. Default 3. |
Example Request
curl -X POST "https://api.recurso.io/v1/dunning-campaigns" \
-H "Authorization: Bearer rsk_live_9f8a7b6c5d4e3f2a1b0c" \
-H "Content-Type: application/json" \
-d '{
"name": "Standard Recovery",
"description": "Default dunning campaign with email reminders and payment wall",
"is_default": true,
"payment_wall_enabled": true,
"payment_wall_grace_days": 5
}'
Response
{
"id": "dc_8mKp3vRn2wXq",
"object": "dunning_campaign",
"name": "Standard Recovery",
"description": "Default dunning campaign with email reminders and payment wall",
"is_default": true,
"payment_wall_enabled": true,
"payment_wall_grace_days": 5,
"steps": [],
"active_subscriptions": 0,
"created_at": "2026-06-23T10:30:00Z",
"updated_at": "2026-06-23T10:30:00Z"
}
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
application/json
⌘I
Create a dunning campaign
curl --request POST \
--url https://billing.example.com/v1/dunning-campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"trigger_event": "payment_failed"
}
'import requests
url = "https://billing.example.com/v1/dunning-campaigns"
payload = {
"name": "<string>",
"trigger_event": "payment_failed"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', trigger_event: 'payment_failed'})
};
fetch('https://billing.example.com/v1/dunning-campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/dunning-campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'trigger_event' => 'payment_failed'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/dunning-campaigns"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/dunning-campaigns")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/dunning-campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"trigger_event\": \"payment_failed\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"is_active": true,
"trigger_event": "payment_failed",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"steps": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"campaign_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"step_order": 123,
"channel": "email",
"delay_hours": 123,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": true,
"created_at": "2023-11-07T05:31:56Z"
}
]
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}