> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging-chore-teams-api-autoupdate.mintlify.site/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/docs-staging-chore-teams-api-autoupdate/0ynazMpWe_jt_ofQ/docs/images/cdy7uua7fh8z/580LNGMxSkRlazJEdcVNpn/5fa98d4b414ac2133d1d6f4e327cea5a/Screenshot_2023-10-05_at_4.07.38_PM.png?fit=max&auto=format&n=0ynazMpWe_jt_ofQ&q=85&s=dfbf1db06d88242ec78e5f9032e801fd" 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/docs-staging-chore-teams-api-autoupdate/0ynazMpWe_jt_ofQ/docs/images/cdy7uua7fh8z/52VSznphe2TyoJQnAn4nQg/ed54ca48dea191916a3173b648463fd8/Create_Action_-_EN.png?fit=max&auto=format&n=0ynazMpWe_jt_ofQ&q=85&s=f0179d89d46ae0c24209b0fcd3e9bd1f" 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/docs-staging-chore-teams-api-autoupdate/BM6XEH2ndiUD0sX_/docs/images/cdy7uua7fh8z/5JmjwcdZCX7pDukNa90cgD/dae853b10cf4c41d2d3543a8e167aae7/3333.png?fit=max&auto=format&n=BM6XEH2ndiUD0sX_&q=85&s=b446551029b42e986fe2bcf713ad95ad" 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/docs-staging-chore-teams-api-autoupdate/byzZXAM7hdw3h1Ux/docs/images/cdy7uua7fh8z/7qIWCsP8doFWPJGvMTNXJY/1225f9b3ff7ac01a7e9b59f03ca5e139/2024-01-31_16-10-10.png?fit=max&auto=format&n=byzZXAM7hdw3h1Ux&q=85&s=6e3f377d6f71debf1738ee5edee9f49b" 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/docs-staging-chore-teams-api-autoupdate/0XDS4fwI8SLm1LYh/docs/images/cdy7uua7fh8z/6TaK1VQyKGELMGmhuRIbVA/b453fe2eb97c95d92e4fbd68ce3cbd6a/2024-01-31_16-12-01.png?fit=max&auto=format&n=0XDS4fwI8SLm1LYh&q=85&s=75f3efb9516f804d335c8e6082dc05ee" 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/docs-staging-chore-teams-api-autoupdate/Xf4Mj52VX3D6GrCj/docs/images/cdy7uua7fh8z/3x5lyrSJJgJQhbjsxoTmG6/033820476be7f67dc688da993fee7924/2024-01-31_16-13-35.png?fit=max&auto=format&n=Xf4Mj52VX3D6GrCj&q=85&s=27ade4877c7fd054ff4ad21c1d140848" alt="" width="1427" height="629" data-path="docs/images/cdy7uua7fh8z/3x5lyrSJJgJQhbjsxoTmG6/033820476be7f67dc688da993fee7924/2024-01-31_16-13-35.png" />
</Frame>
