Back to SwatchBro

Developer API

Find missing variant images by color. Review the proposed matches, then apply confirmed repairs from a merchant-owned backend.

This is the server-side /external/v1 API—not a browser or headless storefront API.

Choose the right access.

Developer API plan access
PlanCapabilitiesOperations
Basic · $7/monthNoneNo Developer API access
Pro · $15/monthvariant_images:readScan and preview without product writes
Enterprise · $29/monthvariant_images:read, variant_images:writeScan, preview, and confirmed apply

Plans are billed in USD with a 14-day trial and no usage charges. Technical request limits still apply. View all plan features.

  1. Open SwatchBro → Developer API in your Shopify admin.
  2. Create a named key. Use audit-only access unless the integration needs Enterprise repairs.
  3. Save the secret when displayed; it is shown only once. Store it in your backend’s secret manager or protected environment.
  4. Send it in the Authorization: Bearer header over HTTPS. Revoke unused or compromised keys in the app.

Never put a key in Liquid, theme JavaScript, browser bundles, mobile apps, source control, URLs, screenshots, or logs. SwatchBro’s Shopify access token is never returned to your integration. The verified key determines the merchant; requests do not accept a caller-selected shop or tenant.

Production base URL: https://swatchbro.brofam.app. Use keys created in the public SwatchBro installation. Development keys and endpoints are separate.

Scan and preview missing images.

Send Shopify product GIDs from your own catalog integration in batches of 1–50 unique products. Use the option names your store actually uses; the default is Color/Colour. Scan and preview currently return the same read-only repair plan.

POST /external/v1/variant-images/scan
Audit missing variant-image coverage.
POST /external/v1/variant-images/preview
Review matches and obtain the revision required for apply.

Set SWATCHBRO_API_KEY securely in the server environment before running this example. Product ID 123 is a placeholder—replace it with a real product GID from your store.

curl --request POST \
  'https://swatchbro.brofam.app/external/v1/variant-images/preview' \
  --header "Authorization: Bearer $SWATCHBRO_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"productIds":["gid://shopify/Product/123"],"optionNames":["Color","Colour"]}'

A successful response includes productsScanned, missingVariants, readyRepairs, ambiguousGroups, a revision, and rows. Each row identifies the product, option value, missing variant GIDs, proposed media, match classification, and writable status.

How proposed images are matched
MatchMeaningEligible for repair?
exact_group_mediaOne existing media image is assigned within the same color group.Yes, when writable: true
exact_altOne product image has alt text matching the option value.Yes, when writable: true
ambiguousMultiple candidate images; no silent choice.No—review in Shopify
missingNo high-confidence existing image match.No—add or assign suitable media first

Only groups with missing assignments appear in the report. A successful response is not proof that every supplied product exists: check the returned products and rows against the batch you requested.

Review first. Apply deliberately.

Enterprise writes require a write-enabled key, explicit confirmation, and the unchanged preview revision. Review the whole preview: apply processes all eligible rows in the requested batch, not a caller-selected subset of preview rows. To narrow the batch, request and review a new preview.

curl --request POST \
  'https://swatchbro.brofam.app/external/v1/variant-images/apply' \
  --header "Authorization: Bearer $SWATCHBRO_API_KEY" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: catalog-repair-20260927-001' \
  --data '{"productIds":["gid://shopify/Product/123"],"optionNames":["Color","Colour"],"revision":"REVISION_FROM_PREVIEW","confirmed":true}'

Replace REVISION_FROM_PREVIEW with the actual returned revision. Keep the same product IDs and option names. The server rescans before writing and rejects a changed preview.

Repairs append existing Shopify product media to variants with no media. They do not upload new images, replace existing variant images, change inventory, prices, options, or product publication, or proxy image delivery. CSV image ingestion is a separate merchant-reviewed workflow.

Successful apply returns productsUpdated, variantsUpdated, and revision. Verify the affected assignments in Shopify. Multi-product repairs are not a single atomic transaction: if a timeout or failure occurs, inspect current assignments and request a fresh preview before attempting remaining repairs.

Use a unique 16–128 character Idempotency-Key containing letters, digits, periods, underscores, colons, or hyphens. Within the receipt window, the same key and identical request return the recorded result; different input with the same key is rejected. Do not create a new key merely to bypass an operation still in progress.

Keep jobs bounded.

Process batches sequentially, checkpoint results, and use bounded retries with backoff. Shopify throttling and execution limits can require smaller batches. These ceilings are safeguards, not a throughput guarantee. API responses use Cache-Control: no-store; do not cache responses in shared public caches.

Handle errors without blind retries.

Common responses and recovery
Status / errorWhat to do
401 invalid_api_keyCheck the backend secret and environment. Revoke and replace a compromised key.
403 capability_requiredCreate a key with the required capability.
403 plan_requiredConfirm the store has Pro for reads or Enterprise for writes.
403 installation_inactiveReconnect SwatchBro; check whether reinstall requires a new key.
409 preview_changedRequest a fresh preview, review it, and explicitly confirm the new revision.
409 idempotency_conflictA different request needs a new key and a reviewed preview.
409 request_in_progressWait; inspect current assignments before deciding whether recovery is needed.
409 authorization_changedRetry a read after a short delay; do not blindly replay a repair.
413 payload_too_largeReduce the request body.
429 rate_limitedHonor retryAfterSeconds; wait at least 60 seconds, then back off.

For validation errors, unexpected responses, timeouts, or failed writes, stop and inspect the result. Do not automatically replay an entire repair batch. Contact BroFam support with a sanitized error and request time—never a key or access token.

Build an audit, not a storefront dependency.

This API is useful for a merchant custom app, PIM, scheduled catalog audit, or controlled repair service. Keep product pages and swatch interactions on Shopify-native data and Shopify-hosted images; no Developer API request is needed for every page render or color click.

Explore SwatchBro · Ask an integration question