function validateAPIKey(key) {
  if (key == '' || key == null) {
    return false;
  } else {
    var today = new Date().toISOString().split('T')[0];

    var URL = buildURL('global', 'day', today, today);

    var options = {
      method: 'GET',
      muteHttpExceptions: true,
      headers: {
        Authorization: 'Bearer ' + key,
        contentType: 'application/json'
      }
    };

    var result = UrlFetchApp.fetch(URL, options);

    if (result.getResponseCode() == 200) {
      return true;
    } else {
      return false;
    }
  }
}
/**
 *
 * @param {string} key - SendGrid API key with permissions to perform stats requests
 */
@param {string} key - SendGrid API key with permissions to perform stats requests
@param { string } key - SendGrid API key with permissions to perform stats requests
function validateAPIKey(key) {
  if (key == '' || key == null) {
    return false;
  } else {
    var today = new Date().toISOString().split('T')[0];
    var URL = buildURL('global', 'day', today, today);
    var options = {
      method: 'GET',
      muteHttpExceptions: true,
      headers: {
        Authorization: 'Bearer ' + key,
        contentType: 'application/json'
      }
    };
    var result = UrlFetchApp.fetch(URL, options);
    if (result.getResponseCode() == 200) {
      return true;
    } else {
      return false;
    }
  }
}
function validateAPIKey ( key ) { if ( key == '' || key == null ) { return false ; } else { var today = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ; var URL = buildURL ( 'global' , 'day' , today , today ) ; var options = { method : 'GET' , muteHttpExceptions : true , headers : { Authorization : 'Bearer ' + key , contentType : 'application/json' } } ; var result = UrlFetchApp . fetch ( URL , options ) ; if ( result . getResponseCode ( ) == 200 ) { return true ; } else { return false ; } } }
@param {string} key - SendGrid API key with permissions to perform stats requests
@param { string } key - SendGrid API key with permissions to perform stats requests