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

# Reset

> Clear a user's session and authentication state

The reset frame is a headless page hosted on a MoonPay domain. Use it to clear the user's authentication tokens stored on MoonPay's domain, allowing partners to log users out. The frame communicates completion or errors to the parent window via postMessage.

## URL

```html theme={null}
https://blocks.moonpay.com/platform/v1/reset
```

## Initialization parameters

| Parameter     | Type     | Required | Description                                                                                                                                                                                    |
| ------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `channelId`   | `string` | ✅        | A unique identifier for the frame generated on your client. This value is attached to each `postMessage` payload to help identify messages.<br /><br />The format of this string is up to you. |
| `clientToken` | `string` |          | The client token returned from the connect flow. Authorizes your domain to embed the frame (see note).                                                                                         |
| `apiKey`      | `string` |          | Your publishable API key. Also authorizes your domain to embed the frame.                                                                                                                      |

<Note>
  The reset frame carries no session of its own, so MoonPay identifies your
  integration from the token you pass — either your connect-flow `clientToken`
  or your publishable `apiKey`. That identity authorizes your domain to embed
  the frame (via the `frame-ancestors` Content Security Policy). Without one,
  the browser blocks the frame from loading on your domain — it never runs, so
  it cannot even report an `error`; the parent simply never receives a
  `handshake`.
</Note>

## Events

All events are dispatched using the message pattern described in the [frames protocol](/frames/overview#frames-protocol#messages). Below are the event payloads specific to the reset frame.

### Outbound events

<Badge size="md" className="px-2" color="purple">
  frame->parent
</Badge>

These events are sent from this frame to the parent window.

#### `handshake`

Sent when the frame loads. The parent must respond with `ack`.

<CodeGroup>
  ```json Example theme={null}
  {
    "version": 2,
    "meta": { "channelId": "ch_1" },
    "kind": "handshake"
  }
  ```

  ```ts twoslash TypeScript definition theme={null}
  type Message<T> = T & {
    version: 2;
    meta: { channelId: string };
  };

  type HandshakeEvent = Message<{
    kind: "handshake";
  }>;
  ```
</CodeGroup>

#### `complete`

Sent when the user's session has been successfully cleared.

<CodeGroup>
  ```json Example theme={null}
  {
    "version": 2,
    "meta": { "channelId": "ch_1" },
    "kind": "complete"
  }
  ```

  ```ts twoslash TypeScript definition theme={null}
  type Message<T> = T & {
    version: 2;
    meta: { channelId: string };
  };

  type ResetCompleteEvent = Message<{
    kind: "complete";
  }>;
  ```
</CodeGroup>

#### `error`

Sent when the reset fails.

<CodeGroup>
  ```json Example theme={null}
  {
    "version": 2,
    "meta": { "channelId": "ch_1" },
    "kind": "error",
    "payload": {
      "code": "generic",
      "message": "Failed to clear session"
    }
  }
  ```

  ```ts twoslash TypeScript definition theme={null}
  type Message<T> = T & {
    version: 2;
    meta: { channelId: string };
  };

  type ResetErrorEvent = Message<{
    kind: "error";
    payload: {
      code: "generic";
      /** A developer-facing error message with details on recovery or documentation. This message is not intended to be rendered in UI. */
      message: string;
    };
  }>;
  ```
</CodeGroup>

### Inbound events

<Badge size="md" className="px-2">
  parent->frame
</Badge>

These events are sent from the parent window to this frame.

#### `ack`

Must be sent in response to `handshake`. The frame will not proceed until it receives this.

<CodeGroup>
  ```json Example theme={null}
  {
    "version": 2,
    "meta": { "channelId": "ch_1" },
    "kind": "ack"
  }
  ```

  ```ts twoslash TypeScript definition theme={null}
  type Message<T> = T & {
    version: 2;
    meta: { channelId: string };
  };

  type AckEvent = Message<{
    kind: "ack";
  }>;
  ```
</CodeGroup>
