Catalog sync (Shopify)

Connect a Shopify store to Kelp - saving credentials, webhook registration, and order sync for product popularity. Catalog ingest, not storefront UI.

This guide covers the backend integration between your Shopify store and Kelp: connecting credentials, automatic webhook registration, and the order sync that populates product popularity fields (bestSeller, trending).

This page is catalog sync (credentials, webhooks, order popularity). Storefront search UI is separate: Shopify Liquid for Online Store themes, or Shopify Hydrogen / React storefronts for a React / Oxygen app.

Save Shopify credentials

Send a PUT /api/v1/tenants/{slug}/integration request with your Shopify store URL and API credentials. This is a tenant-admin operation.

PUT /api/v1/tenants/{slug}/integration

{
  "shopifyStoreUrl": "https://your-store.myshopify.com",
  "shopifyApiKey": "<custom-app-api-key>",
  "shopifyApiSecret": "<custom-app-api-secret-key>"
}

On success Kelp stores the credentials and immediately attempts to register product webhooks on the store (see the next step).

WebhookSecret - the critical detail

Kelp verifies every inbound webhook payload using an HMAC-SHA256 signature that Shopify attaches. Shopify signs API-created webhooks using the API secret key (client secret) of the custom app - not the Admin API access token.

The shopifyApiSecret you supply in the PUT /integration body is the value Kelp stores as the WebhookSecret and uses to verify every X-Shopify-Hmac-Sha256 header on inbound deliveries.

WebhookSecret must be the custom Shopify app's API secret key (client secret). Using the wrong value causes all inbound webhook deliveries to fail HMAC verification and be rejected with 401.

Where to find it:

  1. Shopify admin -> Apps -> Develop apps -> select your custom app.
  2. API credentials tab -> API secret key (the long alphanumeric string beginning with shpss_... or similar).
  3. That value is the shopifyApiSecret in your PUT /integration payload.

Automatic webhook registration

When credentials are saved, Kelp automatically registers three product webhooks on your Shopify store:

TopicPurpose
PRODUCTS_CREATEIndex new products when they are created in Shopify
PRODUCTS_UPDATERe-index products when any field changes
PRODUCTS_DELETERemove products from the index when deleted

All three deliver to:

https://events.{apex}/webhooks/shopify

where {apex} is your Kelp tenant's apex domain (e.g. events.kelp.click for the managed service).

Registration is idempotent: Kelp never deletes or duplicates webhooks. If a webhook for a topic already exists and points to the correct URL, it is left unchanged.

Re-check and repair webhooks

If you suspect a webhook is missing or pointing to the wrong URL, trigger a re-check:

POST /api/v1/tenants/{slug}/integration/webhooks

The response reports the outcome for each topic:

{
  "webhooks": [
    { "topic": "PRODUCTS_CREATE", "status": "Ok",      "message": null },
    { "topic": "PRODUCTS_UPDATE", "status": "Updated", "message": "URL corrected" },
    { "topic": "PRODUCTS_DELETE", "status": "Created", "message": "Registered" }
  ]
}

Possible status values:

StatusMeaning
OkWebhook exists and is correctly configured
CreatedWebhook was missing and has been registered
UpdatedWebhook existed but had a stale URL or config - corrected
FailedKelp could not register or update the webhook; see message for the Shopify error

This endpoint is safe to call repeatedly. It never removes existing webhooks.

Remove legacy admin-UI webhooks

Webhooks created manually through the Shopify admin UI (not via the API) are invisible to the Kelp API and cannot be managed by the re-check endpoint. If your store has any hand-created product webhooks from a previous setup, they will deliver duplicate events.

Delete them manually:

  1. Shopify admin -> Settings -> Notifications -> Webhooks.
  2. Remove any PRODUCTS_CREATE, PRODUCTS_UPDATE, or PRODUCTS_DELETE webhooks that point to a Kelp callback URL.

After removing, run POST /integration/webhooks to confirm the API-managed webhooks are in place.

Duplicate webhook deliveries cause products to be re-indexed twice per event. This is harmless for correctness but doubles Kelp's inbound event volume and may affect rate limits during high-activity periods.

Order sync and product popularity

Kelp tracks two popularity fields on every product in the index:

FieldCovers
bestSellerAll-time units sold, since tracking began
trendingUnits sold in the trailing 60 days

These fields are populated (and kept up to date) by syncing your Shopify order history into Kelp.

Running an order sync

POST /api/v1/tenants/{slug}/sync/orders

This is a tenant-admin operation. The sync reads your full Shopify order history, computes per-product unit totals, and writes bestSeller and trending scores to every document in the catalog.

On completion it automatically chains a catalog sync so updated scores are propagated to the search index without a separate step.

The response reports what happened:

{
  "kind": "OrderSync",
  "ordersProcessed": 14823,
  "unitsRecorded": 38401,
  "syncedFrom": "2024-01-01T00:00:00.000Z",
  "chainedSyncRunId": "sync_01j..."
}
FieldMeaning
ordersProcessedNumber of Shopify orders read
unitsRecordedTotal line-item units counted across all orders
syncedFromEarliest order date included in the sync
chainedSyncRunIdID of the catalog sync that was automatically triggered

Automatic daily sync

Order sync also runs automatically once per day. You do not need to schedule it yourself. Manual triggers are useful after:

  • An initial integration setup (to backfill history immediately)
  • A data correction (e.g. after bulk order cancellations or refunds)

Products with no order data

Products that appear in no synced orders receive bestSeller: 0 and trending: 0. They still appear in results and can be sorted - they sort below products with real scores when you sort descending on either field.

Next steps

On this page