Sites

POST Search Sites

POST /organizations/{organizationId}/site-search

Operation ID: searchSites. Security: AmOAuth2 (sfcc.sites, sfcc.sites.rw).

Searches for sites.

The query attribute specifies a complex query that can be used to narrow down the search. This is the list of searchable attributes:

  • id - String
  • displayName - String
  • description - String
  • inDeletion - Boolean

The output of the query can also be sorted. These are the list of sortable attributes:

  • id - String
  • displayName - String
  • description - String
  • inDeletion - Boolean

Parameters

  • organizationId (path, OrganizationId, required) An identifier for the Salesforce Commerce Cloud organization the request is being made by. It consists of a prefix 'f_ecom_' followed by a 4-character realm identifier and a 3-character instance type identifier.

    Example

    f_ecom_zzxy_prd

Request body (required)

The search request document

Media type: application/json. Schema: SiteSearchRequest.

Example: SiteSearchById Search sites by ID

Example of searching for sites by their ID using a term query

{
  "query": {
    "termQuery": {
      "fields": [
        "id"
      ],
      "operator": "is",
      "values": [
        "RefArch"
      ]
    }
  },
  "limit": 10,
  "offset": 0
}

Example: SiteSearchByDisplayName Search sites by display name

Example of searching for sites by their display name using a text query

{
  "query": {
    "textQuery": {
      "fields": [
        "displayName"
      ],
      "searchPhrase": "Reference Architecture"
    }
  },
  "limit": 25,
  "offset": 0,
  "sorts": [
    {
      "field": "displayName",
      "sortOrder": "asc"
    }
  ]
}

Example: SiteSearchActiveOnly Search only non-deleted sites

Example of searching for sites that are not marked for deletion

{
  "query": {
    "termQuery": {
      "fields": [
        "inDeletion"
      ],
      "operator": "is",
      "values": [
        false
      ]
    }
  },
  "limit": 100,
  "offset": 0,
  "sorts": [
    {
      "field": "id",
      "sortOrder": "asc"
    }
  ]
}

Example: SiteSearchComplex Complex site search with multiple criteria

Example of a complex search combining multiple conditions

{
  "query": {
    "boolQuery": {
      "must": [
        {
          "termQuery": {
            "fields": [
              "inDeletion"
            ],
            "operator": "is",
            "values": [
              false
            ]
          }
        },
        {
          "textQuery": {
            "fields": [
              "displayName",
              "description"
            ],
            "searchPhrase": "production"
          }
        }
      ]
    }
  },
  "limit": 20,
  "offset": 0,
  "sorts": [
    {
      "field": "displayName",
      "sortOrder": "asc"
    }
  ]
}

Responses

  • 200 Returns site search results

    Media type: application/json. Schema: SiteSearchResult.

    Example: SiteSearchResultSuccess Successful site search result

    Example of a successful site search returning multiple sites

    {
      "limit": 2,
      "offset": 0,
      "total": 2,
      "hits": [
        {
          "id": "RefArch",
          "customerListLink": {
            "customerListId": "RefArch",
            "title": "Default Customer List"
          },
          "displayName": {
            "default": "displayName",
            "en": "An English displayName",
            "de": "A German displayName"
          },
          "description": {
            "default": "description",
            "en": "An English description",
            "de": "A German description"
          },
          "inDeletion": false,
          "storefrontStatus": "online",
          "siteCatalogId": "storefront-catalog-m-en",
          "cartridges": "plugin_custom_cartridge:plugin_wishlists:plugin_apple_pay:plugin_facebook:plugin_payments:plugin_pinterest_commerce:plugin_web_payments:bc_content:core",
          "customCartridges": "plugin_custom_cartridge:plugin_wishlists",
          "creationDate": "2024-01-15T10:00:00.000Z",
          "lastModified": "2024-10-14T15:30:00.000Z"
        },
        {
          "id": "RefArchGlobal",
          "customerListLink": {
            "customerListId": "RefArchGlobal",
            "title": "Default Customer List"
          },
          "displayName": {
            "default": "displayName",
            "en": "An English displayName",
            "de": "A German displayName"
          },
          "description": {
            "default": "description",
            "en": "An English description",
            "de": "A German description"
          },
          "inDeletion": false,
          "storefrontStatus": "online",
          "siteCatalogId": "storefront-catalog-m-de",
          "cartridges": "plugin_custom_cartridge:plugin_apple_pay:plugin_facebook:plugin_payments:plugin_pinterest_commerce:plugin_web_payments:bc_content:core",
          "customCartridges": "plugin_custom_cartridge",
          "creationDate": "2024-02-10T08:00:00.000Z",
          "lastModified": "2024-11-01T12:00:00.000Z"
        }
      ],
      "query": {
        "termQuery": {
          "fields": [
            "inDeletion"
          ],
          "operator": "is",
          "values": [
            false
          ]
        }
      },
      "sorts": [
        {
          "field": "id",
          "sortOrder": "asc"
        }
      ]
    }

    Example: SiteSearchResultSingle Single site search result

    Example of a site search returning a single site

    {
      "limit": 1,
      "offset": 0,
      "total": 1,
      "hits": [
        {
          "id": "RefArch",
          "customerListLink": {
            "customerListId": "RefArch",
            "title": "Default Customer List"
          },
          "displayName": {
            "default": "displayName",
            "en": "An English displayName",
            "de": "A German displayName"
          },
          "description": {
            "default": "description",
            "en": "An English description",
            "de": "A German description"
          },
          "inDeletion": false,
          "storefrontStatus": "online",
          "siteCatalogId": "storefront-catalog-m-en",
          "cartridges": "plugin_custom_cartridge:plugin_wishlists:plugin_apple_pay:plugin_facebook:plugin_payments:plugin_pinterest_commerce:plugin_web_payments:bc_content:core",
          "customCartridges": "plugin_custom_cartridge:plugin_wishlists",
          "creationDate": "2024-01-15T10:00:00.000Z",
          "lastModified": "2024-10-14T15:30:00.000Z"
        }
      ],
      "query": {
        "termQuery": {
          "fields": [
            "id"
          ],
          "operator": "is",
          "values": [
            "RefArch"
          ]
        }
      },
      "sorts": [
        {
          "field": "id",
          "sortOrder": "asc"
        }
      ]
    }
  • 400 Bad Request - Malformed search query or invalid parameters

    Media type: application/problem+json. Schema: ErrorResponse.

    Example: MalformedSearchParameter Malformed search query

    Example of an error when the search query is malformed or invalid

    {
      "title": "Malformed Search Parameter",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/malformed-search-parameter",
      "detail": "The search query contains invalid syntax. Please check the query structure and try again."
    }

    Example: InvalidFieldName Unqueryable Field

    Example of an error when an invalid field name is used in the search query

    {
      "title": "Unqueryable Field",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/unqueryable-field",
      "detail": "The field 'invalid_field' is not a searchable attribute for sites. Valid fields are: id, displayName, description, inDeletion."
    }

    Example: InvalidSortField Field Not Sortable

    Example of an error when an invalid field is used for sorting

    {
      "title": "Field Not Sortable",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/field-not-sortable",
      "detail": "The field 'invalid_sort' is not a sortable attribute for sites. Valid sortable fields are: id, displayName, description, inDeletion."
    }
  • 401 Your access token is invalid or expired and can’t be used to identify a user.

    Media type: application/problem+json. Schema: ErrorResponse.

    Example: UnauthorizedExample

    {
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/unauthorized",
      "title": "Unauthorized",
      "detail": "Unauthorized request"
    }
  • 403 Forbidden. Your access token is valid, but you don’t have the required permissions to access the resource.

    Media type: application/problem+json. Schema: ErrorResponse.

    Example: ForbiddenExample

    {
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/forbidden",
      "title": "Forbidden",
      "detail": "Access to requested resource forbidden"
    }