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

# TransactionWorkspaceConnector

> TransactionWorkspaceConnector is a per-row provenance junction that records which WorkspaceConnector sourced or received a given Transaction — analogous to Docu

TransactionWorkspaceConnector is a per-row provenance junction that records which WorkspaceConnector sourced or received a given Transaction — analogous to DocumentWorkspaceConnector. Each row carries a direction discriminator (input = ingestion source, output = egress destination) so that a single transaction can be linked to multiple connectors in each direction without ambiguity. Tenant isolation is inherited transitively through the Transaction's workspace and the WorkspaceConnector's workspace rather than a direct workspace\_pk column. As the highest-volume of the five entity-connector junctions (projected \~436 k rows at 18 months), it ships non-partitioned with two covering indexes: record-led and connector-led for sync-status range queries.

| Naming                          | Value                                  |
| ------------------------------- | -------------------------------------- |
| Object                          | TransactionWorkspaceConnector          |
| Resource type (JSON:API `type`) | `transaction_workspace_connector`      |
| Collection / records root       | — <sub>(not a records root)</sub>      |
| REST base                       | `/v1/transaction-workspace-connectors` |
| Entity class                    | `TransactionWorkspaceConnector`        |

<Note>
  **Internal object.** Not currently exposed on the public REST API. The operations below describe the intended contract.
</Note>

## API operations

| Operation | Method & path                                      | Status     |
| --------- | -------------------------------------------------- | ---------- |
| List      | `GET /v1/transaction-workspace-connectors`         | 🟡 Planned |
| Retrieve  | `GET /v1/transaction-workspace-connectors/{id}`    | 🟡 Planned |
| Create    | `POST /v1/transaction-workspace-connectors`        | 🟡 Planned |
| Update    | `PATCH /v1/transaction-workspace-connectors/{id}`  | 🟡 Planned |
| Delete    | `DELETE /v1/transaction-workspace-connectors/{id}` | 🟡 Planned |

## Data model

### Attributes

| Field       | Type                                                    | Required | Constraints                                               | Allowed values      | Description                                                                                                                                                                                                                                             |
| ----------- | ------------------------------------------------------- | -------- | --------------------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| direction   | enum (direction\_enum — stored as native Postgres enum) | ✅ Yes    | NOT NULL; CHECK enforced by the native Postgres enum type | "input" \| "output" | Indicates whether the associated WorkspaceConnector is the ingestion source (input) or an egress destination (output) for the Transaction. Stored as the native Postgres enum `core_api.direction_enum`; the column value equals the enum VALUE string. |
| created\_at | 🔒 system — datetime                                    | ✅ Yes    | NOT NULL; default now(); timestamptz                      | —                   | Row-creation timestamp set automatically on insert via MikroORM onCreate hook. Never writable by the user.                                                                                                                                              |
| updated\_at | 🔒 system — datetime                                    | ⚪ No     | nullable; timestamptz                                     | —                   | Last-modified timestamp maintained automatically by MikroORM onCreate + onUpdate hooks. Null until the row is first updated after creation.                                                                                                             |
| deleted\_at | 🔒 system — datetime                                    | ⚪ No     | nullable; timestamptz                                     | —                   | Soft-delete timestamp. Null means the row is active. Set by the application when the association is logically removed; never hard-deleted. All queries must filter `deleted_at IS NULL`.                                                                |

### Relationships

| Name               | Type               | Required | Description                                                                                                                                                                                                                                   |
| ------------------ | ------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| transaction        | to-one (ManyToOne) | ✅ Yes    | The Transaction this provenance row belongs to. Foreign key `transaction_pk` references `core_api.transactions.pk` ON UPDATE CASCADE. Tenant scope is inherited through this relationship — there is no direct workspace\_pk on the junction. |
| workspaceConnector | to-one (ManyToOne) | ✅ Yes    | The WorkspaceConnector instance (an activated connector in a specific workspace) that ingested or will receive this transaction. Foreign key `workspace_connector_pk` references `core_api.workspace_connectors.pk` ON UPDATE CASCADE.        |

### System-computed

* pk — serial integer primary key, internal only, never exposed on the public API
* created\_at — set to new Date() on insert via MikroORM onCreate hook; never user-writable
* updated\_at — set to new Date() on insert and on every update via MikroORM onCreate + onUpdate hooks; null until first update
* deleted\_at — null on creation; written by application code for soft-delete; never hard-deleted
* No transaction\_workspace\_connector\_id UUID field is present on this entity — it uses only the internal serial pk (junction tables in this codebase omit the public \*\_id UUID unless externally referenced)
* Rows are written exclusively by the connector sync pipeline (input direction) or by egress sync writers (output direction, iteration 4+); no user-facing PATCH route exists
* Migration20260507000000 backfilled historical input rows from legacy entity.source\_workspace\_connector\_pk values using an idempotent INSERT…SELECT NOT EXISTS guard; idempotency is NOT enforced by a UNIQUE constraint — no UNIQUE on (transaction\_pk, workspace\_connector\_pk, direction) was shipped by design (deduplication is iteration 3+ work)
* Two covering B-tree indexes ship with the table: idx\_transaction\_workspace\_connectors\_record\_created on (transaction\_pk, created\_at) for record-led traversals; idx\_transaction\_workspace\_connectors\_wc\_created\_at on (workspace\_connector\_pk, created\_at) for sync-status range queries

## Example

```json theme={null}
{
  "data": {
    "type": "transaction_workspace_connector",
    "id": "a3f92c01-4e5b-47dc-9a13-001b8e2d7f44",
    "attributes": {
      "direction": "input",
      "created_at": "2026-05-07T14:23:11.000Z",
      "updated_at": "2026-05-07T14:23:11.000Z",
      "deleted_at": null
    },
    "relationships": {
      "transaction": {
        "data": { "type": "transaction", "id": "f1d3c8a2-0011-4bcd-8f2e-ab91c42e7001" }
      },
      "workspace_connector": {
        "data": { "type": "workspace_connector", "id": "9b2a5d3e-ccf1-4a89-b027-0f3d1e7c8a55" }
      }
    }
  }
}
```

<sub>Source: `apps/api/src/database/entities/TransactionWorkspaceConnector.ts` · domain: ingestion · tier: Infrastructure</sub>
