Backend
Schema
New collections go live immediately. Later edits to a live collection stay in draft until you publish.
Field types
string, text, number, bool, enum (set options), date, email, rel, file.
Relationships
Use type: "rel" and relationTo: "<collection slug>". Store the related record's id. Crafio rejects ids that do not exist, and blocks deleting records that are still referenced, including through retired rel fields.
Draft and publish
The customer app and the publishable key read the published schema. A collection that has never been published is already live, so a first build works without you clicking Publish.
- Creating a new collection is live immediately. The agent should not ask you to approve it.
- Changing a collection that is already published stays in draft. The live app keeps the last snapshot until you review it on the Schema page and publish.
- After a draft change, the agent should summarize it, ask you to approve, and share the Schema page link.
schema.publishis only for when you explicitly ask.schema.discardreverts drafts on collections that are already live. New collections stay.
Versioning
- Adding a field creates a new schema version.
- Removing a field retires it. Values stay on every record.
- Redefining a collection is a migration, not a wipe. Old keys remain in record JSON.
- Changing a field type checkpoints current rows first.
schema.restorebrings back a previous field list. Data is not deleted.
Access
Each collection has read, create, update, and delete levels for the customer app: public, signed-in, owner, admin. Set them with schema.set_access or in the collection page. The hosted admin and agent tokens skip these rules.
Tools
schema.list, schema.define_collection, schema.set_access, schema.add_field, schema.remove_field, schema.versions, schema.restore, schema.review, schema.publish, schema.discard. Prefer the suggested collections from project.context. Never create a parallel local database.
