FastTradein

Trade-in widget API and webhooks

Embed the widget and sync request statuses with webhooks signed using HMAC-SHA256. The device catalog stays on FastTradein.

Quick start

Embed the widget with two lines of HTML, then enter your website address under “Website” or “Websites where the widget works” in “Store settings”. The script talks only to FastTradein, not to your CMS.

Paste this into the HTML of the trade-in page. Replace the key with the widget key from the “Widget embed” page in your workspace.

<!-- FastTradein Widget -->
<script src="https://fasttradein.app/widget/fasttradein.js" async data-no-optimize="1" data-no-defer="1"></script>
<fasttradein-widget key="YOUR_PUBLIC_KEY" api="https://fasttradein.app" lang="en"></fasttradein-widget>

The snippet sets the api attribute to this FastTradein host. Without it, the widget uses the address the fasttradein.js script was loaded from.

Snippet parameters

key Required: Yes Widget key from Store settings or the Widget embed page. It can read the catalog, get an estimate, and submit a trade-in request. It cannot change prices or open other stores.
data-key Required: No The same widget key as key. React and Vue reserve key and do not pass it to the element, so use data-key there. The widget reads key first, then data-key, and restarts when either changes.
lang Required: No A language hint for embeds without saved widget languages. Supported codes are en, de, es, pl, ru and uk.
api Required: No FastTradein origin, for example https://fasttradein.app. Keep it in the snippet.
currency Required: No Not an HTML attribute. Display currency (EUR, PLN, UAH, USD, and other workspace currencies) comes from Store settings. Catalog prices stay in EUR and convert at the platform rate.

Events for conversion tracking

The element dispatches fasttradein:quote when the customer gets an estimate and fasttradein:order when a request is sent. Both bubble and cross the shadow DOM (composed), so you can listen on the element or on document. event.detail has device and blocked (quote) or device and payout_method (order), never customer data.

CMS snippets

Find embed instructions and compatibility notes for 111 platforms, with step-by-step guides for WooCommerce, OpenCart, Shopify, and PrestaShop. Before going live, add your store hostname to the allowed websites in your FastTradein workspace.

Showing 111 of 111 platforms

WooCommerce Global

Install the free FastTradein – Electronics Trade-in & Buyback 1.1.9 from WordPress.org. Enter your widget key in Settings → FastTradein and add a widget block or [fasttradein] shortcode to the page. You can also keep the embed code in Custom HTML or Elementor. Requests go to FastTradein, not WooCommerce orders.

Step-by-step guide for WooCommerce →

Free plugin on WordPress.org →

OpenCart Global

Choose the matching FastTradein package: 0.2.7 for OpenCart 2.0–2.2, or separate 0.2.6 packages for 2.3.0.2, 3 and 4. Connect your widget key and add the module through layouts. Alternatively, use the widget code in HTML Content. The guide explains installation for each branch.

Step-by-step guide for OpenCart →

Module in OpenCart Marketplace →

Shopify Global

Online Store → Edit theme: create a page template (Pages → Create template), add a Custom Liquid section with the code, and save. Then choose that template for the trade-in page in Online Store → Pages.

Step-by-step guide for Shopify →

PrestaShop Global

Install the free FastTradein module: Modules → Module Manager → Upload a module, then Configure and paste the code or the key. Write [fasttradein] on its own line in the content of a page in Design → Pages. PrestaShop does not save <script> in page content and strips the widget tag, so the module puts the widget in when the page is shown.

Step-by-step guide for PrestaShop →

Magento / Adobe Commerce Global

Content → Elements → Blocks → create a static HTML block and place it via Content → Pages.

Wix Global

Add Elements → Embed Code → Custom Element. Choose Source: Server URL = https://fasttradein.app/widget/fasttradein.js, Tag Name = fasttradein-widget. Set Attributes: data-key = YOUR_PUBLIC_KEY, api = https://fasttradein.app, lang = en. If the element has no Set Attributes option, this method will not work: Wix has not opened attributes to all accounts yet. This needs a Premium plan with a connected domain and no Wix ads. Do not use Embed HTML: it runs in an iframe on another domain, and the widget will not load there.

BigCommerce Global

Add the script in Storefront → Script Manager and place the <fasttradein-widget> tag through Page Builder (HTML widget).

Squarespace Global

Edit the trade-in page → add a Code block and paste the snippet. To run JavaScript in a Code block, the site needs the Core, Plus, or Advanced plan, and the widget shows only on the live site.

Shopware 6 Europe

Shopware 6.5 and later strip unknown tags and <script> from editor content. Load the <script> line in your theme’s footer.html.twig. Then allow the fasttradein-widget tag in the shopware.html_sanitizer settings (for example config/packages/z-shopware.yaml), open Content → Shopping Experiences, add a Text element to the trade-in page layout, switch its editor to the HTML code view, and paste only the <fasttradein-widget …></fasttradein-widget> tag.

Ecwid by Lightspeed Global

Instant Site: add a Custom code section on the trade-in page (Venture, Business, or Unlimited plan). On your own site, paste the snippet on the trade-in page next to the Ecwid code.

Webflow Global

Add Elements → Components → Embed (HTML Embed Code) on the trade-in page and publish the site. Code embeds need a paid Site or Workspace plan.

Drupal Commerce Global

Structure → Block layout → add a Custom Block with Full HTML format in the target region or Layout Builder.

Framer Global

Add an Embed component on the canvas, set the type to HTML, and paste the script plus the <fasttradein-widget> tag.

nopCommerce Global

Administration → Content Management → Topics (Pages) → open the trade-in page and paste the snippet in Source code mode.

Salesforce Commerce Cloud Global

Merchant Tools → Content → Content Assets → create an HTML asset and place it in Page Designer.

HubSpot CMS Global

Content → Design Manager → create a custom module with the snippet and add it to the trade-in page, or paste the snippet in the source code view of a rich text module.

Ghost Global

Add an HTML card with the snippet in the trade-in page editor. If you prefer, put only the <script> line in Settings → Code injection → Site footer and keep the <fasttradein-widget …></fasttradein-widget> tag in the HTML card.

Weebly Global

Drag an Embed Code (HTML) element onto the trade-in page, click Edit Custom HTML, and paste the snippet.

SAP Commerce Cloud Global

SmartEdit → add a CMS Paragraph or Custom HTML component to the trade-in page within WCMS.

Oracle Commerce Global

Design Studio → create a Custom Widget containing the HTML snippet and place it in the target page layout.

Square Online Global

Site Editor → Add section → Embed code → paste the snippet and publish the site. Embed code needs Square Online Plus or Premium.

Volusion Global

Design → Site Designer → add a Custom Code (HTML) block with the snippet on the trade-in page. If you load the <script> line through footer_custom.html, keep only the <fasttradein-widget …></fasttradein-widget> tag in the block.

Shift4Shop Global

Content → Site Pages → Edit Page → toggle the editor to HTML Source mode and paste the code.

NetSuite SuiteCommerce Global

SuiteCommerce Advanced → add a Custom Content CMS block or place the snippet in the theme layout template.

Zoho Commerce Global

Settings → Visual Builder → add an Embed code element onto the trade-in page and save changes.

VTEX Global

VTEX IO / Site Editor → create a custom block or include the widget web component in the Store Framework layout.

Carrd Global

Click + → Embed → set Type to Code and Style to Inline, paste the snippet, and publish. Embeds need Carrd Pro Standard or higher.

Hostinger Global

Website Builder → add an Embed code element and paste the snippet.

Shoper Europe

Keep HTML cleaning enabled. If you use Shoper Storefront on Shoper Premium, give your theme developer the widget code from your FastTradein workspace. Ask them to adapt it for a custom page layout module and add the module to your trade-in page in Shoper Visual Editor. With a classic RWD theme, your theme developer can load the script for the whole store under Aplikacje i integracje → Własne integracje. Ask them to place the fasttradein-widget element from your snippet only on the trade-in page. If your Storefront plan does not include custom modules, ask Shoper support about embedding options. Open the trade-in page as a customer and check that you can select a device and see a preliminary estimate.

IdoSell Europe

Sklep → Dodatki HTML/JS (HTML/JS add-ons): create an add-on, set “Wyświetlaj na podstronach” (show on subpages) to “Wybranych” (selected) with the trade-in page address, and paste the snippet into the HTML code field.

JTL-Shop Europe

JTL-Shop 5 has no built-in field for custom code. Load the <script> line through your child template (layout/footer.tpl, block layout-footer-js) or a header and footer code plugin from the JTL-Store, then put the <fasttradein-widget …></fasttradein-widget> tag on the trade-in page in HTML source mode.

Gambio Europe

Inhalte (Content) → Content Manager → create the trade-in page, switch the editor to HTML source mode, and paste the snippet.

Sylius Europe

Override templates/bundles/SyliusShopBundle/layout.html.twig (the @SyliusShop/layout.html.twig template) to load the <script> line, and put the <fasttradein-widget …></fasttradein-widget> tag in the trade-in page template.

Lightspeed eCom Europe

Settings → Web Extras → Custom JavaScript / HTML, or paste the code into the theme template.

Spryker Europe

Embed the web component in your Yves storefront Twig template or include the script in the base layout.

Plentymarkets Europe

CMS → Container → insert the widget HTML code into the Ceres template or a custom content block.

OXID eShop Europe

Customer Info → CMS Pages: create the trade-in page and paste the snippet in HTML source mode. If the editor strips the script, load the <script> line in your theme’s base layout (OXID 6: Application/views/<theme>/tpl/layout/base.tpl; OXID 7: the matching Twig template) and keep only the <fasttradein-widget …></fasttradein-widget> tag on the page.

Shoptet Europe

Appearance → HTML codes, or add an HTML block on the trade-in page.

Webnode Europe

Open the trade-in page and add an HTML element with the snippet.

TYPO3 Europe

Add an HTML content element on the trade-in page, or include the snippet in the site template.

Jimdo Europe

Add an HTML element on the trade-in page and paste the snippet.

VirtueMart Europe

Joomla article for the trade-in page → source mode. If the editor strips the script, add it in the template and leave the widget tag in the article.

Medusa.js Headless

Load the widget script in the Next.js or Remix storefront layout and add the <fasttradein-widget> web component on the trade-in page. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Saleor Headless

Load the widget script in the storefront (React / Next.js) and use the <fasttradein-widget> web component in JSX. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Vendure Headless

Load the widget script in the client storefront layout and add the <fasttradein-widget> tag on the trade-in page. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

commercetools Headless

Include the widget script in your React, Vue, or Next.js storefront and use the <fasttradein-widget> tag. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Swell Headless

Add the widget script into your Origin / Next.js storefront layout and place the tag on the trade-in page. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Strapi Headless

Embed the web component into the frontend client (Next.js, Nuxt, Remix) consuming your Strapi backend. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Contentful Headless

Place the widget component in your frontend codebase (Next.js, Astro, Gatsby) querying Contentful. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Sanity Headless

Integrate the web component into your Portable Text blocks or directly into your Next.js / Remix layout. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Next.js Storefront Headless

Load the script with <Script src="https://fasttradein.app/widget/fasttradein.js" strategy="afterInteractive" /> from next/script in app/layout. On the trade-in page, render <fasttradein-widget data-key="YOUR_PUBLIC_KEY" api="https://fasttradein.app" lang="en"></fasttradein-widget>. React reserves key and does not pass it to the element, so use data-key. With TypeScript, declare fasttradein-widget in JSX.IntrinsicElements.

Nuxt.js Storefront Headless

Load the script with useHead({ script: [{ src: "https://fasttradein.app/widget/fasttradein.js", defer: true }] }) and mark the tag as a custom element in nuxt.config: vue.compilerOptions.isCustomElement = (tag) => tag === "fasttradein-widget". On the trade-in page add <fasttradein-widget data-key="YOUR_PUBLIC_KEY" api="https://fasttradein.app" lang="en"></fasttradein-widget>. Vue reserves key and does not pass it to the element, so use data-key.

Vue Storefront Headless

Load the widget script in the storefront layout and place the <fasttradein-widget> tag on the trade-in page. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Commerce Layer Headless

Load the widget script in the storefront layout and place the <fasttradein-widget> tag on the trade-in page. In React and Vue, pass the key as data-key: both reserve key and do not pass it to the element.

Django Framework

Add the script in the base template and place the <fasttradein-widget> tag on the trade-in page.

Laravel Framework

Add the script in the Blade layout and place the <fasttradein-widget> tag on the trade-in view.

Ruby on Rails Framework

Add the script in the application layout and place the <fasttradein-widget> tag on the trade-in view.

Symfony Framework

Add the script in the base Twig layout and place the <fasttradein-widget> tag on the trade-in template.

Horoshop Ukraine

Settings → General settings → Scripts: paste the <script> line into the “before the </body> tag” field and save. Then open the trade-in page, switch its description editor to HTML code, and paste the <fasttradein-widget …></fasttradein-widget> tag.

Prom.ua Ukraine

Prom.ua does not allow your own scripts on a company site, so the widget cannot run there. Put the widget on your own website or landing page and link to that page from your Prom store.

Shop-Express Ukraine

Control panel → Settings → Custom scripts / HTML → paste the code on the trade-in page.

Weblium Ukraine

Add an Embed code block with the snippet directly on the trade-in page. If you prefer, load the <script> line in Site settings → Custom code (Head/Body) and keep only the <fasttradein-widget …></fasttradein-widget> tag in the Embed block. Custom code needs the Weblium Pro plan.

Other platforms

Paste the snippet into the trade-in page in HTML or source mode. If the editor removes the script, put the script in the site header or footer and leave the widget tag on the page.

  • MODX Global
  • GoDaddy Global
  • Miva Global
  • Nuvemshop / Tiendanube Global
  • Cafe24 Global
  • SHOPLINE Global
  • thebase Global
  • Salla Global
  • Tray Commerce Global
  • Sky-Shop Europe
  • RedCart Europe
  • AtomStore Europe
  • Comarch e-Sklep Europe
  • Sote Europe
  • Selly Europe
  • Unas Europe
  • ShopRenter Europe
  • CloudCart Europe
  • MerchantPro Europe
  • Gomag Europe
  • CCV Shop Europe
  • Mijnwebwinkel Europe
  • MyOnlineStore Europe
  • modified eCommerce Europe
  • xt:Commerce Europe
  • Intershop Europe
  • ePages Europe
  • Vilkas Europe
  • MyCashflow Europe
  • DanDomain Europe
  • SmartWeb Europe
  • Abicart Europe
  • Starweb Europe
  • Jetshop Europe
  • Mystore Europe
  • Odoo Europe
  • JouwWeb Europe
  • Webador Europe
  • Upgates Europe
  • EKM Europe
  • Visualsoft Europe
  • IONOS Europe
  • Strato Europe
  • Mozello Europe
  • Litium Europe
  • Cartum Ukraine
  • OkayCMS Ukraine
  • SoloMono Ukraine
  • ImageCMS Ukraine

Security and domain allow-list

The widget API is public by design but tied to your store. It gives no access to the workspace, price editing, or other stores’ data.

Domain allow-list (CORS / Origin)

These are the websites where your widget may run. Browser calls send Origin or Referer. FastTradein allows only the hostnames saved in Store settings (the Website field and “Websites where the widget works”), plus this FastTradein host. A request from any other site is rejected with 403 Forbidden.

Public widget key

The widgetKey in the URL is a public identifier. It can read the store catalog and submit a trade-in request. It cannot change prices, export other customers’ data, or open the workspace.

Rate limiting

Widget routes allow 120 requests per minute per IP for each store. Search is tighter (60 per minute). Creating a trade-in request is tighter still: 10 attempts per minute and 10 created requests per day per IP for each store, 20 created requests per day per network (/24 for IPv4, /64 for IPv6) for a store with a monthly request limit, and 8 per hour per customer email. Over the limit the API returns 429.

The store owner can set a separate limit on counted widget requests in any 24-hour period. It is off by default. When this limit is reached, the widget configuration reports that new requests are temporarily paused. A new request that would count returns 422 with a message in the customer’s language. Spam protection still applies, as does the monthly allowance for plans that have one. The Pro trial has a separate limit of 75 widget submissions in any 24 hours.

Bot protection

Use only the documented fields when submitting a trade-in request. If the request fails validation, the API returns HTTP 422 and does not create a trade-in request.

Storefront REST API

Base path: /api/widget/{widgetKey}. These routes are the same public widget surface the storefront script uses. Workspace and platform admin routes are not part of this contract.

When you change the widget language settings in FastTradein and save your changes, the widget opens in the default language you selected. Customers can switch between the languages you enable. A catalog request with ?locale=de returns German if that language is enabled. For a disabled language, it returns the store’s saved default. formatted_amount and max_buyback_formatted are ready-made strings for the customer: the amount rounded to whole units, with the currency symbol and digit grouping, for example “€1,235”. Their format depends on the language and the currency. For calculations read the numbers in minor units, cents for the euro: max_buyback and quoted_amount_cents. For example, quoted_amount_cents = 123456 means 1234.56 euros.

GET /api/widget/{widgetKey}

Store configuration

Returns store name, colors, currency, locale, enabled categories, payout methods, and widget copy.

Example cURL

curl -sS "https://fasttradein.app/api/widget/YOUR_PUBLIC_KEY?locale=en" \
  -H "Origin: https://shop.example" \
  -H "Accept: application/json"

Example response 200 OK

{
    "tenant": {
        "name": "Your store",
        "currency": "EUR",
        "locale": "en",
        "primary_color": "#1f3a8a",
        "logo_url": null
    },
    "locale": "en",
    "accepting_orders": true,
    "payout_methods": [
        {
            "value": "bank_transfer",
            "label": "Bank transfer"
        },
        {
            "value": "store_credit",
            "label": "Store credit toward a purchase"
        }
    ],
    "categories": [
        {
            "id": 1,
            "slug": "smartphones",
            "name": "Smartphones"
        }
    ],
    "catalog_version": "3f9a1c0b7e"
}
GET /api/widget/{widgetKey}/search?q=iPhone+13

Model search

Looks up models by name. If q is shorter than 2 characters, the response lists up to 6 popular models with "popular": true. Results include the current max buyback for that store. At most 8 hits. Hidden variants are omitted.

Example cURL

curl -sS "https://fasttradein.app/api/widget/YOUR_PUBLIC_KEY/search?q=iPhone+13" \
  -H "Origin: https://shop.example" \
  -H "Accept: application/json"

Example response 200 OK

{
    "results": [
        {
            "model_id": 42,
            "name": "iPhone 13",
            "brand": "Apple",
            "max_buyback": 42000,
            "max_buyback_formatted": "€420"
        }
    ]
}
POST /api/widget/{widgetKey}/orders

Create a trade-in request

Submit a trade-in request from the widget or your own client. A POST without an Origin or Referer header is refused with 403, so a server or app must send Origin: https://<a domain from your allow-list>. Collect variant_id and answer_ids first. Success is HTTP 201 with order_number.

JSON body

variant_id Required: Yes Active catalog variant.
answer_ids Required: Yes Answer IDs from the category questionnaire. One answer per question; a question with multiple set to true takes several, and an answer with exclusive set to true must be the only answer to its question.
customer_name Required: Yes Customer name.
customer_email Required: Yes Customer email.
customer_phone Required: No Optional phone. Digits, spaces, ( ) . / - and a + at the start; at least 6 digits, up to 40 characters. Otherwise the API returns 422.
payout_method Required: No bank_transfer or store_credit; store_voucher when the store has vouchers enabled. Without this field the request gets bank_transfer.

Example cURL

curl -sS -X POST "https://fasttradein.app/api/widget/YOUR_PUBLIC_KEY/orders" \
  -H "Origin: https://shop.example" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"variant_id":101,"answer_ids":[11,24],"customer_name":"Ada Lovelace","customer_email":"ada@example.com","customer_phone":"+49 170 000000","payout_method":"bank_transfer"}'

Replace https://shop.example with a domain from your widget allow-list.

Example response 201 Created

{
    "order_number": "TF-8PGPFFNLM6",
    "quoted_amount_cents": 38000,
    "formatted_amount": "€380",
    "currency": "EUR",
    "status": "submitted"
}

Other public widget routes

Needed to collect variant_id and answer_ids before POST /orders. Same key, same CORS rules.

  • GET /api/widget/{widgetKey}/catalog/{category} Brands, models, and storage variants for a category (id or slug).
  • GET /api/widget/{widgetKey}/questionnaire/{category} Checklist groups, questions, and answer IDs for that category. multiple marks a question that takes several answers, exclusive an answer that must be the only one for its question.
  • POST /api/widget/{widgetKey}/quotes Price the variant with the selected answers before creating a trade-in request. JSON body: variant_id, answer_ids.

Webhooks

Webhooks are available on the Business and Pro plans. In your workspace, open Settings → CRM webhooks, enter an HTTPS URL on the standard port (443) that resolves to a public IPv4 address, and generate the secret key. FastTradein sends the events below to that URL as JSON in an HTTP POST request so your system can process them.

Events

  • order.created The customer submitted a request from the widget.
  • order.received The store marked the device as received.
  • order.counter_offered The inspection changed the offer amount. The customer can accept or decline the new offer using a private link.
  • order.paid The store marked the request as paid.
  • order.accepted The customer accepted the new offer after inspection.
  • order.declined The request ended without a deal: the customer declined the new offer or did not answer it in time, the inspection found an account lock on the device, the store declined the device at intake, or the store marked the request as spam. The data.status field contains “declined”, “expired”, or “cancelled”.

JSON payload

The body is compact JSON (unescaped slashes and Unicode). Verify HMAC-SHA256 against these exact bytes. order_number is a string such as TF-8PGPFFNLM6, and event_id is evt_ followed by a UUID. The voucher_* fields are filled for store voucher requests once the voucher is issued; otherwise they are null.

{
  "event": "order.created",
  "event_id": "evt_c800a9c7-b11c-4b75-810e-e667544d825d",
  "timestamp": 1788550000,
  "tenant_id": 12,
  "data": {
    "order_number": "TF-8PGPFFNLM6",
    "status": "submitted",
    "currency": "EUR",
    "quoted_amount_cents": 38000,
    "inspected_amount_cents": null,
    "final_amount_cents": null,
    "device": "Apple iPhone 13 128GB",
    "customer": {
      "name": "Ada Lovelace",
      "email": "ada@example.com",
      "phone": "+49 170 000000"
    },
    "parcel_tracking_number": null,
    "payout_method": "bank_transfer",
    "voucher_code": null,
    "voucher_amount_cents": null,
    "voucher_url": null,
    "voucher_expires_at": null
  }
}

Headers

  • X-FastTradein-Event: Event name, same as payload.event.
  • X-FastTradein-Signature: HMAC-SHA256, computed over the raw body, prefixed with sha256=.
  • User-Agent: FastTradein-Webhook/1.0

Respond with any 2xx status within 10 seconds. Any other status, a timeout, or a redirect counts as a failure, and we retry twice, after 10 and after 60 seconds, with the same event_id and signature. Redirects are not followed, so use the final HTTPS address. Use event_id to skip duplicates.

Verify HMAC-SHA256

Compute HMAC-SHA256 over the raw POST body with your workspace secret. Compare it to X-FastTradein-Signature with a constant-time check. The header value starts with sha256=.

PHP · HMAC-SHA256

$signature = $_SERVER['HTTP_X_FASTTRADEIN_SIGNATURE'] ?? '';
$payload = file_get_contents('php://input');
$expected = 'sha256='.hash_hmac('sha256', $payload, $secret);
if (!hash_equals($expected, $signature)) {
    http_response_code(401);
    exit('Invalid signature');
}

Node.js · HMAC-SHA256

const crypto = require('node:crypto');

function verifySignature(rawBody, signature, secret) {
  if (!Buffer.isBuffer(rawBody) || !/^sha256=[0-9a-f]{64}$/.test(signature)) {
    return false;
  }
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
}

Runnable PHP receiver

Save this example as a PHP endpoint with PDO SQLite enabled. Set FASTTRADEIN_WEBHOOK_SECRET to your signing secret and FASTTRADEIN_WEBHOOK_DB to a writable database file outside the public web directory. The same event_id can arrive more than once. The database saves it once, and the endpoint returns 204 for both the first delivery and retries. Read the saved events to update your system. Keep those updates idempotent by event_id.

<?php
// PHP with pdo_sqlite. Point FASTTRADEIN_WEBHOOK_DB outside the document root.
$secret = getenv('FASTTRADEIN_WEBHOOK_SECRET');
$database = getenv('FASTTRADEIN_WEBHOOK_DB');
if (!$secret || !$database) {
    http_response_code(503);
    exit;
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header('Allow: POST');
    http_response_code(405);
    exit;
}

$body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FASTTRADEIN_SIGNATURE'] ?? '';
if ($body === false || !hash_equals('sha256='.hash_hmac('sha256', $body, $secret), $signature)) {
    http_response_code(401);
    exit;
}

try {
    $event = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException) {
    http_response_code(400);
    exit;
}
$eventId = $event['event_id'] ?? null;
if (!is_string($eventId) || !preg_match('/^evt_[a-z0-9-]{1,124}$/D', $eventId)) {
    http_response_code(400);
    exit;
}

try {
    $db = new PDO('sqlite:'.$database);
    $db->exec('PRAGMA busy_timeout = 5000');
    $db->exec('CREATE TABLE IF NOT EXISTS webhook_inbox (
        event_id TEXT PRIMARY KEY,
        payload TEXT NOT NULL
    )');
    $save = $db->prepare('INSERT INTO webhook_inbox (event_id, payload) VALUES (?, ?)
        ON CONFLICT (event_id) DO NOTHING');
    $save->execute([$eventId, $body]);
} catch (PDOException) {
    http_response_code(503);
    exit;
}

// The inbox entry now exists, even if this was a retry.
http_response_code(204);

Status codes

200 OK. GET returns the config, search results, catalog, and questionnaire; POST /quotes returns the quote.
201 Created. POST /orders succeeded; read order_number in the JSON.
402 The store cannot take new widget requests right now: the trial has ended or the subscription is canceled (TENANT_BILLING_INACTIVE), or this month’s request limit is used up (TENANT_LIMIT_EXCEEDED).
403 Domain not allowed: Origin / Referer is not on the store allow-list (error WIDGET_DOMAIN_DENIED), or a POST came without either header. The API also returns 403 (SHOPIFY_ENTITLEMENT) if a Shopify store has no active entitlement to accept widget requests.
404 Unknown widget key (error WIDGET_NOT_FOUND), category, or request number.
422 Validation error: missing answers, an inactive variant, or a disabled category. The API also returns 422 when the store reaches its limit for new requests in a 24-hour period.
429 Rate limit exceeded. Slow down and retry.