{"record":{"id":"18ed7117c146953a","repo":"mastra-ai/mastra","slug":"channel-platform-does-not-support-programmati-18ed71","errorCode":null,"errorMessage":"Channel \"${platform}\" does not support programmatic disconnection","messagePattern":"Channel \"(.+?)\" does not support programmatic disconnection","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/channels.ts","lineNumber":217,"sourceCode":" * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n  method: 'POST',\n  path: '/channels/:platform/:agentId/disconnect',\n  responseType: 'json',\n  pathParamSchema: channelAgentPathParams,\n  responseSchema: disconnectChannelResponseSchema,\n  summary: 'Disconnect agent from channel',\n  description: 'Deletes the platform app and cleans up the installation',\n  tags: ['Channels'],\n  requiresAuth: true,\n  handler: async ({ mastra, requestContext, platform, agentId }) => {\n    assertChannelsAvailable();\n    try {\n      const channel = getChannelOrThrow(mastra, platform);\n\n      if (!channel.disconnect) {\n        throw new HTTPException(400, {\n          message: `Channel \"${platform}\" does not support programmatic disconnection`,\n        });\n      }\n\n      await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n      await channel.disconnect(agentId);\n      return { success: true };\n    } catch (error) {\n      return handleError(error, 'Error disconnecting agent from channel');\n    }\n  },\n});\n","sourceCodeStart":199,"sourceCodeEnd":231,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/channels.ts#L199-L231","documentation":"The disconnect-channel handler throws HTTP 400 when the channel instance resolved for the requested platform does not implement a `disconnect` method. Symmetric to connect: channels whose lifecycle is managed externally cannot be programmatically disconnected through this API.","triggerScenarios":"POSTing to the channel disconnect route with a platform whose registered channel lacks `channel.disconnect`, i.e. the integration has no programmatic teardown method, even though the channel is registered.","commonSituations":"Disconnecting a channel that was bound via external dashboard configuration; scripts that loop over all connected platforms and call disconnect on each, hitting a platform without disconnect support; channel implementation changes removing disconnect in an upgrade.","solutions":["Only call disconnect for platforms whose channel implements disconnect(); remove externally-managed channels via their own console","Implement or register a channel subclass that supports programmatic disconnection","Check channel capabilities first and skip platforms without disconnect support","If disconnect support should exist, upgrade the channel/core package to a version that implements it"],"exampleFix":"// before\nfor (const p of ['slack', 'sms']) await client.disconnectChannel({ platform: p, agentId });\n// after\nfor (const p of ['slack', 'sms']) {\n  const ch = channels.find(c => c.platform === p);\n  if (ch?.supportsDisconnect) await client.disconnectChannel({ platform: p, agentId });\n}","handlingStrategy":"validation","validationCode":"const channel = channels.find(c => c.platform === platform);\nif (!channel?.supportsDisconnect) throw new Error(`Platform ${platform} does not support programmatic disconnect`);","typeGuard":"function supportsDisconnect(ch: { disconnect?: unknown } | undefined): ch is { disconnect: Function } {\n  return !!ch && typeof ch.disconnect === 'function';\n}","tryCatchPattern":"try {\n  await client.disconnectChannel({ platform, agentId });\n} catch (e) {\n  if (e.status === 400 && /does not support programmatic disconnection/.test(e.message)) {\n    return { disconnected: false, reason: 'manual-setup-required' };\n  }\n  throw e;\n}","preventionTips":["Check disconnect capability before bulk teardown scripts","Handle externally-managed channels via their own console","Re-verify capabilities after channel package upgrades","Fail soft in cleanup jobs when a platform lacks disconnect"],"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"}