{"record":{"id":"f3b31097cb92c3dc","repo":"crewAIInc/crewAI","slug":"zapier-actions-api-key-is-required","errorCode":null,"errorMessage":"Zapier Actions API key is required","messagePattern":"Zapier Actions API key is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/adapters/zapier_adapter.py","lineNumber":65,"sourceCode":"            execute_url,\n            headers=headers,\n            json=action_params,\n            timeout=30,\n        )\n\n        response.raise_for_status()\n\n        return response.json()\n\n\nclass ZapierActionsAdapter:\n    \"\"\"Adapter for Zapier Actions.\"\"\"\n\n    def __init__(self, api_key: str | None = None):\n        self.api_key = api_key or os.getenv(\"ZAPIER_API_KEY\")\n        if not self.api_key:\n            logger.error(\"Zapier Actions API key is required\")\n            raise ValueError(\"Zapier Actions API key is required\")\n\n    def get_zapier_actions(self) -> Any:\n        headers = {\n            \"x-api-key\": self.api_key or \"\",\n        }\n        response = requests.request(\n            \"GET\",\n            ACTIONS_URL,\n            headers=headers,\n            timeout=30,\n        )\n        response.raise_for_status()\n\n        return response.json()\n\n    def tools(self) -> list[ZapierActionTool]:\n        \"\"\"Convert Zapier actions to BaseTool instances.\"\"\"\n        actions_response = self.get_zapier_actions()","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/adapters/zapier_adapter.py#L47-L83","documentation":"Raised by ZapierActionsAdapter.__init__ when neither the `api_key` argument nor the ZAPIER_API_KEY environment variable yields a non-empty key. It is a hard configuration gate: without a key, no Zapier Actions API call can be authenticated.","triggerScenarios":"Instantiating ZapierActionsAdapter() with no argument while ZAPIER_API_KEY is unset or empty, or passing an empty string api_key explicitly (`api_key=''` falls through to env lookup, which is also empty).","commonSituations":"Forgot to export ZAPIER_API_KEY in the shell/CI environment, .env file not loaded into the process, key set in a different deployment environment, or a copy-pasted snippet that expects the env var at runtime.","solutions":["Export the key before running: `export ZAPIER_API_KEY=your_key` (or add it to your .env and ensure it is loaded).","Pass it explicitly: `ZapierActionsAdapter(api_key='your_key')`.","In CI/deployment, add ZAPIER_API_KEY as a secret env var on the runner.","Verify with `echo ${ZAPIER_API_KEY:-unset}` that the variable actually reaches the process."],"exampleFix":"# before\nadapter = ZapierActionsAdapter()  # ValueError if env var missing\n\n# after\nadapter = ZapierActionsAdapter(api_key=os.environ[\"ZAPIER_API_KEY\"])  # fails fast with KeyError if truly missing\n# or\nexport ZAPIER_API_KEY=your_key","handlingStrategy":"validation","validationCode":"import os\n\napi_key = os.getenv(\"ZAPIER_API_KEY\")\nif not api_key:\n    raise SystemExit(\"ZAPIER_API_KEY is not set — get one at https://zapier.com/appconnections/ai\")\nadapter = ZapierActionsAdapter(api_key)","typeGuard":"def has_zapier_key() -> bool:\n    return bool(os.getenv(\"ZAPIER_API_KEY\"))","tryCatchPattern":"try:\n    adapter = ZapierActionsAdapter()\nexcept ValueError as e:\n    if \"API key\" in str(e):\n        raise SystemExit(\"Set ZAPIER_API_KEY in the environment\") from e\n    raise","preventionTips":["Fail fast on startup: check os.getenv('ZAPIER_API_KEY') before building agents.","Store the key in a secrets manager and inject it as an env var in CI/deploy.","Pass api_key explicitly in scripts instead of relying on ambient env."],"tags":["zapier","authentication","configuration","env-vars"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}