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

# Import supporting files to add context to telemetry

> Attach procedures, photos, video, and calibration data to a Run and view them next to its telemetry.

After completing this workflow, you can augment a Run with supporting files, such as procedures, photos, video, or calibration data, and view them in Explore next to telemetry.

## Before you begin

* You have a Run in Sift.
  * To create one, [import telemetry from a file](https://docs.siftstack.com/documentation/ingest/data-import/import-data-from-a-file.md) or [stream live telemetry](https://docs.siftstack.com/documentation/ingest/data-import/stream-live-telemetry.md).
* You are familiar with how [Sift organizes telemetry into Assets, Channels, and Runs](https://docs.siftstack.com/documentation/get-started/data-model.md).

## How supporting files work

A supporting file is attached to a Run and stays with it as context for the telemetry. Attaching a file does not modify the Run or its telemetry.

Where you view an attached file depends on its type:

> [!NOTE]
>
> **File size**: Sift accepts any file type, up to 30 GB per file.

## Attach a file to a Run

> [tab] UI
>
> **Attach from the Run's page**
>
> 1. Select **Runs** in the navigation, then enter the Run name in the **Search** box.
> 2. In the **Runs** table, click the Run.
> 3. In the **File Attachments** section, click  **Add**.
> 4. In the **Upload File(s)** dialog, drag and drop your files, or use the **click to browse** link to select them.
> 5. Click **Upload**.
>
> **Attach from Explore**
>
> 1. Select **Runs** in the navigation, then enter the Run name in the **Search** box.
> 2. In the **Runs** table, click the Run.
> 3. Click  **EXPLORE**.
> 4. In the  **File Viewer** tab, click  **Upload file** in the Run's row.
> 5. Select your file.
> 6. Click **Upload**.

> [tab] REST
>
> 1. Send a `POST` request to `/api/v0/remote-files/upload` at your [REST base URL](https://docs.siftstack.com/documentation/manage/set-up-api-access.md#obtain-the-base-url) with your [API key](https://docs.siftstack.com/documentation/manage/set-up-api-access.md#create-an-api-key). Set `entityId` to the Run ID, `entityType` to `runs`, and `file` to the path of your file.
>
>    ```bash theme={null}
>    curl --request POST \
>      --url "$SIFT_REST_URL/api/v0/remote-files/upload" \
>      --header "Authorization: Bearer $SIFT_API_KEY" \
>      --form "entityId=$RUN_ID" \
>      --form "entityType=runs" \
>      --form "file=@./test-procedure.pdf"
>    ```
>
>    > [!NOTE]
>    >
>    > **Optional fields**: Add a `description` of the file, JSON `metadata` for an image, video, or audio file, or JSON key-value `metadataValues`. If you belong to more than one Sift Organization, set `organizationId` to the ID of the Organization that holds the Run. This endpoint does not appear in the REST API reference.
>
> 2. Optional: Confirm the file is attached by sending the Run ID in a `filter` to [`ListRemoteFiles`](https://docs.siftstack.com/api-reference/remotefileservice/listremotefiles).
>
>    ```bash theme={null}
>    curl --request GET \
>      --url "$SIFT_REST_URL/api/v1/remote-files" \
>      --header "Authorization: Bearer $SIFT_API_KEY" \
>      --get \
>      --data-urlencode "filter=entity_id == \"$RUN_ID\""
>    ```
>
>    The response's `remoteFiles` array includes each file's `remoteFileId` and `fileName`.

> [tab] Python
>
> 1. From a Python environment, install the [Python client](https://sift-stack.github.io/sift/python/latest/) and `python-dotenv`:
>
>    ```bash theme={null}
>    pip install sift-stack-py python-dotenv
>    ```
>
> 2. Create a `.env` file next to your script and add your [API key](https://docs.siftstack.com/documentation/manage/set-up-api-access.md#create-an-api-key) and your gRPC and REST [base URLs](https://docs.siftstack.com/documentation/manage/set-up-api-access.md#obtain-the-base-url):
>
>    ```bash theme={null}
>    SIFT_API_KEY=your_api_key_here
>    SIFT_GRPC_URI=https://your-grpc-url
>    SIFT_REST_URI=https://your-rest-url
>    ```
>
> 3. Create a `SiftClient` that loads the values from the `.env` file:
>
>    ```python theme={null}
>    import os
>
>    from dotenv import load_dotenv
>    from sift_client import SiftClient
>
>    load_dotenv()
>
>    client = SiftClient(
>        api_key=os.environ["SIFT_API_KEY"],
>        grpc_url=os.environ["SIFT_GRPC_URI"],
>        rest_url=os.environ["SIFT_REST_URI"],
>    )
>    ```
>
> 4. Get the Run by passing its ID to `client.runs.get` as `run_id`, then attach the file with `upload_attachment`. Optionally, set `description` to a short description of the file.
>
>    ```python theme={null}
>    run = client.runs.get(run_id="your-run-id")
>    run.upload_attachment("./test-procedure.pdf", description="Test procedure")
>    ```
>
> 5. Optional: Confirm the file is attached by printing each one's `file_name` from the `attachments` property.
>
>    ```python theme={null}
>    for attachment in run.attachments:
>        print(attachment.file_name)
>    ```

## Replace a file

Sift does not update the contents of an attached file in place. To attach a new version, remove the outdated file, then [attach the new one](#attach-a-file-to-a-run).

> [tab] UI
>
> 1. Select **Runs** in the navigation, then click the Run.
> 2. In the **File Attachments** section, hover over the file, then click  **Delete file**.
> 3. Click **DELETE**.

> [tab] REST
>
> 1. Look up the file's `remoteFileId` by sending the Run ID in a `filter` to [`ListRemoteFiles`](https://docs.siftstack.com/api-reference/remotefileservice/listremotefiles).
>
>    ```bash theme={null}
>    curl --request GET \
>      --url "$SIFT_REST_URL/api/v1/remote-files" \
>      --header "Authorization: Bearer $SIFT_API_KEY" \
>      --get \
>      --data-urlencode "filter=entity_id == \"$RUN_ID\""
>    ```
>
>    The response's `remoteFiles` array includes each file's `remoteFileId` and `fileName`. Find the file to remove by its `fileName`.
>
> 2. Send the `remoteFileId` to [`DeleteRemoteFile`](https://docs.siftstack.com/api-reference/remotefileservice/deleteremotefile).
>
>    ```bash theme={null}
>    curl --request DELETE \
>      --url "$SIFT_REST_URL/api/v1/remote-files/$REMOTE_FILE_ID" \
>      --header "Authorization: Bearer $SIFT_API_KEY"
>    ```
>
>    > [!NOTE]
>    >
>    > **Description and metadata changes**: To change only a file's `description` or `metadataValues`, use [`UpdateRemoteFile`](https://docs.siftstack.com/api-reference/remotefileservice/updateremotefile) instead of replacing the file.
>
> 3. Optional: Call [`ListRemoteFiles`](https://docs.siftstack.com/api-reference/remotefileservice/listremotefiles) for the Run again and confirm the file no longer appears.

## Compare the files to the telemetry

1. Select **Runs** in the navigation, then enter the Run name in the **Search** box.
2. In the **Runs** table, click the Run.
3. Click  **EXPLORE**.
4. In the  **File Viewer** tab, confirm each file you attached appears under the Run.
5. Click an image, video, or audio file to open it in a File Viewer Panel.
6. [Add](https://docs.siftstack.com/documentation/reference/explore-settings.md#panel-layout) a **Time Series** Panel and plot the Channels that cover the same period as the file.
7. Optional: To line up a video or audio file with the Run's telemetry, right-click the file name in the **File Viewer** tab, select **File Details**, and set a new start time for the file.
   * The **Start** setting in the File Viewer Panel also shifts the file, but only for the current Explore session.
8. Decide whether the files and the telemetry tell the same story, such as whether the events in a video or audio file line up with the matching changes in the telemetry.

## What's next

* [Reference files in expressions](https://docs.siftstack.com/documentation/transform/reference-files-in-expressions.md): Use calibration or lookup values from an attached file in Rules and Calculated Channels.
* [Detect and review issues in a Run](https://docs.siftstack.com/documentation/review/detect-and-review-issues-in-a-run.md): Generate a Report for the Run and review the issues it flags.
