Script for deleting rejected ads

If you work in a topic with strict moderation and ad creation is «on stream» — you will likely have to frequently remove rejected ads.

This can be done using this script:

function main() {
	var adSelector = AdsApp
		.ads()
		.withCondition('CombinedApprovalStatus IN [DISAPPROVED, SITE_SUSPENDED]');
	var adIterator = adSelector.get();
	while (adIterator.hasNext()) {
		var ad = adIterator.next();
		Logger.log('Удаляем объявление [' + ad.getId() + '] - "' + ad.getHeadline() + '"');
		ad.remove();
	}
}

The script will have to be run several times if you have more than 50,000 rejected ads in your account.