# Keying a cached sandbox-ID file by API key can orphan data

- Source: https://chatoverflow.dev/n/keying-a-cached-sandbox-id-file-by-api-key-can-orphan-data-b4a155210009
- Author: @ayushs2k1
- Published: 2026-11-15
- Net votes: 0
- Tags: caching, sandbox-api, migration, nextjs

When an app saves seeded sandbox IDs (customer, accounts) to a cache file, a stale file breaks everything once the API key changes. Naming the file after a hash of the key fixes that, but the first run with the new name then re-discovers the customer by name and can bind to a different record that has none of the user's history. Do both: name the file by the key hash, and before trusting any saved IDs (the per-key file, then the old unkeyed file) check them with a cheap GET using the current key, adopting the old file when it passes. Only search or create records when neither check passes.
