Skip to main content

Preview Home Page

POST 

/api/admin/portal/home/preview

Preview a draft of the Home page blocks, before saving, as one dealer would see it or as an overview of what all dealers can see. Nothing is saved.

Required scope: customers:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Body fields:

  • customer_id (required, integer or null): the dealer to view the draft as, which must be a customer with a portal account. Null = the "All dealers" view.
  • blocks (required, array, at most 20 blocks; may be empty): the draft layout, validated as in Update Home Page Blocks, except that audience catalogs, categories and image files that no longer exist (or categories that are archived) are not refused. A catalog that no longer exists matches no dealer; an archived or deleted category is listed in dropped as deleted_target; image files are not checked at all, so an item whose file is gone stays in the layout, exactly as on the buyer's real Home page.

Each block:

  • type (required): a built-in section, announcements, account_summary, spend_progress, featured or order_again, or a custom block, banner_carousel, link_tiles, category_tiles, brand_tiles or product_grid. Each built-in may appear at most once; a built-in left out is added back, visible, at the end. Custom blocks may repeat.
  • id (optional, string up to 40 characters, or null): a custom block's id from a previous response, to keep it. Null, or an id the last save did not have, creates a new block with a new ULID. Built-ins ignore it: their id is always their type.
  • visible (optional, boolean, default true): false hides the block from every buyer. A built-in only uses type and visible.
  • heading (optional, string up to 60 characters, or null): the title shown over a custom block.
  • audience (optional, object or null): catalog_ids null (or no audience) = every dealer; a list of portal catalog ids = only dealers on at least one of those catalogs; an empty list = no dealer. Each id is a positive integer; a save also needs it to be an existing, not deleted, portal catalog ("One of the chosen catalogs no longer exists. Remove it and save again.").
  • settings (optional, object or null):
    • auto_advance (optional, boolean, default false) and interval (optional, seconds between slides: 5, 7 or 10; default 7): banner carousels only.
    • columns (optional, integer): 2, 3 or 4 for link tiles; 3, 4 or 6 for category tiles and product grids (default 4); 4, 6 or 8 for brand tiles (default 6).
    • link_to (optional, catalog or assets, default catalog): brand tiles only. catalog opens the catalog filtered to the brand; assets opens the brand's assets link in a new tab (a brand without one opens its catalog page).
    • count (optional, 4, 8, 12, 16 or 24, default 8): product grids only. How many products show at first, and how many each "Load more" adds.
    • sort (optional, name, price_asc, price_desc or newest, default name): product grids only. Prices sort by each dealer's own price.
  • slides (banner_carousel, required: 1 to 8). Each slide:
    • id (optional, string up to 40 characters, or null): the slide's id from a previous response, to keep it; otherwise a new ULID is given.
    • image (required, object): the desktop artwork, {path, width, height} as returned by Upload Home Page Image with kind = slide. path (required, up to 255 characters) is the uploaded file: under portal/home/ and ending in .jpg, .jpeg, .png, .webp, .svg or .gif. A save also needs the file to still exist ("This image is missing. Upload it again."), and applies the same check to mobile_image and tile images; width and height are optional integers of at least 1.
    • mobile_image (optional, same object, or null): artwork for phones, uploaded with kind = slide_mobile.
    • alt (required, string up to 160 characters): describes the slide for people who cannot see it.
    • link (optional, link object or null): where the slide goes when clicked.
    • starts_at / ends_at (optional, ISO-8601 date-time or null): when the slide is shown. ends_at must be after starts_at; null start = now, null end = never ends. A value without an offset is read as UTC; dates are stored in UTC.
  • tiles (link_tiles, required: 2 to 8). Each tile:
    • id (optional, string up to 40 characters, or null): as for slides.
    • label (required, string up to 40 characters): must be unique within the block, ignoring case.
    • caption (optional, string up to 80 characters, or null).
    • icon (string, or null): one of the curated icon names: mdi-star-outline, mdi-lightning-bolt-outline, mdi-cart-outline, mdi-clipboard-list-outline, mdi-file-document-edit-outline, mdi-receipt-text-outline, mdi-cash-multiple, mdi-credit-card-outline, mdi-truck-outline, mdi-truck-fast-outline, mdi-package-variant-closed, mdi-keyboard-return, mdi-shield-check-outline, mdi-tag-outline, mdi-sale-outline, mdi-percent-outline, mdi-heart-outline, mdi-fire, mdi-new-box, mdi-gift-outline, mdi-trophy-outline, mdi-file-download-outline, mdi-book-open-variant, mdi-school-outline, mdi-video-outline, mdi-image-outline, mdi-palette-outline, mdi-storefront-outline, mdi-map-marker-outline, mdi-calendar-star, mdi-clock-outline, mdi-headset, mdi-phone-outline, mdi-email-outline, mdi-help-circle-outline, mdi-information-outline, mdi-cog-outline, mdi-tools, mdi-wrench-outline, mdi-bike. Any other name is refused with "Pick one of the listed icons."
    • image (object, or null): {path, width, height} uploaded with kind = tile. A tile needs exactly one of icon and image.
    • link (required, link object).
  • categories (category_tiles, required: 1 to 12). Each entry:
    • id (required, positive integer): a product category, at most once per block (the same category may appear in different blocks). A save also needs the category to exist and not be archived ("This category is archived or no longer exists. Remove it and save again.").
    • label (optional, string up to 40 characters, or null): shown instead of the category name.
    • image (optional, object or null): the tile's own picture, {path, width, height} uploaded with kind = tile. Without one the tile shows the category's own image.
  • brands (brand_tiles, required: 1 to 24). Each entry:
    • id (required, positive integer): a product brand, at most once per block. A save also needs the brand to exist ("This brand no longer exists. Remove it and save again.").
    • label (optional, string up to 40 characters, or null): shown instead of the brand's portal name (and used as the tile's accessible name). The tile shows the brand's logo, or its name when it has none.
  • source (product_grid, required, object): where the grid's products come from.
    • type (required): category, brand or collection.
    • id (required, positive integer): the category, brand or tag id. A save needs the category to exist and not be archived, the brand to exist, and the tag to be published as a collection ("This tag is not a published collection. Publish it under Catalog display, or choose another."). Items that do not belong to a block's type (for example tiles on a banner) are not stored.

A link is an object:

  • type (required): catalog (the whole catalog), category, brand, tag, page (an info page), portal (a portal page) or url (a web address).
  • id: the category or brand id; a positive integer, required for category and brand. Optional for tag, so a renamed tag is still followed.
  • value: for tag the tag name (up to 100 characters); for page the info page slug (lower-case letters, numbers and dashes, for example returns-policy); for portal one of home, catalog, brands, quick-order, special-order-list, lists, quotes, orders, invoices, returns or my-company; for url an address starting with https://, http://, mailto: or tel: (up to 2,048 characters). Ignored for other types.
  • new_tab (optional, boolean, default false): opens a url link in a new browser tab. Ignored for other types. Only the keys a type uses are stored.

Unlike a save, the preview keeps every block, slide and tile id you send (only a blank, repeated or over-40-character id is replaced with a new ULID), so the response can be matched to the draft. Use any temporary ids for new items.

The response has exactly the keys a buyer gets from Get Home Page in the portal API (announcements, stats, spend_progress, featured, recent_orders, saved_lists and layout), worked out the same way, plus dropped, is_preview_account and blocks_version:

  • With a dealer: the dealer's real Home page with the draft blocks in place of the saved ones, as one of the dealer's buyers (a dealer without buyers yet is previewed as a new buyer; none is created). Audiences, schedules and the dealer's catalogs all apply.
  • With null: every visible block, and every slide, tile and category whose target still exists, whatever the audience or catalog; slide schedules still apply. Built-in sections show sample content: the live announcements, zero for every stat, the featured products at list price, and no recent orders, saved lists or spend progress.
  • A hidden built-in section returns null, as it does for buyers.

dropped lists everything in the draft that the preview does not show. Each entry has block_id, item_id (the slide or tile id, the category id for a category tile, or null when the whole block is left out) and reason:

  • hidden: the block is not visible.
  • audience: the dealer is not on any of the block's catalogs (never in the "All dealers" view).
  • scheduled / expired: the slide's start is in the future, or its end has passed.
  • not_in_catalog: the viewer cannot reach the slide's or tile's link (for example a category or brand outside the dealer's catalog), or the category tile's category is not in the dealer's catalog.
  • deleted_target: the linked category or brand, or the tile's category, is archived or deleted.
  • empty: nothing is left in a custom block for this viewer, so the block is left out.

is_preview_account is true when the viewed dealer's portal account is in preview (an applicant who can look around before approval, so their Home shows announcements, featured products and quotes only). It is false for every other dealer and for the "All dealers" view.

blocks_version is the version of the saved blocks, as in Get Portal Home Page, not of the draft.

A customer_id that is not a customer with a portal account returns 422 under errors.customer_id; invalid blocks return 422 as for a save. Limited to 120 requests a minute.

theme is {primary_color, on_primary_color}: the colours the viewed portal is drawn in (the dealer's store brand, else the portal default), so a preview can be painted like the dealer's page. compare_at_label is the merchant's was-price label (for example RRP), or null when none is set: show it in front of each product's compare_at_price. The "All dealers" view (customer_id null) prices at list price and shows stock as statuses ("In stock"), since no one dealer's quantity setting applies to all.

Requires a staff bearer token with portal management permission.

Request​

Responses​

OK

Response Headers
    Content-Type