Delete a customer
curl --request DELETE \
--url https://api-eu.flexportal.io/v1/customers/{customerId} \
--header 'Authorization: Bearer <token>' \
--header 'Tenant-ID: <tenant-id>'import requests
url = "https://api-eu.flexportal.io/v1/customers/{customerId}"
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>"
}
response = requests.delete(url, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'Tenant-ID': '<tenant-id>', Authorization: 'Bearer <token>'}
};
fetch('https://api-eu.flexportal.io/v1/customers/{customerId}', 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/customers/{customerId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/customers/{customerId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-eu.flexportal.io/v1/customers/{customerId}")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/customers/{customerId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"customerId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Customers
Delete Customer
Soft deletes a customer by setting status to inactive.
DELETE
/
v1
/
customers
/
{customerId}
Delete a customer
curl --request DELETE \
--url https://api-eu.flexportal.io/v1/customers/{customerId} \
--header 'Authorization: Bearer <token>' \
--header 'Tenant-ID: <tenant-id>'import requests
url = "https://api-eu.flexportal.io/v1/customers/{customerId}"
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>"
}
response = requests.delete(url, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'Tenant-ID': '<tenant-id>', Authorization: 'Bearer <token>'}
};
fetch('https://api-eu.flexportal.io/v1/customers/{customerId}', 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/customers/{customerId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/customers/{customerId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-eu.flexportal.io/v1/customers/{customerId}")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/customers/{customerId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"customerId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Deactivate a customer by marking them as inactive. This is a soft delete—the customer record is preserved for historical data integrity but hidden from active customer lists.Customers with active subscriptions cannot be deleted. Cancel or complete all subscriptions first.
What Happens When You Delete a Customer
- Customer status changes to
inactive - Customer hidden from default list queries
- Historical orders and subscriptions preserved
- New orders cannot be created for this customer
- Reporting data remains intact
Common Use Cases
- Data Cleanup: Remove test customers or duplicate records
- Account Closure: Customer requested account deletion
- Compliance: Remove inactive customers per data retention policies
- Fraud Prevention: Disable accounts flagged for suspicious activity
Prerequisites
Before deleting a customer, ensure:- No active subscriptions
- No pending orders
- All devices returned (if applicable)
async function canDeleteCustomer(customerId) {
const customer = await getCustomer(customerId);
// Check for active subscriptions
if (customer.profitability.activeDevices > 0) {
console.log('Cannot delete: Customer has active subscriptions');
return false;
}
// Check for pending orders
const { orders } = await listOrders({
customerId,
status: 'pending'
});
if (orders.length > 0) {
console.log('Cannot delete: Customer has pending orders');
return false;
}
return true;
}
Reactivating a Customer
To reactivate a deleted customer, use Update Customer:PUT /v1/customers/{customerId}
{
"status": "active"
}
Data Retention
After deletion:| Data | Status |
|---|---|
| Customer profile | Preserved, marked inactive |
| Order history | Preserved |
| Subscription history | Preserved |
| Payment history | Preserved |
| Addresses | Preserved |
Soft deletion ensures data integrity for financial reporting, auditing, and compliance requirements.
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
NOT_FOUND | Customer doesn’t exist | Verify customer ID |
CUSTOMER_HAS_ACTIVE_SUBSCRIPTIONS | Cannot delete with active subscriptions | Cancel subscriptions first |
CUSTOMER_HAS_PENDING_ORDERS | Cannot delete with pending orders | Complete or cancel orders first |
Related Endpoints
- Get Customer - Check customer status before deletion
- Update Customer - Reactivate deleted customer
- List Subscriptions - Check for active subscriptions
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The customer ID
Was this page helpful?