ZenDesk Bulk Delete API call does not delete users with tickets, even if tickets closed. | Community
Skip to main content

ZenDesk Bulk Delete API call does not delete users with tickets, even if tickets closed.

  • September 16, 2022
  • 6 replies
  • 0 views

Hi,

My script to bulk delete users works fine for new users without any tickets, but if there is a ticket in the system for a user, then the bulk delete fails -- even if the ticket is 'solved'. (To test this I've added a new user, created a single ticket, then marked the ticket as solved before running the script).

Here is a section of the code I'm using:

    API = "/api/v2/users/destroy_many.json?ids=" + IDs
    myURL = encodeURI(API);     
    var settings = {
        type:'DELETE',
        url: myURL
    };   
    client.request(settings);

Please can you advise?

Thanks,

SGL.

6 replies

Eric27
  • September 16, 2022
Hey Simon,

Are you receiving an error back when this bulk delete fails? 

Thanks!

  • Author
  • September 16, 2022

Hi Eric,

I am not receiving an error.

Thanks.


Eric27
  • September 16, 2022
Hey Simon, 

Do you mind if we move this into a ticket so you can provide us an example of a user that is failing deletion?

Thanks!

  • Author
  • September 16, 2022

Ok, sure. What do I need to do?


Eric27
  • September 16, 2022
Hey Simon,

I just created a ticket on your behalf where I sent you instruction on what I need for next steps.

Looking forward to working with you via that! 

  • Author
  • September 20, 2022

For the benefit of anyone seeing this thread, here's the solution...

ZenDesk users cannot be bulk deleted if they have any tickets that are not 'Closed'.

'Solved' is not the same as 'Closed' -- see https://support.zendesk.com/hc/en-us/articles/4408887712154

My bulk delete code works fine, but I hadn't realised the distinction between closed and solved.

The advice I received from Eric was to loop through the tickets and close them, like this (quote):

"1. Loop through the id's provided in the "destroy_many" payload and use the search api (https://[domain].zendesk.com/api/v2/search.json?query=status<closed requester:123456789 type:ticket) to check if they have tickets < closed state. 
2. If tickets are found that are less than closed, pop them into an array. Then run an update_many tickets api call to change the status to closed. 
3. When that job is completed, move forward with the bulk_delete"