# User API question.

**URL:** <https://community.sendbird.com/t/user-api-question/4090>\
**Category:** API\
**Created:** [March 4, 2022, 10:50am UTC](https://community.sendbird.com/t/user-api-question/4090 "2022-03-04T10:50:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crom08](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/crom08/32/2143_2.png) [@crom08](https://community.sendbird.com/u/crom08)\
**Post date:** [March 4, 2022, 10:50am UTC](https://community.sendbird.com/t/user-api-question/4090/1 "2022-03-04T10:50:09Z")

</div>

After creating a user with “Create a user” API, I deleted it with “Delete a user” API.

And when I try to create with the same ID with “Create a user” API, an error message appears saying “user\_id violates unique constraint.”

Is the ID created once cannot be regenerated after deletion?

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [March 4, 2022, 12:00pm UTC](https://community.sendbird.com/t/user-api-question/4090/2 "2022-03-04T12:00:43Z")

</div>

Hello, @crom08 Welcome to the Sendbird community!

Our servers need some time (not sure about the exact time) to delete the user from our database so you can’t do requests to create the user again after a few milliseconds you have deleted the user.

There is a database cache that the user might still be there even though the user was deleted from the actual database. If you would try now to create the user it should be fine.

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![ahamdan](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@ahamdan](https://community.sendbird.com/u/ahamdan)\
**Post date:** [March 4, 2022, 10:04pm UTC](https://community.sendbird.com/t/user-api-question/4090/3 "2022-03-04T22:04:51Z")

</div>

Hello @Chinmaya_Gupta. I am facing the exact same issue. I deleted a user over 1 hour ago, and tried to create a new one but it’s still giving me a user\_id constraint.  
In my case, I am creating / deleting users based on their subscription status change on my website. If the user subscribes, a Sendbird account is created. If the user unsubscribes for example, the Sendbird account gets deleted. Since there is caching involved, am I better off deactivating/activating users instead of deleted/creating them on every subscription status change?

---

<div class="post-metadata">

**Author:** ![ahamdan](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@ahamdan](https://community.sendbird.com/u/ahamdan)\
**Post date:** [March 4, 2022, 11:42pm UTC](https://community.sendbird.com/t/user-api-question/4090/4 "2022-03-04T23:42:21Z")

</div>

It seems that I was able to create the user again with the same ID after about 2 hours after I deleted it. To avoid this complication, I switched to activating/deactivating users instead. Hope this information helps.

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [March 7, 2022, 11:32am UTC](https://community.sendbird.com/t/user-api-question/4090/5 "2022-03-07T11:32:41Z")

</div>

Hello @ahamdan It may happen since this user is member of a group channel.

You should be okay to recreate if remove this user from group channel.

You can always deactivate a user (optionally remove it form all channels automatically)  
A deactivated user is like a removed user.

![](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/b/b4e47deb8a74aaec26d0d84642031fe145c9377f.png)[Sendbird Docs](https://sendbird.com/docs/chat/v3/platform-api/guides/user#2-update-a-user-3-http-request)

### [User | Chat Platform API | Sendbird Docs](https://sendbird.com/docs/chat/v3/platform-api/guides/user#2-update-a-user-3-http-request)

Manage the attributes and functionalities of the users.

Set attribute **is\_active** to false.

 ![Screenshot 2022-03-07 at 10.21.35](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/a/aa8013402e591b0072bc49d0c4a78062da789d50.png)

And **leave\_all\_when\_deactivated** to true (optional)

 ![Screenshot 2022-03-07 at 10.26.56](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/9/98a363ba6679a013c48e258cf5191bacd6ef62fa.png)

Let me know if this helps.
