# See how it's done

The Sample Saas application demonstrates the following integration features:

* Generating a new account and contact in Bunny based on signups to your app.
* Controlling features and limits in the SaaS app based on subscriptions in Bunny.
* Self-service upgrade and payment through the Bunny portal.

The Sample SaaS App is a multi-tenant note taking app. The app relies on Bunny to control how many notes can be stored in each tenant. For the sake of simplicity, users are not prompted for a password when signing into the account.

{% hint style="info" %}
The code for the [Sample SaaS app can be found on Github](https://github.com/bunnyapp/sample-saas)
{% endhint %}

## Setting it up

### Configure a new platform in Bunny

{% hint style="warning" %}
A platform in Bunny holds the integration settings for your SaaS product, such as webhook URLs, tokens and signing keys.
{% endhint %}

Since we will later install and run the Sample SaaS App locally, and Bunny will need access to it's API, we suggest installing [ngrok](https://ngrok.com/download) or similar to fascilitate routing the traffic to your local app. Launch ngrok with the following command to setup a tunnel:

`ngrok http 3030`

1. In **Products -> Platforms** click **New Platform**.
2. Configure it as following:\\
   1. Make sure to choose your own signing key.
   2. Copy the ngrok forwarding URL to the webhook URL field:\
      `https://{your ngrok forwarding URL}/api/hook`

<figure><img src="/files/pHRCY0J60MwsqIli2NNm" alt="" width="563"><figcaption></figcaption></figure>

### Configure a new product in Bunny

{% hint style="info" %}
When you sign up for your Bunny account, it will be preloaded with demo data (accounts, contacts, products, deals etc). This can be removed by going to Other -> Settings and clicking **Remove demo data** in the sidebar.
{% endhint %}

1. Setup a new product in your Bunny account. Your trial account may already have a default one with your company name. **Note**: It's important to select the platform created in the previous step.\\

   <figure><img src="/files/2QIiciOmTv7ihGsM2MoI" alt="" width="563"><figcaption></figcaption></figure>
2. Create a new feature called "Notes". Use the following settings:

   <figure><img src="/files/I5xY7ub6p381cOfzpc5C" alt="" width="563"><figcaption></figcaption></figure>
3. On the **Plans and Add-Ons** tab, create a new plan named "Basic". Enable **Self-service purchase**.
4. Hit **Save**.
5. In the **Plan** features section, add the newly created feature to the plan.
6. On the **Price Lists** tab, create a new price list named "Monthly":\\

   <figure><img src="/files/v7Rtb9T98UaMICDKqK4W" alt="" width="563"><figcaption></figcaption></figure>
7. Create a new **Price List Charge** with the following settings:\\

   <figure><img src="/files/qVkWsfTNyTNPatuNePoF" alt="" width="563"><figcaption></figcaption></figure>

### Configure an API key

1. Go to **Other -> API Clients** and click **New API Client**
2. Use the following settings: \\

   <figure><img src="/files/G228YNcbArjMjJojTFjC" alt="" width="563"><figcaption></figcaption></figure>

### Install and configure the Sample SaaS app

{% hint style="warning" %}
The Sample SaaS app runs in Docker, so ensure you have Docker Desktop installed and running. You can download it from [here](https://www.docker.com/products/docker-desktop/).
{% endhint %}

1. In a suitable folder on your local environment, clone the Sample SaaS repository:\
   \
   `git clone git@github.com:bunnyapp/sample-saas.git`
2. Copy .env.example to .env and open the .env file in an editor.
3. Replace **{subdomain}** with the subdomain of your Bunny account.
4. Replace **{access\_token}** with the access token generated when configuring the API Client earlier.
5. Replace **{webhook\_signing\_token}** with the Webhook signing key chosen when configuring the platform earlier.
6. Replace **{price\_list\_code}** with the code from the price list created earlier - **notes\_monthly**
7. Your .env file should look something like this:\\

   <figure><img src="/files/cighhIFTfmTL66HsduPr" alt="" width="563"><figcaption></figcaption></figure>
8. In a Terminal, start the app with the following command:\
   \
   `docker-compose up`

You're all set! Navigate to <http://localhost:3030> to sign up for your Sample SaaS Notes app account.


---

# 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.bunny.com/developer/sample-saas-app/the-sample-saas-app.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.
