     { permission: 'edit groups',     superadmin: yes }
     { permission: 'edit own groups', validateWith: Validators.group.admin }
   ]
-
 
   @share()
 


    queue = [

      ->
        # validating data params
        unless account instanceof JAccount
          return callback new KodingError 'account is not an instance of Jaccount!'

        JGroup.one { slug : group }, (err, group_) ->
          return callback err                                 if err
          return callback new KodingError 'group not found!'  unless group_

          unless !!group_.getAt 'isApiEnabled'
            return callback new KodingError 'API usage is not enabled for this group.'

          groupObj = group_
          queue.next()

      ->
        limitError = "You can't have more than #{JGroup.API_TOKEN_LIMIT} api tokens"
        JApiToken.count { group : groupObj.slug }, (err, count) ->
          return callback err                         if err
          return callback new KodingError limitError  if count >= JGroup.API_TOKEN_LIMIT
          queue.next()

      ->
        # creating token
        token = new JApiToken
          code     : hat()


    { account, group } = data

    token    = null
    groupObj = null

    unless account and group
