> For the complete documentation index, see [llms.txt](https://docs.middle.app/middle-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.middle.app/middle-docs/overview/evaluate/how-is-data-handled-in-middle.md).

# How is data handled in Middle?

Most Middle integrations are data-driven. Middle pulls records from your connected apps, stores them, and makes them available to your workflows. Understanding how that works helps you build more reliable integrations and troubleshoot them when something goes wrong.

## Where does data come from?

Middle connects to your apps and requests data from them directly. Most apps expose their data through an **API**. When you connect an app to Middle, Middle uses that app's API to fetch records on your behalf.

Some apps also support direct database connections or file-based transfers. The connection method depends on how the app is built.

## How does Middle ingest data?

Using app syncs, Middle can ingest data from external applications. Middle's main types of syncs are:

* **Complete transfers:** Grab all the data available from an endpoint or external resource
* **Primary key lookups:** Request data for a specific record using a primary identifier
* **Recent record updates:** Syncs data using a datetime range, such as a last modified date

When Middle syncs a record, it checks to see if that record exists in the Middle database. If it finds one, it compares the new record to the old one. If there are differences, it updates the existing record in Middle. If no matching record is found, it inserts the new record.

## Where is the data stored, and why does that matter?

Middle keeps a copy of your synced records in its own database. Think of it as a live snapshot of your connected apps' data that is updated regularly, searchable, and always available to your workflows.

This matters for three practical reasons:

**Your workflows have reliable data to work with.** When a workflow runs, it can look up related records instantly without making a live call to the original app. For example, a workflow triggered by a new membership can immediately access that member's profile, past check-ins, or billing history, because those are already stored in Middle.

**You can detect what changed.** Middle keeps a previous version of each record alongside the current one. This lets you build workflows that trigger on a change, not just a creation. For example: "send a notification when a membership status changes from active to cancelled."

**You can debug what happened.** Every sync and every workflow run is logged. If something doesn't work as expected, you can look back at exactly what data was synced, when, and what the workflow did with it. You can also re-run failed workflows directly from the history view.

## How long is data kept?

By default, Middle deletes stored records after **30 days** since their last purposeful use. Record history and workflow execution history are kept for the current calendar month and **one full prior month**. This keeps your storage footprint manageable and your history relevant.

If you need a different retention window, record retention can be adjusted per record type within an account's app connection. ENTERPRISE installations can also set platform-wide defaults.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.middle.app/middle-docs/overview/evaluate/how-is-data-handled-in-middle.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
