> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/llms.txt
> Use this file to discover all available pages before exploring further.

> Learn how to use Auth0 Actions to validate and store end-user data.

# Use Actions to Validate and Store End-user Data Gathered By Signup Prompt Customizations

You can use [Signup Prompt Customization](/docs/customize/login-pages/universal-login/customize-signup-and-login-prompts) along with the `pre-user-registration` trigger to add end-user supplied data (like a user's phone number or location) from the signup prompt to `user_metadata`. Optionally, you can validate this data and show a validation error in the prompt.

### Prerequisites

* Tenant has a [Custom Domain](/docs/customize/custom-domains) verified
* Tenant has a [Page Template](/docs/customize/login-pages/universal-login/customize-templates) set

### Add A Field To The Signup Prompt

Use the [Management API](https://auth0.com/docs/api/management/v2/prompts/put-custom-text-by-language) to insert a custom field into a prompt using one of the [Entry Points](/docs/customize/login-pages/universal-login/customize-signup-and-login-prompts#-signup-prompt-entry-points). This example adds the following content to the `ulp-container-form-content-start` insertion point:

```html lines theme={null}
<div class="ulp-field">
  <label for="first-name">First Name</label>
  <input type="text" name="ulp-first-name" id="first-name">
</div>
```

The result is a First Name section in the signup prompt:

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/580LNGMxSkRlazJEdcVNpn/5fa98d4b414ac2133d1d6f4e327cea5a/Screenshot_2023-10-05_at_4.07.38_PM.png" alt="" />
</Frame>

### Create An Action In The Pre-User Registration Trigger

You can build a custom pre-user registration action by going to [**Actions > Library > Build Custom**](https://manage.auth0.com/dashboard/us/dev-6endizjt/actions/library)**.**

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/52VSznphe2TyoJQnAn4nQg/ed54ca48dea191916a3173b648463fd8/Create_Action_-_EN.png" alt="" />
</Frame>

Inside the code editor, update the `onExecutePreUserRegistration` handler:

```js lines theme={null}
exports.onExecutePreUserRegistration = async (event, api) => {
  const firstName = event.request.body['ulp-first-name'];
  api.user.setUserMetadata("firstName", firstName);
};
```

Optionally, you can validate the user input and send a validation error by calling the `api.validation.error` method, then deploy the action:

```js lines theme={null}
exports.onExecutePreUserRegistration = async (event, api) => {
  const firstName = event.request.body['ulp-first-name'];
  if(!firstName) {
    api.validation.error("invalid_payload", "Missing first name");
    return;
  }

  api.user.setUserMetadata("firstName", firstName);
};
```

### Add The Action To The Flow

Navigate to [**Actions > Flows > Pre User Registration > Add Action > Custom**](https://manage.auth0.com/dashboard/us/dev-6endizjt/actions/flows/pre-user-signup/), then drag and drop your new action into the registration flow and select **Apply**.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/5JmjwcdZCX7pDukNa90cgD/dae853b10cf4c41d2d3543a8e167aae7/3333.png" alt="" />
</Frame>

### Test The Action

Sign up for an account in your test flow and leave the **First Name** field blank. You will see an error on submit:

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/7qIWCsP8doFWPJGvMTNXJY/1225f9b3ff7ac01a7e9b59f03ca5e139/2024-01-31_16-10-10.png" alt="" />
</Frame>

After you enter a name in the **First Name** field, you are able to submit successfully:

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/6TaK1VQyKGELMGmhuRIbVA/b453fe2eb97c95d92e4fbd68ce3cbd6a/2024-01-31_16-12-01.png" alt="" />
</Frame>

### Verify That The Data Was Saved On user\_metadata

Navigate to [**User Management > Users**](https://manage.auth0.com/dashboard/us/dev-6endizjt/users), then confirm the data has been saved by viewing the Details tab:

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/auth0/docs/images/cdy7uua7fh8z/3x5lyrSJJgJQhbjsxoTmG6/033820476be7f67dc688da993fee7924/2024-01-31_16-13-35.png" alt="" />
</Frame>
