Skip to main content
POST
/
v1
/
exports
/
rentals
Export rentals to CSV
curl --request POST \
  --url https://api-eu.flexportal.io/v1/exports/rentals \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'Tenant-ID: <tenant-id>' \
  --data '
{
  "startDate": "2023-11-07T05:31:56Z",
  "endDate": "2023-11-07T05:31:56Z",
  "format": "csv",
  "includeFields": {
    "customerDetails": true,
    "deviceDetails": true,
    "financialDetails": true,
    "customFields": true
  },
  "status": "active",
  "customerIds": [
    "<string>"
  ]
}
'
{
  "success": true,
  "filename": "<string>",
  "csvData": "<string>",
  "totalRecords": 123,
  "generatedAt": "<string>",
  "filters": {},
  "totalRentals": 123,
  "activeRentals": 123,
  "totalRevenue": 123,
  "averageMonthlyRevenue": 123
}

Overview

Export subscription data to CSV format. Use this for reporting, data analysis, or importing into external systems like spreadsheets or business intelligence tools.

Common Use Cases

Financial Reporting

Export data for revenue analysis and forecasting

Accounting Integration

Import subscription data into accounting software

Business Intelligence

Feed data into BI tools for advanced analytics

Compliance Audits

Generate reports for audit and compliance needs

Request Fields

FieldRequiredDescription
statusNoFilter by status: active, ended, etc.
startDateFromNoFilter by start date (from)
startDateToNoFilter by start date (to)
endDateFromNoFilter by end date (from)
endDateToNoFilter by end date (to)
customerIdNoFilter by customer

Example: Export All Active Subscriptions

{
  "status": "active"
}

Example: Export by Date Range

{
  "startDateFrom": "2024-01-01",
  "startDateTo": "2024-12-31"
}

Response

The response includes a download URL for the CSV file:
{
  "success": true,
  "downloadUrl": "https://storage.example.com/exports/rentals-2025-01-15.csv?signature=...",
  "expiresAt": "2025-01-15T12:00:00Z",
  "recordCount": 1250
}

CSV Columns

The exported CSV includes:
ColumnDescription
subscriptionIdSubscription ID
customerIdCustomer ID
customerEmailCustomer email
customerNameCustomer full name
companyCompany name (if business)
skuProduct SKU
productNameProduct name
serialNumberAsset serial number
statusSubscription status
startDateContract start date
endDateContract end date
contractLengthDuration in months
monthlyAmountMonthly payment
currencyCurrency code
totalCollectedTotal payments collected
acquisitionCostAsset acquisition cost
costRecoveryPercentCost recovery percentage

Example: Monthly Revenue Report

async function generateMonthlyReport(year, month) {
  const startDate = `${year}-${month.toString().padStart(2, '0')}-01`;
  const endDate = new Date(year, month, 0).toISOString().split('T')[0];

  const { downloadUrl, recordCount } = await exportSubscriptions({
    status: 'active',
    startDateFrom: startDate,
    startDateTo: endDate
  });

  return {
    period: `${year}-${month}`,
    subscriptions: recordCount,
    downloadUrl
  };
}

Example: Customer Data Export

async function exportCustomerData(customerId) {
  const { downloadUrl, recordCount } = await exportSubscriptions({
    customerId
  });

  return {
    customerId,
    totalSubscriptions: recordCount,
    downloadUrl
  };
}

URL Expiration

Download URLs expire after a short period (typically 15-60 minutes). Download the file promptly after generation.

Large Exports

For very large exports:
  • Consider filtering by date range to reduce size
  • Export in batches by customer or time period
  • Monitor the recordCount to estimate file size

Authorizations

Authorization
string
header
required

API key obtained from FlexPortal dashboard

Headers

Tenant-ID
string
required

Your tenant identifier

Body

application/json
startDate
string<date-time>
endDate
string<date-time>
format
enum<string>
default:csv
Available options:
csv
includeFields
object
status
enum<string>
Available options:
active,
cancelled,
ended_completed,
ended_buyout,
ended_upgrade,
ended_early_return
customerIds
string[]

Response

Export generated

success
boolean
required
filename
string
required
csvData
string
required
totalRecords
number
required
generatedAt
string
required
filters
object
required
totalRentals
number
required
activeRentals
number
required
totalRevenue
number
required
averageMonthlyRevenue
number
required