Skip to content
Back to blog

Engineering

Define the export before you need to leave

Reading time
9 min read
Published
Last updated
Define the export before you need to leave

A data portability checklist for SaaS buyers and builders, with a manifest template, a verification script and the restore test that proves the export works.

A complete SaaS data export gives you every record you own as documented files. The links between records stay intact, and a test proves the package loads outside the vendor's software. That is data portability in practice, and the export clause decides how locked in you are.

A “CSV export” checkbox is not a complete SaaS exit plan. Customers need to know which entities are included, how relationships are represented, whether attachments and audit events are delivered, how dates and Arabic text are encoded, how the package is transferred, and when retained copies are deleted. The only reliable specification ends with a restore test.

Write the export specification before you sign the contract, or before a major architecture decision if you are building the product. It sets scope, responsibility, limits and acceptance for both sides. The product team then does not have to invent a package in the middle of a cancellation.

What the law already requires in the EU

The EU Data Act has applied since 12 September 2025, and this section states the position as of 4 November 2026. Providers of cloud software and platforms (SaaS and PaaS) must let customers export their data in a commonly used, machine-readable format. The data includes the metadata their use created. The export does not have to include data protected by the provider's intellectual property rights or trade secrets. Until 12 January 2027 a provider may charge only for the costs it incurs in the switch.

From that date, providers may not charge for switching or for moving data out (egress). Check the current text before you rely on these dates. The Act protects customers in the EU. If that is not you, do not assume it applies, and write these terms into your contract.

How our own export works

ClinicTek is the clinic management system we build and run. It tells clinics that after cancellation they receive a copy of their data within 7 business days. The clinic owner requests the export from the subscription page. A queued job then runs inside that clinic's isolated database context, where it can read only that clinic's rows. The job writes three CSV files: patients, appointments and invoices.

Each file has its own id column, and appointments and invoices point to their patient through patient_id. The job reads 500 rows at a time to keep memory use steady. When it finishes, an email tells the owner the export is ready and to contact support for a secure download link. The email carries none of the exported records.

One choice in that code shows how export decisions pull against each other. Our CSV writer puts an apostrophe in front of any cell that starts with =, +, -, @, a tab or a line break. OWASP (the Open Worldwide Application Security Project) describes this guard against CSV injection, where a spreadsheet runs a cell's text as a formula. OWASP also notes that Excel can lose this protection once the file is saved and reopened.

The guard also changes data. A phone number stored as +962... arrives as '+962.... That protects the person who opens the file in a spreadsheet and adds a step for the system that imports it. A good specification names the columns that get this guard and tells the importer how to remove it.

Inventory entities and ownership

List every kind of data the customer owns: accounts, users, roles, clients, transactions, catalogue, bookings, notes, messages, configuration, files and generated documents, as they apply. Mark what is excluded and why: platform telemetry, secrets, derived aggregates, and data owned by another party.

For each entity, record the tenant key, a stable record key, a human-readable label, the lifecycle state and the parent relationships. The tenant key is the ID of the customer account the record belongs to. Database row IDs are fine as keys only if the specification documents them. The receiving system needs keys that stay stable across files.

Define files, schemas and the manifest

Choose formats by structure. CSV suits flat tables; JSON or another structured format keeps nested data intact. Document every column with its type, null behaviour, allowed values, unit, currency precision, timezone and escaping rule. Version the specification too, because adding a column and changing a column's meaning are different releases.

A manifest is the file that describes the package itself. The recipient reads it first.

Article data table: Define files, schemas and the manifest (1)
Manifest fieldWhat it recordsWhy the recipient needs it
format_versionVersion of the export specificationTo pick the right schema documentation
generated_at, timezoneWhen the package was built, and the timezone of every timestampTo compare against the source and read dates correctly
encoding, csvUTF-8, delimiter, quote, line break, byte-order markTo parse files without guessing
files[].path, entityEach file and the entity it holdsTo load files in the right order
files[].rowsRow count per file at generation timeTo prove nothing was lost in transfer
files[].sha256A checksum: a fingerprint of the file's bytesTo prove the file was not cut or altered
files[].referencesWhich column points to which parent fileTo rebuild relationships
omitted[]Records or entities left out, with the reasonTo replace silence with an explicit gap

A starting template, with fictional values:

{
  "format_version": "1.2",
  "generated_at": "2026-11-04T09:30:00Z",
  "timezone": "UTC",
  "encoding": "UTF-8",
  "csv": { "delimiter": ",", "quote": "\"", "newline": "CRLF", "bom": true },
  "files": [
    { "path": "patients.csv", "entity": "patient", "rows": 1240, "sha256": "<sha256>" },
    { "path": "appointments.csv", "entity": "appointment", "rows": 8312, "sha256": "<sha256>",
      "references": { "patient_id": "patients.csv:id" } },
    { "path": "attachments/index.csv", "entity": "attachment", "rows": 517, "sha256": "<sha256>",
      "references": { "patient_id": "patients.csv:id" } }
  ],
  "omitted": [
    { "entity": "audit_event", "reason": "outside the contract's export scope" }
  ]
}

Preserve relationships

Include the foreign keys that let the recipient reconnect parent and child records. Check that every referenced parent exists in the package or is declared as an external reference, and report orphaned records instead of dropping them. Provide a short entity-relationship summary and sample rows with fictional data. Test duplicate names, deleted parents, archived records and many-to-many links. Readable files with ambiguous links are still unusable.

Package attachments and generated documents

Store attachments under neutral internal paths. Add a mapping file with the record key, original display name, media type, size, checksum, creation time and retention status. Leave out private storage paths, signed URLs and storage credentials. Decide whether generated invoices, receipts, certificates and previews ship as files, as source data that can rebuild them, or both. A database-only export can miss the evidence the customer cares about most.

Handle audit events and history

State whether the package holds current state only, change history, security audit events, or a mix. Audit data can contain platform-sensitive details or another person's data. Review what the package includes before you ship it.

Say what the vendor keeps for legal or security reasons. Use actor references that still make sense after an account is deleted, record timestamps in one timezone, and include the event type and target keys. Raw logs are a poor substitute for a structured history.

Preserve dates, numbers and Arabic text

Use UTF-8 and test Arabic names, mixed-direction text, diacritics and spreadsheet import. State the CSV rules in the manifest: delimiter, quoting, line breaks and whether the file starts with a byte-order mark (BOM). RFC 4180 describes the common CSV conventions, among them CRLF line breaks (carriage return plus line feed) and doubled quotes inside quoted fields.

Some spreadsheet programs show Arabic correctly only when the file starts with a BOM. A comment in ClinicTek's CSV code says its BOM exists so that Arabic renders correctly in Excel. For that reason, the reports that ClinicTek's platform console offers for download start with one. Ship a sample file and an automated parser test with the specification.

Keep timestamps machine-readable with their timezone, and store money and measurements as exact decimals or integers. Quote identifiers, phone numbers and dates as text so a spreadsheet cannot turn them into different values.

Secure package generation and delivery

Build the export in an isolated job that runs in the tenant's context with least-privilege access, so it reads only what the export needs. Bound its memory and clean up on failure. Store the package on private encrypted storage, issue a short-lived download link that requires sign-in, and log both generation and access. Send a notification that carries no package contents, and never put the package on a public link or in an email attachment. Define expiry, retries, cancellation, and what happens when generation fails halfway.

Specify retention and deletion

Say how long the generated package stays available and when temporary files are removed. Name the production records the vendor must keep under contract or law, and how the vendor confirms deletion. Account closure, package expiry and data erasure are three separate events with different approvals and evidence, and cancelling a download must never delete source data. Where the vendor uses subprocessors (other companies that process the data on its behalf), name their responsibilities too.

Add counts and checksums

Compare each file's row count with a scoped query against the source at generation time, and record rejected or omitted items with a reason. A package that silently lost records should never report success.

Give the recipient a short, readable script that checks the package without the original application. This one checks every file's checksum and every CSV's row count against the manifest. Extend it to test each references entry.

import csv, hashlib, json, sys
from pathlib import Path

root = Path(sys.argv[1])
manifest = json.loads((root / "manifest.json").read_text(encoding="utf-8"))
problems = []

for f in manifest["files"]:
    path = root / f["path"]
    if hashlib.sha256(path.read_bytes()).hexdigest() != f["sha256"]:
        problems.append(f"{f['path']}: checksum does not match")
    if f["path"].endswith(".csv"):
        with path.open(encoding="utf-8-sig", newline="") as handle:
            rows = sum(1 for _ in csv.reader(handle)) - 1
        if rows != f["rows"]:
            problems.append(f"{f['path']}: {rows} rows, manifest says {f['rows']}")

print("\n".join(problems) or "Package matches its manifest.")
sys.exit(1 if problems else 0)

Run a neutral restore test

Load the export into an empty neutral database or analysis environment using only the schema documentation. Reconnect relationships, open sampled attachments, verify Arabic text, and reproduce representative totals. Measure time and note manual transformations.

The restore test is not a promise that every competitor can import the package directly. It proves the data is understandable and usable outside the source application. Repeat it after material schema or export changes.

The test in order:

  1. Run the verification script and stop if it reports a problem.
  2. Create an empty database and load the files in the order the references require, parents first.
  3. Rebuild every relationship listed in the manifest and count the orphans.
  4. Open a sample of attachments, including the largest and the oldest.
  5. Compare Arabic names, phone numbers and dates in ten sampled records against the source screens.
  6. Recompute two or three totals the business knows well, such as a month's invoiced amount.
  7. Write down the time taken and every manual step; each one belongs in the specification.

Put the export in the contract and the release process

If you are buying, attach the specification and a sample package to the contract. Add the export frequency, cost, delivery window, format version and exit assistance. Ask for that sample before data volume or a cancellation makes it urgent. Our SaaS build-or-buy worksheet puts the export next to the other exit questions. Who owns your data in a SaaS contract covers the ownership terms that sit above it.

If you are building, cover the export with automated tests and run the restore test as a scheduled drill. The multi-tenant authorization testing checklist covers the tenant boundary every export job must respect.

To have us specify or build the export for your product, send a short project brief or message us with the WhatsApp button on this page. Our SaaS development service builds it in from the first release.

Sources

#SaaS #Architecture #Data

Read our editorial policy

Continue reading

Related articles

  1. Cover: Designing Multi-Tenant SaaS Architecture in Laravel
  2. Cover: Flutter + Laravel: One Backend, Every Screen
  3. Cover: Applying Clean Architecture and DDD in Laravel

Building a custom system for your business?

After “Define the export before you need to leave”: tell us scope, users, and integrations — we reply with a practical plan after reviewing your request.