Cancel Flows
Create Cancel Flow Step
Add a new step to an existing cancel flow.
POST
/
v1
/
cancel-flows
/
{id}
/
steps
Add a step to a cancel flow
curl --request POST \
--url https://billing.example.com/v1/cancel-flows/{id}/steps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"step_order": 2,
"config": {}
}
'import requests
url = "https://billing.example.com/v1/cancel-flows/{id}/steps"
payload = {
"step_order": 2,
"config": {}
}
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, config: {}})
};
fetch('https://billing.example.com/v1/cancel-flows/{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/cancel-flows/{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,
'config' => [
]
]),
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/cancel-flows/{id}/steps"
payload := strings.NewReader("{\n \"step_order\": 2,\n \"config\": {}\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/cancel-flows/{id}/steps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"step_order\": 2,\n \"config\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/cancel-flows/{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 \"config\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"flow_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"step_order": 123,
"step_type": "survey",
"config": "<unknown>",
"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 cancel flow ID (cflow_ prefix). |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
step_order | integer | Yes | Position of this step in the flow (0-indexed). |
step_type | string | Yes | Step type. One of survey, offer, or confirmation. |
config | object | No | JSON configuration for the step (e.g. survey options, offer details). |
Example Request
curl -X POST "https://api.recurso.dev/v1/cancel-flows/cflow_01h8x3kv7m2p/steps" \
-H "Authorization: Bearer rsk_live_9f8a7b6c5d4e3f2a1b0c" \
-H "Content-Type: application/json" \
-d '{
"step_order": 1,
"step_type": "offer",
"config": {
"title": "How about a discount?",
"offer_type": "discount_percent",
"offer_value": 25,
"duration_days": 90
}
}'
Response
{
"id": "cstep_01h8x4qw3s7v",
"object": "cancel_flow_step",
"flow_id": "cflow_01h8x3kv7m2p",
"step_order": 1,
"step_type": "offer",
"config": {
"title": "How about a discount?",
"offer_type": "discount_percent",
"offer_value": 25,
"duration_days": 90
},
"created_at": "2026-06-23T11:20:00Z"
}
Step order is 0-indexed. If a step already exists at the given
step_order, existing steps are shifted forward automatically.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 cancel flow
curl --request POST \
--url https://billing.example.com/v1/cancel-flows/{id}/steps \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"step_order": 2,
"config": {}
}
'import requests
url = "https://billing.example.com/v1/cancel-flows/{id}/steps"
payload = {
"step_order": 2,
"config": {}
}
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, config: {}})
};
fetch('https://billing.example.com/v1/cancel-flows/{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/cancel-flows/{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,
'config' => [
]
]),
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/cancel-flows/{id}/steps"
payload := strings.NewReader("{\n \"step_order\": 2,\n \"config\": {}\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/cancel-flows/{id}/steps")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"step_order\": 2,\n \"config\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/cancel-flows/{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 \"config\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"flow_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"step_order": 123,
"step_type": "survey",
"config": "<unknown>",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}