Active Vehicle Policy Export
Introduction
The Active Vehicle Policy Export produces a daily CSV file listing vehicles with at least one active policy for a specified lease company. The file is packaged as a ZIP archive and delivered to Google Cloud Storage.
Generation is initiated by a Pub/Sub scheduler. There is no on-demand download option within the ViSN platform.
Purpose
The AA requires a recurring export of vehicles that currently hold an active policy agreement. Each row provides the vehicle registration, make, model, date of first registration (DOFR), and a fixed scheme code for consumption by downstream AA systems.
File format
Compressed ZIP file containing a CSV file
File Naming Convention
AA_Fleet_Export_<YYYY>-<MM>-<DD>_<HH>_<mm>_<ss>.zip
The CSV contained within the ZIP shares the same base name with a .csv extension (for example, AA_Fleet_Export_2026-07-01_00_00_00.csv).
Fields
| Column Position | Header Name | Description | Datatype | Rules | Max length | Mandatory | Default Value | Example |
|---|---|---|---|---|---|---|---|---|
| A | Registration | Vehicle registration mark (VRM) | string | Truncated to 8 characters when the value exceeds the maximum length | 8 | No | AB12CDE | |
| B | Make | Vehicle make | string | Resolved in the following order:
Truncated to 40 characters when the value exceeds the maximum length | 40 | No | Ford | |
| C | Model | Vehicle model from the stock record | string | Taken from stock.model as stored; VRM lookup is not used | No | Focus | ||
| D | DOFR | Date of first registration | string | Resolved in the following order:
Formatted as | 10 | No | 15/06/2020 | |
| E | Reserved blank column | string | Always empty | No | ||||
| F | Scheme Code | AA scheme identifier | string | Hard-coded for every row | 3 | Yes | EH1 | EH1 |
Note: When data is unavailable for a field, the corresponding CSV value is left empty. Values containing commas are enclosed in quotes.
Storage locations
Dated archive path
{bucketName}/{destinationFolder}/{year}/{month}/{day}/{AA_Fleet_Export_<timestamp>.zip}
The month folder uses the full English month name in lowercase (for example, july).
Pickup path
{bucketName}/{destinationFolder}/{AA_Fleet_Export_<timestamp>.zip}
The pickup path holds the latest export for downstream collection. Before each run, files located directly under {destinationFolder}/ are removed. Dated subfolders are retained.
Configuration
No lease-company Firebase configuration document or feature flag governs this export. All runtime parameters are supplied in the Pub/Sub scheduler message body.
Cloud Function runtime options:
| Setting | Lower environment | Higher environment |
|---|---|---|
| Timeout | 60 seconds | 300 seconds |
| Memory | 512 MiB | 1024 MiB |
Dependencies
- Typesense — stock index with
hasActivePolicy,leaseId, andcontractStatusfields - Firestore — lease stock documents at
/leasecompany/leaseId/stock - Google Cloud Storage — export file storage
- Ancillary Firestore — process log persistence
- Email queue — optional file delivery and notifications
- Stock index maintenance —
hasActivePolicymust remain synchronised viaupdateStockIndexwhen policies change
Setup Required
A Cloud Scheduler task must be configured to publish messages at the required interval. Configure the task as follows:
- Name: generateActivePolicyVehicleExportCSV
- Region: europe-west2
- Frequency: Daily (configure the cron expression to match operational requirements)
- TimeZone: GMT London
- Topic: projects/biddirect-2/topics/generateActivePolicyVehicleExportCSV
- Message body: JSON object as described below
Pub/Sub message body
{
"leaseCompanyId": "<lease-company-id>",
"bucketName": "<gcs-bucket-name>",
"destinationFolder": "<folder-path-within-bucket>",
"emailExportsTo": "<recipient(s) for export file delivery>",
"successEmailSubject": "<subject for internal success notification>",
"successEmailToAddress": "<recipient for success and support contact in delivery email>",
"fatalErrorEmailToAddress": "<recipient for failure notification>",
"errorEmailSubject": "<subject for failure notification>"
}
| Parameter | Required | Description |
|---|---|---|
leaseCompanyId | Yes | Lease company whose active-policy vehicles are exported |
bucketName | Yes | GCS bucket that receives the export file |
destinationFolder | Yes | Folder path within the bucket (no leading slash) |
emailExportsTo | No | When provided, queues an EXPORT_FILE_DELIVERY email with the ZIP attached from storage |
successEmailSubject | No | Subject for a plain-text success notification; requires successEmailToAddress |
successEmailToAddress | No | Recipient for the success notification; also supplied as supportEmailToAddress in the delivery email template |
fatalErrorEmailToAddress | No | Recipient for failure notification; requires errorEmailSubject |
errorEmailSubject | No | Subject for failure notification |
Example message body
{
"leaseCompanyId": "MyknPNP76jd4uebzantr",
"bucketName": "biddirect-2.appspot.com",
"destinationFolder": "aaActiveVehicles-exports",
"emailExportsTo": "recipient@example.com",
"successEmailSubject": "AA Active Vehicles Export Success",
"successEmailToAddress": "ops@example.com",
"fatalErrorEmailToAddress": "ops@example.com",
"errorEmailSubject": "AA Active Vehicles Export Failed"
}
Examples of Generated Files
A sample CSV with data:
Registration,Make,Model,DOFR,,Scheme Code
AB12CDE,Ford,Focus,15/06/2020,,EH1
VW14KLS,VOLKSWAGEN,Golf,01/03/2026,,EH1
A CSV row where the model contains a comma (quoted):
AB12CDE,Ford,"Focus, ST-Line",15/06/2020,,EH1
An empty CSV file (no eligible vehicles):
Registration,Make,Model,DOFR,,Scheme Code
Troubleshooting
| Symptom | Likely cause | Action |
|---|---|---|
| Export fails immediately | Missing required message parameters | Confirm leaseCompanyId, bucketName, and destinationFolder are present in the scheduler message |
| Fewer vehicles than expected | Typesense filter or policy status mismatch | Verify vehicle policies (LIVE_AGREEMENT, isPolicyAvailable, end date or openEnded); confirm contractStatus is not TERMINATED; validate the Typesense index |
| Empty export | No vehicles meet eligibility criteria | Expected when no active-policy vehicles exist; confirm stock data for the lease company in ViSN |
| Pickup file missing but dated file exists | Copy step failed | Review Cloud Function logs for GCS copy errors |
| No email received | Email parameters omitted or email queue issue | Confirm emailExportsTo and related addresses are configured; inspect email queue documents |
| Function timeout | Large fleet exceeding runtime limits | Review vehiclesInExport in logs; the higher environment permits up to 300 seconds and 1024 MiB |
Status: Accepted
Category: Protected
Authored By: Jeyakumar Arunagiri on Jul 1, 2026
Revisions: