PII Retention Policy — Q-Flow
Status: Draft for legal review
Last updated: 2026-07-18
Effective date: To be determined by legal counsel
1. Purpose
This policy defines how personally identifiable information (PII) is retained, purged, and managed throughout its lifecycle in the Q-Flow platform. The goal is to minimise data retention to what is strictly necessary while meeting operational and regulatory requirements.
2. PII Classification
| Classification | Fields | Sensitivity |
|---|---|---|
| High | citizenPhone, nationalId | Encrypted at rest (AES-256-GCM) |
| Medium | citizenName | Stored in database, access-controlled |
| Low | Token metadata, feedback, language preference | Operational data, no direct PII linkage |
3. Data Lifecycle
Citizen takes token → WAITING → SERVING → FINALISED → [retention period] → AUTO-PURGE
3.1 Active Token
During active queue participation, all token data (including PII) is retained for real-time queue management.
3.2 Post-Finalisation Retention
After a token reaches FINALISED status:
| Data | Retention Period | Auto-Purge |
|---|---|---|
| Token record + PII fields | 90 days after finalisedAt | Yes |
| Push subscriptions for token | 90 days after finalisedAt (cascade delete) | Yes |
| Feedback record | 90 days after finalisedAt (cascade delete) | Yes |
| Audit logs (access events) | 12 months from creation | Yes |
| Application logs with PII | 30 days | Yes (log rotation) |
3.3 Configurable Retention
The 90-day default can be overridden per-organisation via the tokenRetentionDays organisation setting. This allows organisations with different regulatory requirements to adjust retention.
Minimum: 7 days. Maximum: 365 days.
3.4 Token States and Retention
| State | Retention Behaviour |
|---|---|
WAITING, SERVING, TRANSFERRED, STANDBY, DEFERRED, RAINCHECK | Retained indefinitely (active tokens) |
FINALISED | Retention clock starts at finalisedAt |
CANCELLED | Retention clock starts at updatedAt |
NO_SHOW | Retention clock starts at updatedAt |
4. Auto-Purge Mechanism
4.1 How It Works
A scheduled server job runs daily (configurable) and:
- Queries all tokens where the retention period has elapsed
- Deletes PII fields (sets
citizenPhone,citizenPhoneHash,nationalId,citizenNameto null) - Deletes associated PushSubscription records (cascade)
- Deletes associated Feedback records (cascade)
- Retains the anonymised token record for aggregate analytics (token number, status, timestamps, department)
4.2 Purge Schedule
- Default: Daily at 02:00 UTC
- Configurable via:
PURGE_CRON_SCHEDULEenvironment variable - Batch size: 1000 tokens per transaction (to avoid long-running transactions)
4.3 Verification
Each purge run logs:
- Number of tokens processed
- Number of PII fields purged
- Any errors encountered
Logs are retained for 30 days for audit purposes.
5. Citizen Rights
5.1 Right to Deletion
Citizens may request immediate deletion of their personal data by contacting the Organisation's data protection officer with their token number or phone number.
Upon receiving a verified deletion request:
- PII fields are nullified immediately (within 24 hours)
- Push subscriptions for the associated token are removed
- The anonymised token record is retained for aggregate analytics
5.2 Right to Data Portability
Citizens may request an export of their personal data in a machine-readable format (JSON). This export includes all PII fields and associated metadata.
5.3 Right to Opt-Out
- Citizens who did not provide PII have no data to delete
- Citizens who opted in to push notifications may disable them at any time from the token status page
- Disabling notifications removes push subscription data immediately
6. Ghost Tokens
Ghost tokens (failed token creations preserved for replay) contain citizenPhone and citizenPhoneHash. These are:
- Retained for 7 days for idempotency replay
- Automatically purged after 7 days regardless of retention settings
7. Backup and Recovery
- Database backups are encrypted at rest
- Backups containing PII are subject to the same retention schedule
- Restore operations do not extend PII retention beyond the configured period
8. Incident Response
In the event of a data breach involving PII:
- Affected citizens are notified within 72 hours
- The breach is documented with scope, impact, and remediation
- Encryption keys are rotated if compromise is suspected
- The relevant data protection authority is notified as required by law
9. Review and Updates
This policy is reviewed quarterly and updated as needed to reflect:
- Changes in Nepal's data protection legislation
- Changes in the Platform's data handling practices
- Feedback from legal counsel and the Organisation
This is a draft document for legal review. It does not constitute legal advice and should be reviewed by qualified legal counsel before publication.