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

# File Path and Naming Convention

> Configure file paths and naming conventions for MoEngage message archival exports to S3 or SFTP, with customizable attributes and directory structures.

MoEngage provides two primary options for archiving message data: exporting to an S3 bucket or an SFTP server. Each option has its own directory structure and file naming convention. Select the appropriate tab below to view the details for your configured archival method.

<Tabs>
  <Tab title="S3 Bucket Archival">
    The following are the default file paths and file naming conventions for archived messages exported to an S3 bucket.

    <Tabs>
      <Tab title="One-Time Campaign">
        | Channel and Platform | File Path and File Naming Convention                          |
        | -------------------- | ------------------------------------------------------------- |
        | Email                | File Path:  `<bucket_name>/{{db_name}}/{{date}}/email/<file>` |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_email.eml`               |
        | SMS                  | File Path:  `<bucket_name>/{{db_name}}/{{date}}/sms/<file>`   |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_sms.json`                |
        | Push - Android       | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_android.json`       |
        | Push - iOS           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_ios.json`           |
        | Push - Web           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_web.json`           |
      </Tab>

      <Tab title="Periodic Campaign">
        | Channel and Platform | File Path and File Naming Convention                          |
        | -------------------- | ------------------------------------------------------------- |
        | Email                | File Path:  `<bucket_name>/{{db_name}}/{{date}}/email/<file>` |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_email.eml`               |
        | SMS                  | File Path:  `<bucket_name>/{{db_name}}/{{date}}/sms/<file>`   |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_sms.json`                |
        | Push - Android       | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_android.json`       |
        | Push - iOS           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_ios.json`           |
        | Push - Web           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`  |
        |                      | File Name:  `{{id}}_{{cid}}_{{time}}_push_web.json`           |
      </Tab>

      <Tab title="Event-Triggered and Business Event Triggered Campaign">
        | Channel and Platform | File Path and File Naming Convention                                     |
        | -------------------- | ------------------------------------------------------------------------ |
        | Email                | File Path:  `<bucket_name>/{{db_name}}/{{date}}/email/<file>`            |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_event_id}}_{{time}}_email.eml`         |
        | SMS                  | File Path:  `<bucket_name>/{{db_name}}/{{date}}/sms/<file>`              |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_event_id}}_{{time}}_sms.json`          |
        | Push - Android       | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`             |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_event_id}}_{{time}}_push_android.json` |
        | Push - iOS           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`             |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_event_id}}_{{time}}_push_ios.json`     |
        | Push - Web           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`             |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_event_id}}_{{time}}_push_web.json`     |
      </Tab>

      <Tab title="Inform Alert">
        | Channel and Platform | File Path and File Naming Convention                                           |
        | -------------------- | ------------------------------------------------------------------------------ |
        | Email                | File Path:  `<bucket_name>/{{db_name}}/{{date}}/email/<file>`                  |
        |                      | File Name:  `{{id}}_{{alert_ID}}_{{moe_transaction_id}}_{{time}}_email.eml`    |
        | SMS                  | File Path:  `<bucket_name>/{{db_name}}/{{date}}/sms/<file>`                    |
        |                      | File Name:  `{{id}}_{{alert_ID}}_{{moe_transaction_id}}_{{time}}_sms.json`     |
        | Push - Android       | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`                   |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_transaction_id}}_{{time}}_push_android.json` |
        | Push - iOS           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`                   |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_transaction_id}}_{{time}}_push_ios.json`     |
        | Push - Web           | File Path:  `<bucket_name>/{{db_name}}/{{date}}/push/<file>`                   |
        |                      | File Name:  `{{id}}_{{cid}}_{{moe_transaction_id}}_{{time}}_push_web.json`     |
      </Tab>
    </Tabs>

    However, you can customize the file naming conventions based on your requirements, whether in the MoEngage S3 bucket or your S3 bucket.

    * You can add any of the following attributes to the file path or file name:
      | Attribute                | Description                                                             |
      | ------------------------ | ----------------------------------------------------------------------- |
      | `{{cid}}`                | MoEngage Campaign ID                                                    |
      | `{{channel}}`            | Channel type                                                            |
      | `{{db_name}}`            | Workspace name                                                          |
      | `{{date}}`               | Date of archival                                                        |
      | `{{id}}`                 | ID                                                                      |
      | `{{moe_transaction_id}}` | MoEngage transaction ID                                                 |
      | `{{time}}`               | Time of archival                                                        |
      | `{{moe_event_id}}`       | MoEngage event ID                                                       |
      | `{{alert_ID}}`           | Alert ID is for Inform. In the case of Inform, there is no campaign ID. |
    * You can change the order of the attributes in the file name. For example, consider the file naming convention for one-time Email campaigns. Default: `MoeCampaignID_ID_epochtime_email.eml ` Customized: `ID_MoeCampaignID_epochtime_email.eml` (here, ID comes before the MoeCampaignID)
  </Tab>

  <Tab title="SFTP Server Archival">
    After being configured, MoEngage exports message event data to your server. The archival process groups messages from all channels (Push, Email, SMS, etc.) together into the same export files.

    #### Server Directory Path

    MoEngage uploads archive files to a specific directory path on your SFTP server. During setup, you can configure the base path for these uploads. The path you provide must end with a forward slash (/). If you do not provide a base path, MoEngage uses the default: `/home/{username}/uploads/`.

    MoEngage automatically appends your workspace name (db\_name) and the date to create the final directory structure: `your_configured_base_path/{db_name}/{YYYY-MM-DD}/`

    If you do not provide a custom path, MoEngage uses the following default structure:

    `/home/{username}/uploads/{db_name}/{YYYY-MM-DD}/`

    * **/home/**{username}**/uploads/:** The default base path.
    * **username:** The username provided during the SFTP connection setup.
    * **db\_name:** The name of your MoEngage workspace.
    * **YYYY-MM-DD:** The date of the export.

    For Example, using the default path, if your username is `citi-test` and your workspace (db\_name) is `checkfcsgain`, the files for July 15, 2025, are located in: `/home/citi-test/uploads/checkfcsgain/2025-07-15/`.

    #### Archive File Name and Structure

    Files uploaded to your SFTP server are compressed into a .zip archive. These archives are named using a consistent pattern and may be split into multiple parts if the data volume is large.

    **ZIP File Naming Convention:** `[workspace_name]_[date]_[hour]_[chunk_number].zip`

    | Component        | Description                                                                                                |
    | ---------------- | ---------------------------------------------------------------------------------------------------------- |
    | `workspace_name` | The name of your MoEngage workspace (e.g., `checkfcsgain`).                                                |
    | `date`           | The date of the export in YYYY-MM-DD format.                                                               |
    | `hour`           | The hour of the day (00-23) during which the export was generated.                                         |
    | `chunk_number`   | A sequential number starting from 1. If the total hourly data is under 200 MB, the chunk number will be 1. |

    <Info>
      Files are chunked, with a maximum size of 200 MB per chunk. If the data for a given hour exceeds this limit, it is divided into multiple ZIP files. For example, if the data for the 6 AM hour on July 14, 2025, is 350 MB, you will receive two files:

      * `checkfcsgain_2025-07-14_06_1.zip`
      * `checkfcsgain_2025-07-14_06_2.zip`

      An individual message record (a complete JSON object) is never broken or split across two different files.
    </Info>

    **Inside the Archive: The Data File**

    Each .zip archive contains multiple JSON files. Individual JSON files adhere to the following naming and content conventions:

    * **Data File Name:** MoEngage uses system-generated names for these files, reflecting how they were named in the internal system. For example: `sftp.bulk.upload+0+0000049701.json`.
    * **File Content and Format:** Each of these JSON files can contain one or more complete JSON objects back-to-back. There is no delimiter between the individual JSON objects within a single file. Upon opening a file, you will see the complete JSON objects one after another.

    Each JSON object represents a single archived message and begins with the `"message_content"` key.

    **Upload Schedule**

    A MoEngage function runs hourly to manage the export. This function gathers the latest message data, compresses it into zip archives, and uploads them to your SFTP server.
  </Tab>
</Tabs>
