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

# Loops

# Hosted Loop Engine

Better Data’s **managed** loop engine — run governed, observable commerce-chain loops without operating the runtime yourself.

## What is the hosted loop engine?

The hosted loop engine at **[loops.betterdata.co](https://loops.betterdata.co)** runs the Better Data loop model as a **multi-tenant service**. You integrate via APIs and module manifests; Better Data operates scale, isolation, and upgrades.

**Monorepo services:** the running hosted stack includes **hosted-loops** (runtime + loops database API) and **registry-loop** (published loop definitions catalog). See **[Hosted platform apps](/reference/hosted-platform-apps)** for how they relate to **hosted-gateway-mcp** and **registry-mcp-server**.

**OSS alternative:** [`@loop-engine/sdk`](https://www.npmjs.com/search?q=%40loop-engine) and [loopengine.io](https://loopengine.io) for self-hosted runtimes.

## What you get with hosted

* Multi-tenant **org isolation**
* **Outcome-based metering** (billing tied to loop completions — contact us for current model details)
* **TenantCapabilitySnapshot**-style capability enforcement for RBAC
* Tamper-evident **loop audit trail** and export paths for compliance workflows
* **Drift detection** (scheduled validation of expected vs observed state)
* **Outbox relay** for cross-module event delivery
* **Industry Pack** policy overlays (hosted-only; not published as OSS)

## Pricing model

Hosted Loop Engine pricing is **outcome-based** (per loop completion, not per seat).\
Contact **[hello@betterdata.co](mailto:hello@betterdata.co)** for current packaging and terms.

## Loop types (canonical)

| Loop                | Module | What it governs                                      |
| ------------------- | ------ | ---------------------------------------------------- |
| `scm.procurement`   | SCM    | AI-assisted PO recommendation + human approval gates |
| `scm.fulfillment`   | SCM    | Multi-step order fulfillment                         |
| `scm.quality`       | SCM    | Inspection, deviation, CAPA-style disposition        |
| `scm.replenishment` | SCM    | Demand signal → reorder / replenishment              |
| `dcm.demand`        | DCM    | Demand signal detection and replenishment triggers   |
| `dcm.order`         | DCM    | Channel order routing and lifecycle                  |
| `dcm.returns`       | DCM    | Return authorization and reverse logistics           |

See also [Loops](/platform/loops) for the conceptual model.

## Runtime HTTP API (`hosted-loops`)

These routes are implemented under **`apps/hosted-loops/app/api/`** in bd-forge-main (`@repo/hosted-loops`). **Production host / base URL** mapping (e.g. `loops.betterdata.co`) is an **implementation detail pending verification**.

| Prefix                          | Purpose (high level)                                                                                                                                                                                                        |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`/api/v1/loops`**             | List/create loop concerns; **`/api/v1/loops/catalog`**, **`/api/v1/loops/[id]`**, **`/[id]/start`**, **`/[id]/transition`**, **`/[id]/cancel`**, **`/[id]/events`**, **`/[id]/history`**, **`/[id]/google/*`** integrations |
| **`/api/v1/loops/runs`**        | Runs: **`runs/[runId]`**, **`runs/compare`**                                                                                                                                                                                |
| **`/api/v1/loops/definitions`** | **`definitions/[loopId]/runs`**                                                                                                                                                                                             |
| **`/api/v1/baselines`**         | Baselines CRUD, **`/[id]/transition`**, **`/[id]/true-ups`**, delivery routes                                                                                                                                               |
| **`/api/v1/connectors/*`**      | Connector health and **Slack/Google** OAuth + events (**`/connectors/slack/events`**, etc.)                                                                                                                                 |

Handlers use JWT-style **`authenticate`** in route modules (see e.g. `apps/hosted-loops/app/api/v1/loops/[id]/transition/route.ts`). **Exact auth header contract and tenancy claims** — **implementation detail pending verification** (read `apps/hosted-loops/lib/auth` when documenting publicly).

## Getting started

* **Hosted:** [app.betterdata.com](https://app.betterdata.com) or email [hello@betterdata.co](mailto:hello@betterdata.co)
* **Self-hosted:** [loopengine.io](https://loopengine.io) and `@loop-engine/sdk`

## OSS vs hosted

|                            | OSS (`@loop-engine/sdk`) | Hosted ([loops.betterdata.co](https://loops.betterdata.co)) |
| -------------------------- | ------------------------ | ----------------------------------------------------------- |
| Cost                       | Free (OSS)               | Per agreement — contact us                                  |
| Setup                      | You operate              | No infrastructure setup                                     |
| Multi-tenant               | No                       | Yes                                                         |
| Industry Packs             | No                       | Yes                                                         |
| Audit / compliance exports | Your pipelines           | Platform aggregation + reports                              |
| SLA                        | Self-managed             | Better Data SLA                                             |
