@mercatus-liber/adapter-slant3d
A FulfillmentAdapter for @mercatus-liber/fulfillment that has Slant 3D print and ship orders. Slant is a 3D print farm: you upload a model file once, and each order names that file, a filament (material and colour) and a quantity.
Status: built from Slant’s published OpenAPI file and docs site as read on 2026-11-10, and tested against a fake fetch. It has never been run against a live Slant account. Not published to npm; use it from this monorepo via workspace:*.
What it does
- Orders.
submitOrderdrafts the order at Slant, then processes it. Processing is the step that charges the payment method and queues the order for printing. WithholdOrders: trueit stops after the draft and reports the lines asheld. - Status.
getOrderStatusreads the order back from Slant and reports each line’s status and tracking number. - Webhooks.
handleWebhookEventchecks Slant’s signature and the timestamp’s age, then hands the parsed event toonWebhookEvent. - Setup and pricing.
createSlant3dCatalogClientlists filaments, uploads model files, prices a file in whole cents, and manages the platform’s webhook URL and secret. - Products as data.
planSlant3dProductandapplySlant3dProductturn “this file, in these filaments, at these prices” into SKUs, mappings and routing, with each SKU’s cost and margin.
Setup
-
Get an API key. Create one in your Slant account. It starts with
sl-. An account can hold 3 keys. -
Add a payment method to the Slant account. Slant’s docs say a draft needs one connected, and processing an order charges it.
-
Create a platform, or use one you already have. A platform is Slant’s grouping for files, orders and webhooks, and its id goes on most requests. An account can have 5 enabled platforms.
import { createSlant3dCatalogClient } from "@mercatus-liber/adapter-slant3d"; const setup = createSlant3dCatalogClient({ apiKey: process.env.SLANT3D_API_KEY! }); const platform = await setup.createPlatform({ name: "My store", url: "https://store.example" }); // Keep platform.id as SLANT3D_PLATFORM_ID. -
Upload each model file and keep the id that comes back.
const slant = createSlant3dCatalogClient({ apiKey: process.env.SLANT3D_API_KEY!, platformId: process.env.SLANT3D_PLATFORM_ID! }); const file = await slant.uploadFile({ name: "ducky", bytes: await readFile("ducky.stl") }); // file.publicFileServiceId is the file id. -
Map each SKU to a file and a filament. Pick filaments from
slant.listFilaments(). Either save mappings yourself:await mappings.save({ skuId, provider: SLANT3D_PROVIDER, target: { fileId, filamentId } });or describe the product and let the helpers create the SKUs, mappings and routing:
const spec = { slug: "ducky", title: "Ducky", description: "A duck.", fileId, variants: [{ filamentId, retailCents: 1500 }] }; const costs = await estimateSlant3dUnitCosts(slant, fileId, spec.variants.map((v) => v.filamentId)); const plan = planSlant3dProduct(spec, await slant.listFilaments(), costs); // Check plan.skus[].marginCents and plan.unavailable, then: await applySlant3dProduct({ catalog, mappings, routing }, plan); -
Set the webhook URL and read the secret.
await slant.setWebhookUrl("https://store.example/webhooks/slant3d"); const secret = await slant.getWebhookSecret(); // keep as SLANT3D_WEBHOOK_SECRET await slant.sendTestWebhook(); // sends a signed test event to that URLSlant requires the URL to be a reachable HTTPS endpoint.
rotateWebhookSecret()andsetWebhookSecret()replace the secret at once, with no overlap, so update the adapter’s secret at the same time. -
Create the adapter and register it under its provider key.
import { createSlant3dFulfillmentAdapter, slant3dCatalogTargetsFrom, slant3dWebhookSignatureFrom, SLANT3D_PROVIDER } from "@mercatus-liber/adapter-slant3d"; const slant3d = createSlant3dFulfillmentAdapter({ apiKey: process.env.SLANT3D_API_KEY!, platformId: process.env.SLANT3D_PLATFORM_ID!, webhookSecret: process.env.SLANT3D_WEBHOOK_SECRET, resolveCatalogTarget: slant3dCatalogTargetsFrom(mappings), resolveExternalOrderId: async (orderId) => loadSlantOrderId(orderId), onWebhookEvent: async (event) => { if (event.dummy || !event.order) return; // event.type is e.g. "order.shipped"; event.order has publicId, status and trackingNumber. }, }); const adapters = { [SLANT3D_PROVIDER]: slant3d }; -
Route the webhook. Slant signs with two headers, and
handleWebhookEventtakes one signature string, so join them with the helper. Pass the raw request body, not re-serialized JSON.await slant3d.handleWebhookEvent(rawBody, slant3dWebhookSignatureFrom(request.headers));
Options
The environment variable names above are only suggestions; the package reads no environment variables itself.
| Option | Required | What it is |
|---|---|---|
apiKey | yes | Slant API key, sent as a Bearer token. |
platformId | yes | The Slant platform orders are created under. |
resolveCatalogTarget(skuId) | yes | Returns { fileId, filamentId } for a SKU. slant3dCatalogTargetsFrom(repo) builds one from a ProviderCatalogMappingRepository. |
resolveExternalOrderId(orderId) | no | Returns the Slant order id for an order (the externalOrderId on the records submitOrder returned). Slant has no lookup by your own order id, so getOrderStatus needs this. Without it the adapter only knows orders the running process submitted. |
resolveRecipient(orderId) | no | Loads the address when an order arrives without one. |
holdOrders | no | true leaves new orders as Slant drafts. Nothing is charged or printed. Use it for any test against a real account. Default false. |
webhookSecret | no | The platform’s webhook secret. Without it or verifyWebhookSignature, every webhook is refused. |
webhookToleranceMs | no | How old a webhook’s timestamp may be. Default 5 minutes. |
verifyWebhookSignature | no | Replaces the built-in check. |
onWebhookEvent(event) | no | Receives each verified event. |
baseUrl, fetchImpl, httpClient, now | no | For tests and unusual setups. |
The adapter also has processHeldOrder(publicOrderId), to process a held draft, and cancelOrder(publicOrderId).
Behaviour to know about
- Address. An order is refused before anything is sent to Slant if the recipient lacks a name, email, street, city, state, postal code or country. The error is
IncompleteRecipientErrorand lists what is missing. - Status mapping.
DRAFTisheld.SUBMITTEDandPRINTINGaresubmitted.SHIPPEDisshipped.CANCELLEDisunfulfilled. Nothing is reported asdelivered: Slant’s order status ends atSHIPPED. - Tracking. Status and tracking are per order at Slant, so every line of an order reports the same ones. Slant gives tracking numbers but no tracking URL, so
trackingUrlis alwaysnull. If an order has several tracking numbers, the first is reported. - Failed processing. If the draft is created but processing fails (a declined card, say),
submitOrderthrowsSlant3dOrderProcessErrorwith the draft’spublicOrderId. The draft stays at Slant. Submitting again creates a second draft, so process or cancel the first one by its id instead. - Webhook signature. The signature is the hex HMAC-SHA256 of
<X-Webhook-Timestamp>.<raw body>keyed with the platform’s webhook secret, sent asX-Webhook-Signature-256: sha256=<hex>. A webhook is refused if the signature doesn’t match or the timestamp is 5 minutes old or more. This is the scheme in the “Webhook Signature Verification” section of Slant’s docs. - Webhook retries. Slant retries a failed delivery once a minute for up to 10 attempts on a timeout, a 5xx, a 408 or a 429. Any other 4xx is stored without retrying and has to be resent by hand within 30 days. Slant’s docs don’t say whether a resend carries a new timestamp. If it doesn’t, a resend older than the tolerance is refused; raise
webhookToleranceMswhile replaying. - Money. Slant charges in US dollars.
estimateandslant3dUsdToCentsreturn whole cents and don’t use float arithmetic. - Rate limit. Slant allows 100 requests a minute. The package doesn’t throttle or retry.
Limits on Slant’s side
- Parts can be at most 220 mm in each dimension, and files at most 250 MB.
- Slant’s API spec lists STL as the only file type. Its docs page says STL, OBJ and 3MF. Use STL unless you have confirmed otherwise with Slant.
- Filaments are PLA, PETG and “OPM” in the colours
listFilamentsreturns. A filament can go out of stock. - Whether supports are printed is decided by Slant when the file is uploaded and affects the price. It can’t be set per order.
- Cancelling an order refunds it. Slant’s docs say an order that has already shipped is refunded but not recalled.
Not covered
- Shipping cost before an order exists. Slant only prices delivery on a drafted order, so
estimateand the product margins are print cost only. - Slant’s other order item types (components such as magnets or inserts, and printed cards), slicer options, and requested arrival dates.
- Charging a shopper’s own card through Slant (
publicPaymentServiceId, Slant’s customer and checkout endpoints). Orders are charged to the Slant account’s payment method. - Listing or searching Slant orders, deleting files, API key management, usage statistics, OpenSCAD conversion, and listing or resending stored webhooks.
- Storing the Slant order id for you. Persist
externalOrderIdfromsubmitOrderand return it fromresolveExternalOrderId.@mercatus-liber/fulfillment’swithProviderOrderLinksandexternalOrderIdsFromdo both against aProviderOrderLinkRepository. - Acting on webhooks. The adapter verifies and parses them; updating your own records is up to
onWebhookEvent.slant3dOrderStatusUpdateFrom(event)turns an order event into the status update@mercatus-liber/fulfillment’screateProviderOrderStatusRecordertakes.
Key exports
createSlant3dFulfillmentAdapter(config),slant3dCatalogTargetsFrom(repo),SLANT3D_PROVIDER,Slant3dOrderProcessError.createSlant3dCatalogClient(config),InvalidSlant3dWebhookSecretError.planSlant3dProduct,applySlant3dProduct,estimateSlant3dUnitCosts.createSlant3dHttpClient(config),Slant3dApiError(carriesstatusandslantMessage).slant3dWebhookSignatureFrom,verifySlant3dWebhook,verifySlant3dSignature,parseSlant3dWebhookPayload, and the three webhook error classes.mapSlant3dOrderStatus,mapRecipientToSlant3d,assertShippableRecipient,IncompleteRecipientError,buildSlant3dLineRecords,slant3dUsdToCents.