The app manifest, field by field
The manifest is cartbase.app.json at the root of the app folder. The
platform validates it on cartbase app validate and cartbase app deploy;
a refused manifest answers one row per problem, the path and what to change.
Unknown keys are refused by name. This page is generated from the schema
the platform validates with, so it cannot drift. The JSON Schema for
editors is app-manifest.schema.json, also at
https://docs.cartbase.ai/app-manifest.schema.json.
Top level
| Field | Required | What it is |
|---|---|---|
key |
yes | The app's slug: 2 to 40 characters, lowercase letters, digits and hyphens, starting with a letter. The URL segment under Apps and the prefix of every record type. Reserved: reviews, documents, nra-audit, subscriptions, feeds, search, search-discovery, experiments, design-system, new, install, validate, settings, index, viewports. |
name |
yes | The name shown in Apps, up to 60 characters. |
description |
yes | One line saying what the app does, up to 140 characters. |
version |
yes | Three numbers, 1.0.0. Every deploy is kept under its version. |
icon |
no | One of apps, pin, pages, star, tag, chart, users, cart, invoice, dollar, rss, search, van, warehouse, bell, swatches, discount, home, cog. Default apps. |
records |
no | The app's record types, up to 20. See below. |
settings |
no | What the merchant fills on the app's Settings screen, up to 40. See below. |
screens |
no | The screens under the app, up to 8. Omitted: one records screen per record type, then Settings when settings exist. |
storefront |
no | { files: [...], component? }: the files the app adds to the storefront project, relative to its root, up to 200. Recorded so an uninstall removes exactly them. |
fields |
no | The app's own fields on the store's products, collections, customers and orders, up to 40. See below. |
scopes |
no | What of the store the app may reach beyond its own data, as the admin's access areas. Empty: its own records, settings and fields only. See below. |
functions |
no | The app's server side: code the platform compiles, hosts and runs, up to 10. See below. |
events |
no | The platform events the app reacts to, each routed to one of its functions, up to 40 lines. See below. |
schedules |
no | The clocks the app runs on, each a cron line running one of its functions, up to 10. See below. |
egress |
no | The hosts the app's functions may send data to, up to 20. Shown to the merchant at install. See below. |
viewports |
no | The cards the app puts on the store's own order, product, customer and collection pages, from its records and its functions, up to 10. See below. |
A record type
{
"type": "location", // snake_case, up to 40 characters, letters first
"name": "Location", // singular, what a record page is called
"name_plural": "Locations", // the list's title; default: name + "s"
"visibility": "public", // public | private; default public; fixed for life
"fields": [ { "key": "city", "name": "City", "kind": "text", "required": true } ],
"columns": ["city"], // the fields the list shows by default, up to 12; the rest wait behind its column options
"max_records": 10000 // how many records the type may hold; this is the default, 100000 at most
}The platform stores the records as its own metaobjects, owned by the app:
the store type is <key>.<type>, so store-locator.location. A
public type answers at GET /api/store/metaobjects/<key>.<type> with the
publishable key (active records only); a private type never leaves the
admin. Visibility cannot change after the first deploy: declare a new type
and move the records.
Every records screen carries Export and Import: the records as a
CSV file, one column per field headed by the field's key, after the
record's handle, display_name and status. An import's natural key is
the handle; a row without one is a create. The same file goes through
GET and POST /api/admin/metaobjects/definitions/<definition id>/export
and .../import (?dry_run=true, then ?confirm=true), the door every
list in the admin has.
Every app's records share one table, so a type declares how many records it holds and the platform refuses the one past it, in its own words. A type that grows without bound is a log, and logs belong in the execution ledger, never in records.
A field
| Field | Required | What it is |
|---|---|---|
key |
yes | snake_case: lowercase letters, digits, underscores. Unique in the type. |
name |
yes | The label the merchant reads. |
kind |
yes | One of text, rich_text, number, boolean, date, file, color, reference_product, reference_collection, reference_page, reference_metaobject, coordinates. A coordinates value is { "lat": 42.6977, "lng": 23.3219 }, decimal degrees; the record page draws it on a map the merchant clicks, and a CSV cell carries it as lat,lng. |
required |
no | Enforced when a record is or becomes active; drafts may be incomplete. |
validations |
no | { min?, max? } (text: length, number: value), pattern? (text, a regex), metaobject_definition_id (required for reference_metaobject). |
Changing fields on a later deploy follows the platform's own rule: adding is free; removing a field or changing its kind is refused while records carry a value for it; making a field required is refused while an active record lacks it. Clear or migrate the records first.
A setting
{
"key": "maps_key", // snake_case, letters first
"name": "Maps API key",
"description": "From your maps provider's console",
"kind": "secret", // text | number | boolean | select | secret
"required": false,
"options": [ { "value": "light", "label": "Light" } ], // select only
"default": "light" // not for secret; must match the kind
}A secret is written on the app's Settings screen, stored encrypted by the
platform, never sent to a browser, and handed only to the app's own call at
GET /api/apps/me with the app's key.
A screen
{ "kind": "records", "key": "locations", "label": "Locations", "record": "location" }
{ "kind": "settings", "key": "settings", "label": "Settings" }A records screen names a declared record type. A settings screen needs at least one declared setting. Keys are slugs and unique.
A field on the store's own objects
{
"object": "product", // product | collection | order | customer
"key": "available_at", // snake_case, letters first; stored as <app key>.<key> on the object
"name": "Available at", // the label on the record's Custom fields card
"description": "The shops that carry it",
"kind": "metaobject_reference", // text | multi_line_text | number | boolean | date | select | multi_select | json | url | email | rich_text | metaobject_reference | product_reference | file
"list": true, // many values instead of one
"pinned": false, // shown first on the record's card
"visibility": "public", // public | private: public is served on the store API under the key
"options": ["a", "b"], // select and multi_select only
"record": "location" // metaobject_reference only: one of this app's record types
}The platform creates the field as one of the store's own custom fields,
owned by the app: it appears on every product's (collection's, customer's,
order's) Custom fields card like any other, the merchant fills it by hand
or the app fills it through its own door, and a public field is served on
the store API as metafields["<app key>.<key>"]. The merchant cannot edit
or delete it in Settings, Custom fields; the manifest is its truth, and it
leaves with the app at uninstall, values included.
The app reads and writes its own fields with its key and no scope:
GET /api/apps/fields, GET /api/apps/fields/<object>/<key> and
GET | POST | DELETE /api/apps/fields/<object>/<key>/<entity id>
(app-runtime-api.md). Reading the object itself is the
admin API's, within the app's scopes.
A later deploy follows the records' rule: adding a field is free; removing one, or changing its kind, is refused while a record carries a value for it. Clear the values first.
A scope
{ "area": "products", "access": "view", "reason": "Shows which shops carry each product" }Scopes are roles. An app declares the admin's own access areas, the words
the role editor uses, at one of its two levels: view reads every
resource of the area, manage does everything on it. One line per area.
The reason is the sentence the merchant reads at install.
| Area | Covers |
|---|---|
orders |
Orders, draft orders, payments, refunds, returns, exchanges, claims, fulfilment. |
products |
Products, variants, collections, categories, gift cards, files. |
inventory |
Stock levels, reservations, transfers, write-offs. |
purchasing |
Suppliers, purchase orders, receipts, landed cost. |
customers |
Customers, addresses, companies, customer groups. |
discounts |
Promotions, discount codes, price lists. |
content |
Pages, blog, menus, metaobjects, translations. |
analytics |
Sales, products, inventory and customer reports. |
documents |
Invoices, dispatch notes and the other order documents. |
taxes |
Tax regions, rates and providers. |
store |
Store details, languages, currencies, markets, sales channels, search. |
shipping |
Delivery options, shipping profiles, zones, carriers and locations. |
payments |
Payment methods and the checkout's rules. |
integrations |
Connections to couriers, fulfilment partners and other services. |
notifications |
The emails and notifications sent to customers and staff. |
An app never holds team, apps, billing: a program
cannot widen its own grant or touch the store's plan.
What the scopes open is the store's admin API, /api/admin/*, with the
app's own key as the bearer: view Products answers GET /api/admin/products,
manage Orders accepts the order writes. A call outside the scopes answers
403 app_scope naming the resource and the area to declare; a route the
admin's policy matrix does not name is closed to apps. An app with no
scopes reaches its own records, settings and fields through the runtime API
and nothing else.
The person deploying grants the scopes, and grants no more than they hold:
a member whose own access does not include an area the app asks for is
refused (403 scope_exceeds_grant) before anything is written. The owner
holds everything. Access levels: view, manage.
A function
{
"key": "notify", // snake_case, letters first; the name its runs are recorded under
"entry": "functions/notify.ts", // the source file inside the app folder (.ts, .tsx, .js, .mjs)
"name": "Notify the courier", // optional
"description": "Books the parcel when an order is placed", // optional, up to 140 characters
"input": { // optional: declared, the function is a TOOL (see Tools below)
"order_id": { "type": "string", "required": true, "description": "The order to book" },
"service": { "type": "string", "enum": ["standard", "express"] }
},
"output": { "tracking_number": { "type": "string" } } // optional: documented, never checked
}The platform hosts the app's server side. cartbase app deploy compiles
the entry file and its imports into one module, writes it under
.cartbase/functions/<key>.js beside the source (so a shared folder carries
its build) and sends it with the manifest; the platform loads it once to
check it exports a default function, keeps it, and runs it in its own
sandbox on the events and schedules below, or when a person or an agent
asks (cartbase app run <key>, the Run button on the app's home).
The file exports one default function, (input, context), sync or async,
whose return value is the run's result. Inside it: cartbase.get | post | patch | put | delete(path, body?) calls this store's API as the app
(/api/admin/* within the scopes, /api/apps/* for the app's own data),
fetch reaches the hosts in egress over https, console.* writes the
run's log. context carries trigger (event, schedule or manual),
the event or schedule when there is one, app, function, run_id
and settings with the secrets decrypted, here only. What the function
sees and can do is app-runtime-api.md § Functions.
Ceilings, per run: 30 seconds wall clock, 64 MB, 50 fetches and 100 platform calls, 10 seconds a call, 100 log lines, a 64 KB result; a compiled function is at most 200 KB. Per app: 5000 runs a day, whatever starts them, and 600 calls a minute on its key.
Every run is one row on the store's execution ledger under
app:<app key>:<function>: what started it, its input, its log and its
result or error. The app's home shows the latest; GET /api/admin/apps/<key>/runs and cartbase app runs list them.
An event
{ "event": "order.placed", "function": "notify" }One of the platform's events, routed to one of the app's functions, which
receives the event as its input: { id, name, created_at, data }, the
same body a webhook is posted. One line per event and function; one event
may run several functions. A function on events is a subscriber of the
store's event bus with the webhooks worker's own rules: the bus is drained
every minute, a failed run is retried on the ladder (5 minutes, 30, 2
hours, 12, 24) and then marked dead, twenty dead deliveries in a row switch
the function's events off until the next deploy, and events from before the
deploy are never replayed.
The events:
order.placed, order.updated, order.shipped, order.delivered, order.cancelled, order.refunded, customer.created, customer.account_created, customer.updated, customer.deleted, customer.merged, company.created, company.requested, company.approved, company.revoked, customer.tags_updated, customer.email_marketing_changed, marketing-flow.updated, cart.abandoned, cart.recovered, cart.reminder_sent, order.tags_updated, product.tags_updated, company.tags_updated, fulfillment.created, region.created, region.updated, region.deleted, product-collection.created, product-collection.updated, product-collection.deleted, customer-group.created, customer-group.updated, customer-group.deleted, customer-group.memberships_changed, price-list.refresh_requested, sales-channel.created, sales-channel.updated, sales-channel.deleted, order-edit.requested, order-edit.confirmed, order-edit.canceled, order.payment_link_sent, order.return_requested, order.return_received, order.exchange_created, order.claim_created, order.transfer_requested, order.completed, order.archived, shipping-option.created, shipping-option.updated, product-variant.created, product-variant.updated, product-variant.deleted, product-collection.memberships_changed, product-category.memberships_changed, payment.captured, payment.refunded, payment.attempt_failed, user.user.invite.token_generated, user.invite.accepted, document.issued, content-page.created, content-page.updated, content-page.deleted, blog.created, blog.updated, blog.deleted, blog-post.created, blog-post.updated, blog-post.deleted, media-file.created, media-file.deleted, workflow-execution.notify, menu.updated, product.created, product.updated, b2b.account.approved, review.submitted, review.updated, gift_card.issued, gift_card.redeemed, gift_card.disabled, purchase_order.created, purchase_order.sent, goods_receipt.confirmed, stock-ledger.entry.created, landed-cost.applied, stock-valuation.reposted, checkout-rule.created, checkout-rule.updated, checkout-rule.deleted, stock_transfer.completed, inventory.write_off, inventory.pack_relation.created, inventory.pack_relation.updated, inventory.pack_relation.deleted, inventory.unpacked, inventory.packed, metaobject.created, metaobject.updated, metaobject.deleted, app.installed, app.updated, app.disabled, app.enabled, app.uninstalled, app.published, app.unpublished, app.proposed, integration.enabled, integration.disabled, shipment.created, shipment.state_changed, platform.subscription.updated, platform.entitlement.granted, platform.entitlement.revoked, selling-plan.created, selling-plan.updated, selling-plan.deleted, subscription.created, payment-method.created, payment-method.updated, payment-method.deleted, subscription.renewed, subscription.payment_failed, subscription.past_due, subscription.paused, subscription.canceled, subscription.updated, feed.generated, feed.generation_failed, storefront.deploy.created, storefront.deploy.ready, storefront.deploy.failed, storefront.published, storefront.publish.failed, storefront.version.named, storefront.version.labels_updated, storefront.version.scheduled, storefront.version.schedule_canceled, storefront.version.address_minted, storefront.domain.added, storefront.domain.verified, storefront.domain.removed, storefront.domain.primary_set, sender_domain.verified, order.fulfillment_assigned, order.partner_pushed, order.partner_push_canceled, inventory-reservation.transitioned, supplier.created, supplier.updated, supplier.deleted, supplier.product_linked, supplier.product_updated, supplier.product_unlinked, stock_transfer.created, inventory-reservation.created, order.draft_created, fulfillment.inbound_created, fulfillment.canceled, fulfillment.shipped, payment-collection.created, payment-collection.updated, payment-collection.canceled, shipment.canceled, checkout.prepared, checkout.payment_session_rotated, checkout-method-order.updated, document.voided, document.emailed, document-sequence.updated, order-number-format.updated, shopify.installed, document-rule.created, document-rule.updated, document-rule.deleted, document-template.updated, nra-audit-settings.created, nra-audit-settings.updated, nra-audit-tender.updated, nra-audit-file.printed, nra-audit-file.sent, experiment.created, experiment.updated, experiment.started, experiment.ended, experiment-settings.updated, marketing-campaign.created, marketing-campaign.updated, marketing-campaign.status_changed, marketing.signup, loyalty.points_earned, loyalty.points_reversed, loyalty.points_adjusted, loyalty.points_expired, loyalty.points_expiring, loyalty.reward_expiring, loyalty.points_redeemed, loyalty.points_refunded, loyalty.reward_issued, loyalty.reward_used, loyalty.referral_claimed, loyalty.referral_completed, loyalty.referral_blocked, loyalty.referral_unblocked, loyalty.referral_canceled, loyalty.tier_changed, loyalty-tier.created, loyalty-tier.updated, loyalty-tier.deleted, loyalty-campaign.created, loyalty-campaign.updated, loyalty-campaign.started, loyalty-campaign.ended, loyalty-campaign.deleted, loyalty-reward.created, loyalty-reward.updated, loyalty-rule.created, loyalty-rule.updated, loyalty-settings.updated, loyalty-program.activated, loyalty-program.deactivated, loyalty-member.excluded, loyalty-member.included, loyalty-member.birthday_set, gift_card.updated, gift_card.balance_adjusted, gift_card.redemption_reversed, promotion.redeemed, promotion.redemption_reverted, payment-method.regions_changed, platform.subscription.checkout_started, platform.subscription.plan_change_requested, platform.subscription.cancel_scheduled, platform.subscription.cancel_resumed, platform.subscription.card_changed, platform.billing.period_closed, platform.billing.alert, platform.billing.payment_failed, platform.invoice.issued, purchase_order.submitted, purchase_order.status_changed, purchase_order.updated, purchase_order.deleted, purchase_invoice.created, purchase_invoice.confirmed, purchase_invoice.deleted, goods_receipt.created, goods_receipt.deleted, landed-cost.created, landed-cost.deleted, stock_transfer.cancelled, stock_transfer.deleted, inventory-reservation.updated, stock-ledger.entry.cancelled, inventory-level.adjusted, inventory-level.restocked, product-variant.pack_declared, product-variant.pack_cleared, stock_location.created, stock_location.partner_bound, stock_location.partner_unbound, product-variant.partner_linked, integration.settings_updated, order.partner_status_changed, partner_stock_sync.completed, email.sent, email.refused, email.failed, email.delivered, email.delayed, email.bounced, email.complained, email.opened, email.clicked, email.suppressed, email-suppression.created, email-suppression.released, sender_domain.added, sender_domain.removed, sender_domain.updated, store.mail_transport_changed, store.created, store.renamed, store.b2b_group_changed, store.ownership_transferred, store.support_access.opened, store.support_access.closed
A schedule
{ "key": "nightly_sync", "cron": "0 3 * * *", "function": "sync", "timezone": "Europe/Sofia" }A cron line, five fields (minute hour day month weekday) or a nickname
(@hourly, @daily, @weekly, @monthly), running one of the app's
functions with { schedule, at } as its input. timezone is an IANA name;
default UTC. The finest grain is a minute. The platform's clock runs
what is due once, never twice; a schedule that fails twenty times in a row
is switched off until the next deploy. A line that never fires, or a
timezone the platform does not know, is refused with the fix.
Egress
"egress": ["api.courier.example", "hooks.slack.com"]The hosts the app's functions may send data to: host names, lowercase, no
scheme, no path, never an address or localhost. Inside a function, fetch
to any other host is refused by name before a connection opens, and only
https is spoken. The list is the app's data-processing declaration: the
merchant reads it at install beside the scopes.
A viewport
{
"key": "shops", // a slug, unique in the app
"page": "product", // order | product | customer | collection
"title": "Shops that carry it", // the card's title, up to 40 characters
"records": { // optional: the app's records joined to the object
"type": "location", // one of the app's record types
"by": "product", // the field of it that holds the page's object id
"columns": ["city", "stock"] // shown beside the record's name, up to 4
},
"actions": [ // optional, up to 4: buttons that run functions on the object
{ "function": "check_stock", "label": "Check stock", "description": "Asks every shop" }
]
}A viewport is a card the admin draws on one of the store's own pages
(Stripe's word for it): the 10 newest records whose by field holds the
object's id, the count beside, each a link to the record's page under the
app, and the actions as buttons. On a product page the by field is a
reference_product or text field, on a collection page
reference_collection or text, on an order or customer page text (the
record stores the object's id). A viewport needs records, actions or both.
Nothing runs when the page opens: a records viewport is one query. An
action runs the function as a manual run, on the ledger like any other,
with { page, id, viewport } as its input, and the card shows the answer:
a string as is, an object's message, or the answer as JSON. Two apps on
one page are two cards. GET /api/admin/apps/viewports?page=&id= answers
the same cards to an agent.
Tools
Tools are derived, never written. Every function that declares input is a
tool, and every record type gives a list and a get. The catalogue is on
GET /api/apps/me as tools, on the app's detail and on its home:
{
"name": "store-locator.check_stock", // <app>.<function>, <app>.<type>.list, <app>.<type>.get
"kind": "function", // function | records
"title": "Check stock",
"description": "Asks every shop",
"input": { "order_id": { "type": "string", "required": true } },
"output": { "tracking_number": { "type": "string" } },
"call": { "method": "POST", "path": "/api/admin/apps/store-locator/functions/check_stock/run", "body": "{ \"input\": { ...the parameters } }" }
}A parameter is { type, description?, required?, enum? } with type one of
string, number, boolean, object, array, up to 20 of them; enum is for a string. The run door checks a
tool's input against the declaration before the sandbox starts: a missing
required parameter, an undeclared one, a wrong type or a value outside the
enum is refused as 400 invalid_input naming the parameter. output is
documented for the caller and never checked.