{"record":{"id":"2dfb6d18fb8ae52a","repo":"ComposioHQ/composio","slug":"a-composio-project-api-key-is-required-to-create-a","errorCode":null,"errorMessage":"A Composio project API key is required to create a local workbench session","messagePattern":"A Composio project API key is required to create a local workbench session","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/experimental/src/workbench/local-workbench.ts","lineNumber":21,"sourceCode":"  experimental_createPythonWorkbenchHelperSource,\n  experimental_createWorkbenchEnv,\n} from './shim';\nimport type { LocalWorkbenchSession } from './types';\n\nexport async function experimental_createLocalWorkbenchSession(\n  composio: Composio,\n  session: Session<unknown, unknown, never>\n): Promise<LocalWorkbenchSession> {\n  if (session.workbench?.enable !== false) {\n    throw new Error(\n      'experimental_createLocalWorkbenchSession requires a session created with workbench.enable: false. ' +\n        'The remote workbench and a local sandbox cannot both run for one session.'\n    );\n  }\n\n  const { apiKey, baseURL } = composio.getConfig();\n  if (!apiKey) {\n    throw new Error('A Composio project API key is required to create a local workbench session');\n  }\n\n  const env = experimental_createWorkbenchEnv({\n    sessionId: session.sessionId,\n    backendUrl: baseURL ?? 'https://backend.composio.dev',\n    apiKey,\n  });\n\n  return {\n    env,\n    helperSource: experimental_createPythonWorkbenchHelperSource(),\n  };\n}\n","sourceCodeStart":3,"sourceCodeEnd":35,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/experimental/src/workbench/local-workbench.ts#L3-L35","documentation":"experimental_createLocalWorkbenchSession needs a project API key to mint sandbox credentials; if composio.getConfig().apiKey is empty it throws immediately. Anonymous/API-key-less Composio instances cannot create local workbench sessions.","triggerScenarios":"Constructing Composio without an apiKey (relying on some other auth mechanism) and then calling experimental_createLocalWorkbenchSession.","commonSituations":"Missing COMPOSIO_API_KEY env var; initializing Composio({ apiKey: undefined }) due to a typo'd env name; running in CI without secrets configured.","solutions":["Set COMPOSIO_API_KEY or pass apiKey explicitly when constructing Composio","Verify the env var name and that it is loaded (dotenv, CI secrets) before creating the session","Fail fast at startup: if local workbench is required, assert the API key exists during boot"],"exampleFix":"// before\nconst composio = new Composio({}); // apiKey undefined\n// after\nconst composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY! });","handlingStrategy":"validation","validationCode":"if (!process.env.COMPOSIO_API_KEY) throw new Error('COMPOSIO_API_KEY is required for local workbench sessions');","typeGuard":"const hasApiKey = (c: Composio): boolean => Boolean(c.getConfig().apiKey);","tryCatchPattern":"catch (e) { if ((e as Error).message.includes('project API key')) { /* load env, reconstruct Composio, retry */ } throw e; }","preventionTips":["Set COMPOSIO_API_KEY in every environment using workbench features","Fail fast at startup when local workbench is required","Double-check env var name spelling and CI secret wiring"],"tags":["workbench","api-key","authentication","experimental"],"backgroundTag":"missing-api-key","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}