Replace subscription device
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"newSerialNumber": "<string>",
"newSku": "<string>",
"damageAssessment": "<string>",
"insuranceClaim": false,
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace"
payload = {
"rentalId": "<string>",
"newSerialNumber": "<string>",
"newSku": "<string>",
"damageAssessment": "<string>",
"insuranceClaim": False,
"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>',
newSerialNumber: '<string>',
newSku: '<string>',
damageAssessment: '<string>',
insuranceClaim: false,
notes: '<string>'
})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace', 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}/replace",
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>',
'newSerialNumber' => '<string>',
'newSku' => '<string>',
'damageAssessment' => '<string>',
'insuranceClaim' => false,
'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}/replace"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\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}/replace")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace")
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 \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"rentalId": "<string>",
"oldSerialNumber": "<string>",
"newSerialNumber": "<string>",
"reason": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Subscriptions
Replace Device
Replaces the device on a subscription (e.g., for warranty or damage).
POST
/
v1
/
subscriptions
/
{subscriptionId}
/
replace
Replace subscription device
curl --request POST \
--url https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"rentalId": "<string>",
"newSerialNumber": "<string>",
"newSku": "<string>",
"damageAssessment": "<string>",
"insuranceClaim": false,
"notes": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace"
payload = {
"rentalId": "<string>",
"newSerialNumber": "<string>",
"newSku": "<string>",
"damageAssessment": "<string>",
"insuranceClaim": False,
"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>',
newSerialNumber: '<string>',
newSku: '<string>',
damageAssessment: '<string>',
insuranceClaim: false,
notes: '<string>'
})
};
fetch('https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace', 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}/replace",
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>',
'newSerialNumber' => '<string>',
'newSku' => '<string>',
'damageAssessment' => '<string>',
'insuranceClaim' => false,
'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}/replace"
payload := strings.NewReader("{\n \"rentalId\": \"<string>\",\n \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\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}/replace")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rentalId\": \"<string>\",\n \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/subscriptions/{subscriptionId}/replace")
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 \"newSerialNumber\": \"<string>\",\n \"newSku\": \"<string>\",\n \"damageAssessment\": \"<string>\",\n \"insuranceClaim\": false,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"rentalId": "<string>",
"oldSerialNumber": "<string>",
"newSerialNumber": "<string>",
"reason": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Replace a faulty or damaged device with a new one of the same type. Unlike upgrades, replacements keep the same subscription terms—the customer gets a working device without changing their contract.When to Use Replacements
Request Fields
| Field | Required | Description |
|---|---|---|
newSerialNumber | Yes | Serial number of replacement device |
reason | Yes | Reason for replacement |
Example Request
{
"newSerialNumber": "SN987654321",
"reason": "Battery failure - device won't hold charge"
}
What Happens
When you replace a device:- Previous asset status changed to
unavailable - New asset linked to subscription and marked
rented_out - Replacement history logged with both serial numbers
- Contract terms remain unchanged
- Billing continues uninterrupted
Replacement vs Upgrade
| Aspect | Replace | Upgrade |
|---|---|---|
| Device | Same model | Different/better model |
| Contract | Unchanged | New contract |
| Monthly price | Same | May change |
| Typical reason | Fault/damage | Customer request |
| Logistics | Same type swap | Different device |
Asset Requirements
The replacement serial number must:- Exist in your asset inventory
- Match the same SKU as the original (same product type)
- Be available (status:
available)
Replacement History
After replacement, the subscription tracks all swaps:{
"replacementHistory": [
{
"replacedAt": "2025-01-20T14:30:00Z",
"previousSerialNumber": "SN123456789",
"newSerialNumber": "SN987654321",
"reason": "Battery failure - device won't hold charge"
}
],
"currentSerialNumber": "SN987654321"
}
Example: Device Replacement Workflow
async function replaceDevice(subscriptionId, reason) {
// 1. Get subscription to find SKU
const subscription = await getSubscription(subscriptionId);
// 2. Find available replacement of same type
const { assets } = await listAssets({
sku: subscription.sku,
status: 'available',
limit: 1
});
if (assets.length === 0) {
throw new Error(`No available ${subscription.sku} in inventory`);
}
// 3. Process replacement
const result = await replaceSubscriptionDevice(subscriptionId, {
newSerialNumber: assets[0].serialNumber,
reason
});
// 4. Schedule return pickup for faulty device
await scheduleReturnPickup(subscription.serialNumber, subscription.customerId);
return result;
}
Common Replacement Reasons
Document the reason clearly for tracking and warranty purposes:- Battery failure
- Screen damage
- Keyboard malfunction
- Performance issues
- Physical damage (specify type)
- Manufacturing defect
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
SUBSCRIPTION_NOT_ACTIVE | Subscription is not active | Can only replace on active subscriptions |
ASSET_NOT_FOUND | Replacement serial doesn’t exist | Create asset first |
ASSET_NOT_AVAILABLE | Replacement asset not available | Use different asset |
SKU_MISMATCH | Replacement doesn’t match original product | Use same product type |
Related Endpoints
- Get Subscription - Check subscription and current device
- List Assets - Find available replacement devices
- Upgrade Subscription - For changing to different product
- Update Asset - Mark returned device for repair
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The subscription ID
Body
application/json
Was this page helpful?