cancel
Showing results for 
Search instead for 
Did you mean: 
marcelo_amorim
Community Participant

Is it possible to delete an user using Canvas API?

Jump to solution

Hello people,

I'm building a tool to clean inactive users from institution, but unfortunately, there is no API endpoint to delete an entire user.

Ok then, so I've used de Logins API to delete each login from each user until I got a message saying that the users must have at least one login.

Well, I'm stucked. Is it only possible to delete an user by clicking "Delete from Institution" at the users details page?

Hope someone can help.

Thanks!

Labels (1)
1 Solution

Accepted Solutions

Thanks for the solution!

I've thought about this solution already but I've found what I wanted.

I've mailed Canvas Support Team here in Brazil and they've just replied how it is possible to do with the Accounts API:

https://canvas.instructure.com/doc/api/accounts.html#method.accounts.remove_user

I think Canvas documentation should move this endpoint to Users API, not Accounts.

Thank you all, by the way!

Cheers

View solution in original post

9 Replies
pklove
Community Champion

The SIS import users.csv allows a status of 'deleted'.

This might do want you want.

marcelo_amorim
Community Participant

Yes, it does what I want. But in this case, I should manipulate a CSV file to do this.

Actually, I'm making the tool just to not need to import the SIS file and automate this task.

Thank you for replying, anyway.

ben_hudson
Community Contributor

Hi Marcelo,

I just want to add to what Peter said in case you can't find a way for the API to do this. You can automate the .csv import with a little bit of scripting if you need a last resort (I do this for everything instead of using the API). Then you would just need a way to generate the student listing and set their status to deleted in the file. I considered doing this once, then it was shot down by my admins, so I have a plan of how to make it work if you want anymore information.

Thanks,

Ben

Thanks for the solution!

I've thought about this solution already but I've found what I wanted.

I've mailed Canvas Support Team here in Brazil and they've just replied how it is possible to do with the Accounts API:

https://canvas.instructure.com/doc/api/accounts.html#method.accounts.remove_user

I think Canvas documentation should move this endpoint to Users API, not Accounts.

Thank you all, by the way!

Cheers

View solution in original post

I would like to ask how you got that Rest API to work?

When I call:

DELETE /api/v1/accounts/:account_id/users/:user_id

It returns 200 with the user details and it only deleted the user login. I can still see the user in the UI it just has no login now. When I call it again on the same user it returns 404 stating "The specified resource does not exist" which is clearly not true. I can see the user in the UI and I can query the user's information via the API.

Tagging and sharing this with marcelo.amorim &  @ben_hudson ‌ just to make sure they see this follow up question.

Hello,

So I don't usually delete users because the Administrators at the school I work for have no desire to do that. However I created some test accounts to play with and I think this is simply the way Canvas handles 'deleting' a user. From what I can tell they are simply deleting the login information to hide it from you in the UI (what it did in my case). I assume by you saying you still see the user in the UI you are following the steps I had to follow: 1) select an active user. 2) Modify the User ID that is in the URL for the 'Deleted account' and no you see it in the UI without Login Info of course.

To me it doesn't look like we have a way to permanently/completely delete a user.

Sorry I can't be of more help, but I feel like your issue has gone beyond what Marcelo's was and you may want to contact support if you want to completely delete users.

Thanks,

Ben

Yeah it seems that the public API works the same as their private one that is used when you delete from the UI. It removes the login and "hides" the user from normal user lists. You can still go directly to the user via the URL to see them in the UI. You can also request information about the user via their public API.

Which means that it is not really deleted but hidden, unfortunately.   Thanks for you information. 

julian_ebeli
Community Participant

This stopped me banging my head against Canvas LMS REST API Documentation (method.pseudonyms.destroy) which for some reason I've been doing for the last hour.!