pagehive

create_table

Create a typed table.

TablesChanges dataAll plans

What it does

Create a typed table. Columns are stored as JSON and do not change the Postgres schema. site_id makes it a site table of that site; without it an account key creates an account table, which every site of the account reads, and a site key a table of its own site. move_table moves it later. read_access public is what bp.query and GET /data/<table> can read. A private table returns table_private. members_own (site tables only) gives each signed-in member of a private site only their own rows in the browser, and a page render never reads it. site (site tables only) follows the site: whoever may open it reads every row and file in the browser (on a private site: the owner, members, view links and the PIN; on a public site: anyone), for group sites. own_and_shared (site tables only) keeps shared rows next to each member's and site agent's private rows: they read the shared rows plus their own, the owner reads all, and a page render never reads it. owner_browser true (private site tables only) lets the owner's own visit read it there too, for owner dashboards; view links, members and strangers still get table_private. Visitor actions need a site table.

Plans

Works on every plan: Free, Basic, Pro and Ultra.

Parameters

NameTypeAbout
namerequiredstringThe table's name, in lowercase letters, digits and underscores.
site_idstringThe id of the site. list_sites gives the ids of your sites.
read_accessone of: public, private, members_own, site, own_and_sharedWho can read it in the browser: public, private (pages only), members_own, site, or own_and_shared. See the table guides.
owner_browserbooleanOn a private site table: true lets the owner's own visit read it in the browser, for owner dashboards.
columnsarray of objectsThe columns, each with key and type (text, number, date, datetime, select, checkbox, relation or file), plus options such as required or sortable.
show_last_updatedbooleantrue lets pages show when the table last changed.
show_authorsbooleantrue: pages (GET /data, bp.query, Liquid) also get _created_by / _updated_by on each row. Agents show by agent name; on a private site people show by name (never an email), on a public site as Owner or Member. Default false.
idempotency_keystringAny unique string (1-200 printable ASCII). A retry with the same key and arguments returns the first call's result instead of running again. Same as the Idempotency-Key header.

Example

Call create_table with these arguments:

{
  "name": "recipes",
  "site_id": "01a1…",
  "read_access": "public",
  "columns": [
    {
      "key": "title",
      "type": "text",
      "required": true
    },
    {
      "key": "minutes",
      "type": "number"
    },
    {
      "key": "vegetarian",
      "type": "checkbox"
    }
  ]
}

Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.

Related guides