{"record":{"id":"2f33b8509e48404e","repo":"home-assistant/core","slug":"invalid-api-key","errorCode":"invalid_api_key","errorMessage":"Invalid API key. Please verify your API key and try to reauthenticate.","messagePattern":"Invalid API key\\. Please verify your API key and try to reauthenticate\\.","errorType":"exception","errorClass":"ConfigEntryAuthFailed","httpStatus":null,"severity":"error","filePath":"homeassistant/components/aqvify/coordinator.py","lineNumber":76,"sourceCode":"        \"\"\"Initialize the Aqvify data update coordinator.\"\"\"\n        super().__init__(\n            hass,\n            logger=_LOGGER,\n            name=f\"{DOMAIN} main\",\n            update_interval=UPDATE_INTERVAL,\n            config_entry=entry,\n        )\n\n        self.api_client = api_client\n        self.previous_devices: set[str] = set()\n\n    @override\n    async def _async_setup(self) -> None:\n        \"\"\"Set up the coordinator.\"\"\"\n        try:\n            await self.api_client.async_get_account_id()\n        except AqvifyAuthException:\n            raise ConfigEntryAuthFailed(\n                translation_domain=DOMAIN,\n                translation_key=\"invalid_api_key\",\n            ) from None\n        except ClientResponseError as err:\n            raise ConfigEntryNotReady(\n                translation_domain=DOMAIN,\n                translation_key=\"api_error\",\n                translation_placeholders={\n                    \"entry\": self.config_entry.title,\n                },\n            ) from err\n        except TimeoutError as err:\n            raise ConfigEntryNotReady(\n                translation_domain=DOMAIN,\n                translation_key=\"api_timeout\",\n                translation_placeholders={\n                    \"entry\": self.config_entry.title,\n                },","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/aqvify/coordinator.py#L58-L94","documentation":"ConfigEntryAuthFailed raised during Aqvify coordinator setup (translation_key 'invalid_api_key') when api_client.async_get_account_id() raises AqvifyAuthException. It tells Home Assistant the stored API key is no longer accepted, so the config entry is put into setup-error/reauth state instead of retrying uselessly.","triggerScenarios":"During coordinator _async_setup, the first authenticated call async_get_account_id() returns an auth failure (401/403) because the API key in entry.data is wrong, revoked, or belongs to another account.","commonSituations":"Typo in the API key during config flow; key regenerated in the Aqvify portal which invalidates the old one; key copied from a different account; REST client caching an entry with an old key after re-configuration.","solutions":["Open the Aqvify config entry in HA and start the re-authentication flow, pasting the current API key from your Aqvify account.","Verify the key by calling the Aqvify API directly (e.g. GET /accounts/me with the key) outside HA.","Ensure the key comes from the same account that owns the devices you expect."],"exampleFix":"# verify the key before relying on HA setup\ncurl -H \"Authorization: Bearer $AQTIFY_API_KEY\" https://api.aqvify.com/api/v1/accounts/me","handlingStrategy":"try-catch","validationCode":"import aiohttp\n\nasync def key_works(session: aiohttp.ClientSession, api_key: str) -> bool:\n    async with session.get(\n        \"https://api.aqvify.com/api/v1/accounts/me\",\n        headers={\"Authorization\": f\"Bearer {api_key}\"},\n    ) as resp:\n        return resp.status == 200","typeGuard":null,"tryCatchPattern":"from aqvify_client.exceptions import AqvifyAuthException\n\ntry:\n    account_id = await api_client.async_get_account_id()\nexcept AqvifyAuthException:\n    # prompt user for a new API key; run reauth flow\nraise","preventionTips":["Paste API keys via secrets and double-check for whitespace/truncation.","Test the key against the Aqvify API before configuring the integration.","When regenerating a key in the portal, immediately re-authenticate the HA entry."],"tags":["home-assistant","aqvify","api-key","authentication","reauth"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}