normalized table name (see TABLE ID in Raw Data) or numeric row ID in _grist_Tables
query Parameters
noparse
boolean
Set to true to prohibit parsing strings according to the column type.
onmany
string
Enum:"first""none""all"
Which records to update if multiple records are found to match require.
@@ -174,29 +176,29 @@ REST API for manipulating documents, workspaces, and team sites.
allow_empty_require
boolean
Set to true to allow require in the body to be empty, which will match and update all records in the table.
Request Body schema: application/json
The records to add or update. Instead of an id, a require object is provided, with the same structure as fields. If no query parameter options are set, then the operation is as follows. First, we check if a record exists matching the values specified for columns in require. If so, we update it by setting the values specified for columns in fields. If not, we create a new record with a combination of the values in require and fields, with fields taking priority if the same column is specified in both. The query parameters allow for variations on this behavior.
required
Array of objects
Responses
Request samples
Payload
Content type
application/json
{
"records": [
{
"require": {
"pet": "cat"
},
"fields": {
"popularity": 67
}
},
{
"require": {
"pet": "dog"
},
"fields": {
"popularity": 95
}
}
]
}
tables
Documents are structured as a collection of tables.
+
Request samples
Payload
Content type
application/json
{
"records": [
{
"require": {
"pet": "cat"
},
"fields": {
"popularity": 67
}
},
{
"require": {
"pet": "dog"
},
"fields": {
"popularity": 95
}
}
]
}
tables
Documents are structured as a collection of tables.
normalized table name (see TABLE ID in Raw Data) or numeric row ID in _grist_Tables
query Parameters
noadd
boolean
Set to true to prohibit adding columns.
noupdate
boolean
Set to true to prohibit updating columns.
@@ -204,7 +206,7 @@ REST API for manipulating documents, workspaces, and team sites.
Request Body schema: application/json
The columns to add or update. We check whether the specified column ID exists: if so, the column is updated with the provided data, otherwise a new column is created.
Also note that some query parameters alter this behavior.
Deprecated in favor of records endpoints. We have no immediate plans to remove these endpoints, but consider records a better starting point for new projects.
Deprecated in favor of records endpoints. We have no immediate plans to remove these endpoints, but consider records a better starting point for new projects.
Authorizations:
ApiKey
path Parameters
docId
required
string
A string id (UUID)
tableId
required
string
normalized table name (see TABLE ID in Raw Data) or numeric row ID in _grist_Tables
query Parameters
noparse
boolean
Set to true to prohibit parsing strings according to the column type.
Deprecated in favor of records endpoints. We have no immediate plans to remove these endpoints, but consider records a better starting point for new projects.
Deprecated in favor of records endpoints. We have no immediate plans to remove these endpoints, but consider records a better starting point for new projects.
Authorizations:
ApiKey
path Parameters
docId
required
string
A string id (UUID)
tableId
required
string
normalized table name (see TABLE ID in Raw Data) or numeric row ID in _grist_Tables
query Parameters
noparse
boolean
Set to true to prohibit parsing strings according to the column type.
This is a JSON object mapping column names to arrays of allowed values. For example, to filter column pet for values cat and dog, the filter would be {"pet": ["cat", "dog"]}. JSON contains characters that are not safe to place in a URL, so it is important to url-encode them. For this example, the url-encoding is %7B%22pet%22%3A%20%5B%22cat%22%2C%20%22dog%22%5D%7D. See https://rosettacode.org/wiki/URL_encoding for how to url-encode a string, or https://www.urlencoder.org/ to try some examples. Multiple columns can be filtered. For example the filter for pet being either cat or dog, AND size being either tiny or outrageously small, would be {"pet": ["cat", "dog"], "size": ["tiny", "outrageously small"]}.
sort
string
Example: sort=pet,-age
Order in which to return results. If a single column name is given (e.g. pet), results are placed in ascending order of values in that column. To get results in an order that was previously prepared manually in Grist, use the special manualSort column name. Multiple columns can be specified, separated by commas (e.g. pet,age). For descending order, prefix a column name with a - character (e.g. pet,-age). To include additional sorting options append them after a colon (e.g. pet,-age:naturalSort;emptyFirst,owner). Available options are: choiceOrder, naturalSort, emptyFirst. Without the sort parameter, the order of results is unspecified.
@@ -242,40 +244,40 @@ Also note that some query parameters alter this behavior.
The SQL query to run. This GET endpoint is a simplified version of the corresponding POST endpoint, without support for parameters or options. See the POST endpoint for details of what's allowed in the SQL query string.
Responses
Response samples
200
Content type
application/json
{
"statement": "select * from Pets ...",
"records": [
{
"fields": {
"id": 1,
"pet": "cat",
"popularity": 67
}
},
{
"fields": {
"id": 2,
"pet": "dog",
"popularity": 95
}
}
]
}
Run an SQL query against a document, with options or parameters
The SQL query to run. Must be a single SELECT statement, with no trailing semicolon. WITH clauses are permitted. All Grist documents are currently SQLite databases, and the SQL query is interpreted and run by SQLite, with various defensive measures. Statements that would modify the database are not supported.
Array of numbers or strings
Parameters for the query.
timeout
number
Timeout after which operations on the document will be interrupted. Specified in milliseconds. Defaults to 1000 (1 second). This default is controlled by an optional environment variable read by the Grist app, GRIST_SQL_TIMEOUT_MSEC. The default cannot be exceeded, only reduced.
Responses
Request samples
Payload
Content type
application/json
{
"sql": "select * from Pets where popularity >= ?",
"args": [
50
],
"timeout": 500
}
Response samples
200
Content type
application/json
{
"statement": "select * from Pets ...",
"records": [
{
"fields": {
"id": 1,
"pet": "cat",
"popularity": 67
}
},
{
"fields": {
"id": 2,
"pet": "dog",
"popularity": 95
}
}
]
}
+
Request samples
Payload
Content type
application/json
{
"sql": "select * from Pets where popularity >= ?",