# Client-Search Containers and Records

This page describes the containers and records that support the Client Search feature in Caplin FX Sales.

## Requirements

The containers and records on this page are provided by the Client Search Adapter, which integrates with your client directory. This adapter must be written before the Client Search feature in Caplin FX Sales will work.

## Searching for client names

### Request

To retrieve a list of client names matching a search string, subscribe to the subject below:

```
/PRIVATE/CLIENTSEARCH/QUERY/<client_search_string>
```

where `<client_search_string>` is the search string to pass to the Client Search Adapter. You can include spaces in the client search string: the [StreamLink,window="_blank"](../../caplin-platform/streamlink/index.md) JS library will ensure that they are properly encoded.

**📌 NOTE**\
In order to support the FX Sales search-as-you-type capability, your implementation of the Client Search Adapter must support partial matching of client names.

### Response

The search results are presented to FX Sales as a [type 1 record,window="_blank"](../../caplin-platform/datasource/datasource-type-1-data.md), containing a single field: clients

**Record fields**

| Field Name | Description |
| --- | --- |
| Clients | A JSON-formatted object with a single property, `clients`, that contains an array of search-result objects |

#### Field: clients

Format:

```
{
   clients: [
      {"Name":"<value>", "UserCount":"<value>"},
      ...
   ]
}
```

Example value:

```
{
   "clients": [
      {"Name":"Qualcore","UserCount":"104"},
      {"Name":"Thermolock","UserCount":"95"},
      {"Name":"Proline","UserCount":"98"}
   ]
}
```

## Searching for users

### Request

Subscribe to the container subject below:

```
/PRIVATE/USERSEARCH/QUERY/user=<user_search_string>&client=<client_name>
```

The container’s subject includes two parameters: `user` and `client`. The `user` parameter must have a value. The `client` parameter may be empty.

### Response

The container comprises [type 1 records,window="_blank"](../../caplin-platform/datasource/datasource-type-1-data.md) in the following format:

```
/PRIVATE/USERSEARCH/USERS/<user_name>
```

Each record referenced by the container has the following fields:

**Record fields**

| Field Name | Description | Example Value |
| --- | --- | --- |
| Client | The name of the client | Proline |
| UserID | A unique identifer for the user | ID-8 |
| Title | The title of the user’s name | Mr |
| FirstName | The user’s first name | John |
| LastName | The user’s last name | Smith |
| FullName | The user’s full name | John Edward Smith |
| Email | The user’s email address | \john.smith@Proline.com |
| Phone | The user’s phone number | 02071115555 |
| Mobile | The user’s mobile number | 07788844222 |
| Accounts | A comma-separated list of trading accounts. Each item in the list is in the format: `<ACCOUNT_DESCRIPTION>|<ACCOUNT>` | Accounts=Account 1|acc1,Account 2|acc2,Account 3|acc3 |

The fields listed above comprise the minimum field set expected by FX Sales. Your implementation of the Client Search Adapter can include extra fields if required.
