This guide to the DPDP Act for developers is the code-level companion to our DPDP Act compliance checklist for Indian SaaS. That post covered the policies and processes. This one is for the engineers who have to make those policies true: the APIs, tables, jobs and infrastructure that must exist for your DPDP claims to hold up under audit.
Key takeaways: the six DPDP engineering controls
A
consentstable that records every consent event with full context.A user data export API that returns everything you hold.
A user data deletion API with documented cascade behavior.
An immutable audit log of personal-data access.
A breach detection system that is tested.
A scheduled job to expire data past retention.
The database schema for DPDP compliance
Three tables carry most of the evidence. Each one answers a question an auditor or a user is entitled to ask: what did this person agree to, who touched their data, and how long do you keep it.
consents: one row per consent decision
create table consents (
id uuid primary key,
user_id uuid references users(id),
purpose text not null,
consent_version text not null,
text_shown text not null,
granted boolean not null,
granted_at timestamptz,
ip text,
user_agent text,
withdrawn_at timestamptz,
withdrawal_method text
);
Every consent decision is one row. You can prove what the user agreed to, when, and via what UI. Storing text_shown and consent_version on the row matters: the wording on your screen will change, and the record has to show the words this user actually saw, not the ones you show today.
data_access_log: who read whose data
create table data_access_log (
id uuid primary key,
actor_id uuid,
actor_type text, -- 'user' / 'admin' / 'system'
subject_user_id uuid, -- whose data
data_categories text[], -- ['profile', 'payments', 'health']
action text, -- 'read' / 'export' / 'delete'
purpose text,
occurred_at timestamptz not null default now(),
ip text,
request_id text
);
Immutable. Append-only. Enforce that in the database rather than in application code: grant the application role insert and select on this table and nothing else, so no code path can quietly rewrite history. If you run Postgres with row level security, our post on RLS vs schema-per-tenant covers how policies combine.
retention_rules: how long each table keeps data
create table retention_rules (
table_name text primary key,
retention_days integer not null,
delete_method text not null -- 'hard_delete' / 'anonymize' / 'archive'
);
A scheduled job reads this and applies retention. Keeping the rules in a table rather than scattered through code means the retention policy you document and the one you enforce are the same list.
The data principal APIs
Four endpoints cover the requests a user (and your own team, in a breach) will make. The table below summarises what each must do.
Endpoint | Purpose | Behaviour |
|---|---|---|
| Access | Returns all data you hold about the requesting user, in machine-readable JSON. |
| Erasure | Triggers deletion and returns a request ID. Async, completed within the agreed window. Cascades to all dependent records and notifies third parties. |
| Correction | Requests a correction. Goes into a queue if it requires manual review. |
| Breach response | Internal admin endpoint that triggers the breach workflow: logs the incident, notifies the DPO and starts the 72-hour notification clock. |
Each of these calls should also write a row to data_access_log, with action set to export or delete. The request that exercises a user's rights is itself an access to their data.
The scheduled jobs
Job | Frequency | What it does |
|---|---|---|
Retention enforcement | Daily | Applies the rules in |
Backup purge | Monthly | Ensures deleted users are removed from backups |
Consent expiration | As needed | Triggers re-consent flows |
Audit log archival | Monthly | Archives old logs to cold storage |
The observability layer
A control nobody watches drifts. These four signals tell you the controls above are still working:
Dashboard of pending deletion requests
Alert if any deletion request is older than the SLA
Alert on unusual data access patterns (volume, off-hours)
Quarterly access review report
The quarterly access review is also evidence you will reuse elsewhere; it maps closely to what an auditor asks for in SOC 2 readiness.
Common pitfalls in DPDP deletion and logging
Backups
Users get deleted from the primary DB but live in backups for 30+ days. Document the policy and plan for it.
Third-party processors
Stripe still has the user. Your deletion API must trigger downstream deletion.
Logs
Personal data in application logs is not subject to deletion. Do not log PII; if you must, mask or tokenize it.
What we recommend
Build these controls as core platform features, not compliance afterthoughts. They are useful beyond DPDP: they help product (analytics, debugging) and they are good engineering hygiene. Teams that wire them in from the start find they slot naturally into a post-launch SaaS checklist rather than becoming a scramble before an audit.
FAQs
How long can a deletion take?
Within "reasonable time". Interpret that as days, not months.
Do we have to delete from backups?
Document the policy and show due diligence; for many backups it is reasonable to wait out the backup's own expiry.
Does pseudonymization take data out of scope?
No. It is a useful intermediate state, but pseudonymized data is still personal data in DPDP terms.
Want these controls designed into your platform from day one? Talk to Techpuvi about cybersecurity and compliance engineering, or get in touch and we will map the schema, APIs and jobs to your stack.
