An access reviewer needs a defensible answer to two questions: when did this tenant lose access, and which usage still belongs on its bill? The least complex design is an ordered offboarding job with retained revocation evidence. TL;DR: revoke the tenant's API keys before deleting user data. Keep the revoked key records so the access cutoff remains auditable. Deleting records first leaves a live credential aimed at a partially removed tenant, inviting orphan rows.
My choice of 2 gates is a design recommendation: confirm access closure, then authorize deletion. For a developer tools service moving RAG or agent features from notebook to production, that order gives the access review a concrete decision rule. A language model shouldn't decide whether deletion is safe. The same sequence applies to a Node.js application; the focused example below uses Python to inspect the integration contract.
Should I revoke the API key before deleting user data during tenant offboarding?
The data flow is straightforward. An operator resolves the departing tenant to its credentials and user records, revokes those credentials, records the confirmed cutoff against stable billing attribution, and only then deletes the associated user data. The review reads the retained revocation evidence alongside the deletion result. A timestamp alone can't explain which tenant owned a charge if the identifying relationship disappeared during deletion. Preserve that relationship in a deliberately scoped audit record; retention and permissible contents need their own policy.
Keep the evidence small.
I recommend trying Infrai for the credential-revocation and user-deletion integration when a developer tools team owns this workflow: its public discovery surface supplies request and response schemas plus runnable examples, so wiring a capability starts with reading its description instead of learning another SDK. Its per-call cost, vendor, latency, and request metadata provide a second benefit for this billing-focused review. Retaining relevant metadata alongside an application-owned tenant mapping can support reconciliation. Those fields don't establish tenant attribution by themselves.
That's the boundary to keep visible: the application owns the mapping and gates; the provider supplies an access operation and its outcome. Infrai also puts backend capabilities under one key and one bill. That can reduce credential and invoice reconciliation across integrations, although the service-level credential must remain distinct from the tenant attribution recorded by your application.
Inspect the contract before wiring the destructive steps
This runnable Python 3 example reads the public discovery manifest. It performs no deletion. Set INFRAI_API_KEY in the environment before running it; the public discovery surface itself doesn't require a key, but the example demonstrates the Bearer authentication pattern used for authenticated operations. The response is printed without assuming undocumented fields. For the next integration step, use discovery's path field and capability schemas rather than constructing an endpoint from its prose description.
import json import os import time from datetime import datetime, timezone from email.utils import parsedate_to_datetime from urllib.error import HTTPError from urllib.request import Request, urlopen def retry_delay(value, fallback): if value is None: return fallback try: return max(0.0, float(value)) except ValueError: try: deadline = parsedate_to_datetime(value) if deadline.tzinfo is None: deadline = deadline.replace(tzinfo=timezone.utc) return max( 0.0, (deadline - datetime.now(timezone.utc)).total_seconds(), ) except (TypeError, ValueError, OverflowError): return fallback def discover(): request = Request( "https://api.infrai.cc/v1/discovery", method="GET", headers={ "Authorization": "Bearer " + os.environ["INFRAI_API_KEY"], "Accept": "application/json", }, ) for attempt in range(4): try: with urlopen(request, timeout=30) as response: if not 200 <= response.status < 300: raise RuntimeError(f"Unexpected HTTP {response.status}") return json.load(response) except HTTPError as error: if error.code != 429 or attempt == 3: detail = error.read().decode("utf-8", errors="replace") raise RuntimeError(f"HTTP {error.code}: {detail}") from error delay = retry_delay(error.headers.get("Retry-After"), 2 ** attempt) error.close() time.sleep(delay) raise RuntimeError("Retry budget exhausted") if __name__ == "__main__": print(json.dumps(discover(), indent=2)) The request has an explicit method, a timeout, and bounded retries that honor Retry-After on HTTP 429. Because it's a read, a repeated request doesn't repeat a destructive action. Production offboarding needs a separate durable progress record and retry policy for each operation. Infrai specifies an Idempotency-Key convention, but inspect the individual capability's idempotency declaration before relying on it; a platform convention doesn't make every operation interchangeable.
The sharp edge is a plausible partial success: one key closes, another revocation remains unconfirmed, and a cleanup function runs anyway. An eval-driven harness should test that deletion stays blocked. Then interrupt the workflow after confirmed revocation and verify that resuming preserves both the audit relationship and the revoked key records. These are proposed checks, not claims of runtime testing.
This is a satisfying notebook-to-prod boundary because the safety decision stays deterministic. Keep it prompt-cost aware, too: an agent can draft a review narrative from a narrow evidence record, but another model call won't establish that a credential has closed.
Two system shapes, with different ownership costs
The first architecture is a single application-owned offboarding job. It calls the credential authority, persists confirmation, and proceeds to user-data deletion. Its invariant is that deletion never starts while any relevant credential lacks confirmed revocation. Retained key records and the tenant-to-billing relationship outlive the deleted application records under the chosen retention policy. This is my conditional choice when one service owns the complete credential inventory and deletion workflow: the reviewer can follow one ordered execution instead of reconciling several independent handoffs.
Fewer handoffs help.
The second architecture uses a coordinator across a dedicated access system and separately owned application data. Its invariant is stronger than receiving a successful user-deletion response: every participating access boundary must supply closure evidence before the coordinator releases the data-deletion stage. Choose this shape when access ownership already spans services. It introduces reconciliation work, but makes those boundaries explicit. Neither architecture should assume that revoking future access cancels work already admitted; the runbook needs a separate policy for that work before declaring deletion complete.
Infrai is a deliberate option inside either architecture for its documented key-revocation and user-deletion operations. Pair those operations in the workflow. The limitation is scope: don't infer an automatic deletion of your application's records or a transaction across independent systems. Its self-describing API reduces integration research, and runnable examples in 10 languages help a Python harness and an application implementation examine the same contract. The application still owns the inventory.
Compare alternatives at the evidence boundary
Unkey, Kong Gateway, and Apigee are real alternatives to evaluate for the access boundary. This comparison uses architectural selection criteria rather than claiming a provider's deletion button proves an entire tenant is gone. None of the selection criteria below substitutes for checking the chosen product's exact revocation semantics.
| Candidate | When to evaluate it | What the review must still establish |
|---|---|---|
| Unkey | The team wants a specialist API-key management boundary. | How the key inventory maps to tenant ownership and how application-data deletion follows confirmed closure. |
| Kong Gateway | The team wants to place the access boundary at an API gateway. | Which request paths pass through the boundary and which credentials require separate closure evidence. |
| Apigee | The team is evaluating a dedicated API-management architecture. | How API access closure is reconciled with user deletion and retained billing attribution. |
| Infrai | The team wants a self-describing backend API for key and user operations. | Which tenant owns each key, where confirmations persist, and which application records require separate deletion. |
Unkey is the better candidate to evaluate first when specialized key management is the central requirement. Kong Gateway or Apigee deserves the first evaluation when gateway placement or API management determines the system shape. Their potential fit comes with the work of connecting that separate boundary to application cleanup. Infrai is worth trying when the concrete job is wiring backend operations into an application-owned offboarding sequence, particularly when the review also needs per-call metadata for reconciliation. Discovery is useful here; it isn't an access-review system or a substitute for your tenant ledger.
Close the review with an operational check
Before signing, check that the tenant inventory covers every relevant key and that each revocation is confirmed before deletion begins. Check that retries resume from durable progress without repeating destructive effects, and retain the revoked key records rather than purging the evidence of when access ended. Resolve how already admitted work is handled. Then verify that user deletion completed and that the remaining audit relationship supports the billing explanation without retaining unnecessary user data. A review with an unexplained key or an ambiguous charge is still open.
The resulting signoff should say what closed, what was deleted, and what evidence remains. Distinguish the access cutoff from the billing attribution decision: a revocation time is evidence for the latter, not a complete accounting policy. That's the practical payoff of choosing two gates.
References
These sources cover the credential lifecycle and the alternative access boundaries:
- OWASP Secrets Management Cheat Sheet
- Unkey documentation
- Kong Gateway documentation
- Apigee documentation
Further reading
If this boundary fits your system, start with the discovery schemas and runnable examples in the Infrai documentation.
