{"record":{"id":"5e85fc17f5ba22db","repo":"chatwoot/chatwoot","slug":"business-management-token-is-only-supported-for-wh","errorCode":null,"errorMessage":"Business management token is only supported for WhatsApp Embedded Signup inboxes","messagePattern":"Business management token is only supported for WhatsApp Embedded Signup inboxes","errorType":"exception","errorClass":"ArgumentError","httpStatus":422,"severity":"error","filePath":"app/services/whatsapp/business_management_token_service.rb","lineNumber":25,"sourceCode":"    validate_channel!\n    raise ArgumentError, 'Business management token is required' if business_management_token.blank?\n\n    Whatsapp::BusinessManagementTokenValidationService.new(\n      business_management_token,\n      @channel.provider_config['business_account_id']\n    ).perform\n\n    @channel.business_management_token = business_management_token\n    @channel.save!(validate: false)\n  end\n\n  private\n\n  def validate_channel!\n    raise ArgumentError, 'Business management token is only available on Chatwoot Cloud' unless ChatwootApp.chatwoot_cloud?\n    return if @channel.provider == 'whatsapp_cloud' && @channel.provider_config['source'] == 'embedded_signup'\n\n    raise ArgumentError, 'Business management token is only supported for WhatsApp Embedded Signup inboxes'\n  end\nend\n","sourceCodeStart":7,"sourceCodeEnd":28,"githubUrl":"https://github.com/chatwoot/chatwoot/blob/ed230f9bc068e7a13dd5c0404d5465a204b68d4c/app/services/whatsapp/business_management_token_service.rb#L7-L28","documentation":"Whatsapp::BusinessManagementTokenService#validate_channel! raises ArgumentError unless the channel is a WhatsApp Cloud channel created through Embedded Signup — specifically provider == 'whatsapp_cloud' AND provider_config['source'] == 'embedded_signup'. Channels created manually (API/CLI), via other WhatsApp providers, or without the embedded_signup marker fail the second check after the Chatwoot Cloud check passes.","triggerScenarios":"Calling update! with a 360dialog or WhatsApp Cloud channel created by hand (provider_config['source'] nil or 'api'), or a non-WhatsApp channel entirely.","commonSituations":"Admin tries to attach a business token to a manually created WhatsApp inbox; channel was migrated/cloned and lost provider_config['source']; provider_config hash missing entirely.","solutions":["Use a WhatsApp Cloud channel created via the embedded signup flow, then call the service on it.","If the channel is legitimately embedded-signup but misconfigured, set provider_config['source'] = 'embedded_signup' on the channel.","For manually created channels, manage the access token in the channel's own provider config instead of this service."],"exampleFix":"# before (manually created channel)\nchannel.update!(provider: 'whatsapp_cloud', provider_config: { 'source' => 'api' })\nWhatsapp::BusinessManagementTokenService.new(channel).update!(token) # raises\n\n# after\nchannel.update!(provider_config: { 'source' => 'embedded_signup', 'business_account_id' => '123' })\nWhatsapp::BusinessManagementTokenService.new(channel).update!(token)","handlingStrategy":"validation","validationCode":"eligible = channel.provider == 'whatsapp_cloud' && channel.provider_config['source'] == 'embedded_signup'\nrender_error('Token only supported for WhatsApp Embedded Signup inboxes') && next unless eligible\nWhatsapp::BusinessManagementTokenService.new(channel).update!(token)","typeGuard":"def embedded_signup_whatsapp_channel?(channel)\n  channel.provider == 'whatsapp_cloud' && channel.provider_config['source'] == 'embedded_signup'\nend","tryCatchPattern":null,"preventionTips":["Only surface the token settings for channels flagged provider_config['source'] == 'embedded_signup'.","Preserve the source marker when migrating or cloning WhatsApp channels.","For manually created channels, configure tokens in provider settings instead."],"tags":["whatsapp","embedded-signup","channel-config","argument-error"],"backgroundTag":"invalid-channel-config","analyzedSha":"ed230f9bc068e7a13dd5c0404d5465a204b68d4c","analyzedAt":"2026-08-21T12:45:25.920Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}