# Soft-delete a recent search

- Operation ID: `PostDeletedSearch`
- HTTP method: `POST`
- Path: `/search/v2/indices/{indexId}/deleted-searches`
- [Human-readable API reference](https://hub.synerise.com/api-reference/ai-suite#operation/PostDeletedSearch)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /search/v2/indices/{indexId}/deleted-searches:
    post:
      summary: Soft-delete a recent search
      description: |
        Delete a recent search from the history accessible to a profile. The search remains in the database and you can retrieve it by using [this endpoint](#operation/GetDeletedSearches).

        ---

        **API consumers:** <span title="Deprecated">AI API key (legacy)</span>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/docs/settings/tool/tracking_codes" target="_blank" rel="noopener" title="Pass your tracker key in the request header">Web SDK Tracker</a>

        **API key permission required:** `ITEMS_SEARCH_RECENT_SEARCH_CREATE`
      operationId: PostDeletedSearch
      tags:
        - Search
      security:
        - JWT: []
        - TrackerKey: []
      parameters:
        - name: indexId
          in: path
          required: true
          description: ID of the index that the query relates to
          schema:
            type: string
            example: 4add1a1fa877c1651906bb22c9dfd37a1618852272
        - name: clientUUID
          in: query
          required: true
          description: UUID of the profile for which the query is performed
          schema:
            type: string
            example: e0097757-d1e2-44ac-ba3c-d97979a354c1
      requestBody:
        description: Request for deleting search query
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: Deleted search query. Required if `match` field is set to `query`.
                match:
                  type: string
                  description: |
                    Tells how to match this deleted search on recent searches.

                    - `query`: matches only recent searches with provided query
                    - `all`: matches all recent searches
                  default: query
                timestamp:
                  type: string
                  format: date-time
                  description: Time when the search was deleted. If not present current time is taken.
      responses:
        "204":
          description: Soft-delete successful
        "400":
          description: Check error message for more details
          content:
            application/json:
              schema:
                type: object
                properties:
                  timestamp:
                    type: string
                    format: date-time
                    description: Time when the error occurred
                  status:
                    type: integer
                    description: Status code
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  path:
                    type: string
                    description: URL of the requested resource
                required:
                  - timestamp
                  - status
                  - message
      x-snr-doc-urls:
        - /api-reference/ai-search#tag/Search/operation/PostDeletedSearch
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url 'https://api.synerise.com/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches?clientUUID=e0097757-d1e2-44ac-ba3c-d97979a354c1' \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '{"query":"string","match":"query","timestamp":"2019-08-24T14:15:22Z"}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"query\":\"string\",\"match\":\"query\",\"timestamp\":\"2019-08-24T14:15:22Z\"}"

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

            conn.request("POST", "/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches?clientUUID=e0097757-d1e2-44ac-ba3c-d97979a354c1", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "query": "string",
              "match": "query",
              "timestamp": "2019-08-24T14:15:22Z"
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches?clientUUID=e0097757-d1e2-44ac-ba3c-d97979a354c1");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches?clientUUID=e0097757-d1e2-44ac-ba3c-d97979a354c1",
              "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({query: 'string', match: 'query', timestamp: '2019-08-24T14:15:22Z'}));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches');
            $request->setMethod(HTTP_METH_POST);

            $request->setQueryData([
              'clientUUID' => 'e0097757-d1e2-44ac-ba3c-d97979a354c1'
            ]);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"query":"string","match":"query","timestamp":"2019-08-24T14:15:22Z"}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/search/v2/indices/4add1a1fa877c1651906bb22c9dfd37a1618852272/deleted-searches?clientUUID=e0097757-d1e2-44ac-ba3c-d97979a354c1")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"query\":\"string\",\"match\":\"query\",\"timestamp\":\"2019-08-24T14:15:22Z\"}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Search
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
    TrackerKey:
      type: apiKey
      name: token
      in: query
      description: Authorization by tracker key sent as a query parameter. This is the same key as used in the website tracking code.
```
