 
     super options, data
 
+    @initialAPIAccessState = getGroup().isApiEnabled is yes
     @createSwitch()
     @createTabView()
 
 
   createSwitch: ->
 
-    @addSubView @settingsView = new kd.CustomHTMLView
+    @addSubView settingsView = new kd.CustomHTMLView
       partial: 'Enable API Access'
       cssClass: 'settings-row'
 
-    @settingsView.addSubView @apiSwitch = new KodingSwitch
-      callback      : (state) ->
-        getGroup().modify { isApiEnabled : state }, (err) ->
-          showError err  if err
+    settingsView.addSubView apiSwitch = new KodingSwitch
+      callback : (state) =>
+        getGroup().modify { isApiEnabled : state }, (err) =>
+          if err
+            showError err
+            # revert switch state in case of error
+            if state
+            then apiSwitch.setOff no
+            else apiSwitch.setOn no
+
+          else
+            if state
+            then @addNewButton.enable()
+            else @addNewButton.disable()
+
+    apiSwitch.setDefaultValue @initialAPIAccessState
 
 
   createTabView: ->

          return showError err  if err
          kd.utils.defer =>
            @apiTokenListView.listController.addItem apiToken

    tabView.addPane apiTokens = new kd.TabPaneView name: 'API Tokens'


    data    = @getData()
    tabView = new kd.TabView hideHandleCloseIcons: yes

    @addNewButton = tabView.tabHandleContainer.addSubView new kd.ButtonView
      cssClass : 'solid compact green add-new'
      title    : 'Add new API Token'
      callback : =>
