Create, replace or delete a data table
set_dataAttach a data table to a page, replace it entirely, delete it, or open/close reader write-back. Tables are independent of versions: editing data never republishes the page and pushing a new version never changes tables. Call get_data first and pass the revision back unchanged: 0 creates, the current value updates; a mismatch is rejected (409) and requires re-reading, never blind overwrites. Provide rows (array of objects, optional columns for order) or csv (text, first line headers), not both; delete=true removes the table and its appended rows. append_open=true lets viewers append one row from the page with a plain form or POST ./_data/ (or the optional SDK space.data.append) (sign-ups, check-ins, votes, feedback): off by default, per table; passing append_open alone only flips the switch. Appended rows are rate-limited, moderated before other viewers see them, and readable only through list_data_rows; rows the author or another workspace member submits while signed in on the live page carry by=member. members_only=true accepts rows from workspace members only (visitors get 403) and, like append_open, can be passed on its own. In the page read (fetch('./_data/.json') / space.data.get) every viewer row carries _row_id, _at (submission time) and _status (approved / held); rows the current viewer submitted carry _mine: true and submitters can read their own held rows (never other people's); when the viewer is a member, member rows add _by (nickname). A submitter can withdraw their own row within 24 hours with DELETE ./_data//<row_id>. Columns the table does not have are accepted but not stored, and the receipt carries warnings (unknown_columns). Table names start with a lowercase letter and contain only letters, digits and underscores. The receipt states the per-table, per-page and workspace limits with current usage.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| csv | No | CSV text, first line is the header; either this or rows | |
| rows | No | Array of objects, one per row, keys are column names; either this or csv | |
| table | Yes | Table name, e.g. items or sales_2026 | |
| delete | No | true = delete this table (no rows or csv needed) | |
| columns | No | Optional: column order and selection (rows only) | |
| identity | No | Reader WeChat profile: off = anonymous (default) · wechat = only readers who tapped “Join with WeChat”, each row carries _by (nickname, avatar) · wechat_optional = rows carry the profile when the reader authorised, anonymous otherwise. The page reads the current reader with space.me() and asks for authorisation with space.me.request(). Passing it alone only flips the switch | |
| revision | Yes | 0 to create; the current value from get_data to replace or delete | |
| vote_key | No | Which column per_reader=vote counts one vote per reader per value on (must be a table column, e.g. item). Can be passed with per_reader or alone, with `revision`. | |
| per_reader | No | One row per identity: off (default) allows repeats; one rejects repeats with 409; latest shows only the latest row per person on the page and keeps history in list_data_rows; vote allows one vote per reader per value (also pass vote_key=<column>; a repeat vote for the same value gets 409 reader_already_voted; withdrawing your own row frees it, with no 24-hour limit). Requires identity=wechat or wechat_optional. Anonymous rows are unrestricted; members use their user id. Withdrawal does not free a one slot. Can be set alone with `revision`. | |
| append_open | No | 读者写回开关:true 开、false 关。单独传 = 只翻开关(底表不动,仍要带 revision) | |
| proposal_id | Yes | ||
| members_only | No | Accept write-back from workspace members only: when true, visitor submissions get 403. Passed alone = only flips the switch (`revision` still required) | |
| notify_emails | No | 新提交邮件通知:最多 3 个收件邮箱,读者每交一行(过审)发一封邮件给它们,附全部字段;新地址先收确认信、点确认后才发;[] = 不再通知。可单独传 | |
| identity_visibility | No | Who sees participants' nicknames and avatars: all = every reader (default) · author = only the author and workspace members. Passing it alone only flips the switch |