younifyd
Menu

Search

Execute a search query

POST/rest/organizations/{organizationId}/commerce/v2/search

Use it in a workflow

  1. Add a step and choose the Coveo connector.
  2. Pick the Search action (under Commerce).
  3. Fill in the fields below, then reference the result from later steps as {{search.response.data}}.

Request

Path parameters

organizationIdstringrequired

The unique identifier of the target [organization](https://docs.coveo.com/en/185/).<br />**Example:** `acmecorporation8tp8wu3`

Request body

Enter the body as JSON in the step's Body field.

clientIdstring

A GUID which represents the current client.\n\nIf your implementation uses the Atomic or Headless libraries, then the [client ID](https://docs.coveo.com/en/masb0234/) is generated automatically in client-side code.\n\nIf you have a custom Coveo implementation, you will have to generate a [UUID v4](<https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)>)-formatted GUID. You will need to send this ID in every request that is sent to the Commerce API.\n\nCoveo Machine Learning models may use this information to provide contextually relevant output.

contextobjectrequired

Contextual information about the query.

captureboolean

Whether the request should be tracked for analytics and machine learning purposes. When set to `true`, this will trigger a server-side event to be logged. When set to `false`, the server-side event will not be logged.

cartarray<object>2 fields

The cart information.

customobject

Custom context values under context.custom. Use this for context mapping.

labelsobject

Deprecated - The context labels.

sourcearray<string>

Defines one or more client side libraries that generated the analytics event. The format should be the library's name followed by '@', and then the version. For example, '[custom.library.js@2.0.0]'.

userobject1 fields

The user information.

viewobjectrequired2 fields

A collection of data points describing the view. Note: The term 'view' is used instead of 'page' to accommodate usage in contexts such as mobile apps.

countrystringrequired

An ISO 3166-1 alpha-2 country code.

currencystringrequired

An ISO 4217 currency code.

debugboolean

Whether to include the execution report on a successful response.

enableResultsboolean

Enable spotlight content in the results. When enabled, the products list in the response will always be empty and the results list should be used instead.

facetsarray<oneOf>

The facet operations to perform on the query. Note that this parameter is ignored in the '/productSuggest' endpoint.

languagestringrequired

An ISO 639-1 language code.

legacyFacetOptionsobject

Facet Options for legacy (v1) facets.

freezeFacetOrderboolean

Default: `false`<br/>Whether facets should be returned in the same order in which they were requested.

pageinteger (int32)

The page of products to request.

perPageinteger (int32)

The number of products per page. Note that a value greater than 100 may be rejected in the future.

querystringrequired

The query expression, typically the keywords entered by the end user in a search box.

sortoneOf
trackingIdstringrequired

The unique identifier of the tracking target.

json
{
  "context": {
    "view": {
      "url": "https://acme.com/summersale",
      "referrer": "https://example.com/"
    },
    "capture": true,
    "cart": [
      {
        "productId": "shoe-a1-red",
        "quantity": 2
      }
    ],
    "custom": {
      "fitmentProducts": [
        "sku_123",
        "sku_456"
      ]
    },
    "labels": {
      "brand": "ACME",
      "category": "garden > garden-tools > chainsaws"
    },
    "source": [
      "@coveo/headless@2.61.0",
      "custom.library.js@2.0.0"
    ],
    "user": {
      "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
    }
  },
  "country": "US",
  "currency": "USD",
  "language": "en",
  "query": "blue shoes",
  "trackingId": "acmecorporation_ca",
  "clientId": "58bb4b98-1daa-4767-8c15-90a0ea67645c",
  "debug": true,
  "enableResults": false,
  "facets": [
    {
      "field": "ec_category",
      "type": "regular",
      "values": [
        {
          "state": "idle",
          "value": "shoes"
        }
      ]
    }
  ],
  "legacyFacetOptions": {
    "freezeFacetOrder": false
  },
  "page": 7
}

Response

Returns 200 with an object. Read it in later steps with {{search.response.data.<field>}}.

facetsarray<oneOf>

The available facets. Note that this array will always be empty in the '/productSuggest' endpoint.

paginationobject

Contextual pagination information about the query.

pageinteger (int32)

The page of products to request.

perPageinteger (int32)

The number of products per page. Note that a value greater than 100 may be rejected in the future.

totalEntriesinteger (int32)

The total number of results that match the query.

totalPagesinteger (int32)

The total number of pages of items available.

totalProductsinteger (int32)

The total number of products that match the query.

totalSpotlightContentinteger (int32)

The total number of spotlight content that match the query.

productsarray<oneOf>

The subset of products returned by the query.

queryCorrectionobject

The query correction response, if the query was corrected.

correctedQuerystring

If the query was automatically corrected, this property indicates the corrected basic query expression (q) that was executed instead of the original one.

correctionsarray<object>2 fields

If the query wasn't automatically corrected, this property contains the basic query expression (q) keyword corrections provided by the Did You Mean index feature.

originalQuerystring

If the query was automatically corrected, this property indicates the original basic query expression (q) that triggered the automatic query correction.

responseIdstring (uuid)

The unique identifier of the API response. It can be attached to any subsequent impression or click event to attribute them to the request.

resultsarray<oneOf>

List of results including products and spotlight content

sortobject

The applied and available sort options for the query.

appliedSortoneOf
availableSortsarray<oneOf>

The list of available sorting methods.

triggersarray<object>

The actions for the client to perform based on the Trigger statements defined.

contentstring

The content of the trigger.

typestring

The type of trigger.

One ofexecutenotifyredirectquery

json
{
  "facets": [
    null
  ],
  "pagination": {
    "page": 1,
    "perPage": 10,
    "totalEntries": 100,
    "totalPages": 10
  },
  "products": [
    null
  ],
  "queryCorrection": {
    "correctedQuery": "string",
    "corrections": [
      {
        "correctedQuery": "Coveo Cloud V2 platform",
        "wordCorrections": [
          {
            "correctedWord": "platform",
            "length": 8,
            "offset": 15,
            "originalWord": "plattfomr"
          }
        ]
      }
    ],
    "originalQuery": "string"
  },
  "responseId": "123e4567-e89b-12d3-a456-426614174000",
  "results": [
    null
  ],
  "sort": {
    "appliedSort": {
      "fields": [
        {
          "direction": "asc",
          "displayName": "Brand",
          "field": "ec_brand"
        }
      ],
      "sortCriteria": "fields"
    },
    "availableSorts": [
      {
        "sortCriteria": "relevance"
      },
      {
        "fields": [
          {
            "direction": "desc",
            "displayName": "Price",
            "field": "ec_price"
          }
        ],
        "sortCriteria": "fields"
      }
    ]
  },
  "triggers": [
    {
      "content": "https://www.example.com",
      "type": "redirect"
    }
  ]
}

Need more? See the Coveo guide for connection setup and behaviour shared by every action.

Was this page helpful?