Cancel a subscription
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel"
payload = {
"rentalId": "<string>",
"notes": "<string>"
}
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({rentalId: '<string>', notes: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel', 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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel",
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([
'rentalId' => '<string>',
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"rentalId": "<string>",
"assetSerialNumber": "<string>",
"previousStatus": "active",
"cancelledAt": "<string>",
"message": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Subscriptions
Cancel Subscription
Cancels an active subscription. Use when customer wants to end subscription without returning device immediately.
POST
/
v1
/
subscriptions
/
{subscriptionId}
/
cancel
Cancel a subscription
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel"
payload = {
"rentalId": "<string>",
"notes": "<string>"
}
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({rentalId: '<string>', notes: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel', 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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel",
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([
'rentalId' => '<string>',
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
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://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rentalId\": \"<string>\",\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"rentalId": "<string>",
"assetSerialNumber": "<string>",
"previousStatus": "active",
"cancelledAt": "<string>",
"message": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Cancel an active subscription. Use this when a customer wants to terminate their subscription without going through the normal end-of-contract flow. Unlike early return, cancellation doesn’t immediately trigger a device return.When to Use Cancellation
| Scenario | Use This |
|---|---|
| Customer requests termination | Cancel |
| Repeated payment failures | Cancel |
| Fraud detected | Cancel |
| Customer wants device back immediately | Early Return |
| Customer wants to purchase device | Buyout |
Request Fields
| Field | Required | Description |
|---|---|---|
rentalId | Yes | The subscription ID to cancel |
reason | Yes | Cancellation reason (see options below) |
notes | No | Additional notes (max 1000 chars) |
Reason Options
| Reason | When to Use |
|---|---|
customer_request | Customer asked to end subscription |
payment_failure | Repeated failed payment attempts |
fraud | Fraudulent activity detected |
admin_decision | Internal business decision |
other | Other reasons (specify in notes) |
Example Request
{
"rentalId": "sub_abc123",
"reason": "customer_request",
"notes": "Customer relocating internationally"
}
What Happens
When you cancel a subscription:- Subscription status changes to
cancelled - Future payments are voided
- Asset marked for return collection
- Cancellation logged with reason and timestamp
Response Fields
| Field | Description |
|---|---|
success | Always true on success |
rentalId | The cancelled subscription ID |
assetSerialNumber | Serial number of device to collect |
Example: Cancel with Payment Failure
async function cancelForNonPayment(subscriptionId, failedAttempts) {
const subscription = await getSubscription(subscriptionId);
return await cancelSubscription(subscriptionId, {
rentalId: subscriptionId,
reason: 'payment_failure',
notes: `Cancelled after ${failedAttempts} failed payment attempts`
});
}
Example: Customer-Initiated Cancellation
async function processCancellationRequest(subscriptionId, customerReason) {
// Log the cancellation
await cancelSubscription(subscriptionId, {
rentalId: subscriptionId,
reason: 'customer_request',
notes: customerReason
});
// Schedule device collection
const subscription = await getSubscription(subscriptionId);
await scheduleCollection(subscription.assetSerialNumber, subscription.customerId);
}
Cancellation vs Early Return
| Aspect | Cancel | Early Return |
|---|---|---|
| Primary use | Administrative termination | Customer-initiated return |
| Device return | Scheduled separately | Immediate return expected |
| Fees | No automatic fee | May include early return fee |
| Typical scenarios | Payment issues, fraud | Customer doesn’t want device |
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
NOT_FOUND | Subscription doesn’t exist | Verify subscription ID |
ALREADY_CANCELLED | Subscription already cancelled | No action needed |
ALREADY_ENDED | Subscription already ended | Cannot cancel completed subscriptions |
Related Endpoints
- Early Return - Return device and end subscription
- Get Subscription - Check current status
- List Subscriptions - Find subscriptions to cancel
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The subscription ID
Body
application/json
Was this page helpful?