Manage User Metadata

You can create and update metadata using the Authentication and Management APIs.

With the Authentication API

When you use the Authentication API's Signup endpoint, you can create a new Database Connection user and set the user_metadata field.

When setting the user_metadata field using the Authentication API's Signup endpoint, you are limited to a maximum of 10 String fields and 500 characters.

With the Management API

Using Auth0's Management APIv2, you can create a user and set both their app_metadata and user_metadata fields. You can also update these two fields.

The Auth0 Management APIv2 token is required to call the Auth0 Management API. Learn more about Access Tokens for the Management API.

With the Lock Library

You can define, add, read, and update the user_metadata using Auth0's Lock library.

For information on adding user_metadata on signup, please see Additional Signup Fields

When using Lock, you can read the user's user_metadata properties the same way you would for any other user profile property. For example, the following code snippet retrieves the value associated with user_metadata.hobby and assigns it to an element on the page:

// Use the accessToken acquired upon authentication to call getUserInfo
lock.getUserInfo(accessToken, function(error, profile) {
  if (!error) {
    document.getElementById('hobby').textContent = profile.user_metadata.hobby;
  }
});

Metadata and custom databases

If you are using a custom database, the app_metadata field should be referred to as metadata in the scripts you run to manage your metadata.

For example, you would not use this:

{
    "emails": "jane.doe@example.com",
    "user_metadata": {
        "hobby": "surfing"
    },
    "app_metadata": {
        "plan": "full"
    }
}

Instead, you would use this:

{
    "emails": "jane.doe@example.com",
    "user_metadata": {
        "hobby": "surfing"
    },
    "metadata": {
        "plan": "full"
    }
}

Keep reading