Dunning Campaigns
Create Campaign Step
Add a new step to an existing dunning campaign.
POST
/
v1
/
dunning-campaigns
/
{id}
/
steps
Add a step to a dunning campaign
curl --request POST \
--url https://billing.example.com/v1/dunning-campaigns/{id}/steps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"step_order": 2,
"delay_hours": 1,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": true
}
'import requests
url = "https://billing.example.com/v1/dunning-campaigns/{id}/steps"
payload = {
"step_order": 2,
"delay_hours": 1,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": True
}
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({
step_order: 2,
delay_hours: 1,
template_name: '<string>',
subject: '<string>',
body: JSON.stringify('<string>'),
is_payment_wall: true
})
};
fetch('https://billing.example.com/v1/dunning-campaigns/{id}/steps', 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/{id}/steps",
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([
'step_order' => 2,
'delay_hours' => 1,
'template_name' => '<string>',
'subject' => '<string>',
'body' => '<string>',
'is_payment_wall' => true
]),
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/{id}/steps"
payload := strings.NewReader("{\n \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\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/{id}/steps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/dunning-campaigns/{id}/steps")
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 \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
}Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The dunning campaign ID (dc_ prefix). |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
day_offset | integer | Yes | Number of days after the initial payment failure to execute this step. |
channel | string | Yes | Delivery channel. One of email, sms, or payment_wall. |
template_id | string | No | ID of a pre-configured message template. If omitted, subject and body are used. |
subject | string | No | Subject line for the message. Required if template_id is not provided. |
body | string | No | Message body content. Supports Liquid template variables. Required if template_id is not provided. |
Example Request
curl -X POST "https://api.recurso.io/v1/dunning-campaigns/dc_8mKp3vRn2wXq/steps" \
-H "Authorization: Bearer rsk_live_9f8a7b6c5d4e3f2a1b0c" \
-H "Content-Type: application/json" \
-d '{
"day_offset": 1,
"channel": "email",
"subject": "Action required: Your payment failed",
"body": "Hi {{ customer.first_name }}, we were unable to process your payment of {{ amount_due }} for {{ subscription.plan_name }}. Please update your payment method at {{ update_payment_url }}."
}'
Response
{
"id": "dstep_5rMt8wVn3aZs",
"object": "dunning_step",
"campaign_id": "dc_8mKp3vRn2wXq",
"day_offset": 1,
"channel": "email",
"template_id": null,
"subject": "Action required: Your payment failed",
"body": "Hi {{ customer.first_name }}, we were unable to process your payment of {{ amount_due }} for {{ subscription.plan_name }}. Please update your payment method at {{ update_payment_url }}.",
"is_active": true,
"created_at": "2026-06-23T10:35:00Z",
"updated_at": "2026-06-23T10:35:00Z"
}
Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Path Parameters
Body
application/json
⌘I
Add a step to a dunning campaign
curl --request POST \
--url https://billing.example.com/v1/dunning-campaigns/{id}/steps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"step_order": 2,
"delay_hours": 1,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": true
}
'import requests
url = "https://billing.example.com/v1/dunning-campaigns/{id}/steps"
payload = {
"step_order": 2,
"delay_hours": 1,
"template_name": "<string>",
"subject": "<string>",
"body": "<string>",
"is_payment_wall": True
}
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({
step_order: 2,
delay_hours: 1,
template_name: '<string>',
subject: '<string>',
body: JSON.stringify('<string>'),
is_payment_wall: true
})
};
fetch('https://billing.example.com/v1/dunning-campaigns/{id}/steps', 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/{id}/steps",
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([
'step_order' => 2,
'delay_hours' => 1,
'template_name' => '<string>',
'subject' => '<string>',
'body' => '<string>',
'is_payment_wall' => true
]),
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/{id}/steps"
payload := strings.NewReader("{\n \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\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/{id}/steps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/dunning-campaigns/{id}/steps")
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 \"step_order\": 2,\n \"delay_hours\": 1,\n \"template_name\": \"<string>\",\n \"subject\": \"<string>\",\n \"body\": \"<string>\",\n \"is_payment_wall\": true\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
}