Data Dictionary

Canonical reference for every data model and backend function endpoint.

Built-in fields (every entity)

All entities automatically include: id (string), created_date, updated_date, and created_by_id (the authenticated user who created the record). These are managed by the platform and never set by client code.

Listing

The core marketplace record. A listing represents livestock, equipment, feed, property, services, or other rural goods posted by a user. New listings start in Pending approval and require admin approval before going live.

FieldTypeDescription
titlerequiredstringListing title (max 200 chars).
descriptionstringFull listing description (max 10,000 chars).
categoryrequiredenumLivestock · Farm Equipment · Hay, Feed & Seed · Farm Supplies · Property & Agriculture · Services · Pets & Companion Animals · Miscellaneous.
subcategorystringSubcategory (e.g. Cattle, Tractors, Round Bales).
pricenumberAsking price in USD. Null = contact for price.
price_typeenumFixed · Negotiable · Auction · Contact for Price (default Fixed).
conditionenumNew · Like New · Good · Fair · Salvage · N/A (default N/A).
imagesstring[]Image URLs (max 20). First image is the cover.
cityrequiredstringCity.
staterequiredstringState.
zip_codestringZIP code.
contact_namestringDisplay name for the poster.
contact_phonestringServer-anchored to the poster's profile phone.
contact_emailstringServer-anchored to the poster's verified account email.
specsobject<string,string>Key-value attributes (Breed, Year, Make, Model, Acres, etc.).
statusenumActive · Sold · Pending · Expired (default Active).
approval_statusenumPending · Approved · Rejected. Server-set only.
rejection_reasonstringReason given to the poster when rejected.
discounted_pricenumberAdmin-overridden discounted sale price.
promo_partnerstringVendor/partner name for promotional listings.
viewsnumberView counter (incremented server-side).
inquiriesnumberInquiry counter (incremented server-side).
fb_postedbooleanWhether posted to the Facebook page.
fb_posted_datedateDate last posted to Facebook.
fb_post_idstringFacebook post ID (pageId_postId).

RLS — Row-Level Security

Read: public (empty rule). Create / Update: admin-only via direct SDK — normal users must go through the create-listing and update-listing backend functions, which run as service role and enforce field control. Delete: the record owner or an admin.

Inquiry

A message from a buyer to a listing owner. Buyers may be anonymous (no account required). The listing_owner_id field anchors RLS so only the listing owner and admins can read and manage inquiries on their listings.

FieldTypeDescription
listing_idrequiredstringID of the listing inquired about.
listing_owner_idstringUser ID of the listing owner — anchors RLS.
sender_namerequiredstringBuyer's name.
sender_emailstringBuyer's email (optional).
sender_phonestringBuyer's phone (optional).
messagerequiredstringThe inquiry message.
descriptionstringOptional additional details (max 1,000 chars).
statusenumNew · Read · Replied (default New).

RLS

Read / Update: the listing owner (matched on listing_owner_id == user.id) or an admin. Create: public (buyers need no account). Delete: admin-only.

BlogPost

An editorial blog post. Published posts are auto-shared to the Barnyard Listing Facebook page.

FieldTypeDescription
titlerequiredstringPost title.
bodystringFull post content (plain text / light markdown).
excerptstringShort summary shown in cards and the Facebook post.
image_urlstringCover image URL.
categoryenumGeneral · News · Tips & Guides · Announcement · Market Update · Featured (default General).
statusenumDraft · Published (default Draft).
published_datedateDate published.
authorstringAuthor name.
fb_postedbooleanWhether pushed to Facebook.
fb_posted_datedateDate last pushed to Facebook.
fb_post_idstringFacebook post ID (pageId_postId).

RLS

Read: public. Create / Update / Delete: admin-only.

FacebookPost

An audit log record of every listing or blog post pushed to the Barnyard Listing Facebook page.

FieldTypeDescription
listing_idrequiredstringID of the listing or blog post promoted.
listing_titlestringTitle at time of posting.
categorystringListing category.
subcategorystringListing subcategory.
fb_post_idrequiredstringFacebook post ID (pageId_postId).
messagestringThe policy-safe message that was posted.
page_idstringFacebook page ID.
page_namestringFacebook page name.
posted_daterequireddateDate posted.
sourceenumlisting · blog (default listing).
linkstringThe public URL shared in the post.

RLS

All operations (create / read / update / delete) restricted to admins. This is an internal audit table.

User

The built-in platform user. Users join via invite; records cannot be created directly through the SDK. The phone field is the user's profile phone, shown on their listings.

FieldTypeDescription
rolerequiredenumadmin · user.
phonestringProfile phone — shown on the user's listings. Set from the Dashboard profile tab.
full_namestringDisplay name (read-only, platform-managed).
emailstringVerified account email (read-only, platform-managed).

Built-in security

Only admins can list, update, or delete other users. A user updates their own profile (e.g. phone) via base44.auth.updateMe().

Backend Function API Reference

Backend functions are HTTP handlers deployed at /functions/<name>. From the frontend, invoke them through the SDK: base44.functions.invoke('name', payload) — never a raw fetch. All functions return JSON.

create-listing

Auth: logged-in user Creates a listing. Validates and whitelists user fields; sets all system/moderation fields server-side. Contact email & phone are anchored to the authenticated account.

Request

POST /functions/create-listing
{
  "title": "Angus Cow — Bred Heifer",
  "category": "Livestock",
  "subcategory": "Cattle",
  "description": "...",
  "price": 1200,
  "price_type": "Fixed",
  "condition": "Good",
  "city": "Austin", "state": "TX", "zip_code": "78701",
  "images": ["https://..."],
  "specs": { "Breed": "Angus" },
  "contact_name": "Jane"
}

Response (200)

{ "ok": true, "id": "<listing_id>" }

update-listing

Auth: owner or admin Partial update of a listing. Verifies ownership; strips all system fields. Contact email & phone are re-anchored to the account on every call.

Request

POST /functions/update-listing
{ "id": "<listing_id>", "title": "...", "price": 1100, ... }

Response (200)

{ "ok": true, "listing": { ...updated } }

admin-portal

Auth: admin A single multiplexed endpoint for moderation actions. The action field selects the operation.

FieldTypeDescription
approve_listingactionApprove a listing → Active, emails creator, auto-posts to Facebook.
reject_listingactionReject a listing (requires reason), emails creator.
unpublish_listingactionPull a live listing back to Pending review, emails creator.
discount_listingactionSet discounted_price / promo_partner.
delete_listingactionAdmin deletes a listing.
approve_adactionApprove an ad → Active, emails advertiser.
reject_adactionReject an ad (requires reason), emails advertiser.
create_adactionAdmin-authored vendor ad (no payment).
update_adactionEdit an existing ad.
publish_blogactionPublish a blog post + auto-post to Facebook.
delete_blogactionDelete a blog post.

create-checkout

Auth: admin Creates a Wix (Base44 Payments) subscription checkout session for an ad and persists a pending Advertisement linked by checkout_id. Returns a redirect URL.

Request

POST /functions/create-checkout
{
  "plan": "Monthly",            // Monthly | Quarterly | Annual
  "business_name": "Acme Feed",
  "headline": "Quality feed, delivered",
  "target_url": "https://acme.com",
  "contact_phone": "555-123-4567",
  ...
}

Response (200)

{ "redirectUrl": "https://...wix checkout URL..." }

wix-payments-webhook

Auth: JWT (Wix) Receives Wix payment events. Verifies the RS256 JWT with WIX_PAYMENTS_WEBHOOK_PUBLIC_KEY. On order_approved, moves the matching ad to Pending Review and stores the subscription ID. On subscription cancel/expire, marks the ad Expired. Registered for ORDER_APPROVED, SUBSCRIPTION_CANCELED, SUBSCRIPTION_ENDED.

notify-admin

Auth: authenticated Emails all admin users. Action: new_listing (poster must be logged in & own the listing). All user-supplied text is sanitized against header/HTML injection. Inquiry notifications are handled internally by submit-inquiry.

increment-listing-stat

Auth: public Increments views or inquiries on a listing. Runs as service role (Listing RLS blocks anonymous writes). Rate-limited to one increment per IP + listing + field per minute.

Request

POST /functions/increment-listing-stat
{ "listing_id": "<id>", "field": "views" }

post-to-facebook / post-blog-to-facebook

Auth: admin Manually trigger a Facebook cross-post for a listing or blog post. (Approval also auto-triggers listing posts.) Both delegate to the shared fb-post.ts module, which runs an AI safety check on photos before posting.