# Memberstack

## Configuration

{% hint style="info" %}
You can find your Memberstack Site Id in your Memberstack V2 dashboard.
{% endhint %}

{% hint style="warning" %}
Memberstack V1 does not display the Site Id within the dashboard instead, you have to extract it from the JWT. Please raise a support ticket if you would like assistance getting your Memberstack V1 Site Id.
{% endhint %}

1. In the navigation, click the ⚙️ icon
2. In the Memberstack Site Id field, enter your Id
3. Save the changes
4. Open the flow you want to secure and add the Memberstack node after the `start` node.

🎉 Congratulations, you successfully secured your flow using Memberstack.

{% hint style="info" %}
The Memberstack node does **not** need to be added after the `start` node. If you would like to perform some logic before performing the authorisation check, this is absolutely fine.
{% endhint %}

### Access User Data

To access data associated with the user making the request, you can use the handlebar expressions e.g. `{{request.user.id}}`.

### Properties

<table><thead><tr><th width="132.5">Name</th><th>Expression</th></tr></thead><tbody><tr><td>id</td><td><code>{{request.user.id}}</code></td></tr><tr><td>email</td><td><code>{{request.user.email}}</code></td></tr></tbody></table>

{% hint style="danger" %}
WARNING the email property was deprecated in Memberstack V2!
{% endhint %}

{% hint style="info" %}
If you would like to access additional user data associated to the logged in user you will need to use the HTTP Request node to call the [Memberstack Admin API](https://support.memberstack.com/hc/en-us/articles/7444702068763-Memberstack-API).
{% endhint %}

## User Token

To access a user token for testing log into your website and run the following code snippet within the console.

#### Memberstack V1

```
MemberStack.getToken()
```

#### Memberstack V2

```
$memberstackDom.getMemberCookie()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alphi.dev/authentication/memberstack.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
