> To build a Wix site agentically, follow https://www.wix.com/headless/skill.md
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# AddRecentSearch

# Package: dashboard

# Namespace: BackOfficeSearch

# Method link: https://dev.wix.com/docs/api-reference/business-management/dashboard/back-office-search/add-recent-search.md

## Permission Scopes:
SCOPE.BACK_OFFICE.SEARCH: SCOPE.BACK_OFFICE.SEARCH

## Introduction

Adds a term to the top of the calling user's recent searches on this site.

An earlier copy of the same term, in any letter case, is removed, and only the newest 10 terms
are kept. Call this once the user settles on a term, not on every keystroke.

When the user edits a term you added earlier in the same session, pass the earlier one in
`replacedSearchTerm` so the list doesn't keep both. Don't pass a term that was already in the list
when the session started, or an older search the user made is removed.

An invalid term is rejected. Saving a valid one is best effort: if it can't be stored, the call
still succeeds, so a successful call doesn't confirm the term was kept. Two calls close together may keep only the
later term, so wait for one call to finish before sending the next.

To retrieve the list, call [Get Recent Searches](https://dev.wix.com/docs/api-reference/business-management/dashboard/back-office-search/get-recent-searches.md).

---

## REST API

### Schema

```
 Method: addRecentSearch
 Description: Adds a term to the top of the calling user's recent searches on this site.  An earlier copy of the same term, in any letter case, is removed, and only the newest 10 terms are kept. Call this once the user settles on a term, not on every keystroke.  When the user edits a term you added earlier in the same session, pass the earlier one in `replacedSearchTerm` so the list doesn't keep both. Don't pass a term that was already in the list when the session started, or an older search the user made is removed.  An invalid term is rejected. Saving a valid one is best effort: if it can't be stored, the call still succeeds, so a successful call doesn't confirm the term was kept. Two calls close together may keep only the later term, so wait for one call to finish before sending the next.  To retrieve the list, call [Get Recent Searches](https://dev.wix.com/docs/api-reference/business-management/dashboard/back-office-search/get-recent-searches.md).
 URL: https://www.wixapis.com/back-office-search/v1/recent-searches
 Method: POST
 Method parameters:
   param name: replacedSearchTerm | type: replacedSearchTerm | description: Earlier term to remove, which the user edited into this one, such as `dom` before they typed on to `domain`. Only pass a term you added in the same session.  | validation: minLength 2, maxLength 200
   param name: searchTerm | type: searchTerm | description: Term the user searched for. Spaces at the start and end are trimmed before the term is checked and saved.  | validation: minLength 2, maxLength 200
 Return type: AddRecentSearchResponse
  EMPTY-OBJECT {}


```

### Examples

### Add a term to the user's recent searches
Adds `domain` to the top of the user's recent searches, replacing `dom`, which the user typed earlier in the same session.

```curl
curl -X POST \
'https://www.wixapis.com/back-office-search/v1/recent-searches' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "searchTerm": "domain",
  "replacedSearchTerm": "dom"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.backOfficeSearch.backOfficeSearch.addRecentSearch(options)
 Description: Adds a term to the top of the calling user's recent searches on this site.  An earlier copy of the same term, in any letter case, is removed, and only the newest 10 terms are kept. Call this once the user settles on a term, not on every keystroke.  When the user edits a term you added earlier in the same session, pass the earlier one in `replacedSearchTerm` so the list doesn't keep both. Don't pass a term that was already in the list when the session started, or an older search the user made is removed.  An invalid term is rejected. Saving a valid one is best effort: if it can't be stored, the call still succeeds, so a successful call doesn't confirm the term was kept. Two calls close together may keep only the later term, so wait for one call to finish before sending the next.  To retrieve the list, call [Get Recent Searches](https://dev.wix.com/docs/api-reference/business-management/dashboard/back-office-search/get-recent-searches.md).
 Method parameters:
   param name: options | type: AddRecentSearchOptions  none  
        - name: searchTerm | type: string | description: Term the user searched for. Spaces at the start and end are trimmed before the term is checked and saved.  | validation: minLength 2, maxLength 200
        - name: replacedSearchTerm | type: string | description: Earlier term to remove, which the user edited into this one, such as `dom` before they typed on to `domain`. Only pass a term you added in the same session.  | validation: minLength 2, maxLength 200
 Return type: PROMISE<AddRecentSearchResponse>
  EMPTY-OBJECT {}


```

### Examples

### Add a term to the user's recent searches
Adds `domain` to the top of the user's recent searches, replacing `dom`, which the user typed earlier in the same session.

```javascript
import { backOfficeSearch } from "@wix/back-office-search";

async function addRecentSearch() {
  const response = await backOfficeSearch.addRecentSearch({
    searchTerm: "domain",
    replacedSearchTerm: "dom",
  });
}

/* Promise resolves to:
 * {}
 */

```

### addRecentSearch (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { backOfficeSearch } from '@wix/back-office-search';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { backOfficeSearch },
  // Include the auth strategy and host as relevant
});


async function addRecentSearch(options) {
  const response = await myWixClient.backOfficeSearch.addRecentSearch(options);
};
```

---