--- title: "Build a record storage entity" slug: "build-ai-ready-systems-business-entities-guides-build-record-storage-entity" description: "CLI-first checklist for entityType recordStorage — primaryKey, externalId, sync, fieldMappings, exposed. Step-by-step for integrators — prerequisites, validate" tags: ["Integration", "Developer", "Integrator"] updated: 2026-11-30T18:59:36Z published: 2026-11-17T07:08:17Z canonical: "docs.aifabrix.ai/build-ai-ready-systems-business-entities-guides-build-record-storage-entity" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.aifabrix.ai/llms.txt > Use this file to discover all available pages before exploring further. # Build a record storage entity Step-by-step checklist for **`entityType: recordStorage`** — CRM-style entities with normalized metadata, sync, and governed capabilities. ## Prerequisites - External system JSON with `type: openapi` (or compatible type) - [Resource type](/docs/build-ai-ready-systems-business-entities-entity-basics-types-resource) registered in catalog (`customer`, `contact`, `deal`, …) - Integration folder: `integration/<systemKey>/` ## Where it lives One JSON file per business entity, for example `integration/<systemKey>/<systemKey>-datasource-companies.json`. Required root fields: `key`, `displayName`, `systemKey`, **`entityType`**, **`resourceType`**. ## How to set 1. **Copy a known-good record fixture** and trim — do not start from `{}`. Align `systemKey` with the system file and list the file in `application.yaml`. 2. **Set identity band** (required for recordStorage): ``` { "key": "example-companies", "displayName": "Companies", "systemKey": "example-crm", "entityType": "recordStorage", "resourceType": "customer", "primaryKey": ["externalId"], "metadataSchema": { "type": "object", "properties": { "externalId": { "type": "string", "index": true, "description": "Stable join identity across datasources" }, "name": { "type": "string", "index": true, "filter": true } } } } ``` 1. **Add `fieldMappings.attributes`** — map vendor payload paths to normalized names. See [Field mappings](/docs/build-ai-ready-systems-business-entities-configure-business-vocabulary). 2. **Configure `sync`** — inbound record sync (schedule, operations, pagination). Validator expects sync shape for recordStorage. 3. **Configure `exposed`** — governed capabilities (`read`, `search`, `create`, …) with OpenAPI operation bindings. 4. **Add dimensions** (recommended) — top-level `dimensions` object with local or fk bindings. See [Configure business policies](/docs/build-ai-ready-systems-business-entities-configure-business-policies). 5. **Repair manifest drift**: ``` aifabrix repair --dry-run aifabrix repair --expose --rbac ``` 1. **Validate in tight loops**: ``` aifabrix datasource validate aifabrix validate ``` 1. **Upload and E2E** after integration is green — see [Test ladder](/docs/build-ai-ready-systems-validate-test-test-ladder-protection). ## Defaults and examples | Field | recordStorage rule | | --- | --- | | `key` | Unique datasource key listed in `application.yaml` | | `displayName` | Human label in UI and logs | | `systemKey` | Must match `<systemKey>-system.json` | | `entityType` | Must be `recordStorage` | | `resourceType` | Top-level catalog key (`customer`, not vendor name) | | `primaryKey` | Array of normalized attribute names | | `externalId` | Required indexed string in `metadataSchema` — global join identity | | `sync` | Record pull/push configuration | | `exposed` | Capability gateway for AI and workers | Typical CRM split: one business entity file per entity (`companies` → `customer`, `contacts` → `contact`, `deals` → `deal`). Minimal **`capabilities`** and **`exposed`** bands (trim from a validated fixture): ``` { "capabilities": [ { "key": "list", "description": "List companies", "riskLevel": "low" }, { "key": "get", "description": "Get company by id", "riskLevel": "low" } ], "exposed": { "filterable": ["name", "country"], "schema": { "externalId": "metadata.externalId", "name": "metadata.name", "country": "metadata.country" } } } ``` ## Validate ``` aifabrix resource-type list aifabrix datasource validate aifabrix validate aifabrix test-integration aifabrix datasource test-e2e --app ``` ## Common mistakes | Mistake | Fix | | --- | --- | | Missing `externalId` in metadataSchema | Add indexed string property | | Missing root `resourceType` | Set catalog key; create in catalog first | | recordStorage without sync | Add sync block or confirm entityType choice | | One file mixing entity types | Split into one JSON per entity | | Skipping datasource validate | Run `datasource validate` after each JSON edit | ## Limits This page covers manifest shape — not vendor API quirks. OpenAPI operation IDs, pagination, and CIP transforms may need [CIP execution](/docs/build-ai-ready-systems-publish-certify-cip-execution). Foreign keys and protection are separate govern steps. After first green `datasource validate`, keep running it after every JSON edit — it is faster than full system validate while iterating on `fieldMappings` or `sync`. Upload only when both system and business entity validators pass without warnings you cannot explain. Treat **`displayName`** changes as operator-facing — they do not replace stable **`key`** or **`externalId`** semantics used by sync and search. Before first upload, confirm **`entityType`** is `recordStorage`, root **`resourceType`** appears in `resource-type list`, and **`systemKey`** matches the system file — these three checks prevent most probe-upload failures. ## Related - [Entity basics, types, and resource type](/build-ai-ready-systems-business-entities-entity-basics-types-resource.md) - [Build a document storage entity](/build-ai-ready-systems-business-entities-guides-build-document-storage-entity.md) - [Record, document, and message contracts](/enterprise-knowledge-record-document-service-contracts.md)