How to prevent user ids or channel urls from violating unique constraints?

If you accidentally deleted your user ID or channel URL and you would like to create the same user ID and channel URL again, then you may receive an error message saying that your user ID or channel URL violates the unique constraint as shown below.

`400 Bad Request` response:
{"message":"\"user_id\" violates unique constraint.","code":400202, "error": true}

Why do we get this error?

  • When you delete a user or channel, Sendbird must update the user ID or channel URL in the database first and then replicate it to the local cache in order to use it again. If the database or the local cache hasn’t been updated yet, you’ll receive a 400 error code.
  • If the local cache hasn’t been updated, you can’t reuse the user ID or the channel URL. You’ll receive an error message saying ““channel_url” violates the unique constraint.”

Solution:

  • Try creating the channel after 30 to 60 mins and this issue will be resolved.