Auth0 Home Blog Docs

How to remove data previously saved in user_metadata using the Management API

I’m trying to remove some properties that I’ve set during testing in the user_metadata. Since this field works by merging the new content you sent I cannot find a way to remove only some key inside it using the API.

I can remove it editing by hand the metadata in the UI, but I cannot script this removal using the API.

Hey there!

As far as I can see you can do that hitting this endpoint from our Management API:

https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id

Can you tell me what your user_metadata field is like right now and what you want it to be after change?

Hi, I’ve figure it out how to do it. You need to do an update where the fields in the metadata you want to remove have null as value.

So, for example doing a PATCH with "user_metadata": {"company":null}, will remove the field company from the user metadata.

Maybe the documentation can be improved in this regard, because it mention that the fields are merged but not how to remove one field previously present.

1 Like

Perfect! Glad to hear that! I will relay that feedback to our docs team.