# Demo

{% hint style="success" %}
All users with valid credentials can access demo mode for testing purposes; however, only those with a Super Admin role have the permissions required to create, manage, and delete demo accounts. This structure maintains administrative control over demo environments, ensuring organized setup and consistent maintenance.
{% endhint %}

## Flow

The Demo Account feature enables users to set up and manage test environments for various products and services. Below is an outline of the flow.

#### Prerequisites

* Valid email address
* Strong password (8-32 characters)
* First and last name

#### Steps

1. **Create Demo Account**
   * Access the demo account page, click "Add User" and enter email, password, first and last name into sidebar form, then click "Add User" to save your account.
2. **Preview Link Generation**
   * An encrypted preview link is generated for the new account.
3. **User Data Creation**
   * Default teams, businesses, leads, and lead statuses are created.
4. **Subscription Registration**
   * The account is automatically registered with a subscription.
5. **Environment Access**
   * Access to the test environment with the generated data is provided via the preview link or by email sent to the entered email address.

#### Key Benefits

* Rapid environment setup
* Secure preview link generation
* Genereted data for faster introduction
* Automated subscription
* **Account Reset**: Demo accounts are automatically deleted at midnight daily.

#### Security Note

* Demo accounts are for testing and introductional purposes only, with encrypted password storage and secure preview link generation.

## API Methods

Here's an overview of each API method, with a focus on functionality and use case.

#### **getAll**

Retrieves all demo accounts with a non-null preview link. Supports pagination using `skip` and `take` parameters.

***

#### **createDemoAccount**

Creates a new demo account with user details (email, password, first name, last name), generating an encrypted preview link and storing credentials.

***

#### **editDemoAccount**

Updates an existing demo account’s user details. Ensures no duplicate email registrations when updating the email.

***

#### **populateAccount**

Populates a demo account with test data: teams, businesses, leads, and lead statuses to simulate real scenarios.

***

#### **resetDemoAccounts**

Removes all demo accounts and associated data (teams, businesses, leads) from the database.

***

#### **deleteDemoAccount**

Deletes a demo account, including associated teams, businesses, and leads. Verifies user existence before deletion.

***

#### **manualReset**

Clears a demo account's data but keeps the subscription active, recreating the test environment.

***

#### **deleteSubscription**

Cancels a demo subscription and deletes associated test data (teams, businesses, leads).

***

#### **registerSubscription**

Creates a new demo user with an active subscription and default settings (e.g., tier, order ID).

***

#### **deleteUserData**

Deletes a demo account's related teams, businesses, and leads, usually before deleting the account itself.

{% hint style="warning" %}
Encryption and decryption details are omitted for security
{% endhint %}


---

# 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://intercode.gitbook.io/intercode-saas-kit/pages/demo.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.
