Skip to content
AM

Entity types and custom_fields registry

The Accounting substrate query_records surface reads a fixed whitelist of CRM and Commerce entity types. This registry describes that read contract; it is not a catalog of every entity in the platform.

Entity registry

entity_typeSource tablePillar
crm_contactcrm.contactsCustomer 360
crm_companycrm.companiesCustomer 360
crm_activitycrm.activitiesCustomer 360
commerce_ordercommerce.ordersCommerce
commerce_productcommerce.productsCommerce
commerce_fulfillmentcommerce.fulfillmentsCommerce

Unknown values are rejected. Names such as contact, order, invoice, and journal_entry are not valid query_records entity types.

Query behavior

query_records reads the live OLTP tables and returns substrate: "oltp" with an as_of timestamp. Tenant isolation comes from row-level security after the service sets the tenant database context.

InputBehavior
limit omitted or less than 1Uses 100
limit greater than 1,000Clamps to 1,000
Negative offsetClamps to 0
Empty cel_filterNo filter
freshness_required_secondsPassed to Class B formula enrichment; it does not select a different data store

Filterable typed fields

Only the following typed fields can appear on the left side of a CEL predicate.

Entity typeTyped fields
crm_contactfirst_name, last_name, display_name, company_id, job_title, email, phone, status, lifetime_revenue, lifetime_orders, last_order_at, last_invoice_at, last_payment_at, last_activity_at, created_at, updated_at
crm_companyname, legal_name, website, industry, email, phone, status, tax_id, tax_exempt, lifetime_revenue, outstanding_balance, contact_count, created_at, updated_at
crm_activitycontact_id, company_id, activity_type, source_product, source_stream, actor_type, actor_id, summary, occurred_at, created_at
commerce_orderchannel_id, external_id, order_number, status, customer_id, subtotal, shipping_cost, tax, total, currency, shipped_at, delivered_at, created_at, updated_at
commerce_productsku, name, type, status, description, short_description, created_at, updated_at
commerce_fulfillmentorder_id, warehouse_id, status, tracking_number, carrier, shipping_method, shipping_cost, shipped_at, delivered_at, created_at, updated_at

Tenant IDs are deliberately excluded. Array and unrelated JSONB fields are also excluded from the typed whitelist.

Custom fields

The CEL translator permits explicit access to a key in the custom_fields JSONB object:

custom_fields.referred_by == "Instagram"

An unrecognized bare identifier does not fall back to JSONB. Use the custom_fields.<key> path explicitly.

Custom-field values are extracted as text on this surface. Compare them with string literals unless the field has a separate typed-column declaration.

Supported CEL subset

The shared translator supports:

  • Comparisons: ==, !=, <, <=, >, >=
  • Boolean composition: &&, ||, !
  • Membership: field in ["a", "b"]
  • Time builders: timestamp("RFC3339"), now(), and supported duration arithmetic
  • String operations: startsWith, endsWith, contains, matches, and size

Examples:

status == "paid" && total >= 100
created_at >= now() - duration("720h")
email.endsWith("@example.com")
custom_fields.region in ["north", "west"]

Literal values are bound as SQL parameters. Unsupported but syntactically valid CEL features map to a 501 subset error; malformed filters and unknown columns map to 400.

Write scope

The update_record tool may use the same entity-type vocabulary, but write support and approval tier are enforced separately. Read support on this page does not guarantee that every returned field is writable.