Skip to main content
POST
/
search
/
content
/
{searchQuery}
/
execute
Content Search: Execute Search
curl --request POST \
  --url https://app.uselayers.com/api/storefront/v1/search/content/{searchQuery}/execute \
  --header 'Accept: <accept>' \
  --header 'Content-Type: <content-type>' \
  --header 'X-Storefront-Access-Token: <x-storefront-access-token>' \
  --data '
{
  "content_type": "<string>",
  "pagination": {
    "page": 123,
    "limit": 123
  },
  "tuning": {
    "textualWeight": 123,
    "visualWeight": 123,
    "topK": 123
  },
  "identity": {
    "deviceId": "<string>",
    "sessionId": "<string>",
    "customerId": "<string>"
  },
  "context": {
    "geo": {
      "country": "<string>",
      "province": "<string>",
      "city": "<string>"
    },
    "productsInCart": [
      {
        "title": "<string>",
        "price": 123,
        "type": "<string>",
        "productId": "<string>",
        "variantId": "<string>",
        "options": {}
      }
    ],
    "productsPurchased": [
      {
        "title": "<string>",
        "price": 123,
        "type": "<string>",
        "productId": "<string>",
        "variantId": "<string>",
        "options": {}
      }
    ],
    "priorSearches": [
      {
        "searchQuery": "<string>",
        "hadClick": true,
        "hasResults": true,
        "fromPage": "<string>"
      }
    ],
    "marketing": {
      "source": "<string>",
      "medium": "<string>",
      "campaign": "<string>",
      "term": "<string>"
    },
    "customer": {
      "signedIn": true,
      "returning": true,
      "numberOfOrders": 123,
      "averageOrderValue": 123,
      "daysBetweenOrders": 123,
      "daysSinceLastOrder": 123,
      "daysSinceOldestOrder": 123,
      "totalSpent": 123
    },
    "shoppingChannel": "<string>",
    "custom": {}
  }
}
'
{
    "query": "sustainable fashion tips",
    "contentType": "article",
    "resultsPerPage": 20,
    "totalResults": 12,
    "page": 1,
    "totalPages": 1,
    "results": [
        {
            "__typename": "Article",
            "content_type": "article",
            "content_id": 12345678901,
            "title": "10 Ways to Build a Sustainable Wardrobe",
            "handle": "sustainable-wardrobe-tips",
            "summary_text": "Discover practical tips for creating an eco-friendly wardrobe that's both stylish and sustainable.",
            "author": "Emma Green",
            "tags": ["sustainability", "fashion", "eco-friendly"],
            "image": {
                "url": "https://cdn.shopify.com/s/files/1/0588/3677/9194/articles/sustainable-fashion.jpg",
                "width": 1200,
                "height": 630,
                "altText": "Sustainable Fashion Guide"
            },
            "published_at": "2024-06-01T12:00:00Z"
        }
    ]
}

Authorization

X-Storefront-Access-Token
string
required
Token-based authentication header in the form of <YOUR_LAYERS_TOKEN>.

Headers

Content-Type
string
default:"application/json"
required
Accept
string
default:"application/json"
required

Path Parameters

searchQuery
string
required
The url-encoded search query.

Body

content_type
string
Filter results by content type. Currently supports "article". When omitted, all content types are searched.
pagination
Pagination Object
tuning
object
Override default ranking weights for content search.
identity
object
User identity information for tracking and personalization. Automatically managed by the Storefront Pixel; required for headless integrations.
context
object
Contextual information about the customer’s session, behavior, and environment. Automatically collected by the Storefront Pixel; must be manually provided for headless integrations. See Contextual Information for implementation guidance.

Response

results
array
Array of content items matching the search query. Each item includes:
query
string
The search query that was executed.
contentType
string
The content type filter applied, if any.
totalResults
number
The total number of results matching the search query.
page
number
The current page number.
totalPages
number
The total number of pages.
resultsPerPage
number
The number of results per page.

Search Behavior

Content Search uses AI-powered semantic matching to find relevant articles:
  • Text Analysis: Analyzes article title, body content, author, and tags
  • Image Analysis: Analyzes the article’s featured image and images within the body

Error Handling

When search processing fails (e.g., due to rate limits or service issues), the API returns an empty result set with totalResults: 0 rather than throwing an error. This ensures graceful degradation of the search experience.
{
    "query": "sustainable fashion tips",
    "contentType": "article",
    "resultsPerPage": 20,
    "totalResults": 12,
    "page": 1,
    "totalPages": 1,
    "results": [
        {
            "__typename": "Article",
            "content_type": "article",
            "content_id": 12345678901,
            "title": "10 Ways to Build a Sustainable Wardrobe",
            "handle": "sustainable-wardrobe-tips",
            "summary_text": "Discover practical tips for creating an eco-friendly wardrobe that's both stylish and sustainable.",
            "author": "Emma Green",
            "tags": ["sustainability", "fashion", "eco-friendly"],
            "image": {
                "url": "https://cdn.shopify.com/s/files/1/0588/3677/9194/articles/sustainable-fashion.jpg",
                "width": 1200,
                "height": 630,
                "altText": "Sustainable Fashion Guide"
            },
            "published_at": "2024-06-01T12:00:00Z"
        }
    ]
}

Usage Example

cURL
curl -X POST "https://app.uselayers.com/api/storefront/v1/search/content/sustainable%20fashion/execute" \
  -H "X-Storefront-Access-Token: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content_type": "article",
    "pagination": {
      "page": 1,
      "limit": 20
    },
    "context": {
      "geo": {
        "country": "US"
      },
      "shoppingChannel": "web"
    },
    "identity": {
      "sessionId": "abc123",
      "deviceId": "device-uuid"
    }
  }'
Article Sync: Articles are automatically synced from Shopify via webhooks and bulk operations. Only published articles without the seo.hidden metafield are included in search results.