> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.generaltranslation.app/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://mintcdn.com/generaltranslationinc/Tx-zTp2kMjjdY0gu/docs/images/cdy7uua7fh8z/580LNGMxSkRlazJEdcVNpn/5fa98d4b414ac2133d1d6f4e327cea5a/Screenshot_2023-10-05_at_4.07.38_PM.png?fit=max&auto=format&n=Tx-zTp2kMjjdY0gu&q=85&s=a6935d7b42c01872576d9a3be68bbf26" alt="" width="627" height="1196" data-path="docs/images/cdy7uua7fh8z/580LNGMxSkRlazJEdcVNpn/5fa98d4b414ac2133d1d6f4e327cea5a/Screenshot_2023-10-05_at_4.07.38_PM.png" />
</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://mintcdn.com/generaltranslationinc/Mf1t9PpRn-EsYzg5/docs/images/cdy7uua7fh8z/52VSznphe2TyoJQnAn4nQg/ed54ca48dea191916a3173b648463fd8/Create_Action_-_EN.png?fit=max&auto=format&n=Mf1t9PpRn-EsYzg5&q=85&s=ebc53812ee5188e88ee068288cc5a800" alt="" width="502" height="555" data-path="docs/images/cdy7uua7fh8z/52VSznphe2TyoJQnAn4nQg/ed54ca48dea191916a3173b648463fd8/Create_Action_-_EN.png" />
</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://mintcdn.com/generaltranslationinc/Tx-zTp2kMjjdY0gu/docs/images/cdy7uua7fh8z/5JmjwcdZCX7pDukNa90cgD/dae853b10cf4c41d2d3543a8e167aae7/3333.png?fit=max&auto=format&n=Tx-zTp2kMjjdY0gu&q=85&s=cdde1c3e22a615c048091e3c064b520a" alt="" width="2222" height="795" data-path="docs/images/cdy7uua7fh8z/5JmjwcdZCX7pDukNa90cgD/dae853b10cf4c41d2d3543a8e167aae7/3333.png" />
</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://mintcdn.com/generaltranslationinc/IhLUvTv5J5eZ1VeH/docs/images/cdy7uua7fh8z/7qIWCsP8doFWPJGvMTNXJY/1225f9b3ff7ac01a7e9b59f03ca5e139/2024-01-31_16-10-10.png?fit=max&auto=format&n=IhLUvTv5J5eZ1VeH&q=85&s=594b85a7ed4b4fab9f394d72aea6258a" alt="" width="369" height="773" data-path="docs/images/cdy7uua7fh8z/7qIWCsP8doFWPJGvMTNXJY/1225f9b3ff7ac01a7e9b59f03ca5e139/2024-01-31_16-10-10.png" />
</Frame>

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

<Frame>
  <img src="https://mintcdn.com/generaltranslationinc/Q_4pAdRoZm2wi1v5/docs/images/cdy7uua7fh8z/6TaK1VQyKGELMGmhuRIbVA/b453fe2eb97c95d92e4fbd68ce3cbd6a/2024-01-31_16-12-01.png?fit=max&auto=format&n=Q_4pAdRoZm2wi1v5&q=85&s=e3a475e89ce3d0a4fbf8488f312b269f" alt="" width="325" height="722" data-path="docs/images/cdy7uua7fh8z/6TaK1VQyKGELMGmhuRIbVA/b453fe2eb97c95d92e4fbd68ce3cbd6a/2024-01-31_16-12-01.png" />
</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://mintcdn.com/generaltranslationinc/ZBZaCyGCDGYmrL4v/docs/images/cdy7uua7fh8z/3x5lyrSJJgJQhbjsxoTmG6/033820476be7f67dc688da993fee7924/2024-01-31_16-13-35.png?fit=max&auto=format&n=ZBZaCyGCDGYmrL4v&q=85&s=954777b4f535274f254e80a6ce31bdb5" alt="" width="1427" height="629" data-path="docs/images/cdy7uua7fh8z/3x5lyrSJJgJQhbjsxoTmG6/033820476be7f67dc688da993fee7924/2024-01-31_16-13-35.png" />
</Frame>
