> ## Documentation Index
> Fetch the complete documentation index at: https://help.teable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Clear selected records and fields by id

> Clear selected cells using record and field identifiers instead of row ranges.

Required token scopes: `record|update`



## OpenAPI

````yaml /swagger.json patch /table/{tableId}/selection/clear-by-id
openapi: 3.0.0
info:
  version: 1.0.0
  title: Teable App
  description: Manage Data as easy as drink a cup of tea
  x-logo:
    backgroundColor: '#F0F0F0'
    altText: Teable logo
servers:
  - url: https://app.teable.ai/api
security: []
tags:
  - name: base
    x-group: project
  - name: base node
    x-group: project node
  - name: base-share
    x-group: project-share
paths:
  /table/{tableId}/selection/clear-by-id:
    patch:
      tags:
        - selection
      summary: Clear selected records and fields by id
      description: >-
        Clear selected cells using record and field identifiers instead of row
        ranges.


        Required token scopes: `record|update`
      parameters:
        - schema:
            type: string
          required: true
          name: tableId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                viewId:
                  type: string
                  example: viwXXXXXXX
                  description: >-
                    Set the view you want to fetch. When provided, records will
                    follow that view's filter and sort settings. When omitted,
                    the API queries the table without applying a view.
                ignoreViewQuery:
                  anyOf:
                    - type: string
                    - type: boolean
                  description: >-
                    When a viewId is specified, configure this to true will
                    ignore the view's filter, sort, etc
                filterByTql:
                  type: string
                  example: '{field} = ''Completed'' AND {field} > 5'
                  deprecated: true
                filter:
                  type: string
                  description: >-
                    A filter object for complex query conditions based on
                    fields, operators, and values. Use our visual query builder
                    at https://app.teable.ai/developer/tool/query-builder to
                    build filters.
                search:
                  anyOf:
                    - type: array
                      items:
                        type: string
                      minItems: 1
                      maxItems: 1
                    - type: array
                      items:
                        type: string
                      minItems: 2
                      maxItems: 2
                    - type: array
                      items:
                        anyOf:
                          - type: string
                          - anyOf:
                              - type: string
                              - type: boolean
                      minItems: 3
                      maxItems: 3
                  default:
                    - searchValue
                    - fieldIdOrName
                    - false
                  description: Search for records that match the specified field and value
                filterLinkCellCandidate:
                  anyOf:
                    - type: array
                      items:
                        type: string
                      minItems: 2
                      maxItems: 2
                    - type: string
                  example:
                    - fldXXXXXXX
                    - recXXXXXXX
                  description: >-
                    Filter out the records that can be selected by a given link
                    cell from the relational table. For example, if the
                    specified field is one to many or one to one relationship,
                    recordId for which the field has already been selected will
                    not appear.
                filterLinkCellSelected:
                  anyOf:
                    - type: array
                      items:
                        type: string
                      minItems: 2
                      maxItems: 2
                    - type: string
                  example:
                    - fldXXXXXXX
                    - recXXXXXXX
                  description: >-
                    Filter out selected records based on this link cell from the
                    relational table. Note that viewId, filter, and orderBy will
                    not take effect in this case because selected records has it
                    own order. Ignoring recordId gets all the selected records
                    for the field
                selectedRecordIds:
                  type: array
                  items:
                    type: string
                  description: Filter selected records by record ids
                orderBy:
                  type: string
                  description: >-
                    An array of sort objects that specifies how the records
                    should be ordered.
                groupBy:
                  type: string
                  description: >-
                    An array of group objects that specifies how the records
                    should be grouped.
                collapsedGroupIds:
                  type: string
                  description: >-
                    An array of group ids that specifies which groups are
                    collapsed
                queryId:
                  type: string
                  example: qry_xxxxxxxx
                  description: >-
                    When provided, other query parameters will be merged with
                    the saved ones.
                includeQueryExtra:
                  anyOf:
                    - type: string
                    - type: boolean
                  description: >-
                    Whether to include query extra metadata such as group points
                    and search hit indexes. Group metadata defaults to enabled;
                    optimized generated-index searches require explicit opt-in
                    for search hit indexes.
                projection:
                  type: array
                  items:
                    type: string
                  description: >-
                    Visible field ids for query-scoped field selection. If
                    omitted, all visible view fields are used.
                selection:
                  type: object
                  properties:
                    recordIds:
                      type: array
                      items:
                        type: string
                      description: >-
                        Explicit selected record ids. If omitted, records are
                        resolved from the current query scope. An empty array
                        means no existing records are selected.
                    excludeRecordIds:
                      type: array
                      items:
                        type: string
                      description: >-
                        Record ids to exclude from the current query scope, for
                        inverse selections.
                    fieldIds:
                      type: array
                      items:
                        type: string
                      minItems: 1
                      description: >-
                        Explicit selected field ids. If omitted, fields are
                        resolved from visible query fields.
              required:
                - selection
      responses:
        '200':
          description: Successful clean up
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request PATCH \
              --url https://app.teable.ai/api/table/%7BtableId%7D/selection/clear-by-id \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"viewId":"viwXXXXXXX","ignoreViewQuery":"string","filterByTql":"{field} = '\''Completed'\'' AND {field} > 5","filter":"string","search":["searchValue","fieldIdOrName",false],"filterLinkCellCandidate":["fldXXXXXXX","recXXXXXXX"],"filterLinkCellSelected":["fldXXXXXXX","recXXXXXXX"],"selectedRecordIds":["string"],"orderBy":"string","groupBy":"string","collapsedGroupIds":"string","queryId":"qry_xxxxxxxx","includeQueryExtra":"string","projection":["string"],"selection":{"recordIds":["string"],"excludeRecordIds":["string"],"fieldIds":["string"]}}'
        - lang: JavaScript
          source: >-
            const url =
            'https://app.teable.ai/api/table/%7BtableId%7D/selection/clear-by-id';

            const options = {
              method: 'PATCH',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              },
              body: '{"viewId":"viwXXXXXXX","ignoreViewQuery":"string","filterByTql":"{field} = \'Completed\' AND {field} > 5","filter":"string","search":["searchValue","fieldIdOrName",false],"filterLinkCellCandidate":["fldXXXXXXX","recXXXXXXX"],"filterLinkCellSelected":["fldXXXXXXX","recXXXXXXX"],"selectedRecordIds":["string"],"orderBy":"string","groupBy":"string","collapsedGroupIds":"string","queryId":"qry_xxxxxxxx","includeQueryExtra":"string","projection":["string"],"selection":{"recordIds":["string"],"excludeRecordIds":["string"],"fieldIds":["string"]}}'
            };


            try {
              const response = await fetch(url, options);
              const data = await response.json();
              console.log(data);
            } catch (error) {
              console.error(error);
            }
        - lang: Node.js
          source: |-
            const http = require('https');

            const options = {
              method: 'PATCH',
              hostname: 'app.teable.ai',
              port: null,
              path: '/api/table/%7BtableId%7D/selection/clear-by-id',
              headers: {
                Authorization: 'Bearer REPLACE_BEARER_TOKEN',
                'content-type': 'application/json'
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on('data', function (chunk) {
                chunks.push(chunk);
              });

              res.on('end', function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              viewId: 'viwXXXXXXX',
              ignoreViewQuery: 'string',
              filterByTql: '{field} = \'Completed\' AND {field} > 5',
              filter: 'string',
              search: ['searchValue', 'fieldIdOrName', false],
              filterLinkCellCandidate: ['fldXXXXXXX', 'recXXXXXXX'],
              filterLinkCellSelected: ['fldXXXXXXX', 'recXXXXXXX'],
              selectedRecordIds: ['string'],
              orderBy: 'string',
              groupBy: 'string',
              collapsedGroupIds: 'string',
              queryId: 'qry_xxxxxxxx',
              includeQueryExtra: 'string',
              projection: ['string'],
              selection: {recordIds: ['string'], excludeRecordIds: ['string'], fieldIds: ['string']}
            }));
            req.end();
        - lang: Python
          source: >-
            import http.client


            conn = http.client.HTTPSConnection("app.teable.ai")


            payload =
            "{\"viewId\":\"viwXXXXXXX\",\"ignoreViewQuery\":\"string\",\"filterByTql\":\"{field}
            = 'Completed' AND {field} >
            5\",\"filter\":\"string\",\"search\":[\"searchValue\",\"fieldIdOrName\",false],\"filterLinkCellCandidate\":[\"fldXXXXXXX\",\"recXXXXXXX\"],\"filterLinkCellSelected\":[\"fldXXXXXXX\",\"recXXXXXXX\"],\"selectedRecordIds\":[\"string\"],\"orderBy\":\"string\",\"groupBy\":\"string\",\"collapsedGroupIds\":\"string\",\"queryId\":\"qry_xxxxxxxx\",\"includeQueryExtra\":\"string\",\"projection\":[\"string\"],\"selection\":{\"recordIds\":[\"string\"],\"excludeRecordIds\":[\"string\"],\"fieldIds\":[\"string\"]}}"


            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
            }


            conn.request("PATCH",
            "/api/table/%7BtableId%7D/selection/clear-by-id", payload, headers)


            res = conn.getresponse()

            data = res.read()


            print(data.decode("utf-8"))
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````