# Use records and private files

Store separates persistent data from a tool's layout. A collection copies a published declaration's record schema, schema version, indexes and exact provider pin. Layout undo or version restore preserves records, private files and created collections.

## Choose a collection and provider

Read the tool's current collections and the consuming package's exact declaration. Reuse a compatible owned collection, or explicitly create one with `flip_collection_create` under `flip:configure`. A provider reference contains only its exact plugin ID, package version and extension ID. It cannot contain a service URL, SQL connection, credential or caller-selected owner.

Provider eligibility follows the source package/dependencies, required capabilities and existing tool pin. A conflict fails instead of upgrading or silently migrating existing data. New provider publication does not retarget an old collection. A pure Store package can back its declared collection in a blank tool without using a connected-display starter.

## Read and change records

Use `flip_records_query` and `flip_record_get` under record-read permission. Query in bounded pages and follow the returned cursor; filters/sorts are restricted to supported fields and declared indexes. A record ID is not an ownership credential.

Create, update and delete use the record-write scope, current owned collection, schema and a stable original idempotency key. Updates/deletes require the current optimistic revision. Validate against the copied schema; no implicit schema migration or raw SQL is exposed.

After a conflict, reread current state before proposing another edit. After an interrupted write, retain the original request/key and inspect its receipt/current record. Read-only Preview and shared viewers cannot write. A saved layout checkpoint is not a database backup or a record rollback.

## Store calls from Run source

`flip.store({operation,payload,idempotencyKey})` uses the Run component's declared collection key, such as `payload.collectionId: "entries"`, matching its `collection:entries` permission. The action must require that permission, and the saved Run instance maps its permission ID to the owned collection UUID. Core supplies the actual provider alias. Native/MCP record APIs use the owned UUID; a different app alias is not a guest-source key.

The awaited value is the Store response payload: query returns `{records,nextCursor}` and user values are in `record.data`. It is not an outer `{payload: ...}` envelope. Read and Preview cannot write. See [Run](flip://docs/run) and the live authoring info for mapping/query examples and immutable runtime upgrades.

## Account storage allowance

Call `flip_storage_usage` with `{}` under existing `flip:read` to inspect the current account allowance and usage before a substantial import or upload. Standard accounts share **1 GiB (1,073,741,824 bytes)** across all their apps: live typed-record JSON data plus private files. Pending uploads reserve their declared bytes; ready files and files awaiting deletion still count. The returned record, file and reservation bytes add to `usedBytes`; `limitBytes:null` means an operator-assigned unlimited account. Clients cannot choose an owner, change a limit or grant an exemption. Selected-app clients receive only account quota aggregates, without app names or record contents; this does not expand their data access.

The server serializes storage growth across apps, providers and write channels, including the web interface, MCP, incoming webhooks and Run-to-Store writes. Existing over-limit data is preserved. Reading, deleting and updates that do not increase stored bytes remain available; new growth beyond the limit returns `quota_exceeded`. Do not repeatedly retry a full account or delete data without the user's permission. Inspect usage and help the user choose what to remove. Keep original keys after an interrupted write; a transport failure remains an unknown outcome until reconciled.

Retained live records/files in a soft-deleted app continue to count. Hiding an app does not erase its data or release its allowance. Platform metadata, layout/version history, plugin source, database indexes, backups and retained cloud-object versions are excluded from the user allowance; the meter is logical app storage, not the Google Cloud bill. Existing per-app and per-file provider limits also apply, including on unlimited accounts. The web workspace links to Account → Storage; admins have an aggregate and per-account storage dashboard.

## Private files

New native PostgreSQL/GCS Store1.0.2 supports PNG/JPEG/WebP/GIF, PDF, macro-free DOCX/XLSX/PPTX and UTF-8 TXT/CSV/Markdown up to25MiB, within200 files/1GiB per app. Non-images are download-only; format checks do not scan for malware. Existing pinned versions keep their original image-only policy and cannot be silently upgraded. Inspect the actual provider before choosing a file type. `flip_file_begin_upload` returns an authorized short-lived PUT capability; transfer the exact bytes, then call `flip_file_finalize_upload` for that original upload. File reads use `flip_file_get` for metadata or `flip_file_read` for temporary download access. File scopes are independent from record scopes.

Keep signed transfer URLs and their headers out of logs, public source, shared notes and citations. Store file IDs in records when the schema allows them, not signed URLs. Transfer links can remain usable until expiry after a permission change. A records-only provider cannot attach files; choose an eligible file-capable declaration/provider or keep attachments separate.

## Author records-only Store source

Get the live authoring example and source contracts. Export `default async function({operation,payload}, flip)`. Validate the incoming request as needed, then `await flip.store()` to delegate only that exact scoped request to the trusted records kernel. Return its confirmed payload.

A source module cannot choose another grant, collection request, operation, owner or database connection. The kernel checks current authority, schema, revisions, bounded queries and durable original-key receipts. Confirmed kernel effects remain confirmed if source later fails. Source Store has no direct SQL, files, network or cloud credentials; adding an entirely new backend capability requires a versioned host change, not credentials embedded in a module.

Related: [Plugin model](flip://docs/plugin-model), [Display](flip://docs/display), [Data in](flip://docs/data-in), [Source publishing](flip://docs/source-publishing). Human guide: [Store](https://buildyourflip.com/docs#plugin-model/store).
