Sunny Sinha
Sunny Sinha

Reputation: 37

Undelete a deleted google workspace user via google admin sdk/api using postman

Did anyone used undelete command to restore the deleted users using google admin SDK API in google workspace ?

https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/undelete

I want to undelete a user who is recently delete but the command requires a {userKey}, is string (The immutable id of the user), which i don't know where and how to find out:

HTTP request

POST https://admin.googleapis.com/admin/directory/v1/users/{userKey}/undelete

Can anyone help me with below :

  1. We need to send a request to find this user's immutable id.
  2. Using that ID we will be able to undelete it
  3. add the user to org A.D
  4. any other thing which would be required after that.

Thanks in advance for any help.

I have tried deleting a user, where it only requires "Email address" as identifier. I have tried to get users details, where it only requires "Email address" as identifier.

But when i try to undelete, using "email address" as userkey it doesn't recognise that user as it is already deleted.

Upvotes: 0

Views: 296

Answers (1)

DuuEyn
DuuEyn

Reputation: 777

Suggestion: Use the users.list method

Unlike the delete method, you cannot use the user's email address in the userKey field when restoring them. You would have to use the 21-character userID instead. On the users.list method, specify your domain name on the domain field and enter true on the showDeleted field to filter the deleted users.

Sample screenshot of the parameters on the users.list API explorer:

users.list params

Expected result:

result


In addition, I recommend specifying the orgUnitPath when running the users.undelete method.

user.Undelete sample request params:

enter image description here

Reference:

Upvotes: 1

Related Questions