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

# Data Sharing via S3

> Automated data transfer to business S3 buckets with scheduled intervals

## Overview

Data Sharing via S3 provides businesses with automated transfer of user financial data to their designated Amazon S3 buckets. This service operates on configurable schedules, ensuring businesses receive timely updates without manual intervention.

## Data Extraction & Transfer Process

```mermaid theme={null}
flowchart TD
    A[Data Sharing Scheduled<br/>as per Business Interval] --> B[Cron Triggered]
    B --> C[Fetch All Users<br/>of Business]
    C --> D[For Each User:<br/>Extract All Available Data]
    D --> E[Send to Business's<br/>S3 bucket]
```

### Process Explanation

1. **Data Sharing Scheduled**: The business configures a data sharing schedule based on their requirements (e.g., daily, weekly).

2. **Cron Triggered**: At the scheduled interval, a cron job is automatically triggered to initiate the data sharing process.

3. **Fetch All Users of Business**: The system retrieves a list of all users associated with the business.

4. **Extract All Available Data**: For each user, the system extracts all available financial data including analytics and FI (Financial Information) data (as per business requirement)

5. **Send to Business's S3 Bucket**: The extracted data is transferred to the business's designated S3 bucket.

## S3 File Structure

```mermaid theme={null}
flowchart TD
    F[S3 File Structure] --> G["bucket_name/date/user_id/"]
    G --> H["ANALYTICS"]
    G --> I["FI_DATA"]
    G --> J["NUDGES"]
```

### File Structure Explanation

The data is organized in the S3 bucket using a hierarchical folder structure:

| Level            | Description                                               |
| ---------------- | --------------------------------------------------------- |
| **bucket\_name** | The S3 bucket name shared by the business                 |
| **date**         | Date folder for organizing data by transfer date          |
| **user\_id**     | Individual folder for each user's data                    |
| **ANALYTICS**    | Analytics data file containing analytics for all FI types |
| **FI\_DATA**     | Raw financial data file containing all FI types data      |
| **NUDGES**       | Nudges data file containing eligible nudges for the user  |

### Example Path

```
s3-data-bucket/
└── 2024-12-24/
    └── user_12345/
        ├── ANALYTICS
        ├── FI_DATA
        └── NUDGES
```

## File Format Reference

Each file pushed to S3 is a JSON object. The `dataType` field identifies the file type, and the payload key (`analytics` or `fiData`) contains one key per FI type present for that user.

### ANALYTICS

Contains processed analytics output for all FI types linked to the user.

```json theme={null}
{
  "referenceId": "<string>",
  "dataDate": "2026-04-22",
  "dataType": "ANALYTICS",
  "analytics": {
    "MUTUAL_FUNDS": { ... },
    "EQUITIES":     { ... },
    "ETF":          { ... },
    "DEPOSIT":      { ... }
  }
}
```

| Field         | Type                | Description                                                                        |
| ------------- | ------------------- | ---------------------------------------------------------------------------------- |
| `referenceId` | string              | Unique identifier for this data push event                                         |
| `dataDate`    | string (yyyy-MM-dd) | Date for which this data was generated                                             |
| `dataType`    | string              | Always `"ANALYTICS"` for this file                                                 |
| `analytics`   | object              | Map of FI type → analytics payload; only FI types with available data are included |

For full sample responses across all FI types for analytics, refer to the drive folder:

👉 **[View All Analytics Sample Responses](https://drive.google.com/drive/folders/1PlodnsftfrEKebdGz-vIEv9RwhuVUqvd?usp=drive_link)**

### FI\_DATA

Contains raw financial data for all FI types linked to the user.

```json theme={null}
{
  "referenceId": "<string>",
  "dataDate": "2026-04-22",
  "dataType": "FI_DATA",
  "fiData": {
    "MUTUAL_FUNDS": { ... },
    "EQUITIES":     { ... },
    "ETF":          { ... },
    "DEPOSIT":      { ... }
  }
}
```

| Field         | Type                | Description                                                                     |
| ------------- | ------------------- | ------------------------------------------------------------------------------- |
| `referenceId` | string              | Unique identifier for this data push event                                      |
| `dataDate`    | string (yyyy-MM-dd) | Date for which this data was generated                                          |
| `dataType`    | string              | Always `"FI_DATA"` for this file                                                |
| `fiData`      | object              | Map of FI type → raw FI payload; only FI types with available data are included |

### NUDGES

Contains personalised nudges evaluated for the user based on their financial profile.

```json theme={null}
{
  "referenceId": "ref_u7x9k2m4p1q8",
  "dataDate": "2026-04-22",
  "dataType": "NUDGES",
  "nudges": {
    "evaluated_at": "2026-04-22T10:32:45",
    "eligible_nudges": [
      {
        "nudge_id": "nudge_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "nudge_name": "Diversification for Young Investors (18-40)",
        "message": "As per your age, it is a good idea to increase allocation to Equity Funds to potentially maximise your returns in the long term. Click here to invest",
        "metadata": {}
      },
      {
        "nudge_id": "nudge_i9j0k1l2-m3n4-5678-ijkl-901234567890",
        "nudge_name": "No Lumpsum Investment in Last 3 Months",
        "message": "Make an investment in one of our Trending Funds today",
        "metadata": {}
      }
    ]
  }
}
```

| Field                                 | Type                | Description                                                                                                      |
| ------------------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `referenceId`                         | string              | Unique identifier for this data push event                                                                       |
| `dataDate`                            | string (yyyy-MM-dd) | Date for which this data was generated                                                                           |
| `dataType`                            | string              | Always `"NUDGES"` for this file                                                                                  |
| `nudges.evaluated_at`                 | string (ISO 8601)   | Timestamp at which nudges were last evaluated for the user                                                       |
| `nudges.eligible_nudges`              | array               | List of nudges the user is currently eligible for; empty array if none                                           |
| `nudges.eligible_nudges[].nudge_id`   | string              | Unique identifier for the nudge                                                                                  |
| `nudges.eligible_nudges[].nudge_name` | string              | Display name of the nudge                                                                                        |
| `nudges.eligible_nudges[].message`    | string              | Actionable message to be shown to the user                                                                       |
| `nudges.eligible_nudges[].metadata`   | object              | Additional context for the nudge; fields vary based on the nudge type and can be customised per business request |

***

## Configuration Requirements

### S3 Bucket Setup

The data sharing service requires cross-account access between our system and your S3 bucket. This involves configuration on both sides:

#### On Your Side (Business S3 Account)

* **S3 Bucket ARN**: Share your S3 bucket ARN with us
* **Bucket Policy**: Add our IAM role to your S3 bucket policy to grant write access

Example bucket policy structure:

```json theme={null}
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": {
      "AWS": "<IAM_ROLE_ARN_PROVIDED_BY_US>"
    },
    "Action": ["s3:PutObject"],
    "Resource": "arn:aws:s3:::your-bucket-name/*"
  }]
}
```

#### On Our Side

* **IAM Role**: We configure an IAM role with access to your S3 bucket ARN and share the role ARN with you for bucket policy configuration

#### Required Information Exchange

* **We Provide** - IAM Role ARN (to be added in your bucket policy)
* **You Provide** - S3 Bucket ARN
