> ## 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.

# FieldRuleValue

> FieldRuleValue stores the computed or user-supplied value for a single custom-column rule applied to a single record

FieldRuleValue stores the computed or user-supplied value for a single custom-column rule applied to a single record. Each row binds a FieldRule (the definition of a custom AI column) to a specific record by its string identifier and record root type, holding the computed JSONB value. It is the output store for the AI custom-column enrichment pipeline: the pipeline writes rows here after computing values; nothing else creates or modifies them via user interaction. There is no soft-delete column — rows are hard-deleted when their parent FieldRule is cascade-deleted.

| Naming                          | Value                             |
| ------------------------------- | --------------------------------- |
| Object                          | FieldRuleValue                    |
| Resource type (JSON:API `type`) | `field_rule_value`                |
| Collection / records root       | — <sub>(not a records root)</sub> |
| REST base                       | `/v1/field-rule-values`           |
| Entity class                    | `FieldRuleValue`                  |

<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/field-rule-values`         | 🟡 Planned |
| Retrieve  | `GET /v1/field-rule-values/{id}`    | 🟡 Planned |
| Create    | `POST /v1/field-rule-values`        | 🟡 Planned |
| Update    | `PATCH /v1/field-rule-values/{id}`  | 🟡 Planned |
| Delete    | `DELETE /v1/field-rule-values/{id}` | 🟡 Planned |

## Data model

### Attributes

| Field       | Type                      | Required | Constraints                                                                                   | Allowed values | Description                                                                                                                                                                                                                                 |
| ----------- | ------------------------- | -------- | --------------------------------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| value\_id   | string (UUID) — 🔒 system | ✅ Yes    | UNIQUE; defaultRaw gen\_random\_uuid()                                                        | —              | Public UUID identifier for the row. Generated by the database on insert; never writable by callers.                                                                                                                                         |
| record\_id  | string                    | ✅ Yes    | max length 255; composite UNIQUE with field\_rule (field\_rule\_values\_rule\_record\_unique) | —              | The public UUID string of the record (e.g. a company\_id or person\_id) to which this computed value applies. Together with field\_rule this pair is unique in the table, enabling race-condition-safe upserts.                             |
| root        | string                    | ✅ Yes    | max length 50; part of composite hot-path index idx\_field\_rule\_values\_root\_record\_rule  | —              | The record root type (e.g. 'companies', 'people') to which this value belongs. Denormalized from FieldRule.root for hot-path batch queries in the AI column-context assembly pipeline.                                                      |
| value       | jsonb (nullable)          | ⚪ No     | nullable                                                                                      | —              | The computed value for the custom column on this record, stored as arbitrary JSONB. Null when the pipeline has not yet produced a value or when the result was explicitly null. Shape is determined by the parent FieldRule's column\_type. |
| created\_at | datetime — 🔒 system      | ✅ Yes    | set by onCreate hook; not nullable                                                            | —              | Timestamp when this value row was first written by the enrichment pipeline.                                                                                                                                                                 |
| updated\_at | datetime — 🔒 system      | ⚪ No     | nullable; set by onCreate and onUpdate hooks                                                  | —              | Timestamp of the most recent update to this row by the pipeline. Null if the row has never been updated after creation.                                                                                                                     |

### Relationships

| Name        | Type               | Required                            | Description                                                                                                                                                                                                                                                   |
| ----------- | ------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| field\_rule | to-one (ManyToOne) | Yes — NOT NULL; deleteRule: cascade | The FieldRule that defines the custom column whose computed value this row stores. Cascade deletion means all FieldRuleValue rows are hard-deleted when their parent FieldRule is removed. Part of the composite unique constraint (field\_rule, record\_id). |

### System-computed

* value\_id: auto-generated UUID via gen\_random\_uuid() on insert
* created\_at: set by MikroORM onCreate hook; not user-settable
* updated\_at: set by MikroORM onCreate and onUpdate hooks; not user-settable
* No soft-delete (deleted\_at column absent): rows are hard-deleted on cascade from FieldRule deletion
* Hot-path composite index idx\_field\_rule\_values\_root\_record\_rule (root, record\_id, field\_rule\_pk) added in Migration20260416000000 for AI custom-column batch context assembly
* Unique constraint field\_rule\_values\_rule\_record\_unique (field\_rule\_pk, record\_id) added in Migration20260330153340 to enable race-condition-safe upserts from the enrichment pipeline

## Example

```json theme={null}
{
  "data": {
    "type": "field_rule_value",
    "id": "a3f1c2d4-8e5b-4a7f-92b1-0123456789ab",
    "attributes": {
      "value_id": "a3f1c2d4-8e5b-4a7f-92b1-0123456789ab",
      "record_id": "c7e9a1b2-3d4f-4e5a-8b9c-0a1b2c3d4e5f",
      "root": "companies",
      "value": { "text": "B2B SaaS company focused on developer tooling", "confidence": 0.92 },
      "created_at": "2026-04-02T14:23:11.000Z",
      "updated_at": "2026-04-02T14:23:11.000Z"
    },
    "relationships": {
      "field_rule": {
        "data": { "type": "field_rule", "id": "f8a2b3c4-1d2e-3f4a-5b6c-7d8e9f0a1b2c" }
      }
    }
  }
}
```

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