Capture the response safely
Record the HTTP status, request ID, timestamp, API route, environment, and authentication method. Check the API or gateway's structured error code for the specific reason. Never paste bearer tokens, client secrets, or full authorization headers into tickets, chat, or public token-inspection sites.
Example error shape (codes and response bodies vary by API):
401 Unauthorized
{"code":"invalid_token","requestId":"req-7f31"}
403 Forbidden
{"code":"missing_permission","requestId":"req-7f32"}
For a 401: verify authentication
- Confirm the request uses the expected authentication scheme and sends credentials to the correct host.
- Check whether the credential or access token is expired, revoked, malformed, or issued for a different environment.
- For a token, verify issuer, audience, tenant, and clock assumptions using approved identity-provider tooling.
- Confirm the client requested the API's expected scope or resource, and that the gateway accepts the same issuer and audience.
Some APIs return 401 for missing scopes or other policy failures, so use the response body and server-side request ID rather than relying on the status alone.
For a 403: verify authorization
- Confirm the authenticated identity is the intended user or workload identity.
- Check the specific role, scope, or resource-level permission required by this operation.
- Inspect API gateway policies, network restrictions, tenant boundaries, and data-level authorization rules.
- Compare a permitted request with the failing one without sharing credentials or sensitive records.
Do not solve a 403 by granting broad administrator access. Identify the narrow permission needed for the exact operation and resource, then test that boundary.
For service-to-service calls
Verify which identity the running workload actually uses in this environment. A developer's local credentials can hide a missing production role assignment. Check token acquisition logs and the target resource's access policy without logging token contents. After a role or policy change, account for propagation delay and acquire a fresh token before testing again.
Verify and prevent recurrence
- Reproduce with the same identity, route, and environment.
- Confirm the expected access succeeds and a disallowed identity still fails.
- Keep a request ID and a safe error reason in logs, but redact credentials and sensitive claims.
- Document the required permission with the API contract and deployment checklist.
For guidance on defining API access boundaries, see the API governance security checklist.