In development I would like to use the API to delete all contacted except conctact_id 1 and 2. With Contact


$result=civicrm_api3('Contact', 'delete', array(
      'id' => array('NOT IN' => array(1, 2)),
      'skip_undelete' => "1",

.. won't work even though with get it does. Would seem there is no good way to do this fast, without making a complicated MySQL query. Who knows a quick work around. Mine were extremely slow and ran into error 500 timeout errors.


Api4 will likely to be able to do this, but it is not yet released. It is not possible with api3. You'll need to write a custom php script to loop and call the api repeatedly, or else execute a sql query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.