The key issue is that API keys from api.data.gov do not work with SAM.gov APIs. Although both are managed by GSA, they are separate systems with separate authentication mechanisms. The SAM.gov Entity Information API requires a SAM.gov–issued Public API Key, not an api.data.gov key.
Here’s how to obtain the correct key:
Log in to SAM.gov
Navigate to Profile → Account Details
Locate the section labeled Public API Key
Click the eye icon and complete the one-time verification to reveal the key
This is the only API key that will work with endpoints such as:
https://api.sam.gov/entity-information/v1/entities