{"record":{"id":"e48051256703c536","repo":"mastra-ai/mastra","slug":"channel-platform-does-not-support-programmati","errorCode":null,"errorMessage":"Channel \"${platform}\" does not support programmatic connection","messagePattern":"Channel \"(.+?)\" does not support programmatic connection","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/channels.ts","lineNumber":184,"sourceCode":" */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n  method: 'POST',\n  path: '/channels/:platform/connect',\n  responseType: 'json',\n  pathParamSchema: channelPlatformPathParams,\n  bodySchema: connectChannelBodySchema,\n  responseSchema: connectChannelResponseSchema,\n  summary: 'Connect agent to channel',\n  description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n  tags: ['Channels'],\n  requiresAuth: true,\n  handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n    assertChannelsAvailable();\n    try {\n      const channel = getChannelOrThrow(mastra, platform);\n\n      if (!channel.connect) {\n        throw new HTTPException(400, {\n          message: `Channel \"${platform}\" does not support programmatic connection`,\n        });\n      }\n\n      await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n      return await channel.connect(agentId, options);\n    } catch (error) {\n      return handleError(error, 'Error connecting agent to channel');\n    }\n  },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n  method: 'POST',","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/channels.ts#L166-L202","documentation":"The connect-channel handler looks up the channel instance registered on the Mastra instance for the requested platform and throws HTTP 400 when the channel object has no `connect` method. Channels only expose programmatic connect/disconnect when the underlying integration supports it; presence-only channels (e.g. ones that connect via external dashboard configuration) do not implement it.","triggerScenarios":"POSTing to the channel connect route with a platform whose registered channel class does not implement `connect` (channel.connect is undefined), even though the channel itself exists in mastra.getChannels().","commonSituations":"Attempting to programmatically connect a channel that is wired up via webhook/manifest configuration (e.g. some Slack or telephony channels registered via external setup); calling connect on a channel type that was swapped for a variant lacking connect; copy-pasting connect calls across channel platforms.","solutions":["Check whether the channel class for that platform implements a connect() method before calling the API; configure it through its native setup flow instead","Register a channel implementation that supports programmatic connection (implements connect) for that platform","Upgrade @mastra/core / the channel package if a newer version added connect support for your channel","Use GET the channel list/capabilities endpoint to confirm which platforms support connect"],"exampleFix":"// before\nawait client.connectChannel({ platform: 'sms', agentId: 'agent-1' }) // sms channel has no connect\n// after\nconst channels = await client.listChannels();\nif (channels.find(c => c.platform === 'slack')?.supportsConnect) {\n  await client.connectChannel({ platform: 'slack', agentId: 'agent-1' });\n}","handlingStrategy":"validation","validationCode":"const channel = channels.find(c => c.platform === platform);\nif (!channel?.supportsConnect) throw new Error(`Platform ${platform} does not support programmatic connect`);","typeGuard":"function supportsConnect(ch: { connect?: unknown } | undefined): ch is { connect: Function } {\n  return !!ch && typeof ch.connect === 'function';\n}","tryCatchPattern":"try {\n  await client.connectChannel({ platform, agentId });\n} catch (e) {\n  if (e.status === 400 && /does not support programmatic connection/.test(e.message)) {\n    // configure this channel through its external setup flow instead\n    return { connected: false, reason: 'manual-setup-required' };\n  }\n  throw e;\n}","preventionTips":["Inspect channel capabilities before calling connect","Document which channel integrations require external (dashboard) setup","Gate automation code paths on capability flags, not platform name","Keep channel packages current so newly added connect support is picked up"],"tags":["channels","http-400","unsupported-operation","server-api"],"backgroundTag":"unsupported-channel-operation","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}