Buyout a subscription
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"buyoutPrice": 1,
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout"
payload = {
"rentalId": "<string>",
"buyoutPrice": 1,
"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>', buyoutPrice: 1, notes: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout', 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}/buyout",
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>',
'buyoutPrice' => 1,
'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}/buyout"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"buyoutPrice\": 1,\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}/buyout")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"buyoutPrice\": 1,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout")
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 \"buyoutPrice\": 1,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"rentalId": "<string>",
"assetSerialNumber": "<string>",
"buyoutPrice": 1,
"currency": "<string>",
"effectiveDate": "<string>",
"message": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Subscriptions
Buyout Subscription
Customer purchases the device, ending the subscription.
POST
/
v1
/
subscriptions
/
{subscriptionId}
/
buyout
Buyout a subscription
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"buyoutPrice": 1,
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout"
payload = {
"rentalId": "<string>",
"buyoutPrice": 1,
"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>', buyoutPrice: 1, notes: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout', 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}/buyout",
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>',
'buyoutPrice' => 1,
'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}/buyout"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"buyoutPrice\": 1,\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}/buyout")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"buyoutPrice\": 1,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/buyout")
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 \"buyoutPrice\": 1,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"rentalId": "<string>",
"assetSerialNumber": "<string>",
"buyoutPrice": 1,
"currency": "<string>",
"effectiveDate": "<string>",
"message": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Process a buyout to convert a subscription into a purchase. The customer pays a buyout price and keeps the device permanently. This ends the subscription and transfers ownership of the asset.When to Offer Buyouts
| Scenario | Buyout Makes Sense |
|---|---|
| Near end of contract | Customer wants to keep device |
| Cost fully recovered | Asset is paid off, buyout is pure profit |
| Customer preference | Customer prefers ownership |
| Old inventory | Simplify operations by selling older devices |
Buyout Pricing
Before processing a buyout, calculate the price using Calculate Buyout. Buyout prices typically consider:- Remaining contract value: Unpaid months × monthly rate
- Residual value: Expected asset value at contract end
- Cost recovery status: How much you’ve already collected
// Common buyout formula
const remainingMonths = subscription.monthsRemaining;
const monthlyAmount = subscription.monthlyAmount;
const residualValue = 200; // Tenant-configured minimum
const buyoutPrice = (remainingMonths * monthlyAmount) + residualValue;
Request Fields
| Field | Required | Description |
|---|---|---|
buyoutPrice | Yes | The buyout amount to charge |
effectiveDate | No | When ownership transfers (default: today) |
reason | No | Reason for buyout |
Example Request
{
"buyoutPrice": 450.00,
"reason": "Customer requested purchase at contract end"
}
What Happens
When you process a buyout:- Subscription status changes to
ended_buyout - Asset ownership transferred to customer
- Asset status changed to
soldorunavailable - Buyout details recorded on subscription
- Future payments cancelled
- Final invoice generated for buyout amount
Response Structure
{
"success": true,
"message": "Buyout processed successfully",
"subscription": {
"subscriptionId": "sub_abc123",
"status": "ended_buyout",
"buyoutDetails": {
"buyoutDate": "2025-01-20",
"buyoutPrice": 450.00,
"remainingMonths": 6,
"costRecoveryAtBuyout": 95.5
}
}
}
Buyout Workflow
1. Customer requests buyout
2. Calculate buyout price → /calculate-buyout
3. Present price to customer
4. Customer agrees and pays
5. Process buyout → /buyout
6. Send ownership confirmation
7. Update asset records
Example: End-to-End Buyout
async function processBuyout(subscriptionId) {
// 1. Calculate buyout price
const quote = await calculateBuyout(subscriptionId);
// 2. Present to customer (in your UI)
console.log(`Buyout price: €${quote.buyoutPrice}`);
// 3. After customer payment confirmed, process buyout
const result = await buyoutSubscription(subscriptionId, {
buyoutPrice: quote.buyoutPrice,
reason: 'Customer purchase request'
});
return result;
}
Buyout vs Early Return
| Aspect | Buyout | Early Return |
|---|---|---|
| Device | Customer keeps | Device returned |
| Payment | Buyout price | Early return fee |
| Asset | Removed from inventory | Returns to inventory |
| Best for | Customer wants ownership | Customer done with device |
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
SUBSCRIPTION_NOT_ACTIVE | Subscription is not active | Can only buyout active subscriptions |
INVALID_BUYOUT_PRICE | Buyout price must be positive | Provide valid price |
Related Endpoints
- Calculate Buyout - Get recommended buyout price
- Get Subscription - Check subscription details
- Early Return - Alternative: return device early
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The subscription ID
Body
application/json
Was this page helpful?