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

# Microsoft OneDrive

> Export data from any source to Microsoft OneDrive as CSV or JSON files on a schedule.

## Supported syncing

| Object Type | Description | Supported Sync Modes |
| - | - | - |
| Any data set | Sync data from a source to One Drive as JSON or CSV files | Insert, All, Diff |

* **All**: All mode creates one file with all the rows in the query results, every time the sync runs.
* **Insert**: Insert mode creates one file with the rows that were added since the last sync.
* **Diff**: Diff mode creates three files, one for rows added, one for rows changed, and another for rows removed since the last sync.

For more information about sync modes, refer to the [sync modes](https://docs.hightouch.com/syncs/types-and-modes.md#sync-modes) docs.

> [!NOTE]
>
> The order of rows and columns in uploaded files may differ from how they appear in your model. This is expected behavior and applies to all sync modes. [Learn more about row and column ordering](https://docs.hightouch.com/models/creating-models.md#row-and-column-ordering).

## Connect to Microsoft OneDrive

Go to the [**Destinations** overview page](https://app.hightouch.com/destinations?from=docs) and click the **Add destination** button. Select **Microsoft OneDrive** and click **Continue**. You can then connect to Microsoft OneDrive via OAuth.

![](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-onedrive-oauth.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=37b40a0a43d8790ec963675f81653755)

After authorizing, you will have successfully connected Hightouch to Microsoft OneDrive.

## Sync configuration

Once you've set up your OneDrive destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull data from, you can set up your sync configuration to begin syncing data. Go to the [**Syncs** overview page](https://app.hightouch.com/syncs?from=docs) and click the **Add sync** button to begin. Then, select the relevant model and the OneDrive destination you want to sync to.

### Select file format

Hightouch supports syncing JSON and CSV files to OneDrive.

### Write to an Owned folder or Shared folder

You can sync to a folder that is owned by or shared to the account connected to Hightouch.
Select either **Owned folders** or **Shared folders** to see available folder options.

### Enter filename

The filename field lets you specify the parent directory and the name of the file you want to use for your results.
You can include timestamp variables in the filename, surrounding each with `{}`.
Hightouch supports these timestamp variables:

* `YYYY`: Represents the full year in four digits.
* `YY`: The last two digits of the year.
* `MM`: Two-digit month format (01-12).
* `DD`: Two-digit day format (01-31).
* `HH`: Two-digit hour format in 24-hour clock (00-23).
* `mm`: Two-digit minute format (00-59).
* `ss`: Two-digit second format (00-59).
* `ms`: Three-digit millisecond format.
* `X`: Unix timestamp in seconds.
* `x`: Unix timestamp in milliseconds.

All dates and times are UTC.

For example, you could enter `upload/{YYYY}-{MM}-{DD}-{HH}-{mm}-result.json` to dynamically include the year, month, date, hour, and minute in each uploaded file. Hightouch would insert each file in the `upload` directory, which would need to already exist in your bucket.

You can also use other [variable values](https://docs.hightouch.com/syncs/mapping-data.md#variable-values) to include sync metadata in the filename:

* `{model.id}`
* `{model.name}`
* `{sync.id}`
* `{sync.run.id}`

> [!NOTE]
>
> If a file already exists at the path you entered at the time of a sync,
> Hightouch overwrites it. To view different versions of the same file, you can
> right-click the file in Microsoft OneDrive and then click **Version history**.

> [!TIP]
>
> If you are using an audience and would like to include the audience name, you
> will still use `{model.name}`.

### Set filename offset

By default, Hightouch uses the timestamp of the sync run to fill in timestamp variables. You can optionally include an offset in seconds. For example, if you want the filename's date to be 24 hours *before* the sync takes place, enter '-86400' (`24 hours * 60 minutes * 60 seconds`).

### Columns to sync

You can export all columns exactly as your model returns them or choose to export specific ones.

If you need to rename or transform any column values you're syncing, you can use the [advanced mapper](https://docs.hightouch.com/syncs/mapping-data.md#advanced-mapper) to do so. If you choose this option, Hightouch only syncs the fields you explicitly map.

![Exporting and remapping select columns in your model](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-onedrive-add-mappings.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=1973de447427038d14c7a384a5a70cdc)

The preceding example shows how to selectively export the `company`, `email`, `name`, and `primaryKey` fields. Hightouch exports these fields to new fields in the file and ignores all other columns from your results.

### CSV options

If you're syncing to a CSV file, you have additional configuration options:

* **Delimiter**: Your options are comma (`,`), semicolon (`;`), pipe (`|`), tilde (`~`), and tab
* (Optional) Whether to **include a CSV header row** in the exported files
* (Optional) Whether to **include a [byte order mark (BOM)](https://en.wikipedia.org/wiki/Byte_order_mark)** in the exported files, the BOM is `<U+FEFF>`

### Empty file results

You can select how Hightouch should handle empty results files. Empty result files can occur if your model's query results haven't changed since the last sync.

You can select whether to **skip empty files**. If you skip empty files, it means Hightouch won't export any files if your model's query results haven't changed since your last sync.

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

### Need admin approval

If you see a **Need admin approval** page appear when [accessing Microsoft's OAuth login flow](#connect-to-microsoft-onedrive), your Azure Active Directory user account might not have the necessary permissions to connect applications to your organization.

![Microsoft's "Need admin approval" screen](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/workspace-management/permissions/microsoft-need-admin-approval.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=c9cf06dcd44f67bebf71c67bb2339af2)

Ask one of your Azure organization's admins to edit your user account permissions.

You can read more about [Azure user permissions](https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-how-applications-are-added#who-has-permission-to-add-applications-to-my-azure-ad-instance) and [configuring user settings](https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/configure-user-consent?pivots=portal#configure-user-consent-settings) in Azure's documentation.
