API Testing error

Error: Request failed with status code 401

The API rejected the request as unauthenticated, and in test suites this is often a token lifecycle bug, not a credentials typo.

Why this happens

How to fix it

  1. Fetch a fresh token per test (or per suite) instead of reusing one long-lived token across a whole run
  2. Log the actual outgoing `Authorization` header in a failing case to rule out a wiring bug before suspecting expiry
  3. If tests run in parallel, give each one its own auth session instead of sharing one