Overview
Icon for BaseLinker

BaseLinker

Two-way Base.com catalog, stock and order sync

BaseLinker by Koda Plus

Connect Medusa to BaseLinker (Base, base.com), the order and warehouse hub most Polish online stores run their marketplaces through, in both directions. You decide where the catalog lives and whose stock is the truth, and the plugin carries the rest: it links Medusa variants to BaseLinker cards or creates the missing cards, imports BaseLinker products when the catalog lives there, carries stock and prices the way you chose, sends store orders to BaseLinker exactly once, imports Allegro, Amazon and other marketplace orders into Medusa exactly once, and keeps statuses, parcels, returns and invoice numbers in step.

Every write that changes data ships switched off. It waits behind a plan your team reads item by item, and behind a writer a person arms in the admin, with their name and the date next to it.

Live demo: Medusa admin medusa.koda.plus/app/baselinker, signed in to a public demo account by the link itself, and the storefront demo.koda.plus. The demo runs the plugin in demo mode (Copy to clipboarddemo: true with Copy to clipboarddemoCreatesOrders: true), so every screen has data: place an order in the storefront and watch its BaseLinker row reach "Wysłane" with a tracking number a few minutes later, read the plans, arm a writer, and watch simulated Allegro and Amazon orders become Medusa orders. The Setup guide view (Copy to clipboard?view=guide) walks through a real setup step by step.

What it syncs

  • Card links (BaseLinker card to Medusa variant, by SKU, then EAN): read only, every hour at minute 15 and on Sync cards now. Variant cards are read too; a main card that has variants is a container and is never linked itself.
  • Catalog from BaseLinker (with Copy to clipboardcatalogSource: "baselinker"): products and variants with the price of one price group, SKU, EAN, weight, images, description, category and manufacturer, into Medusa after every complete read. Planned; applied by the Copy to clipboardcatalogImport writer.
  • Cards from Medusa (with Copy to clipboardcatalogSource: "medusa", the default): a new BaseLinker card for each variant that has none (name, SKU, EAN, weight, description, images, and the price and stock where they are known), and the name and EAN of linked cards kept in step. Planned; applied by the Copy to clipboardcards writer.
  • Stock, BaseLinker to Medusa (with Copy to clipboardstockSource: "baselinker", the default): one BaseLinker warehouse into Medusa inventory levels. Planned; applied by the Copy to clipboardstockToMedusa writer.
  • Stock, Medusa to BaseLinker (with Copy to clipboardstockSource: "medusa"): what Medusa can still sell, into one Copy to clipboardbl_ warehouse. Planned; applied by the Copy to clipboardstockToBaseLinker writer.
  • Prices, Medusa to BaseLinker (catalog in Medusa and Copy to clipboardpriceGroupId set): the Medusa price in Copy to clipboardpriceCurrency, gross, into the price group. Planned; applied by the Copy to clipboardprices writer. With the catalog in BaseLinker, prices come in with the catalog import instead.
  • Store orders (lines, prices, shipping address, invoice data, payment and cash on delivery flags): Medusa to BaseLinker on Copy to clipboardorder.placed, then every 2 minutes for retries, and on Send to BaseLinker now.
  • Marketplace orders (the BaseLinker order sources you choose: Allegro, Amazon, eBay, Erli and the rest): BaseLinker to Medusa, found every 5 minutes, created by the Copy to clipboardorderImport writer, exactly once each.
  • Order status and tracking (status name, parcel number, carrier, tracking link): BaseLinker to Medusa order metadata, for sent and for imported orders, every 15 minutes (from the BaseLinker order journal when it is enabled) and on Read statuses.
  • Fulfillment and cancellation: the Medusa fulfillment of the remaining items when BaseLinker reaches one of Copy to clipboardfulfillOnStatusIds (imported orders need Copy to clipboardorderImportShippingOptionId for that); an imported order is cancelled in Medusa when BaseLinker reaches one of Copy to clipboardorderImportCancelStatusIds and nothing is fulfilled yet, and flagged for a person otherwise. A payment that arrives later in BaseLinker marks the imported order paid.
  • Returns: the BaseLinker return manager, read only, every hour at minute 45 and on Read returns, linked to the Medusa order when the order is one this plugin sent or imported.
  • Invoice numbers: the number of each invoice or receipt the Fakturownia plugin of Koda Plus issues, into one field of the BaseLinker order. Applied by the Copy to clipboardinvoiceNumbers writer.

Write safety

  • Off until a person arms it. Seven writers: Copy to clipboardcatalogImport, Copy to clipboardcards, Copy to clipboardstockToMedusa, Copy to clipboardstockToBaseLinker, Copy to clipboardprices, Copy to clipboardorderImport and Copy to clipboardinvoiceNumbers. Each has two switches. The option Copy to clipboardwriters: { <name>: false } is a hard switch: it wins and cannot be overridden from the admin. The arm switch in the admin is stored in the database with who flipped it and when. Both stock writers also need Copy to clipboardstockSync: "write".
  • Write barrier by method name. Every Copy to clipboardget* method passes. Copy to clipboardaddOrder passes only while Copy to clipboardexportOrders is on. Copy to clipboardaddInventoryProduct, Copy to clipboardupdateInventoryProductsStock, Copy to clipboardupdateInventoryProductsPrices and Copy to clipboardsetOrderFields pass only with the permit of the writer that owns them, which a run gets only while that writer is armed. Every other method (Copy to clipboarddelete*, Copy to clipboardsetOrderStatus, Copy to clipboardsetOrderPayment, Copy to clipboardaddInvoice and the rest) is blocked by name before a request leaves the process.
  • Plan first. Catalog, card, stock and price changes are computed as a plan (what changes, from what to what), shown in the admin, and applied only by an armed writer, up to a cap per run. An item that fails Copy to clipboardquarantineAfter runs in a row (3 by default) is quarantined until a person releases it. An incomplete read plans nothing, and an item missing from a read is never zeroed or deleted.
  • Exactly once. Store orders, marketplace orders and invoice numbers each get a unique row before anything goes to the network and a lease, so a crashed process never leaves a row stuck. One run of each job and one worker per order, marketplace order and invoice document hold across every process of the store (a server and a worker, or several instances), as "Running more than one process" below explains. Every create is preceded by a lookup: the Copy to clipboard[medusa:<order id>] marker in BaseLinker for store orders, Copy to clipboardmetadata.baselinker_order_id and Copy to clipboardmetadata.marketplace_order_ref in Medusa for marketplace orders, the SKU in BaseLinker for new cards, the current value of the order field for invoice numbers. An unclear answer is settled by another lookup, never by a blind retry.
  • Retries only for transient errors (network, timeouts, 5xx responses, the rate limit), with backoff. A refusal about the item itself counts towards its quarantine; an outage does not.

Features

  • Admin page with two views. The Panel: connection check with everything the account offers (catalogs, warehouses and which of them take stock, price groups, order sources, statuses, custom order fields, journal state), the directions and writers, the plan of every direction in force with its filters and quarantine, the cards, the store orders, the marketplace orders, the returns, the invoice numbers and the history of runs. The Setup guide: a diagram of the parts, eleven steps from the token to go-live with a live state each, a go-live checklist ticked from the store itself, and answers to the failures this integration really meets.
  • Order widget on every order: the BaseLinker order, its status and the tracking link with Send to BaseLinker now, or why the order stays out; for an imported marketplace order its source, payment state and parcel instead. Product widget on every product: the linked cards, their BaseLinker stock and the main card they hang under. Both can be embedded by an app that hosts every Koda Plus plugin in one card (see "Works with Koda Plus hosts").
  • Deep links: the page opens on one list from a link, for example Copy to clipboard/baselinker?section=orders&filter=failed, Copy to clipboard/baselinker?section=cards&q=prod_... or Copy to clipboard/baselinker?view=settings&tab=plans&filter=quarantined.
  • Demo mode: a simulated BaseLinker account built from your own catalog, with duplicated SKUs and EANs, price groups, both stock directions, Allegro and Amazon orders and returns. Nothing leaves Medusa.
  • Admin in English and Polish.
  • Workflows and events for your own code.

Requirements

  • Medusa 2.12 to 2.21 and Node.js 20+ (see "Compatibility").
  • For a real account: a BaseLinker API token (in BaseLinker: Account & other, My account, API) and a catalog (inventory) with a Copy to clipboardbl_ warehouse. The plugin works with catalogs, not with BaseLinker's old storage.
  • For marketplace orders: a Medusa region for the order currency and a sales channel whose stock location holds the stock. For invoice numbers: the Fakturownia plugin of Koda Plus (optional, never imported as a package).

Installation

npm install @koda-plus/medusa-plugin-baselinker

Yarn and pnpm work the same way: Copy to clipboardyarn add @koda-plus/medusa-plugin-baselinker or Copy to clipboardpnpm add @koda-plus/medusa-plugin-baselinker.

Configuration

Add the plugin to Copy to clipboardmedusa-config.ts:

module.exports = defineConfig({
// ...
plugins: [
{
resolve: "@koda-plus/medusa-plugin-baselinker",
options: {
apiToken: process.env.BASELINKER_API_TOKEN,
inventoryId: process.env.BASELINKER_INVENTORY_ID, // the BaseLinker catalog
warehouseId: process.env.BASELINKER_WAREHOUSE_ID, // like bl_12345
orderStatusId: process.env.BASELINKER_ORDER_STATUS_ID, // status of new orders
customSourceId: process.env.BASELINKER_SOURCE_ID, // recommended
priceGroupId: process.env.BASELINKER_PRICE_GROUP_ID,
// catalogSource: "medusa", // or "baselinker"
// stockSource: "baselinker", // or "medusa"
// stockSync: "plan", // "off" | "plan" | "write"
// orderImportSources: ["allegro", "amazon:7245"],
// writers: { prices: false }, // a hard switch: false wins over the admin
// demo: process.env.BASELINKER_DEMO === "true", // sample data, only when switched on
},
},

Run the migrations, then open BaseLinker in the admin sidebar and click Check connection:

npx medusa db:migrate

Setup in brief

The Setup guide view of the admin page has the same steps, each with its live state.

  1. Create the API token. In BaseLinker open Account & other, My account, API and generate a token for this store. Put it in Copy to clipboardBASELINKER_API_TOKEN.
  2. Configure the plugin as above and run Copy to clipboardnpx medusa db:migrate. Missing values never break the start: the Panel lists what is missing.
  3. Choose the catalog and the warehouse. Check connection lists the catalogs with their warehouses. Set Copy to clipboardinventoryId, and a warehouse of type Copy to clipboardbl as Copy to clipboardwarehouseId: only Copy to clipboardbl_ warehouses take stock writes, Copy to clipboardshop_ and Copy to clipboardwarehouse_ ones mirror an external system.
  4. Price group and order statuses. Check connection lists the price groups and the order statuses. Set Copy to clipboardpriceGroupId (a standard group in your currency, not a derived one), Copy to clipboardorderStatusId for new orders, Copy to clipboardfulfillOnStatusIds for shipped, Copy to clipboardclosedStatusIds for finished and Copy to clipboardorderImportCancelStatusIds for cancelled.
  5. A custom order source (recommended). In BaseLinker open Orders, Settings, Custom order sources, create one named after the store and set its id as Copy to clipboardcustomSourceId.
  6. Decide the source of truth for each kind of data: the catalog (Copy to clipboardcatalogSource), stock (Copy to clipboardstockSource), prices (they follow the catalog) and marketplace orders (Copy to clipboardorderImportSources). Clear the duplicated SKUs and EANs the cards show before any import or push.
  7. Read the plans. Sync cards now reads BaseLinker and makes the plan of every direction in force. Nothing is written.
  8. Arm the writers one at a time, reading the history after each. Start the cards writer with Copy to clipboardmaxCatalogChangesPerRun: 1 and look at that one card in BaseLinker.
  9. Marketplace orders (optional). Set Copy to clipboardorderImportSources, make the store's confirmation e-mail skip orders with Copy to clipboardmetadata.marketplace_order_ref, then arm the order import writer.
  10. Invoice numbers (optional). Choose Copy to clipboardinvoiceNumberField, then arm the invoice number writer.
  11. Go live with the checklist of the guide.

Options

Every option is optional. Numbers may come as strings (environment variables), lists as comma separated strings. Missing options never break the boot: the module registers, the admin lists what is missing and each job waits for the options it needs. Demo mode never switches itself on: it runs only with an explicit Copy to clipboarddemo: true (the live demo sets Copy to clipboarddemo: process.env.BASELINKER_DEMO === "true"). Without a token and without demo mode the plugin says "Not configured" and sends nothing.

Order export starts the moment Copy to clipboardexportOrders is on (the default) and Copy to clipboardorderStatusId is set, before any writer is armed: every new order goes to BaseLinker from then on, test orders of the setup included. Keep Copy to clipboardexportOrders: false until the store goes live, or mark test orders with the skip key.

Connection

  • Copy to clipboardapiToken: BaseLinker API token. Stays on the server and is masked in every log, stored error and admin screen.
  • Copy to clipboardinventoryId: the BaseLinker catalog (inventory) the cards live in.
  • Copy to clipboardwarehouseId: the warehouse whose stock counts, like Copy to clipboardbl_12345 (a bare number becomes Copy to clipboardbl_<number>). Stock pushed from Medusa needs a Copy to clipboardbl_ warehouse.
  • Copy to clipboardorderStatusId: the BaseLinker status new store orders get.
  • Copy to clipboardcustomSourceId (optional): a custom order source created in BaseLinker, so Medusa orders are labeled there. It also lets the status read fetch 100 orders per request, and keeps the marketplace import from taking our own orders back.
  • Copy to clipboardstockLocationId (optional when the store has one location): the Medusa stock location stock is read from and written to.
  • Copy to clipboarddemo (default Copy to clipboardfalse): the simulated BaseLinker account. Only an explicit Copy to clipboardtrue (or Copy to clipboard"true") switches it on.
  • Copy to clipboarddemoCreatesOrders (default Copy to clipboardfalse): demo mode only. Simulated marketplace orders become Medusa orders of the store (flagged Copy to clipboardmetadata.baselinker_demo) once the order import writer is armed. Off, they stay rows of the import list. Meant for a demo store like medusa.koda.plus, never for a store that sells.
  • Copy to clipboardrequestsPerMinute (default Copy to clipboard80, at most Copy to clipboard100): self-imposed rate limit shared by every job.
  • Copy to clipboardtimeoutMs (default Copy to clipboard20000): one BaseLinker request.

Directions, writers and limits

  • Copy to clipboardcatalogSource (default Copy to clipboardmedusa): Copy to clipboardmedusa links cards and lets the Copy to clipboardcards writer create the missing ones; Copy to clipboardbaselinker lets the Copy to clipboardcatalogImport writer import BaseLinker products into Medusa. Prices follow the catalog.
  • Copy to clipboardstockSource (default Copy to clipboardbaselinker): Copy to clipboardbaselinker plans BaseLinker stock into Medusa; Copy to clipboardmedusa plans Medusa stock into the Copy to clipboardbl_ warehouse.
  • Copy to clipboardstockSync (default Copy to clipboardplan): Copy to clipboardoff (no stock plan at all), Copy to clipboardplan (plans are stored and shown, nothing is written) or Copy to clipboardwrite (the stock writer of the direction may be armed). Version 0.1 configurations with Copy to clipboardwrite keep writing BaseLinker stock into Medusa until a person touches the arm switch.
  • Copy to clipboardwriters (default: none switched off): hard switches by writer name, for example Copy to clipboard{ catalogImport: false, prices: false }. Copy to clipboardfalse (or Copy to clipboard"false") wins over the admin.
  • Copy to clipboardpriceGroupId (default none): the BaseLinker price group the catalog import reads and the price push writes.
  • Copy to clipboardpriceCurrency (default Copy to clipboardpln): the Medusa currency of that price group.
  • Copy to clipboardmaxCatalogChangesPerRun (default Copy to clipboard200): imported products and created or updated cards per run.
  • Copy to clipboardmaxStockChangesPerRun (default Copy to clipboard500): stock changes per run, in either direction; decreases go first.
  • Copy to clipboardmaxPriceChangesPerRun (default Copy to clipboard1000): price changes per run.
  • Copy to clipboardquarantineAfter (default Copy to clipboard3): failed runs of one item before it is quarantined.
  • Copy to clipboardcatalogSyncEnabled (default Copy to clipboardtrue): the hourly read and every plan after it.

Catalog import (Copy to clipboardcatalogSource: "baselinker")

  • Copy to clipboardcatalogImportStatus (default Copy to clipboardpublished): status of the products the import creates, or Copy to clipboarddraft.
  • Copy to clipboardcatalogImportSalesChannelId (default: the store's default sales channel): sales channel of imported products.
  • Copy to clipboardcatalogImportShippingProfileId (default: the default shipping profile): shipping profile of imported products.
  • Copy to clipboardcatalogImportOptionTitle (default Copy to clipboardVariant): the option of imported products with several variants; its values are the variant names.
  • Copy to clipboardcreateMissingCategories (default Copy to clipboardfalse): create Medusa categories that do not exist yet (matched by name). Off, a missing category is only reported.
  • Copy to clipboardmanufacturerAs (default Copy to clipboardmetadata): the manufacturer goes to Copy to clipboardmetadata.manufacturer, or to a product tag with Copy to clipboardtag (only the tag naming a BaseLinker manufacturer is ever replaced).
  • Copy to clipboarddraftRemovedProducts (default Copy to clipboardfalse): an imported product removed in BaseLinker becomes a draft. Off, it is only reported. Nothing is ever deleted.
  • Copy to clipboardweightUnit (default Copy to clipboardg): the unit of Medusa weights, Copy to clipboardg or Copy to clipboardkg. BaseLinker uses kilograms.

Store orders to BaseLinker

  • Copy to clipboardexportOrders (default Copy to clipboardtrue): send placed orders to BaseLinker.
  • Copy to clipboardfulfillOnStatusIds (default none): BaseLinker status ids that create the Medusa fulfillment for the remaining items. BaseLinker sent the parcel: the fulfillment carries Copy to clipboardmetadata.shipped_outside_medusa = "baselinker", which the InPost plugin of Koda Plus reads, so it creates no parcel of its own.
  • Copy to clipboardclosedStatusIds (default none): BaseLinker status ids after which an order is no longer read. Without them, orders are followed for 30 days.
  • Copy to clipboardcodProviders (default Copy to clipboardpp_cod, Copy to clipboardpp_cash): payment provider id prefixes meaning cash on delivery.
  • Copy to clipboardpaymentLabels (default: built-in English names): payment method names shown in BaseLinker by provider id prefix, for example Copy to clipboard{ pp_cod: "Pobranie", pp_stripe: "Karta / BLIK" }. Up to 30 characters each.
  • Copy to clipboardskipOrderMetadataKey (default Copy to clipboardbaselinker_skip): an order with Copy to clipboardmetadata[key] === true never goes to BaseLinker. Use it for test orders.
  • Copy to clipboardexportMarketplaceOrders (default Copy to clipboardfalse): orders another plugin took straight from a marketplace (they carry Copy to clipboardmetadata.marketplace_order_ref) go to BaseLinker too. Off by default, because BaseLinker usually gets them from its own marketplace integration.

Marketplace orders into Medusa

  • Copy to clipboardorderImportSources (default none, nothing is imported): BaseLinker order sources to import, as types or Copy to clipboardtype:id, for example Copy to clipboard["allegro", "amazon:7245"] or Copy to clipboard"allegro,erli". The ids come from Check connection.
  • Copy to clipboardorderImportRegionId (default: the region of the order currency): region of imported orders.
  • Copy to clipboardorderImportSalesChannelId (default: the store's default sales channel): sales channel of imported orders.
  • Copy to clipboardorderImportShippingOptionId (optional): shipping option of imported orders. With it, Copy to clipboardfulfillOnStatusIds fulfills them too.
  • Copy to clipboardorderImportCancelStatusIds (default none): BaseLinker statuses that cancel the imported Medusa order while nothing is fulfilled.
  • Copy to clipboardorderImportSince (default: 24 hours before the first discovery): ISO date of the first orders to read.
  • Copy to clipboardorderImportMaxAgeHours (default Copy to clipboard72): an order older than this when the writer reaches it waits for a person instead of being imported.

Returns, journal, invoice numbers

  • Copy to clipboardreturnsSync (default Copy to clipboardtrue): read returns, read only.
  • Copy to clipboardreturnsWindowDays (default Copy to clipboard30): returns of the last N days.
  • Copy to clipboardjournal (default Copy to clipboardauto): Copy to clipboardauto reads statuses from the BaseLinker order journal when it returns events, with a full read every 2 hours and after a gap of more than 2 days; Copy to clipboardoff always reads the full way.
  • Copy to clipboardinvoiceNumberField (default Copy to clipboardextra_field_1): the BaseLinker order field for invoice numbers: Copy to clipboardextra_field_1, Copy to clipboardextra_field_2 or a custom order field id (Copy to clipboard135 or Copy to clipboardcustom:135).
  • Copy to clipboardinvoiceNumberKinds (default Copy to clipboardvat, Copy to clipboardreceipt): Fakturownia document kinds whose number is written.

How linking works

  1. The whole catalog is read with Copy to clipboardgetInventoryProductsList and Copy to clipboardinclude_variants, 1 000 cards per page, from page 1 until a short page. A failed page or the page ceiling makes the read incomplete.
  2. A main card that has variants is a container: stored and shown, never linked. Its variant cards are linked like simple cards.
  3. Every card is looked up by SKU, uppercased and trimmed on both sides. A SKU that sits on two or more cards is a Copy to clipboardduplicate_sku conflict; two variants with one SKU are an Copy to clipboardambiguous_variant conflict. Neither is linked.
  4. A card the SKU did not settle is looked up by EAN (digits only, 8 to 14), with the same rules (Copy to clipboardduplicate_ean). A variant is linked to at most one card, and a SKU link wins over an EAN link.
  5. A complete read replaces the snapshot. An incomplete read only adds and updates: a card missing from a broken list looks exactly like a deleted one, so nothing is unlinked.
  6. Variants with a SKU that no card carries are counted as "only in Medusa".

Why so strict: on a production account we measured 12 993 cards carrying 8 522 distinct SKUs, and at a tyre retailer with about 11 000 cards, 4 438 SKU pairs were the same physical item entered twice. Linking "the first one" would send stock and orders to a random copy.

Catalog import (plan first)

With Copy to clipboardcatalogSource: "baselinker", every complete read is followed by Copy to clipboardgetInventoryProductsData (100 cards per request), Copy to clipboardgetInventoryCategories and Copy to clipboardgetInventoryManufacturers, and a plan:

  • Create: a BaseLinker product with no Medusa counterpart becomes a Medusa product with its variants (one option, Copy to clipboardcatalogImportOptionTitle), the price of Copy to clipboardpriceGroupId, SKU, EAN, weight, images in BaseLinker's order, description, category (by name) and manufacturer, and Copy to clipboardmetadata.baselinker_product_id. The new variants are linked to their cards at once.
  • Update: a linked product whose title, description, images, category, manufacturer, variant title, price, EAN or weight differs is updated field by field; unchanged fields stay out of the write. A new BaseLinker variant of an imported product adds an option value and a variant.
  • Draft: an imported product removed in BaseLinker, only with Copy to clipboarddraftRemovedProducts.
  • Skip or conflict, with the reason: bundles, cards without a SKU, duplicated SKUs or EANs, a SKU on two Medusa variants, variants spread over two Medusa products, a new variant of a product the import did not create, a missing category while Copy to clipboardcreateMissingCategories is off.

The import is idempotent by the BaseLinker id: a product it created is found by Copy to clipboardmetadata.baselinker_product_id and its variants by their card links, so a second run updates instead of creating again. Writes go through Medusa's own workflows (Copy to clipboardcreateProductsWorkflow in batches of 10, Copy to clipboardupdateProductsWorkflow, Copy to clipboardupdateProductVariantsWorkflow) and prices through the Pricing module, which adds or replaces only the base price of Copy to clipboardpriceCurrency and leaves every other price alone. BaseLinker prices are gross: for net Medusa prices they are divided by the product's VAT rate, and a product without a rate gets no price change at all.

Cards from Medusa (plan first)

With Copy to clipboardcatalogSource: "medusa", every complete read is followed by the card plan:

  • Create a card for a variant that has none: name (product and variant title, up to 200 characters), SKU, EAN, weight in kilograms, description, up to 16 images, the price in Copy to clipboardpriceGroupId when Medusa prices include tax, and the first stock when Medusa is the source of stock. Each variant becomes its own card; grouping cards under a main card stays a decision made in BaseLinker.
  • Update a linked card whose name or EAN no longer matches Medusa. Only those two fields are sent: prices and stock have their own plans.
  • Never a second card for the same goods. A variant whose SKU already sits on any card, or whose EAN sits on a card with another SKU, is a conflict. Before every create the plugin looks the SKU up in BaseLinker, and after an unclear answer it looks again instead of creating twice. A SKU longer than the 50 characters BaseLinker keeps is skipped, never sent cut.

The created card is linked to its variant at once, so the next plans (stock, prices) already see it.

Stock in both directions (plan first)

The plan covers linked, conflict-free variants that manage inventory with exactly one inventory item, after every complete read. Kits are skipped, and so is everything after an incomplete read.

  • BaseLinker to Medusa (Copy to clipboardstockSource: "baselinker"): Copy to clipboardtarget stocked = max(0, BaseLinker stock) + reserved quantity of the level. BaseLinker reports what can still be sold while Medusa keeps Copy to clipboardstocked before its reservations; adding the reservations back makes Medusa's available quantity equal to BaseLinker's, and an order already sent to BaseLinker does not take the item twice. Applied with Medusa's own Copy to clipboardbatchInventoryItemLevelsWorkflow.
  • Medusa to BaseLinker (Copy to clipboardstockSource: "medusa"): Copy to clipboardtarget = max(0, stocked - reserved) of the Medusa level, written with Copy to clipboardupdateInventoryProductsStock into the Copy to clipboardbl_ warehouse, 1 000 cards per request. A level that does not exist is unknown, never zero. A card BaseLinker refuses (its warning names the card) fails alone and counts towards its quarantine.

Both directions write absolute numbers, never deltas, so a repeated write is harmless; decreases go first and Copy to clipboardmaxStockChangesPerRun caps a run. Why a plan first: BaseLinker numbers are not always the truth. On a production account we found duplicated cards with different stock, negative stock after overselling and a nightly import that kept raising zeros back.

Prices (plan first)

With the catalog in Medusa and Copy to clipboardpriceGroupId set, the base Medusa price in Copy to clipboardpriceCurrency of every linked variant is compared with the card's price in that group and changed ones are written with Copy to clipboardupdateInventoryProductsPrices, 1 000 per request, within Copy to clipboardmaxPriceChangesPerRun. BaseLinker keeps gross prices: net Medusa prices are multiplied by the card's VAT rate, and a card without a rate is left alone. Before the first write of a run the plugin reads the price groups and writes nothing into a group derived from another one (BaseLinker computes those itself), a group the account does not have, or a group in another currency than Copy to clipboardpriceCurrency; Check connection shows the same warnings.

Store orders exactly once

BaseLinker has no idempotency key, and a mapping row written after Copy to clipboardaddOrder cannot protect against a lost answer. So:

  1. Copy to clipboardorder.placed writes a row in Copy to clipboardbaselinker_order first, then sends in the background. The payload is built from the order at send time and never stored, because it carries personal data.
  2. Every attempt scans Copy to clipboardgetOrders (from the order date minus one hour, unconfirmed orders included, paging by Copy to clipboardid_from) for the marker Copy to clipboard[medusa:<order id>]. Found: that BaseLinker order is adopted and nothing is written.
  3. Otherwise one Copy to clipboardaddOrder. It is never retried blindly; only a rate limit refusal repeats, because then BaseLinker took nothing.
  4. A timeout, a 502 or broken JSON after Copy to clipboardaddOrder means "no answer", not "no order": the plugin waits and scans again. Still not found, the row is retried later, and that attempt scans first.
  5. Success writes Copy to clipboardsent, the BaseLinker order id and Copy to clipboardmetadata.baselinker_order_id, and emits Copy to clipboardbaselinker.order_sent (live mode; the demo writes its own row only). After the backoff runs out (about two and a half days) the row is Copy to clipboardfailed, Copy to clipboardbaselinker.order_failed is emitted, and a person can Send again, which is always safe.

Lines whose variant is linked go to their card (Copy to clipboardstorage: "db", the catalog id, the card id), so stock moves on the right card in BaseLinker. Other lines go as free lines with name, SKU and EAN; the order still arrives. The unit price is the line total after discounts divided by the quantity, the tax rate is the highest rate of the line. Copy to clipboardpaid is 1 only when the payment is captured in full; Copy to clipboardpayment_method_cod marks cash on delivery by payment provider. Invoice fields go only when the buyer asked for one (Copy to clipboardmetadata.invoice or a tax id such as Copy to clipboardmetadata.invoice_nip), and the parcel locker from the shipping method data becomes the delivery point (id, name, address, post code, city): Copy to clipboardmachine_id with Copy to clipboardmachine_name and Copy to clipboardmachine_address (the InPost plugin of Koda Plus, InPost Pay, the InPost geowidget), else Copy to clipboardpickup_point, Copy to clipboardtarget_point, Copy to clipboardlocker_code and similar keys. The parcel is sent in one place: a fulfillment that Copy to clipboardfulfillOnStatusIds creates carries Copy to clipboardshipped_outside_medusa: "baselinker" in its metadata, and the InPost plugin of Koda Plus records it as shipped outside Medusa, so an order on an InPost option never gets a second parcel from it.

Orders that came from a marketplace never go back: an order this plugin imported (its import table says so, never the order metadata) gets no row, and an order another plugin created with Copy to clipboardmetadata.marketplace_order_ref is skipped unless Copy to clipboardexportMarketplaceOrders is on. Every skip is a visible Copy to clipboardskipped row with a code: Copy to clipboardcanceled, Copy to clipboardskip_key, Copy to clipboardmarketplace_order or Copy to clipboardimported.

If Medusa cannot compute an order's totals (a shipping method without a version, as some orders created by other plugins have), the order is read again without them and its totals are computed from the lines: unit price times quantity minus adjustments, with the tax of the tax lines on net prices. Copy to clipboardadmin_comments says so, and Copy to clipboardpaid is 1 only when the captured money covers both that sum and the payment collection. When even that read fails, the row waits with Copy to clipboardtotals_unavailable and tries again.

Marketplace orders into Medusa (exactly once)

Discovery runs every 5 minutes while Copy to clipboardorderImportSources is set: Copy to clipboardgetOrders from a cursor on Copy to clipboarddate_confirmed (confirmed orders only, 100 per page), filtered to the chosen sources. Our own exports (the marker in Copy to clipboardadmin_comments) and orders of our custom source are never taken. Each order becomes a Copy to clipboardpending row, one per BaseLinker order id: the admin shows them before anything is created. The cursor starts again at the same second and skips the ids it has seen, so orders confirmed in the same second as a page boundary are not lost.

Import runs only while the Copy to clipboardorderImport writer is armed, per row, under a lock on the BaseLinker id:

  1. The row's next attempt moves ten minutes ahead first, so a crashed process leaves a row that comes back by itself.
  2. An order older than Copy to clipboardorderImportMaxAgeHours waits for a person (Import now imports it anyway).
  3. The order is read again from BaseLinker. The buyer's data goes onto the Medusa order and nowhere else.
  4. Lookups before create: a Medusa order this row created earlier (it carries the row's id in Copy to clipboardmetadata.baselinker_import_id, or it has no cart behind it) is adopted. A Medusa order created by backend code with the same Copy to clipboardmetadata.marketplace_order_ref (taken by another plugin or by hand) makes this one Copy to clipboardskipped. An order placed from a storefront cart counts for neither: its metadata is the shopper's word. The reference is looked up again inside a lock named Copy to clipboardmarketplace-order-ref:<ref>, the key the other marketplace plugins of Koda Plus take for the same order, so the one that comes second sees the first one's order.
  5. The order is created as a draft with Medusa's own Copy to clipboardcreateOrderWorkflow and its id is stored at once, then placed with Copy to clipboardconvertDraftOrderWorkflow, which reserves the inventory and emits Copy to clipboardorder.placed, just as the admin does with draft orders. Lines of linked cards get their variant, other lines stay custom lines; prices come from the order (gross, Copy to clipboardis_tax_inclusive), taxes from the region, delivery becomes a shipping method with its price, a pickup point goes to the shipping method data (Copy to clipboardpickup_point, BaseLinker's own keys: the order is not handed to the shipping provider of Copy to clipboardorderImportShippingOptionId, because BaseLinker sends the parcels of these orders and that one option lands every carrier, so the InPost plugin of Koda Plus records no parcel for them), and the e-mail is set on the order itself, never through a guest customer.
  6. A payment collection for the total, marked paid through Medusa's Copy to clipboardmarkPaymentCollectionAsPaid when BaseLinker has the order paid in full. Cash on delivery and unpaid orders stay unpaid until BaseLinker reports the payment.

Why Copy to clipboardcreateOrderWorkflow and not the cart: Medusa documents it for importing orders from an external system, it takes our own unit prices, checks the inventory, computes tax lines from the region and keeps the shipping method we give it. The cart path would need a payment session and a shipping option the marketplace order never had.

Imported orders carry Copy to clipboardmetadata.baselinker_imported, Copy to clipboardbaselinker_order_id, Copy to clipboardbaselinker_order_source, Copy to clipboardbaselinker_external_order_id and Copy to clipboardmarketplace_order_ref = "<source>:<external order id>" (lowercased, for Allegro Copy to clipboardallegro:<checkout form id>), plus Copy to clipboardno_notification: true. Copy to clipboardorder.placed is emitted for them on purpose (invoices, ERP documents and stock follow-ups should see them), so make your order confirmation e-mail skip orders with Copy to clipboardmetadata.marketplace_order_ref: the marketplace talks to its buyer.

Statuses and the order journal

Every 15 minutes the plugin reads the status, parcel number and carrier of the orders it sent and of the orders it imported, writes them into its rows and into order metadata and creates fulfillments or cancellations as described above. The 60 orders read in one pass are chosen by the database: never checked first, then the oldest check, closed statuses left out. Copy to clipboardbaselinker.order_status_changed is emitted for sent and for imported orders (Copy to clipboardimported: true). With Copy to clipboardjournal: "auto" it first asks Copy to clipboardgetJournalList for order events since the last one it processed; only the orders with events are read. The journal keeps three days and has to be enabled for the account (Account & other, My account, API, or Base support), so the plugin also reads everything the full way every 2 hours, after a gap of more than 2 days, and for as long as the journal has never returned an event.

Returns (read only)

Every hour the plugin reads Copy to clipboardgetOrderReturns for the last Copy to clipboardreturnsWindowDays days with the return statuses and reasons, and shows each return with its products, status, reason, refunded amount and parcel, linked to the Medusa order when the order is one it sent or imported. Buyer data (e-mail, phone, address, bank account, the buyer's comment) is dropped before anything is stored. Nothing is written anywhere.

Invoice numbers from Fakturownia

When the Fakturownia plugin of Koda Plus emits Copy to clipboardfakturownia.document.issued for an order that is in BaseLinker (sent or imported), the number goes into the order field Copy to clipboardinvoiceNumberField with Copy to clipboardsetOrderFields, exactly once per document. The field is read first: empty means write, the same number means it is already there, any other value is a conflict for a person and is never overwritten. Copy to clipboardextra_field_1 and Copy to clipboardextra_field_2 hold 50 characters; a longer number is refused rather than cut. The dependency is soft: the event is subscribed by name, the Fakturownia package is never imported, and a simulated document never reaches a real account. BaseLinker's own Copy to clipboardaddInvoice is not used, because it would issue a second invoice in BaseLinker's numbering.

Demo mode

Without an account, Copy to clipboarddemo: true runs every feature against a simulated BaseLinker account built from the store's own catalog, through the same parsers, planners and workflows as live mode. Rows are flagged Copy to clipboarddemo, and the admin says it is a simulation on every view.

The demo writes only its own rows. The store's orders never get a simulated BaseLinker number, status or parcel in their metadata, and no event goes out for them; a demo plan or snapshot never replaces what a real account read. The snapshot is built by the Copy to clipboardbaselinker-demo job (every minute, demo mode only) or by Prepare now on the page (Copy to clipboardPOST /admin/baselinker/demo/prepare), never by opening a page. A warning goes to the log when demo mode runs in a production build.

  • Catalog: one card per variant, grouped under a main card for products with several variants, plus cards only BaseLinker has (one of them a bundle, one a main card with two variants), a card duplicated under the same SKU, an EAN on two cards, a renamed card and a few changed prices, so every plan has something to show.
  • Account: two price groups (one derived), a Copy to clipboardbl_ warehouse and a shop warehouse that cannot take stock, Allegro and Amazon order sources, a custom order field.
  • Directions: a visitor may switch the catalog and stock directions in the admin to try each plan; writers "succeed" against the simulation and the next simulated read reflects what they wrote.
  • Orders: store orders get BaseLinker ids in seconds and are "shipped" with an InPost number a few minutes later, in the plugin's rows. Deterministic Allegro and Amazon orders appear over the day (at most 5 a day, buyers at Copy to clipboard@example.com only); with Copy to clipboarddemoCreatesOrders: true, once a visitor arms the order import writer they become Medusa orders of the demo store (Copy to clipboardmetadata.baselinker_demo: true), and their statuses move on, one of them cancelled.
  • Returns and invoice numbers are simulated too. Nothing leaves Medusa.

Admin API

  • Copy to clipboardGET /admin/baselinker: configuration summary (never the token), counters, directions, writers with who armed them and when, journal state, the last run of each kind and, in demo mode, whether the snapshot exists. Reads the database only. Every Copy to clipboardGET route only reads, in demo mode too.
  • Copy to clipboardGET /admin/baselinker/running: what runs right now in any process (the job leases); the page polls it while a run is under way.
  • Copy to clipboardPOST /admin/baselinker/demo/prepare: demo mode only, builds the simulated snapshot now (idempotent).
  • Copy to clipboardPOST /admin/baselinker/check: what the account offers, read now.
  • Copy to clipboardPOST /admin/baselinker/sync with Copy to clipboard{ "what": "catalog" | "statuses" | "orders" | "imports" | "returns" | "invoices" }: run a job now (202, background), under the same lease as the scheduled job.
  • Copy to clipboardPOST /admin/baselinker/writers/:key with Copy to clipboard{ "armed": true | false }: arm or disarm a writer. Refused while the options switch it off.
  • Copy to clipboardPOST /admin/baselinker/directions with Copy to clipboard{ "catalog"?, "stock"? }: demo mode only, to try the other directions.
  • Copy to clipboardGET /admin/baselinker/plans?kind=catalog_import|cards|stock_push|prices&filter=&q=: the plan of one direction.
  • Copy to clipboardPOST /admin/baselinker/quarantine/:id/release: release a quarantined item.
  • Copy to clipboardGET /admin/baselinker/products?filter=all|linked|unmatched|conflicts|nosku&q=: the card snapshot.
  • Copy to clipboardGET /admin/baselinker/products/by-medusa/:productId: cards of one product, for the product widget.
  • Copy to clipboardGET /admin/baselinker/stock?q=: the current plan of BaseLinker stock into Medusa.
  • Copy to clipboardGET /admin/baselinker/orders?filter=all|pending|sent|failed|skipped&q=: the outbox and the way back.
  • Copy to clipboardPOST /admin/baselinker/orders/:id/send: send (or send again) one order now.
  • Copy to clipboardGET /admin/baselinker/orders/by-medusa/:orderId: the BaseLinker side of one order, for the order widget.
  • Copy to clipboardGET /admin/baselinker/imports?filter=all|pending|imported|skipped|failed|flagged&q=: marketplace orders.
  • Copy to clipboardPOST /admin/baselinker/imports/:id/import: import one marketplace order now (needs the armed writer).
  • Copy to clipboardGET /admin/baselinker/returns?q=&linked=1: returns.
  • Copy to clipboardGET /admin/baselinker/invoices?filter=: invoice numbers.
  • Copy to clipboardPOST /admin/baselinker/invoices/:id/retry: write one invoice number again.
  • Copy to clipboardGET /admin/baselinker/runs?kind=: the history.
  • Copy to clipboardGET /admin/baselinker/integration, Copy to clipboard/integration/summary and Copy to clipboard/integration/attention: the koda.integration/1 contract, described in "Works with Koda Plus hosts".

No route deletes anything. Every write route takes a JSON body or the Copy to clipboardx-koda-request header (415 otherwise), and an unexpected error answers a plain sentence while the details stay in the server log.

Use it from your code

import {
sendOrderToBaseLinkerWorkflow,
syncBaseLinkerCatalogWorkflow,
syncBaseLinkerStatusesWorkflow,
importBaseLinkerOrdersWorkflow,
syncBaseLinkerReturnsWorkflow,
} from "@koda-plus/medusa-plugin-baselinker/workflows"
const { result } = await sendOrderToBaseLinkerWorkflow(container).run({
input: { order_id: "order_01J..." },
})
// result.status === "sent", result.blOrderId === "21468320" (the BaseLinker order id)
// result.adopted === true when the order was already in BaseLinker and nothing was written

Also exported: Copy to clipboardprocessBaseLinkerOrdersWorkflow (one pass of the outbox) and Copy to clipboardcheckBaseLinkerConnectionWorkflow. Copy to clipboardsyncBaseLinkerStatusesWorkflow reads the orders the plugin sent; the scheduled status job also follows the imported orders and the order journal, which Copy to clipboardrunStatusPass(container, "manual") does in one call.

Events on the Medusa event bus:

  • Copy to clipboardbaselinker.order_sent: Copy to clipboard{ order_id, display_id, baselinker_order_id, adopted, linked_lines, free_lines, demo }
  • Copy to clipboardbaselinker.order_failed: Copy to clipboard{ order_id, display_id, code, message, attempts, demo }
  • Copy to clipboardbaselinker.order_status_changed: Copy to clipboard{ order_id, display_id, baselinker_order_id, status_id, status_name, previous_status_id, tracking_number, tracking_url, carrier, imported, demo }, for sent orders (Copy to clipboardimported: false) and for imported ones (Copy to clipboardimported: true)
  • Copy to clipboardbaselinker.order_imported: Copy to clipboard{ order_id, display_id, baselinker_order_id, source, marketplace_order_ref, payment_state, adopted, demo }
  • Copy to clipboardbaselinker.order_import_failed: Copy to clipboard{ baselinker_order_id, code, message, attempts, demo }
  • Copy to clipboardbaselinker.plan_applied: Copy to clipboard{ kind, applied, failed, demo }, kind Copy to clipboardcatalog_import, Copy to clipboardcards, Copy to clipboardstock_push or Copy to clipboardprices
  • Copy to clipboardbaselinker.invoice_number_written: Copy to clipboard{ order_id, baselinker_order_id, number, field, adopted, demo }

The plugin listens to Copy to clipboardorder.placed and, when the Fakturownia plugin is installed, to Copy to clipboardfakturownia.document.issued.

Order metadata the plugin writes in live mode, readable by your storefront through the Store API: Copy to clipboardbaselinker_order_id, Copy to clipboardbaselinker_status_id, Copy to clipboardbaselinker_status_name, Copy to clipboardbaselinker_tracking_number, Copy to clipboardbaselinker_tracking_url, Copy to clipboardbaselinker_carrier; on imported orders also Copy to clipboardbaselinker_imported, Copy to clipboardbaselinker_import_id, Copy to clipboardbaselinker_order_source, Copy to clipboardbaselinker_external_order_id and Copy to clipboardmarketplace_order_ref (and Copy to clipboardbaselinker_demo on orders the demo created). The plugin itself never decides anything by these keys: its tables are the record. Products created by the catalog import carry Copy to clipboardmetadata.baselinker_product_id (and Copy to clipboardmetadata.manufacturer unless Copy to clipboardmanufacturerAs is Copy to clipboardtag).

Security and personal data

  • Write barrier by method name, as described above: nothing outside the permitted methods leaves the process, and a writer that is not armed cannot use its method.
  • One HTTP client: the BaseLinker URL appears in one file, behind the barrier, a process-wide rate limiter and a timeout.
  • Masked token: the token and every token-like run of characters are masked in logs, stored errors and the admin, and so are e-mail addresses and international phone numbers an error may echo. The token never leaves the server: the admin only learns whether it is set.
  • Personal data: the plugin's own tables hold ids, statuses, totals and tracking, never buyer data. The order payload sent to BaseLinker is built at send time and not stored. An imported marketplace order carries the buyer's name, address, e-mail and phone on the Medusa order itself, as any order does, because the store has to ship it. Returns are stored without the buyer's data.
  • Reads only while rendering: the admin never calls BaseLinker and never writes to draw a page; network calls and the demo snapshot sit behind jobs and clicks.
  • One worker per item: leases in the plugin's own table (per job, per store order, per marketplace order, per invoice document) that hold across processes, plus the Medusa Locking module for the shared Copy to clipboardmarketplace-order-ref:<ref> key, plus the lookups before every create.
  • Write guard: writes to Copy to clipboard/admin/baselinker/* need a JSON body or the Copy to clipboardx-koda-request header, so a form on another site cannot arm a writer or send an order with an admin's session cookie.
  • Metadata a buyer can write: the Store API takes any cart metadata and Medusa copies it to the order. The plugin decides by its own tables, never by order metadata (an order counts as imported only by its import row; a marketplace reference counts only on an order created without a cart), and the store routes refuse Copy to clipboardbaselinker_* keys, Copy to clipboardmarketplace_order_ref and the skip key with 400 Copy to clipboardreserved_metadata_key. A tax id or a note the buyer types stays allowed.

Works with Koda Plus hosts

An app that shows every Koda Plus plugin in one place (like medusa.koda.plus) reads BaseLinker through the shared contract Copy to clipboardkoda.integration/1 and never needs to know its tables:

  • Copy to clipboardGET /admin/baselinker/integration: the manifest (mode, configuration and what is missing, writers armed, the last run, widgets, the hosts an external link may point to: the carriers' tracking pages and baselinker.com).
  • Copy to clipboardGET /admin/baselinker/integration/summary?entity=order&id=order_... (or Copy to clipboardids=, up to 50; also Copy to clipboardentity=product and Copy to clipboardentity=inventory_item): one line per record, the worst row speaking. An order: in BaseLinker or imported is green, on its way is blue, a send retrying after an error, a failed Medusa fulfillment or a cancellation blocked by a fulfillment is orange, a failed send or import is red, and a skipped order is grey with its reason in the title key (Copy to clipboardintegration.order.skip.canceled, Copy to clipboardskip_key, Copy to clipboardmarketplace_order, Copy to clipboardimported). Its facts: Copy to clipboardchannel for an imported order ("BaseLinker: Allegro", code Copy to clipboardbaselinker, the external order reference, priority 60), Copy to clipboardpayment as BaseLinker reports it (code Copy to clipboardpaid, Copy to clipboardcod or Copy to clipboardpending, priority 50), Copy to clipboarddelivery with the carrier, the parcel number and its tracking page (priority 50), Copy to clipboarddocument with the invoice number BaseLinker holds (priority 50, so the invoicing plugin's own document wins). A product: linked cards green, a card conflict on its SKU orange, an item held in quarantine red, and a Copy to clipboardstock fact while a stock plan has changes for it. An inventory item: in step with BaseLinker green, a difference waiting for the stock writer orange, a quarantined or failed stock write red, with a Copy to clipboardstock fact. Facts come from the plugin's rows (and from Medusa records read by id), never from order metadata.
  • Copy to clipboardGET /admin/baselinker/integration/attention?scope=orders,products,inventory: the counters Copy to clipboardorders_failed and Copy to clipboardimports_failed (red, orders), Copy to clipboardquarantined (red, inventory) and Copy to clipboardcards_conflict (orange, products), each with a link to its filtered list (Copy to clipboard/baselinker?section=orders&filter=failed, Copy to clipboard/baselinker?section=imports&filter=failed, Copy to clipboard/baselinker?view=settings&tab=plans&filter=quarantined, Copy to clipboard/baselinker?section=cards&filter=conflicts).
  • The order card registers as Copy to clipboardbaselinker.order for the zone Copy to clipboardorder.details (hidden while the order summary says "none") and the product card as Copy to clipboardbaselinker.product for Copy to clipboardproduct.details, both at tab order 60. A host that claims a zone shows the card as a tab (Copy to clipboardembedded: no frame or header of its own, a line while loading, on an error and when there is nothing to show) and Medusa's own spot stays empty. Without a host nothing changes.

Public API

What other code may import: Copy to clipboard@koda-plus/medusa-plugin-baselinker/workflows (the workflows, Copy to clipboardcheckConnection, Copy to clipboardloadWriters, Copy to clipboardsetArm, Copy to clipboardactiveRunKinds and the rest listed in "Use it from your code"), Copy to clipboard@koda-plus/medusa-plugin-baselinker/modules/baselinker (the module, its options and service) and Copy to clipboard/admin. Type declarations ship with the package. Every other path is internal and may change in any release.

Running more than one process

Medusa can run a store as a server and a worker, or as several instances. The plugin keeps one run of each job and one worker per store order, marketplace order and invoice document across all of them with leases in its own table (Copy to clipboardbaselinker_setting, keys Copy to clipboardlease:job:<kind> and Copy to clipboardlease:lock:<key>): a lease is renewed every minute while its holder works and expires 5 minutes after a process died. A click on Sync in the admin takes the same lease as the scheduled job, so it never runs next to it. The shared Copy to clipboardmarketplace-order-ref:<ref> key also goes through the Medusa Locking module, which spans processes only with a Redis or Postgres provider. A lock store that does not answer is an error in the history and the log, never a quiet "busy". The rate limit (Copy to clipboardrequestsPerMinute) is counted per process: with a server and a worker, keep their sum under BaseLinker's 100 requests per minute.

Out of scope

  • It never deletes anything, in BaseLinker or in Medusa. A product removed in BaseLinker can only become a draft, and only with Copy to clipboarddraftRemovedProducts.
  • Cards created from Medusa are simple cards, one per variant: it does not build main cards with variants in BaseLinker. Card updates cover the name and the EAN only; descriptions, images, categories and manufacturers of existing cards are left as they are. BaseLinker does not document whether an update keeps the text fields that are not sent; the plugin relies on the per key behaviour the documentation describes for images, and the guide advises trying the cards writer on one card first.
  • The catalog import gives products one option axis (Copy to clipboardcatalogImportOptionTitle) whose values are the variant names; it does not turn BaseLinker features into separate options like Colour and Size. Categories are matched by name, flat; the category tree is not rebuilt.
  • One catalog, one warehouse and one price group per store. Kits and bundles are left out of stock, prices and the import.
  • Orders that already reached BaseLinker stay as BaseLinker has them: edits, refunds and cancellations made in Medusa afterwards are not carried over, so change such an order in BaseLinker by hand. An order cancelled in Medusa before its send never goes out (a Copy to clipboardskipped row with the code Copy to clipboardcanceled).
  • Imported orders are fulfilled from BaseLinker statuses only when Copy to clipboardorderImportShippingOptionId is set. An imported order that BaseLinker cancels after it was fulfilled in Medusa is flagged for a person, never cancelled automatically.
  • Returns are read only: no Medusa return or refund is created from them.
  • It does not send e-mails, and it cannot see your e-mail code: skipping the confirmation e-mail for marketplace orders is up to your Copy to clipboardorder.placed subscriber.
  • The Allegro reference of imported orders assumes BaseLinker's Copy to clipboardexternal_order_id of an Allegro order is the Allegro checkout form id, as BaseLinker documents it ("Allegro transaction number"); it has not been checked against an account connected to Allegro yet.

Uninstall

  1. Disarm the writers in Settings (or switch them off with Copy to clipboardwriters: { <name>: false }) and set Copy to clipboardexportOrders: false, so nothing is written while you remove the plugin.
  2. Remove the plugin from Copy to clipboardmedusa-config.ts and the package from Copy to clipboardpackage.json.
  3. What stays, on purpose: the plugin's tables (Copy to clipboardbaselinker_product, Copy to clipboardbaselinker_order, Copy to clipboardbaselinker_stock_change, Copy to clipboardbaselinker_sync_run, Copy to clipboardbaselinker_setting, Copy to clipboardbaselinker_plan_item, Copy to clipboardbaselinker_quarantine, Copy to clipboardbaselinker_import, Copy to clipboardbaselinker_return, Copy to clipboardbaselinker_invoice) with their history, the Copy to clipboardbaselinker_* and Copy to clipboardmarketplace_order_ref keys in order metadata, the cards created in BaseLinker and the orders imported into Medusa. Drop the tables by hand when you no longer need the history; nothing in BaseLinker is deleted.

Compatibility

Medusa 2.12 to 2.21 (peer range Copy to clipboard^2.12.0) and Node.js 20+. The release of each version runs the smoke test on a fresh Medusa 2.12.6 and 2.21.2 app: migrations, build, start and the admin pages. Developing the plugin needs Node.js 22.6+ (the tests run the TypeScript sources directly).

Development

npm install
npm test
npm run typecheck
npm run build

Copy to clipboardnpm test covers the write barrier, token masking, response errors, the client retry policy, linking with variants and containers, every planner (catalog import, cards, stock both ways, prices) with the caps and the quarantine, the writers and their switches, the order payload and the totals computed from the lines, the marker scan, the leases across processes, the marketplace order import across a crash and a race, metadata a shopper could set, statuses and the journal, returns without personal data, invoice numbers, demo isolation, the admin reads that never write, the guards, the koda.integration/1 contract and backoff, without a network or a build.

Commercial support

Built and maintained by Koda Plus, a Medusa agency from Poland. The same BaseLinker logic runs in production since August 2026 at a Polish tyre and wheel retailer, next to our Allegro, OLX, Fakturownia and Subiekt nexo integrations. Need a custom integration or help with a migration to BaseLinker? Write to kontakt@koda.plus.

Trademarks

BaseLinker and Base are trademarks of their owner, used here only to identify the service this plugin connects to. This is an independent integration built on the public BaseLinker API, not affiliated with or endorsed by BaseLinker.

License

MIT, see LICENSE.

Changelog

The full notes of every version are in CHANGELOG.md.

0.3.0 (unreleased)

  • Demo mode only with Copy to clipboarddemo: true, and it writes only its own rows: the store's orders never get simulated numbers, statuses or parcels, and simulated marketplace orders become Medusa orders only with Copy to clipboarddemoCreatesOrders.
  • Reads never write; the demo snapshot comes from the Copy to clipboardbaselinker-demo job or Prepare now.
  • One run of each job and one worker per order across every process (leases), orders whose totals Medusa cannot compute still go, order metadata a shopper can set decides nothing.
  • The koda.integration/1 contract (summaries of orders, products and inventory items, board counters), embeddable order and product cards, deep links, type declarations.

0.2.1 (2026-10-07)

  • References: stores that start soon on Medusa can be listed with Copy to clipboardsoon: true (a Soon badge, no link, Copy to clipboardurl optional); the since date is no longer shown, and an old Copy to clipboardsince in the options is ignored.

0.2.0 (2026-10-06)

  • Both catalog directions (Copy to clipboardcatalogSource): the catalog import from BaseLinker (prices of a price group, SKU, EAN, weight, images, description, categories by name, manufacturer; idempotent by the BaseLinker id; duplicates are conflicts; never a delete) and the card plan from Medusa (create and update, a lookup by SKU before every create, the new card linked at once).
  • Stock in both directions (Copy to clipboardstockSource): Medusa stock into a Copy to clipboardbl_ warehouse with Copy to clipboardupdateInventoryProductsStock, plan first, capped, per item quarantine.
  • Price push into a BaseLinker price group with Copy to clipboardupdateInventoryProductsPrices, gross prices from net Medusa prices with the card's VAT rate.
  • Seven writers, each off by default, with a hard switch in the options (Copy to clipboardwriters) and an arm switch in the admin that records who and when.
  • Marketplace orders into Medusa, exactly once per BaseLinker order: chosen sources, region and sales channel, lines by card link, prices from the order, delivery as a shipping method, taxes from the region, payment, inventory reserved, Copy to clipboardmarketplace_order_ref shared with the other Koda Plus plugins and checked under a shared lock, loop guard in both directions, cancellation while nothing is fulfilled.
  • Returns, read only, without buyer data, linked to Medusa orders.
  • Faster status pickup through the BaseLinker order journal, with the full read as a fallback.
  • Invoice numbers from the Fakturownia plugin into a BaseLinker order field, exactly once, never over another value.
  • Variant cards read with Copy to clipboardinclude_variants; main cards with variants are containers, never linked.
  • Admin: Panel and Setup guide views (Copy to clipboard?view=guide), the directions and writers matrix, every plan with filters and quarantine release, marketplace orders, returns, invoice numbers, the account lists in the connection check, references ("Running in production"), widgets for imported orders and main cards.
  • Demo mode simulates all of it: duplicated SKUs and EANs, price groups, both stock directions, deterministic Allegro and Amazon orders (at most 5 a day, Copy to clipboard@example.com buyers) that become real Medusa orders, returns and invoice numbers.
  • Six new tables (Copy to clipboardbaselinker_setting, Copy to clipboardbaselinker_plan_item, Copy to clipboardbaselinker_quarantine, Copy to clipboardbaselinker_import, Copy to clipboardbaselinker_return, Copy to clipboardbaselinker_invoice): run Copy to clipboardnpx medusa db:migrate.

0.1.0 (2026-10-05)

First public release: card linking by SKU and EAN with conflicts never linked, stock planned before it is written (BaseLinker to Medusa), store orders exactly once with a marker scan, statuses, tracking and fulfillment back, admin page and widgets in English and Polish, demo mode.

You may also like

Browse all integrations

Build your own

Develop your own custom integration

Build your own integration with our API to speed up your processes. Make your integration available via npm for it to be shared in our Library with the broader Medusa community.

gift card interface

Ready to build your custom commerce setup?