{"record":{"id":"f28716bf3a7ce6bd","repo":"usestrix/strix","slug":"postman-api-key-is-not-set-export-a-postman-api-k","errorCode":null,"errorMessage":"POSTMAN_API_KEY is not set. Export a Postman API key (PMAK-…) to fetch from the Postman API, or pass a local collection file instead.","messagePattern":"POSTMAN_API_KEY is not set\\. Export a Postman API key \\(PMAK-…\\) to fetch from the Postman API, or pass a local collection file instead\\.","errorType":"exception","errorClass":"SpecParseError","httpStatus":null,"severity":"error","filePath":"strix/utils/api_spec.py","lineNumber":245,"sourceCode":"    if spec_format == \"swagger\":\n        return _swagger_base_urls(raw)\n    if spec_format == \"postman\":\n        return _postman_base_urls(raw, extra_variables)\n    raise SpecParseError(\"File is not a recognized OpenAPI, Swagger, or Postman spec\")\n\n\nPOSTMAN_API_BASE = \"https://api.getpostman.com\"\n_POSTMAN_FETCH_TIMEOUT = 30\n\n\ndef _postman_api_json(url: str, api_key: str, label: str) -> dict[str, Any]:\n    \"\"\"GET a Postman API resource and return the parsed JSON payload.\n\n    Raises :class:`SpecParseError` with an actionable message on auth, network,\n    or shape errors.\n    \"\"\"\n    if not api_key:\n        raise SpecParseError(\n            \"POSTMAN_API_KEY is not set. Export a Postman API key (PMAK-…) to \"\n            \"fetch from the Postman API, or pass a local collection file instead.\",\n        )\n    try:\n        response = requests.get(\n            url,\n            headers={\"X-Api-Key\": api_key, \"Accept\": \"application/json\"},\n            timeout=_POSTMAN_FETCH_TIMEOUT,\n        )\n    except requests.RequestException as exc:\n        raise SpecParseError(f\"Failed to reach the Postman API: {exc}\") from exc\n\n    if response.status_code == 401:\n        raise SpecParseError(\"Postman API rejected the key (401). Check POSTMAN_API_KEY.\")\n    if response.status_code == 404:\n        raise SpecParseError(\n            f\"Postman {label} not found (404). Check the id and that the key can access it.\",\n        )","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/utils/api_spec.py#L227-L263","documentation":"SpecParseError raised by _postman_api_json when fetching a Postman resource by UID but no API key was supplied (empty POSTMAN_API_KEY). The Postman API requires an X-Api-Key header (PMAK-…); without it the request is never attempted.","triggerScenarios":"Passing a postman:// or collection-UID style spec target without exporting POSTMAN_API_KEY; the variable set to an empty string in the shell or Docker env; the key present in a .env file that was never loaded.","commonSituations":"CI job that omits the secret; key defined for the interactive shell but not passed to the Docker sandbox; typo in the variable name (POSTMAN_KEY, POSTMAN_APIKEY).","solutions":["export POSTMAN_API_KEY=PMAK-xxxx (Settings → API Keys in Postman) and re-run","Pass the key explicitly if the CLI supports it, or mount it into the container env","Alternative: skip the API entirely and export the collection JSON, then pass the local file"],"exampleFix":"# before\nstrix --api-spec postman:12345-abcdef  # no key in env\n\n# after\nexport POSTMAN_API_KEY=\"PMAK-xxxxxxxx\"\nstrix --api-spec postman:12345-abcdef","handlingStrategy":"validation","validationCode":"import os\n\nif spec.startswith(\"postman\") and not (os.environ.get(\"POSTMAN_API_KEY\") or \"\").startswith(\"PMAK-\"):\n    raise RuntimeError(\"export POSTMAN_API_KEY (PMAK-…) or pass a local collection file\")","typeGuard":"def has_postman_key() -> bool:\n    import os\n    return os.environ.get(\"POSTMAN_API_KEY\", \"\").startswith(\"PMAK-\")","tryCatchPattern":"try:\n    coll = fetch_postman_collection(uid, api_key)\nexcept SpecParseError as e:\n    if \"POSTMAN_API_KEY is not set\" in str(e):\n        prompt for the key or switch to a local export — do not retry unchanged","preventionTips":["Check the env var at job start, not at call time","For Docker runs, pass -e POSTMAN_API_KEY or mount the secret","Keep a local collection export as a no-network fallback"],"tags":["authentication","postman","environment-variables"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}