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

# Data warehouse

> Connect BigQuery, Snowflake, or Redshift for historical cohort analysis and revenue reconciliation.

Connecting your data warehouse gives FloKit access to finance-approved revenue figures, multi-year cohort histories, and custom acquisition cost exports that aren't available through your subscription platform or MMP alone. This is the highest-fidelity data path into FloKit.

## What FloKit reads from your warehouse

* **Historical subscription cohorts** — cohort tables spanning months or years, going back further than RevenueCat or Adapty retain by default.
* **Finance-reconciled revenue** — figures that match what your finance team reports, net of refunds, chargebacks, and adjustments.
* **Acquisition cost exports** — blended or platform-level spend data, including channels not covered by AppsFlyer or Adjust.
* **Custom event tables** — app-specific events (feature usage, onboarding milestones) that correlate with LTV.
* **Revenue tables** — transaction-level subscription revenue for precise payback calculations.

## Supported warehouses

| Warehouse  | Status         |
| ---------- | -------------- |
| BigQuery   | Available      |
| Snowflake  | Available      |
| Redshift   | Available      |
| Databricks | Contact FloKit |

## What warehouse access unlocks

* **Historical payback analysis** going back months or years — beyond what live event streams provide.
* **Finance-approved revenue figures** — use numbers your CFO has already signed off on, not estimates.
* **Cohort exports with custom dimensions** — segment by any dimension in your warehouse, not just those captured in FloKit events.
* **Multi-year LTV models** — long-horizon projections grounded in your actual renewal history.

## Access model

FloKit connects via a **read-only service account or role**. No write access is requested or required. FloKit queries your warehouse on a scheduled basis — typically every 6 hours — and does not cache data outside your FloKit workspace.

***

## BigQuery

<Steps>
  <Step title="Create a service account">
    In [Google Cloud IAM](https://console.cloud.google.com/iam-admin/serviceaccounts), create a new service account for FloKit. Assign two roles:

    * **BigQuery Data Viewer** — read access to datasets and tables.
    * **BigQuery Job User** — permission to run queries.

    No other roles are required.
  </Step>

  <Step title="Download the JSON key file">
    In the service account detail page, go to **Keys → Add Key → Create new key → JSON**. Download the file and keep it secure — you'll upload it to FloKit once.
  </Step>

  <Step title="Connect in FloKit">
    Go to **FloKit → Settings → Integrations → Warehouse → BigQuery**.

    Upload the JSON key file, then enter:

    * **Project ID** — your GCP project ID (e.g. `acme-analytics-prod`).
    * **Dataset name** — the dataset containing your subscription or cohort tables.

    Click **Connect**. FloKit will validate credentials before saving.
  </Step>
</Steps>

***

## Snowflake

<Steps>
  <Step title="Create a Snowflake role">
    In Snowflake, create a dedicated role for FloKit and grant it the following:

    ```sql theme={null}
    CREATE ROLE flokit_reader;

    GRANT USAGE ON DATABASE your_database TO ROLE flokit_reader;
    GRANT USAGE ON SCHEMA your_database.your_schema TO ROLE flokit_reader;
    GRANT SELECT ON ALL TABLES IN SCHEMA your_database.your_schema TO ROLE flokit_reader;
    GRANT USAGE ON WAREHOUSE your_warehouse TO ROLE flokit_reader;
    ```

    Create a user, assign the role, and note the credentials.
  </Step>

  <Step title="Connect in FloKit">
    Go to **FloKit → Settings → Integrations → Warehouse → Snowflake**.

    Enter:

    * **Account identifier** — e.g. `xy12345.us-east-1` (from your Snowflake URL).
    * **Username** — the Snowflake user you created.
    * **Authentication** — password or key-pair. For key-pair, paste your private key (PEM format).
    * **Warehouse** — the virtual warehouse to use for queries.
    * **Database** and **Schema** — target location for your subscription tables.
  </Step>
</Steps>

***

## Redshift

<Steps>
  <Step title="Create a Redshift user">
    Connect to your Redshift cluster and create a read-only user:

    ```sql theme={null}
    CREATE USER flokit_reader PASSWORD 'your_secure_password';
    GRANT SELECT ON ALL TABLES IN SCHEMA your_schema TO flokit_reader;
    ```

    If your tables span multiple schemas, grant SELECT per schema.
  </Step>

  <Step title="Connect in FloKit">
    Go to **FloKit → Settings → Integrations → Warehouse → Redshift**.

    Enter:

    * **Host** — your Redshift cluster endpoint.
    * **Port** — default `5439`.
    * **Database** — target database name.
    * **Username** and **Password** — credentials for the read-only user.
  </Step>
</Steps>

***

## Schema requirements

FloKit accepts two table shapes:

**Option A — Pre-built cohort table (recommended)**

A single table with one row per cohort, pre-aggregated. Minimum required columns:

| Column          | Type    | Description                             |
| --------------- | ------- | --------------------------------------- |
| `cohort_date`   | DATE    | The week or day the cohort was acquired |
| `user_id`       | STRING  | Unique user identifier                  |
| `channel`       | STRING  | Acquisition channel                     |
| `campaign`      | STRING  | Campaign name or ID                     |
| `spend`         | FLOAT   | Acquisition spend for this cohort       |
| `trials`        | INTEGER | Number of trials started                |
| `subscriptions` | INTEGER | Number of paid subscriptions started    |
| `renewals`      | INTEGER | Number of renewals                      |
| `revenue_30d`   | FLOAT   | Cumulative revenue at 30 days           |
| `revenue_90d`   | FLOAT   | Cumulative revenue at 90 days           |

**Option B — Raw event + subscription tables**

FloKit can join raw install, subscription, and revenue event tables if you haven't pre-aggregated. Contact FloKit for the raw table schema template and join logic.

For the full schema template, including optional columns for country, offer, paywall variant, and custom dimensions, contact the FloKit team.

***

## Validating your connection

After connecting, go to **FloKit → Data → Sources → \[your warehouse] → Preview**. FloKit will display the first 20 rows it's reading. Verify:

* Row counts look correct for your expected data range.
* `cohort_date` values fall within the expected historical window.
* Revenue columns are not null for cohorts old enough to have accumulated revenue.

If Preview returns zero rows, check that the role or service account has SELECT access on the specific tables FloKit is querying — schema-level grants don't always cascade to tables created before the grant.
