# App Data

The rows inside the tables of an app: what people add and change as they use an app. Who sees which rows is decided by the table: shared (everyone with access), own (each person sees their own rows; admins see all) or portal customer (a client sees only their own rows). Required scopes: app-data:read, app-data:write, app-data:delete.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /apps/:app_id/tables/:table_key/rows

Add rows to an app table, up to 50 in one call. Each row is { data: { <column key>: value } }. Values are checked against the table's columns and nothing is added if any row is wrong. A row belongs to the person adding it unless an admin names another owner; on a customer table say which contact it is for with portal_contact_id. On a table that is one of the workspace's spreadsheets kept on records, say which record each row is for (record: { type, id }): it goes on that record's sheet. The caller needs a share that lets them write rows.

**Scopes:** `app-data:write` — [full detail](./app-data/post-apps-app-id-tables-table-key-rows.md)

### DELETE /apps/:app_id/tables/:table_key/rows/:row_id

Delete one row from an app table. The caller can delete only rows they can see and may change. Waits for approval when called by an AI connection.

**Scopes:** `app-data:delete` — [full detail](./app-data/delete-apps-app-id-tables-table-key-rows-row-id.md)

### POST /apps/:app_id/tables/:table_key/files/complete

Step 2 of adding a file to an app table: call it after the PUT to upload_url. It reads the real type and size from the file itself, runs the virus check and publishes a clean file. A file that fails (wrong type, too big, virus found) is refused with the reason and nothing is kept. Safe to call again for the same file.

**Scopes:** `app-data:write` — [full detail](./app-data/post-apps-app-id-tables-table-key-files-complete.md)

### GET /apps/:app_id/tables/:table_key/rows/:row_id/files/:column

A short-lived link (5 minutes) to a file in one row's file column, with its name, size and type. For a "files" column pass file: the reference of the one wanted, taken from the value the row holds. The caller can get it only if they can see the row (some tables show each person only their own rows, or a client only their own customer's rows). Pass download=true for a link that saves the file instead of showing it.

**Scopes:** `app-data:read` — [full detail](./app-data/get-apps-app-id-tables-table-key-rows-row-id-files-column.md)

### GET /apps/:app_id/tables/:table_key/rows

List the rows of one app table that the caller is allowed to see (some tables show each person only their own rows, or a client only their own customer's rows). Sort by created_at, updated_at or a column key. Filter with filter, a JSON object: {"stage":"won"} for equals, or {"amount":{"in":["a","b"]}}, {"title":{"contains":"roof"}}, {"due":{"gte":"2026-11-01"}}. "At least" and "at most" (gte, lte) and "more than" and "less than" (gt, lt) work on number, money, date and datetime columns: {"amount":{"gte":1000}} is amounts of 1000 or more, {"amount":{"lte":5000}} is 5000 or less, and {"amount":{"gte":1000,"lte":5000}} is between the two. Numbers are compared as numbers, dates as dates (2026-11-01) and datetimes as times (2026-11-01T09:00:00Z). Each row holds only the fields the caller may see (the builder of the app can keep a field to the team, to clients, to admins or to some versions), and labels: the names of the records and rows its record columns point at. On a table that is one of the workspace's spreadsheets each row also says which record its sheet is kept on (record: { type, id, name }). Returns up to 200 rows and a cursor for the next page. Free read.

**Scopes:** `app-data:read` — [full detail](./app-data/get-apps-app-id-tables-table-key-rows.md)

### POST /apps/:app_id/tables/:table_key/files

Step 1 of adding a file to a row of an app table (a column of type "file", "files" or "signature"). Answers `file` (the reference to store in the row), `upload_url` and `upload_headers`. Then PUT the file's bytes to upload_url with exactly those headers (a plain HTTP PUT, no TrustPager key), call finish_app_file_upload, and store `file` in the row's file column with add_app_rows or update_app_row: as the value itself for a "file" column, inside a list for a "files" column (up to 20 files, send the whole list each time), or as { file, name } for a "signature" column (name is who signed; a PNG picture of at most 1 MB; a signed field must be cleared with null before it is signed again). Files can be up to 15 MB: pictures, PDFs, Word, Excel and PowerPoint files, CSV and text files. The caller needs a share that lets them write rows. A file reference not made this way is refused, so a row can only hold files uploaded to its own table.

**Scopes:** `app-data:write` — [full detail](./app-data/post-apps-app-id-tables-table-key-files.md)

### PATCH /apps/:app_id/tables/:table_key/rows/:row_id

Change one row: send only the column values that change (a null removes a value). The caller can change only rows they can see, and on a table where each person sees only their own rows, only their own. A field the caller may see but not change (its access.edit rule) is refused if its value changes; sending it back unchanged is fine.

**Scopes:** `app-data:write` — [full detail](./app-data/patch-apps-app-id-tables-table-key-rows-row-id.md)
