---
schema_version: "1"
id: 20b95fcd366b3985ba047530de6c0f1f9b9792bcef6cc74d028f2532017b7d50
title: Search Templates
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/standard_cart/std_comms-search-template.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/std_comms-search-template.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4b486e537071cf5cb49f1f5c32314693d2edd35eb6c64806c14b5ef66e6890e8
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Search Templates

Searches, filters, sorts, and paginates Sales Configuration Templates, supporting field-level filtering (AND logic), free-text search (OR logic), tag-based filtering, and multi-field sorting.

## Resource Information

- **Resource URL:** `/services/apexrest/<namespace>/v1/cpq/templates/search`
- **HTTP Method:** POST
- **Content-Type:** application/json
- **Response Format:** JSON

## Request Body

| Parameter | Type    | Required | Description                                                    |
| --------- | ------- | -------- | -------------------------------------------------------------- |
| filter    | Object  | No       | Filter criteria applied with AND logic.                        |
| offset    | Integer | No       | Number of records to skip. Default value is 0.                 |
| pageSize  | Integer | No       | Number of results per page. Default value is 20.               |
| search    | Object  | No       | Search criteria applied with OR logic across specified fields. |
| sortby    | Array   | No       | Array of sort clauses.                                         |

## Filter Object

```
{
  "filter": {
    "criteria": [
      {
        "field": "Status__c",
        "operator": "=",
        "values": "Approved"
      },
      {
        "field": "Category__c",
        "operator": "IN",
        "values": "Enterprise,Premium"
      }
    ]
  }
}
```

### Parameters

| Property            | Type   | Description                                                                                                                                                     |
| ------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| criteria            | Array  | Array of filter criterion objects. All criteria are combined with AND logic.                                                                                    |
| criteria[].field    | String | The API name of the field to filter on. Supports SalesConfigTemplate\_\_c fields and relationship fields through TemplateQuoteId\_\_r and TemplateOrderId\_\_r. |
| criteria[].operator | String | The comparison operator.                                                                                                                                        |
| criteria[].values   | String | The value(s) to compare against. For IN and NOT IN, provide comma-separated values.                                                                             |

### Supported Operators

| Operator | Description                           | Example Values   |
| -------- | ------------------------------------- | ---------------- |
| =        | Equals                                | "Approved"       |
| !=       | Not equals                            | "Draft"          |
| IN       | Value is in list                      | "Draft,Approved" |
| NOT IN   | Value is not in list                  | "Obsolete"       |
| LIKE     | Pattern match (auto-adds % wildcards) | "Enterprise"     |
| >        | Greater than                          | "2024-01-01"     |
| >=       | Greater than or equal                 | "100"            |
| <        | Less than                             | "500"            |
| <=       | Less than or equal                    | "1000"           |

## Tag Filtering

To filter templates by tag IDs, use the special field name tagIds with the IN operator.

```
{
  "filter": {
    "criteria": [
      {
        "field": "tags",
        "operator": "IN",
        "values": "Internet,Standard"
      }
    ]
  }
}
```

## Relationship Field Filtering

You can filter on fields from the related Quote or Order

```
{
  "filter": {
    "criteria": [
      {
        "field": "TemplateQuoteId__r.Name",
        "operator": "LIKE",
        "values": "Enterprise"
      }
    ]
  }
}

```

**note:** Only TemplateQuoteId\_\_r (Quote) and TemplateOrderId\_\_r (Order) relationships are supported.

## Search Object

```
{
  "search": {
    "fields": "Name,Tags",
    "value": "fiber"
  }
}
```

### Parameters

| Property | Type   | Description                                                                                                                                             |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fields   | String | Comma-separated list of field names to search across. Use Tags to include tag name matching. All fields are searched with OR logic using LIKE matching. |
| value    | String | The search term. Automatically wrapped with % wildcards for LIKE queries.                                                                               |

## Sort Object

```
{
  "sortby": [
    { "field": "Name", "direction": "ASC" },
    { "field": "CreatedDate", "direction": "DESC" }
  ]
}
```

### Parameters

| Property  | Type   | Description                                               |
| --------- | ------ | --------------------------------------------------------- |
| field     | String | The API name of the field to sort by.                     |
| direction | String | "ASC" (ascending) or "DESC" (descending). Default: "ASC". |

|

## Example REST Request: Full Search

```
{
  "filter": {
    "criteria": [
      { "field": "Status__c", "operator": "=", "values": "Approved" },
      { "field": "Category__c", "operator": "IN", "values": "Enterprise,Premium" }
    ]
  },
  "search": {
    "fields": "Name,Description__c,tags",
    "value": "fiber"
  },
  "sortby": [
    { "field": "Name", "direction": "ASC" }
  ],
  "pageSize": 10,
  "offset": 0
}
```

## Example REST Response

Success Response (200):

```
{
  "success": true,
  "errorCode": "INVOKE-200",
  "error": "OK",
  "result": {
    "records": [
      {
        "Id": "a1Bxx0000004XyzDEF",
        "Name": "Enterprise Fiber Bundle",
        "vlocity_cmt__Description__c": "Standard fiber bundle for enterprise customers",
        "vlocity_cmt__Status__c": "Approved",
        "vlocity_cmt__Category__c": "Enterprise",
        "Tags": ["Enterprise", "Fiber"],
        "vlocity_cmt__EffectiveOneTimeTotal__c": 299.99,
        "vlocity_cmt__EffectiveRecurringTotal__c": 89.99,
        "vlocity_cmt__PriceList__r": {
          "Id": "a3Dxx0000002GhiJKL",
          "Name": "Standard Price List",
          "vlocity_cmt__CurrencyCode__c": "USD"
        }
      }
    ],
    "messages": []
  },
  "totalCount": 1,
  "offset": 0,
  "pageSize": 10,
  "totalPages": 1
}

```
