Cancel Flows
Create Cancel Flow
Create a cancellation flow with configurable steps to retain customers before they cancel.
POST
/
v1
/
cancel-flows
Create a cancel flow
curl --request POST \
--url https://billing.example.com/v1/cancel-flows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"is_default": true,
"cooldown_days": 30
}
'import requests
url = "https://billing.example.com/v1/cancel-flows"
payload = {
"name": "<string>",
"is_default": True,
"cooldown_days": 30
}
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>', is_default: true, cooldown_days: 30})
};
fetch('https://billing.example.com/v1/cancel-flows', 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",
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>',
'is_default' => true,
'cooldown_days' => 30
]),
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"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"is_default\": true,\n \"cooldown_days\": 30\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"is_default\": true,\n \"cooldown_days\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/cancel-flows")
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 \"is_default\": true,\n \"cooldown_days\": 30\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,
"is_default": true,
"cooldown_days": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"steps": [
{
"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>"
}
}Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the cancel flow (max 255 characters). |
description | string | No | Internal description of the flow’s purpose. |
cooldown_hours | integer | No | Minimum hours before a customer can be shown this flow again (default 0). |
steps | array | Yes | Ordered list of steps in the cancellation flow. |
steps[].type | string | Yes | Step type: survey, offer, or confirmation. |
steps[].title | string | Yes | Heading displayed to the customer for this step. |
steps[].description | string | No | Explanatory text shown below the title. |
steps[].required | boolean | No | Whether the customer must complete this step to proceed (default false). |
steps[].offer | object | No | Retention offer details. Only applicable when type is offer. |
steps[].offer.type | string | No | Offer type: discount_percent, discount_fixed, extend_trial, or pause. |
steps[].offer.value | number | No | Numeric value of the offer (e.g. 20 for 20% off, or amount in paise for fixed). |
steps[].offer.duration_days | integer | No | Number of days the offer is valid. |
Example Request
curl -X POST https://api.recurso.dev/v1/cancel-flows \
-H "Authorization: Bearer rsk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"name": "Standard Retention Flow",
"description": "Default flow for Pro plan customers attempting to cancel",
"cooldown_hours": 72,
"steps": [
{
"type": "survey",
"title": "We are sorry to see you go",
"description": "Help us understand why you are cancelling so we can improve.",
"required": true
},
{
"type": "offer",
"title": "How about a discount?",
"description": "We would love to keep you. Here is a special offer.",
"required": false,
"offer": {
"type": "discount_percent",
"value": 20,
"duration_days": 90
}
},
{
"type": "confirmation",
"title": "Confirm cancellation",
"description": "Your subscription will remain active until the end of the current billing period.",
"required": true
}
]
}'
Response
Returns the newly created cancel flow object. Theid uses the cf_ prefix.
{
"id": "cf_9a8b7c6d5e4f3210",
"object": "cancel_flow",
"name": "Standard Retention Flow",
"description": "Default flow for Pro plan customers attempting to cancel",
"cooldown_hours": 72,
"steps": [
{
"id": "step_001",
"type": "survey",
"title": "We are sorry to see you go",
"description": "Help us understand why you are cancelling so we can improve.",
"required": true,
"offer": null
},
{
"id": "step_002",
"type": "offer",
"title": "How about a discount?",
"description": "We would love to keep you. Here is a special offer.",
"required": false,
"offer": {
"type": "discount_percent",
"value": 20,
"duration_days": 90
}
},
{
"id": "step_003",
"type": "confirmation",
"title": "Confirm cancellation",
"description": "Your subscription will remain active until the end of the current billing period.",
"required": true,
"offer": null
}
],
"status": "draft",
"created_at": "2026-06-23T10:15:30Z",
"updated_at": "2026-06-23T10:15:30Z"
}
Cancel flows are created in
draft status. Publish a flow via
POST /v1/cancel-flows/{id}/publish before it can be triggered during
customer cancellation attempts.Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Body
application/json
⌘I
Create a cancel flow
curl --request POST \
--url https://billing.example.com/v1/cancel-flows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"is_default": true,
"cooldown_days": 30
}
'import requests
url = "https://billing.example.com/v1/cancel-flows"
payload = {
"name": "<string>",
"is_default": True,
"cooldown_days": 30
}
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>', is_default: true, cooldown_days: 30})
};
fetch('https://billing.example.com/v1/cancel-flows', 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",
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>',
'is_default' => true,
'cooldown_days' => 30
]),
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"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"is_default\": true,\n \"cooldown_days\": 30\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"is_default\": true,\n \"cooldown_days\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/cancel-flows")
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 \"is_default\": true,\n \"cooldown_days\": 30\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,
"is_default": true,
"cooldown_days": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"steps": [
{
"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>"
}
}