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

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

# Actions Triggers: pre-user-registration - 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 registration 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.

Returns a reference to the `api` object.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>reason</code></td>

      <td>
        <p>
          <em>String</em>. An internal reason describing why this registration attempt is being denied. This value
          will appear in tenant logs.
        </p>
      </td>
    </tr>

    <tr>
      <td><code>userMessage</code></td>

      <td>
        <p>
          <em>String</em>. A human-readable explanation for rejecting the registration attempt. This may be presented
          directly in end-user interfaces.
        </p>
      </td>
    </tr>
  </tbody>
</table>

## `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.

Returns a `CacheWriteResult` object with  `type: "success"` if a value was removed from the cache. A failed operation returns `type: "error"`. For errors, the returned object will have a
`code` property that indicates the nature of the failure.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>key</code></td>

      <td>
        <p><em>String</em>. The key of the record stored in the cache.</p>
      </td>
    </tr>
  </tbody>
</table>

### `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.

Returns a cache record if an item is found in the cache for the supplied
`key`. Cache records are objects with a
`value` property holding the cached value as well as an
`expires_at` property indicating the maximum expiry of
the record in milliseconds since the Unix epoch.

**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.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>key</code></td>

      <td>
        <p><em>String</em>. The key of the record stored in the cache.</p>
      </td>
    </tr>
  </tbody>
</table>

### `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](/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](/docs/customize/actions/limitations).

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>key</code></td>

      <td>
        <p><em>String</em>. The key of the record stored in the cache.</p>
      </td>
    </tr>

    <tr>
      <td><code>value</code></td>

      <td>
        <p><em>String</em>. The value of the record to be stored.</p>
      </td>
    </tr>

    <tr>
      <td><code>options</code></td>

      <td>
        <p><em>Optional object</em>. Options for adjusting cache behavior.</p>
      </td>
    </tr>

    <tr>
      <td><code>options.expires\_at</code></td>

      <td>
        <p>
          <em>Optional number</em>. The absolute expiry time in milliseconds
          since the unix epoch. While cached records may be evicted earlier,
          they will never remain beyond the the supplied
          <code>expires\_at</code>.
        </p>

        <p>
          <em>Note:</em> This value should not be supplied if a value was also
          provided for <code>ttl</code>. If both options are supplied, the
          earlier expiry of the two will be used.
        </p>
      </td>
    </tr>

    <tr>
      <td><code>options.ttl</code></td>

      <td>
        <p>
          <em>Optional number</em>. The time-to-live value of this cache entry
          in milliseconds. While cached values may be evicted earlier, they
          will never remain beyond the the supplied <code>ttl</code>.
        </p>

        <p>
          <em>Note:</em> This value should not be supplied if a value was also
          provided for <code>expires\_at</code>. If both options are supplied,
          the earlier expiry of the two will be used.
        </p>
      </td>
    </tr>
  </tbody>
</table>

## `api.user`

Make changes to the metadata of the user that is registering.

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

Set metadata for the user that is registering. Data stored within user\_metadata is visible and editable by the user.

Note: This trigger makes a call to the Management API, consuming the Management API rate limit. If this request reaches the rate limit and fails to retry within the timeout window, the API returns a `Deadline Exceeded` error.

Returns a reference to the `api` object.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>name</code></td>

      <td>
        <p>
          <em>String</em>. The name of metadata property.
        </p>
      </td>
    </tr>

    <tr>
      <td><code>value</code></td>

      <td>
        <p><em>Any value</em>. The value of the metadata property. This may be set to `null` to remove the metadata property.</p>
      </td>
    </tr>
  </tbody>
</table>

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

Set application metadata for the user that is registering. Data stored within app\_metadata is not visible or editable by the user.

Note: This trigger makes a call to the Management API, consuming the Management API rate limit. If this request reaches the rate limit and fails to retry within the timeout window, the API returns a `Deadline Exceeded` error.

Returns a reference to the `api` object.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>name</code></td>

      <td>
        <p>
          <em>String</em>. The name of metadata property.
        </p>
      </td>
    </tr>

    <tr>
      <td><code>value</code></td>

      <td>
        <p><em>Any value</em>. The value of the metadata property. This may be set to `null` to remove the metadata property.</p>
      </td>
    </tr>
  </tbody>
</table>

## `api.validation`

Configure custom error messaging for denied user registrations.

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

Define custom error codes and user messaging for denied registration attempts.

When a user's attempt to register is denied, the signup flow immediately stops following the completion of the current Action and no further Actions are executed.

<table class="table">
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>errorCode</code></td>

      <td>
        <p>
          <em>String</em>. A custom error code that describes why a registration attempt was denied. This value appears in tenant logs.
        </p>
      </td>
    </tr>

    <tr>
      <td><code>errorMessage</code></td>

      <td>
        <p><em>String</em>. A custom error message presented to users when their registrations are deinied.</p>
      </td>
    </tr>
  </tbody>
</table>
