Answers.Body: <p>Potentially you could do this in a little script using the API?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T10:35:14.180Z
Answers.Text: Now for the stupid question. I have the abulity to go into support/developer/api3 [api 4 doesn't seem to be there and in the extension page it just says "obsolete"] and I can delete one contact but the only operator avilable to me with contact ID is =  I was hoping I could use greater than but that doesnt seem to be an option. Can I run this script outside of my website? eg using ssh?
Answers.UserDisplayName: Caroline B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T12:46:29.233Z
Answers.Text: No, the delete API requires the ID. You can not mass delete directly, you will first have to retrieve the IDs of the ones you want to delete. That is why I recommended a little PHP job (as a scheduled job) but that needs some development skills. If you do not want to do that or can not, I would recommend the UI....
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T13:54:03.447Z
Answers.Text: Thanks Erik that's very helpful to know.
Answers.UserDisplayName: Caroline B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T09:46:44.730Z
Answers.LastActivityDate: 2020-12-01T09:46:44.730Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>In APIv3 you delete one contact at at time using <code>id = ...</code>.  In APIv4 you can delete based on more flexible conditions.</p>
  <p>You can get to both versions from <code>Support &gt; Developer &gt; API Explorer 3</code> or <code>4</code>.   If that is not showing up, what version are you on?</p>
  <p>You can run it as a script via ssh.  Both API Explorers show you the equivalent php code.  Copy that into a file then you can run it with <code>cv scr /your/script/file</code>.</p>
  <p>Alternatively, Explorer also shows you a <code>cv</code> version section (APIv3) or <code>CLI</code> (APIv4).  Quoting can get awkward for anything complex directly on the command line.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T13:57:26.517Z
Answers.Text: I think I might need to work out where my API v 4 went (it was there but complained that it needed bootstrap and shoreditch which I installed which is when it dissappeared). I think once I have resolved that I may be back here. But the other question you have answered which I wasn't sure of was where to put the script - now I understand. In case you are feeling frightened on my behalf - this is a development instance of an existing site. I'm deleting all the contacts from it. So even if I screw up it's not going to be disastrous! Thanks Aidan!
Answers.UserDisplayName: Caroline B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T17:11:05.297Z
Answers.Text: APIv4 was originally an extension but it is now part of core.  So it depends what version you are using as to what you need to do to get it working.  The upgrades should take care of the change but if not, go your extensions page and disable and uninstall APIv4 if it is there.  If that doesn't fix it create a separate question.  And good that this is a development box :-)
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-03T17:42:04.057Z
Answers.Text: Thanks for that Aidan - my civi is 5.26.2.  so i think fairly up to date. The APIv4 extension doesn't have a disable button - it just says obselete. But I know have APIv4  working through the support menu item so I don't think the old extension is getting in the way. Thanks
Answers.UserDisplayName: Caroline B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-02T11:21:39.017Z
Answers.Text: For anyone else trying to do this I found this very useful video that helped flesh out the answers above https://www.youtube.com/watch?v=-vy62VwKm9E
Answers.UserDisplayName: Caroline B
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-01T12:40:37.070Z
Answers.LastActivityDate: 2020-12-01T12:40:37.070Z
Answers.UserDisplayName: Aidan
Body: <p>I woudl like to mass delete contacts in my civicrm. I could search and delete using the GUI but it woudl take ages as there are so many.</p>
  <p>I feel like I might be able to do this via the api?</p>
  <p>Also another response suggested using views <a href="https://civicrm.stackexchange.com/questions/22242/bulk-delete-of-spam-contacts-and-related-drupal-users?rq=1">Bulk Delete of Spam Contacts and related Drupal Users</a></p>
  <p>Does anyone have any tips?</p>
  <p>I will have another question depending on the tips probably!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-01T18:18:19.617Z
Comments.Text: what is it about using the UI that would make it so slow?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-02T16:08:15.947Z
Comments.Text: You might get better answers if you provide some more background, i.e why you want to mass delete contacts.
Comments.UserDisplayName: Alan Dixon
Tags: <api><delete>
Title: Mass deletion of contacts
ThreadText: # Mass deletion of contacts
  
  (Asked by: username_0 on 2020-12-01)
  
  I woudl like to mass delete contacts in my civicrm. I could search and delete using the GUI but it woudl take ages as there are so many.
  
  I feel like I might be able to do this via the api?
  
  Also another response suggested using views [Bulk Delete of Spam Contacts and related Drupal Users](https://civicrm.stackexchange.com/questions/22242/bulk-delete-of-spam-contacts-and-related-drupal-users?rq=1)
  
  Does anyone have any tips?
  
  I will have another question depending on the tips probably!
  
  **Tags:** api, delete
  
  > **Comments:**
  > **username_1**: what is it about using the UI that would make it so slow?  
  > **username_2**: You might get better answers if you provide some more background, i.e why you want to mass delete contacts.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2020-12-01. Score: 0 | Accepted answer
  
  Potentially you could do this in a little script using the API?
  
  > **Comments:**
  > **username_0**: Now for the stupid question. I have the abulity to go into support/developer/api3 [api 4 doesn't seem to be there and in the extension page it just says "obsolete"] and I can delete one contact but the only operator avilable to me with contact ID is =  I was hoping I could use greater than but that doesnt seem to be an option. Can I run this script outside of my website? eg using ssh?  
  > **username_3**: No, the delete API requires the ID. You can not mass delete directly, you will first have to retrieve the IDs of the ones you want to delete. That is why I recommended a little PHP job (as a scheduled job) but that needs some development skills. If you do not want to do that or can not, I would recommend the UI....  
  > **username_0**: Thanks Erik that's very helpful to know.  
  
  ---
  
  ### Answer by username_4 on 2020-12-01. Score: 0
  
  In APIv3 you delete one contact at at time using `id = ...`. In APIv4 you can delete based on more flexible conditions.
  
  You can get to both versions from `Support > Developer > API Explorer 3` or `4`. If that is not showing up, what version are you on?
  
  You can run it as a script via ssh. Both API Explorers show you the equivalent php code. Copy that into a file then you can run it with `cv scr /your/script/file`.
  
  Alternatively, Explorer also shows you a `cv` version section (APIv3) or `CLI` (APIv4). Quoting can get awkward for anything complex directly on the command line.
  
  > **Comments:**
  > **username_0**: I think I might need to work out where my API v 4 went (it was there but complained that it needed bootstrap and shoreditch which I installed which is when it dissappeared). I think once I have resolved that I may be back here. But the other question you have answered which I wasn't sure of was where to put the script - now I understand. In case you are feeling frightened on my behalf - this is a development instance of an existing site. I'm deleting all the contacts from it. So even if I screw up it's not going to be disastrous! Thanks username_4!  
  > **username_4**: APIv4 was originally an extension but it is now part of core.  So it depends what version you are using as to what you need to do to get it working.  The upgrades should take care of the change but if not, go your extensions page and disable and uninstall APIv4 if it is there.  If that doesn't fix it create a separate question.  And good that this is a development box :-)  
  > **username_0**: Thanks for that username_4 - my civi is 5.26.2.  so i think fairly up to date. The APIv4 extension doesn't have a disable button - it just says obselete. But I know have APIv4  working through the support menu item so I don't think the old extension is getting in the way. Thanks  
  > **username_0**: For anyone else trying to do this I found this very useful video that helped flesh out the answers above https://www.youtube.com/watch?v=-vy62VwKm9E  
  
  ---
  
  