> ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # Update a query of a Tulip Table > Updates a query in a Tulip Table by the query id Requires the `table-queries:write` API key scope. ## OpenAPI ````json PUT /tables/{tableId}/query/{queryId} { "openapi": "3.0.3", "info": { "title": "Tulip API", "description": "The Tulip API gives you programmatic access to your Tulip data.\n\n### Query Parameters\n\nSome Tulip API endpoints take parameters specified in the [URL query](https://en.wikipedia.org/wiki/Query_string). In the Tulip API, the URL query is expected to be a list of key-value pairs, with pairs separated by `&`, keys and values separated by `=`, and keys and values being [percent-encoded](https://en.wikipedia.org/wiki/Percent-encoding). Keys are parsed as strings, values *must* be present for each key, and values are parsed as JSON. Simple string values may be specified as-is instead of being JSON-encoded. A query parameter may be specified multiple times, but only the final value will be used. Examples (shown without percent encoding for readability):\n\n * `a=1&b=true&c=\"hello\"` would parse a parameter `a` as the number 1, `b` as the boolean `true`, and `c` as the string `hello`\n * `a=foo&b=\"foo\"` would parse a parameter `a` as the string `foo` and `b` as the string `foo`\n * `data={\"points\":[{\"x\":3,\"y\":4},{\"x\":2,\"y\":-9}]}` would parse a parameter `data` as an object with a single field `points` containing an array with two elements: an object with `x` as the number 3 and `y` as the number 4, and an object with `x` as the number 2 and `y` as the number -9\n * `a=foo&a=bar` would parse a parameter `a` as the string `bar`\n", "termsOfService": "https://tulip.co/tos/", "contact": { "name": "Tulip Interfaces", "url": "https://tulip.co/contact-us/", "email": "sales@tulip.co" }, "version": "3.0" }, "servers": [ { "url": "http://localhost:8088/api/v3", "description": "Cypress Tulip API Server" } ], "paths": { "/tables/{tableId}/query/{queryId}": { "parameters": [ { "$ref": "#/components/parameters/tableId" }, { "$ref": "#/components/parameters/queryId" } ], "put": { "summary": "Update a query of a Tulip Table", "description": "Updates a query in a Tulip Table by the query id\n\nRequires the `table-queries:write` API key scope.\n", "operationId": "updateTableQuery", "x-tulip-visibility": "public", "tags": [ "Tulip Tables" ], "security": [ { "apiKey": [ "table-queries:write" ] } ], "requestBody": { "description": "The updated Tulip Table query. All fields must be set.\n", "content": { "application/json": { "schema": { "type": "object", "properties": { "tableId": { "description": "The ID of the Tulip Table that the query is being created on.\n", "type": "string" }, "label": { "description": "The display label for the query.\n", "type": "string", "minLength": 1, "maxLength": 255 }, "filters": { "description": "The filters that the query uses.\n", "type": "array", "maxLength": 100, "items": { "$ref": "#/components/schemas/TulipTableFilter" } }, "filterAggregator": { "description": "The aggregator of all filters defined on the query.\n", "type": "string" }, "sortOptions": { "description": "The sorts that will order the records returned by the query.\n", "type": "array", "maxLength": 100, "items": { "$ref": "#/components/schemas/TulipTableSortOption" } }, "limit": { "description": "The number of records that the query returns.\n", "type": "number", "minimum": 1, "maximum": 1000, "default": 1000 } }, "required": [ "tableId", "label", "limit" ] } } } }, "responses": { "200": { "description": "The Tulip Table query was updated successfully. The details of the updated Table query are returned in the response.\n", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TulipTableQuery" } } } }, "400": { "$ref": "#/components/responses/badRequestError" }, "401": { "$ref": "#/components/responses/authenticationRequiredError" }, "403": { "$ref": "#/components/responses/authenticationFailedError" }, "404": { "$ref": "#/components/responses/notFoundError" }, "422": { "$ref": "#/components/responses/badRequestError" }, "500": { "$ref": "#/components/responses/internalServerError" } } } } }, "components": { "parameters": { "tableId": { "name": "tableId", "description": "The id of a Tulip Table.\n", "in": "path", "required": true, "schema": { "$ref": "#/components/schemas/ObjectId" } }, "queryId": { "name": "queryId", "description": "The id of a Tulip Table query.\n", "in": "path", "required": true, "schema": { "$ref": "#/components/schemas/ObjectId" } } }, "schemas": { "TulipTableFilter": { "x-tulip-visibility": "public", "description": "The filters can use any of the columns defined in the Tulip Table (including `_createdAt` and `_updatedAt`) that the query exists on with any of the functions.\n", "example": { "_id": "abcdefg", "field": "Color", "functionType": "equal", "value": { "datasourceType": "static", "params": { "value": "yellow" } } }, "type": "object", "properties": { "_id": { "type": "string" }, "field": { "type": "string" }, "functionType": { "type": "string", "enum": [ "equal", "notEqual", "blank", "notBlank", "greaterThanOrEqual", "lessThanOrEqual", "greaterThan", "lessThan", "contains", "notContains", "startsWith", "notStartsWith", "endsWith", "notEndsWith", "isIn", "notIsIn" ] }, "value": { "description": "The value to compare to.\n\nIf `datasourceType` is set to `\"app-info\"`, then `params` is not required.\n\nIf `datasourceType` is set to `\"static\"`, then `params` is required.\n", "type": "object", "properties": { "datasourceType": { "type": "string", "enum": [ "static", "app-info" ] }, "params": { "type": "object", "properties": { "value": { "description": "The static value to compare to. Must be of the same type as the data in the column specified by `field`.\n" } } } }, "required": [ "datasourceType" ] } }, "required": [ "_id", "field", "functionType" ] }, "TulipTableSortOption": { "x-tulip-visibility": "public", "description": "Sorts are used to order the queries based on columns defined in the Tulip Table where the query exists.\n", "example": { "sortBy": "Color", "sortDir": "asc" }, "type": "object", "properties": { "sortBy": { "description": "The field that records should be sorted by in the response. Can be the name of any of the columns of the Table (including `id`) or one of these special values:\n* `_sequenceNumber`\n* `_createdAt`\n* `_updatedAt`\n", "type": "string" }, "sortDir": { "description": "The direction of the records, either ascending or descending\n", "type": "string", "enum": [ "asc", "desc" ], "default": "asc" } }, "required": [ "sortBy", "sortDir" ] }, "TulipTableQuery": { "x-tulip-visibility": "public", "description": "A Tulip Table query that exists on a Tulip Table. The record object will include all the fields of the query, addition to the record's created timestamp and last updated timestamp.\n", "example": { "id": "PRYGkKgnqySMcpWwr", "createdAt": "2019-01-15T17:30:01.244018Z", "createdBy": "N24uug8iXSTWR39rB", "updatedAt": "2019-01-15T17:31:20.002696Z", "updatedBy": "N24uug8iXSTWR39rB", "tableId": "b93Aj93KlIoaw", "label": "Basic Query", "filters": [ { "_id": "aidv93mise9", "field": "Color", "functionType": "equal", "value": { "datasourceType": "static", "params": { "value": "yellow" } } }, { "_id": "jfsa093m9ds", "field": "ID", "functionType": "notEqual", "value": { "datasourceType": "static", "params": { "value": "a" } } } ], "filterAggregator": "all", "sortOptions": [ { "sortBy": "Color", "sortDir": "asc" } ], "limit": 1000 }, "type": "object", "properties": { "_createdAt": { "allOf": [ { "description": "The time this record was created.\n" }, { "$ref": "#/components/schemas/DateTime" } ] }, "_updatedAt": { "allOf": [ { "description": "The time this record was last updated.\n" }, { "$ref": "#/components/schemas/DateTime" } ] }, "tableId": { "description": "The ID of the Tulip Table that the query exists on.\n", "type": "string" }, "label": { "description": "The name of the Tulip Table Query.\n", "type": "string" }, "filters": { "description": "The filters that are applied on this Tulip Table Query.\n", "type": "array", "items": { "$ref": "#/components/schemas/TulipTableFilter" } }, "filterAggregator": { "allOf": [ { "$ref": "#/components/schemas/TulipTableFilterAggregator" }, { "description": "How the filters applied on this Tulip Table Query are aggregated.\n" } ] }, "sortOptions": { "description": "The field and sorting direction used to sort the query results\n", "type": "array", "items": { "$ref": "#/components/schemas/TulipTableSortOption" } }, "limit": { "description": "The number of records that will be returned at most from this Tulip Table query.\n", "type": "number" } }, "required": [ "tableId", "label", "limit" ] }, "ObjectId": { "$ref": "#/components/schemas/RandomId" }, "DateTime": { "x-tulip-visibility": "public", "description": "A date-time string as defined by [RFC 3339 ยง5.6](https://tools.ietf.org/html/rfc3339#section-5.6).\n", "type": "string", "format": "date-time" }, "TulipTableFilterAggregator": { "description": "How the filters in a table filter are combined.\n- `all` means that every filter must match a record in order for the record to be included.\n- `any` means at least one filter must match a record in order for the record to be included.\n", "type": "string", "enum": [ "all", "any" ], "default": "all" }, "ApiError": { "x-tulip-visibility": "public", "type": "object", "properties": { "errorCode": { "type": "string" }, "errorUniqueID": { "$ref": "#/components/schemas/RandomSecret" }, "details": { "type": "string" } }, "required": [ "errorCode", "details" ] }, "RandomId": { "x-tulip-visibility": "public", "example": "g56RCoZCtzv7borvp", "type": "string", "pattern": "^[a-zA-Z0-9_]+$" }, "RandomSecret": { "x-tulip-visibility": "public", "example": "aq21mSKC1rbO87TjC/4Hz2EJHd/v+jxf7MtC315vo0Y", "type": "string", "pattern": "^[a-zA-Z0-9+/]+$" } }, "responses": { "badRequestError": { "description": "The request was malformed. This could mean that headers, query parameters, or the request body was unable to be parsed or had unexpected values.\n", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiError" } } } }, "authenticationRequiredError": { "description": "The request was made unauthorized. HTTP Basic Authorization using a Tulip API Key is required for use of the API.\n", "content": { "application/json": { "schema": { "allOf": [ { "$ref": "#/components/schemas/ApiError" }, { "type": "object", "properties": { "errorCode": { "enum": [ "AuthenticationRequired" ] } } } ] } } } }, "authenticationFailedError": { "description": "The provided authentication info was rejected. The response will provide additional details.\n", "content": { "application/json": { "schema": { "allOf": [ { "$ref": "#/components/schemas/ApiError" }, { "type": "object", "properties": { "errorCode": { "enum": [ "AuthenticationFailed" ] } } } ] } } } }, "notFoundError": { "description": "The requested database entry was not found.\n", "content": { "application/json": { "schema": { "allOf": [ { "$ref": "#/components/schemas/ApiError" }, { "type": "object", "properties": { "errorCode": { "enum": [ "NoSuchDatabaseEntry" ] } } } ] } } } }, "internalServerError": { "description": "The server encountered an unexpected error.\n", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiError" } } } } }, "securitySchemes": { "apiKey": { "type": "http", "scheme": "basic", "description": "Access to the Tulip API requires the use of [HTTP Basic Authentication](https://datatracker.ietf.org/doc/html/rfc7617) using the credentials of an active [Tulip API Token](https://support.tulip.co/docs/set-up-a-tulip-api). All requests require the `Authorization` HTTP header with the `Basic` scheme to provide API credentials unless otherwise noted.\n\nAPI tokens can be configured with a set of _scopes_ which determine what parts of the API that specific token has access to. Security best practices dictate that API credentials be given the minimum set of capabilities required to fulfill their intended purpose. For example, an API token created for use in an integration that is only designed to use the Tables API should probably only be given the `tables:read` and `tables:write` scopes. In this way you can minimize risk in the event that API credentials are compromised. API endpoints will document what API token scopes are required to access that endpoint in their descriptions. If a request is made to an endpoint with an API token which does not have the required scopes, the response will be an authorization error.\n" } } } } ````