Data protection

API Security Compliance: GDPR, HIPAA and PCI

Published: 19 September 2026

Map each legal or contractual obligation to the data an API handles and to a control you can demonstrate.

Start with a data and jurisdiction map

API security compliance begins by identifying what data crosses each route, who controls it, where it is stored, and who receives it. Mark personal data, health information, and payment account data separately. An endpoint can fall under more than one regime, but the obligations depend on the organisation's role, jurisdiction, contract, and actual processing. Ask legal and privacy owners to confirm applicability rather than declaring a service compliant because it passed a scanner.

Keep a record of the purpose for each data field and downstream transfer. Review OpenAPI schemas and examples for fields that clients do not need. Compare the published contract with actual responses, including expanded relations, errors, exports, and webhooks. An undocumented field can undermine a minimisation plan even when the main response model looks narrow.

Apply data minimisation in response design

For GDPR-related processing, collect and expose data appropriate to the stated purpose. Design separate response shapes for public, account, and administrative clients rather than returning one broad object and asking every consumer to ignore sensitive fields. Remove precise identifiers, dates, or notes when a less detailed value suffices. Test a lower-privilege user against each representation.

Do not put personal data in URL parameters if it can enter browser history, reverse-proxy logs, and analytics. Avoid realistic patient records, card numbers, or credentials in OpenAPI examples. Check whether error messages, pagination totals, and search suggestions reveal the existence of protected records. Data minimisation also applies to telemetry and support exports, not just the documented success response.

Protect access and transmission

Use strong client and workload authentication, then enforce role and object permissions on every operation. A token with a valid signature is not permission to fetch another patient's file or a different merchant's transaction. Encrypt traffic on each relevant hop and manage keys with rotation and access controls. Define how a lost credential is revoked and how service-to-service access is reviewed.

HIPAA safeguards and PCI DSS requirements have their own scope and detailed controls. Do not assume that TLS plus a privacy notice satisfies them. Bring compliance specialists into the design review for regulated data, and capture the system boundary, vendors, and shared responsibilities. Keep evidence of access decisions and configuration reviews without storing sensitive payloads unnecessarily.

Log enough to investigate without copying the data

A useful audit event identifies actor, action, resource type, time, decision, and correlation ID. It does not need a full request body or a raw bearer token. Use structured fields and a redaction policy at collection time; later scrubbing cannot guarantee every downstream copy disappears. Restrict access to logs and define retention based on the applicable requirement and operational need.

Test failures as carefully as successes. Invalid requests often trigger verbose exception traces that include database values, headers, or third-party responses. Make client errors stable and generic enough to avoid disclosure while retaining details in controlled server logs. Sample logs from staging and inspect them with realistic sensitive test data before enabling a new route.

Turn requirements into evidence

For each control, write down its owner, configuration source, test, and review frequency. An access rule may have a unit test, a live cross-tenant test, and a gateway policy review. A data retention rule needs evidence that records and backups expire as intended. A scanner report can show that a contract declares security and constrained fields, but it cannot prove the application applies those controls.

Use APISAST to flag missing design declarations and suspicious contract patterns. Follow each finding with a decision: update the specification, fix the service, or document why the rule does not apply. Avoid presenting a passing contract scan as a GDPR, HIPAA, or PCI certification. Certification and legal compliance require broader organisational and technical evidence.

Plan for changes and incidents

A new analytics integration, export route, or region can change the data map. Make data classification part of API review so teams assess those changes before release. Keep incident contacts and escalation steps current; a suspected data exposure needs a known owner, a way to preserve evidence, and a process for legal assessment.

Revisit the inventory when clients stop using old versions. Retire unused routes, credentials, and data stores rather than leaving personal data reachable indefinitely. Test deletion and access requests through the real system where applicable. The practical goal is a set of controls and records that match the API people actually run, not a policy document that describes a different system.

Example: a patient appointment API

Consider GET /appointments/{id} used by a patient portal and clinical staff. The contract may show authentication and a response schema, but the actual permission rule differs by actor. A patient may read only their own appointment; a clinician may read appointments for patients under an authorised care relationship. An administrator might see scheduling details but not clinical notes. Model separate response views and test each role against the same record.

Then inspect secondary paths: a search result, email notification, calendar export, and error response might reveal the same appointment even if the detail route is protected. Record where data is sent and which processor stores it. For regulated information, the team needs a legal and compliance review of the full flow; an OpenAPI scan provides useful design evidence but cannot decide whether a particular disclosure meets the applicable rule.

Check vendor and retention assumptions

An API often sends logs, traces, messages, or analytics to third parties. Document which vendor receives which fields and whether the contract and region are approved for that data class. A new monitoring library can widen exposure without changing any public route. Test redaction at the point where data leaves the service.

Define how long operational records, exports, backups, and failed requests are retained. Confirm deletion in a staging drill using known test records. Keep only the evidence needed to show a control worked, and restrict who can read it. The data map should include these operational copies so privacy decisions reflect the system that actually runs.

Continue the work

Use these guides to put the checks into your API review process:

Primary reference: EU General Data Protection Regulation.

APISAST reviews OpenAPI and Swagger contracts for documented design signals. Confirm authorization, enforcement, performance, and abuse controls against a running service.

More API security guides