Skip to main content
POST
https://app.uselayers.com/api/storefront/v1
/
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>",
  "tuning": {
    "textualWeight": 123,
    "visualWeight": 123,
    "multipleFactor": 123,
    "minimumMatch": 123,
    "missingEmbeddingScore": 123,
    "highSignalWeight": 123,
    "canonicalWeight": 123,
    "matchBoostExponent": 123
  },
  "pagination": {
    "page": 123,
    "limit": 123
  },
  "identity": {
    "deviceId": "<string>",
    "sessionId": "<string>",
    "customerId": "<string>"
  }
}
'
{
    "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.
tuning
object
Parameters to fine-tune the search results.
pagination
Pagination Object
identity
object
User identity information for tracking and personalization. Automatically managed by the Storefront Pixel; required for headless integrations.

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
  • Hybrid Scoring: Combines text and image similarity using configurable weights
  • Tuning Parameters: Control the balance between textual and visual similarity

Default Tuning Parameters

The Content Search endpoint uses different default tuning parameters than product search:
  • textualWeight: 0.7 (higher emphasis on text content)
  • visualWeight: 0.3 (lower emphasis on images)
  • topK: 3 (number of top candidates to consider)
  • minimumMatch: 0.0 (no minimum similarity threshold)
These defaults can be overridden using the tuning parameter in the request 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
    },
    "tuning": {
      "textualWeight": 0.8,
      "visualWeight": 0.2,
      "topK": 5,
      "minimumMatch": 0.3
    }
  }'
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.