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

> Learn about the pre-user-registration Action trigger's API object.

# API Object

The API object for the pre-user-registration Actions trigger includes:

## `api.access`

Modify the access of the user that is logging in, such as rejecting the login attempt.

### `api.access.deny(reason, userMessage)`

Deny the user from being able to register. The signup flow will immediately stop following the
completion of this action and no further Actions will be executed.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="reason" type="string">
    An internal reason describing why this registration attempt is being denied. This value
    will appear in tenant logs.
  </ParamField>

  <ParamField body="userMessage" type="string">
    A human-readable explanation for rejecting the registration attempt. This may be presented
    directly in end-user interfaces.
  </ParamField>
</Expandable>

## `api.user`

Make changes to the metadata of the user that is logging in.

### `api.user.setAppMetadata(key, value)`

Set application-specific metadata for the user that is logging in.

Note: This method should not be used in callbacks. Invoking this method won't update the metadata immediately.
You can call this several times throughout multiple actions of the same flow and the engine will aggregate the
changes and update the metadata at once before the flow is completed.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="key" type="string">
    The metadata property to be set.
  </ParamField>

  <ParamField body="value" type="unknown">
    The value of the metadata property. This may be set to `null` to remove the
    metadata property.
  </ParamField>
</Expandable>

### `api.user.setUserMetadata(key, value)`

Set general metadata for the user that is logging in.

Note: This method should not be used in callbacks. Invoking this method won't update the metadata immediately.
You can call this several times throughout multiple actions of the same flow and the engine will aggregate the
changes and update the metadata at once before the flow is completed.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="key" type="string">
    The metadata property to be set.
  </ParamField>

  <ParamField body="value" type="unknown">
    The value of the metadata property. This may be set to `null` to remove the
    metadata property.
  </ParamField>
</Expandable>

## `api.cache`

Store and retrieve data that persists across executions.

### `api.cache.delete(key)`

Delete a record describing a cached value at the supplied
key if it exists.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="key" type="string">
    The key of the cache record to delete.
  </ParamField>
</Expandable>

### `api.cache.get(key)`

Retrieve a record describing a cached value at the supplied key,
if it exists. If a record is found, the cached value can be found
at the `value` property of the returned object.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="key" type="string">
    The key of the record stored in the cache.
  </ParamField>
</Expandable>

### `api.cache.set(key, value, options)`

Store or update a string value in the cache at the specified key.

Values stored in this cache are scoped to the Trigger in which they
are set. They are subject to the [Actions Cache Limits](https://auth0.com/docs/customize/actions/limitations).

Values stored in this way will have lifetimes of *up to* the specified
`ttl` or `expires_at` values. If no lifetime is specified, a default of
lifetime of 15 minutes will be used. Lifetimes may not exceed the maximum
duration listed at [Actions Cache Limits](https://auth0.com/docs/customize/actions/limitations).

**Important**: This cache is designed for short-lived, ephemeral data. Items may not be
available in later transactions even if they are within their supplied their lifetime.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="key" type="string">
    The key of the record to be stored.
  </ParamField>

  <ParamField body="value" type="string">
    The value of the record to be stored.
  </ParamField>

  <ParamField body="options" type="cachesetoptions">
    Options for adjusting cache behavior.
    Optional.

    <Expandable title="options properties">
      <ParamField body="expires_at" type="number">
        The absolute expiry time in milliseconds since the unix epoch.
        While cached records may be evicted earlier, they will
        never remain beyond the supplied `expires_at`.

        *Note*: This value should not be supplied if a value was also
        provided for `ttl`. If both options are supplied, the
        earlier expiry of the two will be used.
        Optional.
      </ParamField>

      <ParamField body="ttl" type="number">
        The time-to-live value of this cache entry in milliseconds.
        While cached values may be evicted earlier, they will
        never remain beyond the supplied `ttl`.

        *Note*: This value should not be supplied if a value was also
        provided for `expires_at`. If both options are supplied, the
        earlier expiry of the two will be used.
        Optional.
      </ParamField>
    </Expandable>
  </ParamField>
</Expandable>

## `api.validation`

Modify the access of the user that is logging in, such as rejecting the login attempt due to validation errors.

### `api.validation.error(errorCode, errorMessage)`

Deny the user from being able to register. The signup flow will immediately stop following the
completion of this action and no further Actions will be executed.

**Parameters**

<Expandable title="Parameters" defaultOpen>
  <ParamField body="errorCode" type="string">
    A customer defined error code describing why this registration attempt is being denied. This value
    will appear in tenant logs.
  </ParamField>

  <ParamField body="errorMessage" type="string">
    A customer defined explanation for rejecting the registration attempt. This may be presented
    directly in end-user interfaces.
  </ParamField>
</Expandable>
