Skip to content

Pages ​

  Table of Contents

Pages are custom screens built from a single HTML file containing JavaScript and CSS. Use them for station screens, dashboards, or focused workflows over Factorial's API. The code runs in the viewer's browser. Factorial stores the HTML in its configured object storage and serves it at /pages/<slug> on the same origin as the application.

Creating a page ​

  1. Open Pages → All pages in the main menu.
  2. Select New, enter a name and URL slug, then select Save.
  3. Open the page from the list, then describe it under Describe the page for AI to write it, or upload your own HTML under Settings.

All pages lists every page with its URL, status, and when it last changed. Search by name or URL, filter, and sort by name or by when pages changed. Select a page's name to open its details. The sparkles button on each row opens the page with the request box ready to type into.

A file may be at most 20 MB and must begin with an HTML doctype or element, such as <!doctype html>. Include scripts and styles in the file; additional uploaded assets and server-side code are not supported. Slugs use lowercase letters, numbers, and single hyphens, up to 80 characters. manage, create, and starter are reserved.

Published pages appear in the Pages menu, which shows the first 20 by name. A page with nothing published has no screen at its URL yet.

The Pages permission controls creating, renaming, replacing, publishing, restoring, and deleting pages. Administrators receive it automatically; grant it to other trusted authors through roles. Any signed-in user can open a published page, its details, and its versions; previewing a draft takes the Pages permission. A published page's API calls use that viewer's current permissions, and changes are attributed to that viewer through the API. That means a page's author decides what it does with an administrator's access when an administrator opens it, so grant the Pages permission only to people you would trust as administrators.

Asking AI to write a page ​

A page's details start with a request box. Describe what the page should show or do, such as "A dashboard of open work orders by queue, with this week's completions", and select Write page, or press Cmd+Enter. Writing a whole page can take a few minutes. It happens in the background: the details show Writing and update when the page is ready, and you can leave and come back. A page takes one request at a time, so the request box waits until the current one finishes.

The model writes a complete HTML page, and Factorial saves it as a draft. A draft isn't published: the page's URL keeps showing what it showed before. The draft appears under Draft preview, but doesn't run until you select Run preview, or Open full size to open it in its own tab. It then runs in your browser with your permissions, as the published page will for each viewer, so check what its buttons do before publishing. Only people with the Pages permission can preview a draft; everyone else sees that one is waiting.

To change a page, ask again under Ask for changes: the model edits the draft if there is one, or the published page if not, and keeps what you didn't ask to change. Each answer replaces the draft. When you're happy with it, select Publish to make it live, or Discard to drop it.

A request that doesn't produce a page says why above the request box, to people with the Pages permission, and leaves the draft as it was. The note stays for an hour, until you ask again or change the page, such as by uploading, publishing, restoring, or discarding. That covers a reply that isn't a page, such as when the API can't do what you asked, or a page the model was cut off writing. A server restart while Ask is writing ends the request without a draft. If you were watching, the details say Ask stopped before it finished; ask again. If the page was uploaded to, published, restored, or its draft discarded while the model was writing, the new draft is dropped rather than quietly undoing that change; ask again.

Factorial sends the provider your request, the page's current HTML (or the starter page for a new one), the Analytics views and columns, a list of the API's endpoints, and a few written instructions. It never sends rows or results. Pages the model writes read data mostly through Analytics queries, so their viewers need the Analytics permission to see those parts.

Asking uses the same AI keys and settings as Analytics: it is off until an administrator turns on AI features, and With, under the request, picks the key and model as described in Choosing a key and model. Without a key to ask with, the details show a short note saying what would turn it on instead. Hidden AI features remove the request box, the note, and the sparkles buttons. HTML over 40 KB is too large to edit this way, since the model writes the whole page back; upload changes instead. The model is asked to keep what it writes within that size.

Versions ​

Every time a page is published, Factorial keeps that HTML as a version: an upload, a draft written by AI with the last request asked of it, or a restore. Versions on the page's details lists them newest first, with who published each and how. The newest is live.

View opens a version in a new tab, running as it did when it was live. Restore publishes an older version again, right away. Restoring adds a new version rather than removing anything, so the version it replaced stays in the list and can be restored in turn. A draft waiting to be published is left as it is.

Updating and deleting ​

Under Settings, save a new name or slug, or upload replacement HTML. An upload publishes as soon as it succeeds, as a new version; a failed upload leaves the previous version live. A draft waiting to be published stays. Viewers reload the page to see the change. Changing the slug changes the URL; old links stop working.

Download HTML, beside Open page, retrieves the published file. Delete page removes the menu entry, stops serving its URL, and removes its draft and versions from the page. Uploaded files follow Factorial's existing file retention behavior; deleting a page does not purge its uploaded objects.

Calling the API ​

Use root-relative URLs beginning with /api/v1/. The browser automatically includes the signed-in session cookie for same-origin requests. The cookie is HttpOnly: JavaScript does not need to read it or copy it into an Authorization header. Do not embed API keys in pages.

js
const response = await fetch('/api/v1/tasks/query', {
  method: 'POST',
  credentials: 'same-origin',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ pagination: { next: 25 } })
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.error || `Request failed (${response.status})`);
}

const page = await response.json();
// page.items contains this batch. Continue with page.next_cursor when
// page.has_next_page is true, keeping the same query and sort order.

Writes use the same session. For example, starting a task:

js
await fetch('/api/v1/tasks/status', {
  method: 'PATCH',
  credentials: 'same-origin',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ task_ids: [taskId], status: 'IN_PROGRESS' })
});

Check every response before displaying a change as saved. A 401 means the viewer needs to sign in again; a 403 means their role does not allow the operation. Other errors include a JSON error message. Network failures may leave the outcome unknown: refresh the affected records before retrying a write.

Pages use ordinary API requests. They do not receive Factorial's built-in live page updates or session keepalive. Include a refresh button or deliberately spaced polling, and display when the data was last refreshed. Stop polling while the tab is hidden and avoid overlapping requests. Handle session expiry even while a custom page remains open.

Who's viewing ​

GET /api/v1/me returns the signed-in viewer's id, name, and email. Use it to greet the viewer or show their own work. For example, list the viewer's open tasks:

js
const meResponse = await fetch('/api/v1/me', { credentials: 'same-origin' });
if (!meResponse.ok) throw new Error(`Couldn't load the viewer (${meResponse.status})`);
const me = await meResponse.json();
const response = await fetch('/api/v1/tasks/query', {
  method: 'POST',
  credentials: 'same-origin',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    filters: [
      { r: ['ASSIGNEE'], f: 'id', o: 'EQ', v: me.id },
      { f: 'status', o: 'IN', v: ['TODO', 'IN_PROGRESS'] }
    ]
  })
});

Starter and API reference ​

Starter HTML on All pages provides a complete task board with pagination, refresh, error handling, and a Start action. Download it, edit it with your preferred coding tool, and upload it to a page. API calls work when the file is served by Factorial; opening it from your local filesystem does not provide a Factorial session.

API → API Docs, also linked from All pages as API docs, opens the generated reference at /api. API schema retrieves the OpenAPI document at /api/openapi.json. Give that document and the starter HTML to your coding agent so it can use the endpoints and request shapes available in your installed version. The reference supports requests using your browser session.

See API for queries, pagination, file uploads, and write behavior. Prefer the documented /api/v1/ endpoints when building pages.