E-shop
Products, bookings, carts and checkout, orders, payments, returns, rentals, inventory, and companies
Commerce in Arky runs through one path: a buyer shops in one package
in one market, fills a cart, and checkout turns it into one order with its payment. Product
variants, booking offerings and packages are all sellables in that path. Products, booking services,
booking resources and packages have a key and blocks, never a separate name or title: the name a
buyer sees is a block.
Every create on this page takes the id the app picks; every change carries the
expected_updated_at it read. A refusal names its reason in a code such as
409 PRODUCT.KEY_TAKEN; only 409 GENERAL.CONFLICT means “changed since you read it, reload”. See
Core Concepts and Errors.
Products And Variants
import type { Block, CategoryEntry, EpochMilliseconds } from "arky-sdk";
interface Product {
id: string;
store_id: string;
key: string;
slugs: Record<string, string>;
blocks: Block[];
categories: CategoryEntry[];
status: { type: "active" } | { type: "draft" } | { type: "archived" } | { type: "deleting" };
created_at: EpochMilliseconds;
updated_at: EpochMilliseconds;
}
interface ProductVariant {
id: string;
store_id: string;
product_id: string;
sku: string | null;
blocks: Block[];
fulfillment:
| { type: "none" }
| {
type: "physical";
shipping_profile_id: string;
inventory_requirements: { inventory_item_id: string; quantity: number }[];
backorder: { type: "disallow" } | { type: "allow" };
}
| { type: "digital"; asset_ids: string[] };
tax_category_id: string;
measure: { type: "not_counted" } | { type: "counts"; amount: number };
status: { type: "active" } | { type: "draft" } | { type: "archived" } | { type: "deleting" };
created_at: EpochMilliseconds;
updated_at: EpochMilliseconds;
}/v1/stores/{store_id}/products sdk.eshop.product.create() /v1/stores/{store_id}/product-variants sdk.eshop.productVariant.create() /v1/stores/{store_id}/digital-assets sdk.eshop.digitalAsset.upload() /v1/stores/{store_id}/digital-assets/{id}/archive sdk.eshop.digitalAsset.archive() const product = await sdk.eshop.product.create({
store_id: storeId,
id: crypto.randomUUID(),
key: "linen-shirt",
slugs: { en: "linen-shirt" },
blocks: [{ id: crypto.randomUUID(), key: "name", type: "localized_text", value: { en: "Linen shirt" } }],
categories: [],
});
const variant = await sdk.eshop.productVariant.create({
store_id: storeId,
id: crypto.randomUUID(),
product_id: product.id,
sku: "SHIRT-M",
blocks: [{ id: crypto.randomUUID(), key: "size", type: "text", value: "M" }],
fulfillment: {
type: "physical",
shipping_profile_id: standardProfile.id,
inventory_requirements: [{ inventory_item_id: shirtItem.id, quantity: 1 }],
backorder: { type: "disallow" },
},
tax_category_id: standardTax.id,
measure: { type: "not_counted" },
});
- Variants are independent. A variant’s attributes, such as its size or colour, and its own
pictures and texts are its
blocks; the storefront decides which block keys it shows. Arky never builds a name from a variant’s blocks and asks for no unique label or SKU, so two variants may read alike and are still two variants. Theskuis optional, and staff’s exact SKU filter finds a variant by it. A product holds at most 100 variants (409 PRODUCT_VARIANT.LIMIT). measuresays how much one unit counts toward a package’s category minimum, such as 1,000 for a 1 litre carton:not_counted, orcountswith anamountof 1 or more.- The product key is unique in the store (
409 PRODUCT.KEY_TAKEN) and its slugs per store and language (409 PRODUCT.SLUG_TAKEN). - A variant is physical (shipped from stock, with a shipping profile), digital (files the
buyer downloads from their library) or neither (a service or membership sold as a product).
Every variant names a tax category. Checkout copies the bought variant’s blocks onto the order
line as
variant_blocks, so the order keeps what was bought when the variant changes later. - A digital variant lists 1 to 100 digital assets: private files with their size and
sha256, uploaded with an id the app picks. An asset is archived rather than deleted; archiving is refused while a variant still lists it, and past buyers keep their files. - Deleting a product is refused while anything but its own variants, the package items and prices
that list it, and carts points at it, such as an order line; archive a sold product instead. A deleted product and its
variants read
deletinguntil cleanup has removed them. A variant on its own is refused while anything but its prices and carts points at it.
Storefront reads name the package, and the market comes from the request. One search pages the package’s priced items in that market, and each item’s prices carry what the buyer would pay:
/v1/storefront/packages arky.eshop.package.find() /v1/storefront/package-items arky.eshop.packageItem.find() /v1/storefront/package-items/by-parent arky.eshop.packageItem.getByParent() /v1/storefront/package-items/{package_item_id}/prices arky.eshop.packageItem.findPrices() /v1/storefront/products/{id_or_slug} arky.eshop.product.get() /v1/storefront/products/by-key/{key} arky.eshop.product.getByKey() /v1/storefront/products/{product_id}/variants/{id} arky.eshop.productVariant.get() const { items: [shopPackage] } = await arky.eshop.package.find();
const page = await arky.eshop.packageItem.find({
package_id: shopPackage.id,
include_price: true,
selection: { types: ["product"], price: { max_amount: 5000 } },
limit: 20,
});
const shirt = await arky.eshop.product.get({ slug: "linen-shirt", package_id: shopPackage.id });
const { items: choices } = await arky.eshop.packageItem.findPrices({
package_item_id: shirt.package_item_id,
package_id: shopPackage.id,
include_price: true,
});
package.findlists the open packages usable in the request’s market in which the buyer has any level, each{ id, key, level }; which one a page uses is up to the storefront. Every product read names itspackage_id; Arky never picks or merges packages.- One answer per priced item.
packageItem.findpages the package’s priced items in the market (products, booking services and packages, each once), each with itspackage_item_id,package_id,market_id, the typeditem, itspositionand the listed record’scontent(key,slugs,blocks,categories).selectionnarrows it bytypes,text,categories(products and booking services), block filters on the listed record, apricewithmin_amountandmax_amountand aprice_basis, and orders it bypackage_order(the default),relevance(needstext) orstarting_price(needs aprice_basis). A filter or sort that doesn’t fit the types asked for is refused with400. - Search is per item, not per variant.
priceandprice_basismatch on one basis of the item, and a range matches an item whose prices of that basis overlap it, so “at most 50” asks whether its lowest price is at most 50. No search names a SKU or a variant’s blocks: a storefront that needs one variant filters its own read of the item’s prices. - Prices on items. With
include_price: trueand a level that shows prices, an answer has itscurrencyandprice_summary,{ basis, min_amount, max_amount, price_count }: the basis every price of the item shares, the lowest and highest price on sale and how many. A plan’s answer also names its one price asprice_id. A price filter or a starting-price sort withoutsee_pricesis refused with403. The search can trail an edit by a few seconds; the price page and the quote always read the current price. - Pages. A page holds 20 answers unless you ask for more, and it can come back short or empty with
a
cursor: follow the cursor when the visitor asks for more, and never treat a short page as the end. A relevance search ranks at most 1,000 candidates; following its cursor past them is refused with409 SEARCH.RESULT_LIMIT, so narrow the text or sort by package order or price. A change of the buyer’s own access between two pages answers409 PACKAGE.ACCESS_CHANGED: start a new search. - Prices.
findPricespages one item’s prices, oldest first: each names itsprice_id, thesellableit prices, itscontent(sku,blocksand the pricebasis) and, withinclude_price: true, itsprice. A cart line names the package, the item and the price it is bought at. getreads a canonical UUID as the id and anything else as a slug in the request’s language; a miss is404and is never retried as a key.getByKeyreads the key. Both answer the product with thepackage_item_idof its item in that package and market.packageItem.getByParentreads the item of one record, without prices.productVariant.get({ product_id, id })reads one variant, with its price when you passinclude_price: true. Link pages by slug or id, never by key.
Bookings
A booking service is what is booked (a haircut, a fitting) and sets what every booking of it is: its segments, buffers, slot interval, booking window, how long before the start a customer may still change it, its reminders and its tax category. A booking resource is who or what does it (a stylist, a room), with its timezone, capacity and working hours. A booking offering says one resource provides one service, when and where.
/v1/stores/{store_id}/booking-services sdk.eshop.bookingService.create() /v1/stores/{store_id}/booking-resources sdk.eshop.bookingResource.create() /v1/stores/{store_id}/booking-offerings sdk.eshop.bookingOffering.create() /v1/storefront/booking-services/availability arky.eshop.bookingService.getAvailability() const haircut = await sdk.eshop.bookingService.create({
store_id: storeId,
id: crypto.randomUUID(),
key: "haircut",
slugs: { en: "haircut" },
blocks: [],
categories: [],
segments: [{ type: "service", minutes: 45 }],
buffer_before_minutes: 0,
buffer_after_minutes: 15,
slot_interval_minutes: 15,
booking_window: { opens_before_start_minutes: null, closes_before_start_minutes: 120 },
customer_changes: { type: "until_before_start", minutes: 1440 },
reminder_offsets_minutes: [1440],
tax_category_id: servicesTax.id,
});
const stylist = await sdk.eshop.bookingResource.create({
store_id: storeId,
id: crypto.randomUUID(),
key: "lena",
slugs: { en: "lena" },
blocks: [],
categories: [],
timezone: "Europe/Berlin",
capacity: 1,
hours: {
weekly_availability: {
monday: [{ from_minute: 540, to_minute: 1020 }],
tuesday: [{ from_minute: 540, to_minute: 1020 }],
},
date_overrides: { "2026-12-24": [] },
},
});
await sdk.eshop.bookingOffering.create({
store_id: storeId,
id: crypto.randomUUID(),
booking_service_id: haircut.id,
booking_resource_id: stylist.id,
hours: { type: "resource" },
venue: { type: "store_location", store_location_id: salon.id },
status: { type: "active" },
});
- Hours are minutes of the day in the resource’s timezone;
date_overridesreplaces a day’s hours by its calendar day (YYYY-MM-DD), and an empty list closes it, for every offering of the resource. An offering books inside its resource’s hours (resource) or only where its own hours overlap them (within). The windows of a day neither overlap nor meet: windows that meet are one window, saved as one (400onhours). Service, buffer and slot minutes run on the same local clock, so on a daylight-saving day a day-long booking still runs from one local midnight to the next, an hour shorter or longer. - Buffers hold the resource before and after the appointment but aren’t part of it. Edits to segments, buffers or hours affect only later bookings.
- The venue always names a store location: where the customer comes (
store_location), or where the service is supplied from (not_fixed). Booking tax uses that location’s address. Astore_locationvenue books in that location’s timezone, so the offering’s resource has the same one, as the stylist and the salon here shareEurope/Berlin: saving such an offering whose resource has another timezone is refused with409 BOOKING_OFFERING.VENUE_TIMEZONE, and so is a resource or location timezone change that would part them while an offering that isn’tdeletingjoins them. The names are compared exactly. Anot_fixedvenue has no such rule, so an online or at-the-customer’s offering may use any resource timezone. - A service’s key is unique in the store (
409 BOOKING_SERVICE.KEY_TAKEN), and so are its slugs (409 BOOKING_SERVICE.SLUG_TAKEN); a resource’s key is unique too (409 BOOKING_RESOURCE.KEY_TAKEN), and one offering links a service and a resource (409 BOOKING_OFFERING.PAIR_TAKENfor a second). A service holds at most 100 offerings (409 BOOKING_OFFERING.LIMIT), because each one takes a price in the service’s package item. - A resource’s capacity can’t be cut below the bookings that still hold it
(
409 BOOKING_RESOURCE.CAPACITY_IN_USE), and its timezone can’t change while a booking still to end, or any booking on today’s local date, holds it (409 BOOKING_RESOURCE.TIMEZONE_IN_USE). Bookings that have ended never block a change. Until a day the resource keeps in its earlier timezone has passed, a slot whose time reaches that day shows no spots and can’t be sold (ORDER.BOOKING_TIMEZONE_CHANGED). - Availability answers each resource’s days with slots and the spots left, for at most 60 days per request. A booking is a booking line on the cart and on the order; there is no separate booking record.
reminder_offsets_minutesschedules thebooking_reminderemail before the booking. A reminder goes only while its booking is confirmed and upcoming, and only for the start it was planned for, so reminders follow a moved booking.
See Scheduled Services for the storefront flow.
Packages And Prices
What a store sells, to whom and at what price lives on Packages. A
package’s priced items hold the prices of one market, its access rows say who may browse, see prices or
buy, and its automatic items say what members get. A store starts with one package, keyed public.
Carts And Checkout
/v1/storefront/carts arky.eshop.cart(scope).create() /v1/storefront/carts/{id}/product-items arky.eshop.cart(scope).addProduct() /v1/storefront/carts/{id}/quote arky.eshop.cart(scope).quote() /v1/storefront/carts/accept arky.eshop.cart(scope).checkout() /v1/stores/{store_id}/carts/{id}/offer/quote sdk.eshop.cart.offer.quote() import { initialize } from "arky-sdk/storefront";
import { createOrderToken } from "arky-sdk/utils";
const arky = initialize("arky_pk_...", {
locale: "hr",
market: "hr",
createVisitorIdentity: () => ({
customer_id: crypto.randomUUID(),
session_id: crypto.randomUUID(),
}),
createSessionId: () => crypto.randomUUID(),
createId: () => crypto.randomUUID(),
createOrderToken,
});
const { items: packages } = await arky.eshop.package.find();
const shopPackage = packages.find((candidate) => candidate.key === "public");
if (!shopPackage) throw new Error("This buyer can't shop here");
const shirt = await arky.eshop.product.get({ slug: "linen-shirt", package_id: shopPackage.id });
const { items: choices } = await arky.eshop.packageItem.findPrices({
package_item_id: shirt.package_item_id,
package_id: shopPackage.id,
include_price: true,
});
const cart = arky.eshop.cart({ buyer: { type: "customer" }, package_id: shopPackage.id });
await cart.ensure();
await cart.addProduct({
variant_id: variant.id,
quantity: 2,
price: {
package_id: shopPackage.id,
package_item_id: shirt.package_item_id,
price_id: choices[0].price_id,
},
});
await cart.selectShippingMethod({ shipping_method_id: courier.id });
const quote = await cart.quote();
const accepted = await cart.checkout({
contact_email: { email: "[email protected]", language: "hr" },
payment: {
type: "payment_option",
payment_option_id: quote.suggested_payment_option_id!,
return_url: window.location.href,
save_payment_method: false,
payment_method_terms: null,
},
});
- A storefront cart sells through its publishable key’s sales channel and names one package and
one market; there is no fallback package. The SDK takes the market from the client’s context, and
every storefront call that changes, quotes or checks out a cart names the cart’s market in
X-Arky-Market(409 CART.OTHER_MARKET), so a shopper who switches market gets that market’s cart; reading a cart or the buyer’s offers names none. Anupdatemay change the cart’s package or market: it names the market it moves to, re-checks each line and refuses the ones that no longer fit. - Every line carries its own id, from the app’s
createIdunless it passes one. Lines areproduct,bookingandpackage, and each names the exact price it is bought at asprice,{ package_id, package_item_id, price_id }; a product line also names its variant. The item must belong to the cart’s package (409 PACKAGE.NOT_PRICED) and be priced in the cart’s market (409 PACKAGE.OTHER_MARKET), at least one of its prices must be in force (409 PACKAGE.ITEM_NOT_LISTED), and the named price must be in force and of the line’s own choice (409 PACKAGE.NOT_PRICED,409 PACKAGE_ITEM_PRICE.WRONG_CHOICE). Every line is priced from the cart’s own package: a club’s prices are the products the club package lists, bought in a cart of that package. - The quote is what checkout would create: lines with snapshots, deliveries with their
shipping offers, promotions, taxes and totals, the payment options that can pay it and a
presentation_digest. It is in the client’s language.readyis false while something blocks checkout;blockerssays what. A shipping rate that needs a weight Arky doesn’t know is left out of a delivery’soffersand listed in itsunavailablewith the codeSHIPPING.WEIGHT_UNKNOWN, and a selected one becomes ashipping_rate_unavailableblocker; the other rates stay. A booking line that can’t be sold readsavailability: { type: "unavailable", code }, with abooking_unavailableblocker carrying the same code (Scheduled Services). A unit priced below its fixed per-unit tax in aninclusivemarket is atax_unavailableblocker on its line (TAX.FIXED_ABOVE_PRICE), and a delivery that no longer fits its lines, such as a passed window, adelivery_unavailableblocker with its code (CART.DELIVERY_WINDOW_PASSED,CART.DELIVERY_PROFILE_MIXED,CART.DELIVERY_LINE_NOT_SHIPPED,CART.DELIVERY_UNITS_MISMATCHorCART.PACKAGE_DELIVERY_CHANGED). Aswitchoramendpackage line’s quote runs the change’s own checks: a delivery its move still needs is apackage_delivery_requiredblocker on that line, and any other refusal of the change apackage_change_refusedblocker with that refusal’scode, which checkout answers with that refusal. The quote lists each code the cart holds inpromotion_codes, with itsstate:applied,stoppedornot_applied(Promotions). - Payment options. The quote’s
payment_option_idslists only the market’s options the buyer may use that can pay this cart, in the market’s order. At a total of zero it lists none, unless a package line saves a card, and then only Stripe options. A cart with a package line that charges money or saves a card lists only card options, with their saved-card wording in the quote’s language when a card is saved (Packages). When the cart needs a payment and no option can take it, the quote has apayment_unavailableblocker naming why (CART.DEDICATED_SETUP_NEEDS_STRIPE,CART.CARD_REQUIRED,PAYMENT_METHOD.TERMS_UNAVAILABLEorCART.PAYMENT_OPTION_UNAVAILABLE), and checkout answers that code instead ofCART.NOT_READY. Checkout through an option the quote leaves out is refused with the same code. - Checkout carries the
order_idandorder_token(the SDK takes them from the app’screateIdandcreateOrderTokenunless you pass both), the cart’sexpected_updated_at, the quote’spresentation_digest, the contact as{ email, language }(the language the order’s emails go in, one of the store’s languages:409 CART.LANGUAGE_NOT_SUPPORTEDotherwise), an optionalcontact_first_nameandcontact_last_name, and how the order is paid:free(only at a total of zero), apayment_optionthe quote lists, oron_accountfor a company or company location whose purchasing policy is on account. At a total of zero apayment_optionwithsave_payment_method: truesaves the card a renewing package needs through Stripe’s setup; it is refused with409 CART.NOTHING_DUEwhen no line saves a card and409 CART.DEDICATED_SETUP_NEEDS_STRIPEfor a Monri option. To save a card for later, setsave_payment_methodand send the exactsaved_card_termswording the buyer saw inpayment_method_terms. The order’s language is the client’s language (X-Arky-Locale), as for the quote. A changed quote is refused with409 COMMERCE.PRESENTATION_CHANGEDand the new quote, which the SDK raises asCartPresentationChangedError. - The answer is
{ type: "placed", order_id, number, payment_id, payment_action, payment_method_id, payment_method_setup }(the last two set when placing saves a card), or{ type: "already_member", package_member_id }when the cart is a free sign-up for a package the buyer already belongs to: no order is made. The payment action says what the buyer does next: nothing, or a Stripe embedded checkout or Monri card form to mount.mountCheckoutActioninarky-sdk/storefrontmounts it. A card action’sruns_onsays where the payment runs:{ type: "provider" }, or{ type: "simulator", api_url }on a test store. - Retries: without
order_idandorder_token, checkout keeps the request across reloads before sending it, the same checkout again recovers the kept one, and a different checkout is refused untilrecoverCheckoutsettles it. With both given, useretainCheckoutbefore posting andrecoverCheckouton the next page load. The sameorder_idnever makes a second order. A definite refusal (any4xxexcept408and429) drops the kept request, so the buyer can change the cart and check out again.eshop.checkoutFlow({ buyer, package_id })runs the whole checkout page on these rules (Checkout). - A cart is
active,abandoned,converted(with its order),superseded,mergedorexpired. A shopper’s cart becomesabandonedan hour after its last change andexpired30 days after that change; a change or checkout of a finished cart is refused with409 CART.FINISHED, so the storefront starts a new cart. Carts staff build and carts holding an offer never become abandoned. The browser keeps the cart’s recovery token, which the SDK sends asX-Arky-Cart-Token. A cart holds at most 100 lines of each kind and 100 deliveries, and a cart too large to store is refused with413 CART.TOO_LARGE.
Company carts and offers. A cart’s buyer is the customer themself, a company, a
company_location, or a company_location_selection: a company cart whose location isn’t picked
yet, which takes no lines until one is. Company buyers carry an optional purchase order number, and
buying for a company or location needs the place_orders company permission there. A company
buying for itself buys nothing that ships or is lent: those goods need a location
(409 CART.COMPANY_PHYSICAL). Staff can
review a company or location cart and make it an offer for a contact ({ email, language }), then
send it with an optional expiry and a note for the customer; an offer locks the cart, holds only
lines priced from its package (no switch or amendment), and a changed offer is a new
cart that supersedes it. An offer’s discounts come only from the promotion codes on the cart,
never from automatic promotions, and a package line’s discount is shared evenly by its seats
(409 CART.OFFER_UNEVEN_REBATE when it can’t be). cart.offer.quote answers the quote the offer
would be made from, so staff see its price before making it; making the offer is refused with
409 COMMERCE.PRESENTATION_CHANGED when that quote moved since. The
customer signs in with the email code to open and order it before it expires
(409 CART.OFFER_EXPIRED after); an expired offer sends no reminder and stays locked until staff
withdraw or revise it. Offers send the offer_sent, offer_revised and offer_reminder emails to the offer’s
contact, whose wording reads the note at cart.offer.status.note and the expiry at
cart.offer.status.expires_at.
Orders
import type {
Actor,
Block,
Currency,
EpochMilliseconds,
OnAccountApproval,
OrderBuyer,
OrderDeliveryGroup,
OrderInvoice,
OrderLineItem,
OrderPromotion,
OrderTotals,
PaymentTerms,
PostalAddress,
RenewalRecovery,
} from "arky-sdk";
interface Order {
id: string;
blocks: Block[];
number: string;
invoices: OrderInvoice[];
store_id: string;
source:
| { type: "cart"; cart_id: string; placed_by: Actor }
| { type: "renewal"; order_package_line_item_id: string; recovery: RenewalRecovery | null };
customer_id: string;
contact: { email: { email: string; language: string } | null; first_name: string | null; last_name: string | null; phone: string | null };
buyer: OrderBuyer;
market_id: string;
sales_channel_id: string;
tax_mode: "exclusive" | "inclusive";
collection:
| { type: "free" }
| { type: "payment_option"; payment_option_id: string }
| { type: "package_member" }
| { type: "on_account"; payment_option_id: string; terms: PaymentTerms; due_at: EpochMilliseconds; approval: OnAccountApproval };
line_items: OrderLineItem[];
delivery_groups: OrderDeliveryGroup[];
currency: Currency;
promotions: OrderPromotion[];
billing_address: PostalAddress | null;
language: string;
created_at: EpochMilliseconds;
updated_at: EpochMilliseconds;
status: "pending" | "confirmed" | "partially_cancelled" | "cancelled";
totals: OrderTotals;
}
Storefront calls (eshop.order.get, find, the cart’s order, a member’s Orders, booking changes)
answer StorefrontOrder: the same fields, with source.placed_by as
{ type: "customer", customer_id } or { type: "account" }, an on-account approval as
{ type: "buyer_terms" } or { type: "account" }, and a booking’s attendance and reschedules
and an access revocation keeping only their times.
/v1/stores/{store_id}/orders sdk.eshop.order.find() /v1/stores/{store_id}/orders/{id} sdk.eshop.order.get() /v1/stores/{store_id}/orders/{id}/cancel sdk.eshop.order.cancel() /v1/stores/{store_id}/orders/{id}/product-items/{line_item_id}/cancel sdk.eshop.order.cancelProductItem() /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/cancel sdk.eshop.order.cancelBookingItem() /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/reschedule sdk.eshop.order.rescheduleBookingItem() /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/attend sdk.eshop.order.attendBookingItem() /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/no-show sdk.eshop.order.markBookingItemNoShow() /v1/stores/{store_id}/orders/{id}/resend-receipt sdk.eshop.order.resendReceipt() /v1/stores/{store_id}/orders/{id}/credits sdk.eshop.order.credit.create() - Lines are
product,booking,packageandrental_use, each with its frozen snapshot, money and tax. A line keeps the exact price it was bought at, as package, item and price, and a product line’s snapshot keeps the variant’svariant_blocks, itscategory_idsand itsmeasure. A line never copies its product’s, booking service’s or package’s own blocks, so the name and description of what was sold are read live through the line’s ids: a later rename shows on earlier orders, while the keys, SKU,variant_blocks, prices and tax stay as sold. A store that wants a product’s name kept as sold writes it into its variants’ blocks. A line ispending(a card checkout waiting 30 minutes for its payment),confirmedorcancelledwith a reason:store_cancelled,customer_cancelled,payment_failedorexpired. The order’s status is computed from its lines. - Arky gives each order a
numberat placement, unique in its store, which never changes. An order holds at most 500 lines and 100 deliveries. - Lines start
confirmedwhen nothing must be paid first: a free order, an on-account order, and cash on delivery or a manual option, whose payment stays open until the money is recorded. Staff can’t confirm a card order’s waiting lines by hand. - Booking lines are the bookings: staff mark attendance (
attendBookingItem) or a no-show once the booking has started (409 ORDER.BOOKING_NOT_STARTEDbefore), move it to another start of the same offering before it starts (rescheduleBookingItem, at most 20 moves, emailingbooking_confirmedagain unlessnotify_customeris false), or cancel it until it ends. Customers move or cancel their own booking on the storefront only as the service’scustomer_changesallows.sdk.eshop.order.findBookingItemslists bookings across orders bypending,confirmed,attended,no_showorcancelled. - Cancelling a confirmed product or booking line names the app-picked id of the credit it
creates; a credit is money owed back to the buyer, refunded through the payment. Only staff
cancel product items; a customer asks the store. Nobody cancels an item that a
preparingorreadyfulfillment holds (409 FULFILLMENT_JOB.PREPARED_UNIT_CONFLICT): unpack it first. Cancelling every line of an order paid by cash or a manual option closes its open payment. A cancellation credits everything left on what it cancels, never a part: a store that keeps a cancellation fee refunds that credit and charges the fee as its own order of a priced item. - Staff credits (
credit.create, under a credit id the app picks, with itstargetsandreason) lower what the buyer owes. Each target names a line, units or a delivery with anamount:{ type: "remaining" }or{ type: "part", subtotal_reduction }, at most what is left on it, and discounts and tax follow in proportion; the same id with othertargetsor anotherreasonis409 GENERAL.CONFLICT. A credit that leaves nothing owed settles the order like a payment would, so goods heldawaiting_paymentcan leave. - Staff with
ordersmay correct the order’s contact (its email and language; a newly chosen language must be one of the store’s,409 ORDER.LANGUAGE_NOT_SUPPORTED, and a kept one the store has since removed stays) and, while nothing of a delivery has left, its address; they also edit the order’sblocksand attach up to 20 invoice or credit note links from the store’s accounting software. - Resend receipt sends the
order_receivedemail again to the order’s contact, as a new outgoing email under the id the app picks, and answers with that email. When that email is queued to go, the order gets a new link and the old link stops working; a resend recordednot_sent, for example to a blocked address, leaves the old link working. It is refused while the store has noorder_receivedemail selected (409 STORE_EMAILS.ORDER_RECEIVED_EMPTY). - Customers read their own orders, deliveries and payments on the storefront through
arky.eshop.order.
Payments
Payment options are how a market’s buyers pay: stripe (cards, after connecting the store’s
Stripe account and its webhook), monri, cash_on_delivery and manual (such as a bank transfer,
with blocks telling the buyer where to pay). A market lists its options in order, and a quote offers
those of them that can pay its cart; a paid package is paid by card. A Stripe or Monri
option holds the store’s own saved_card_terms, per language: the wording a person accepts when a
card is saved under it.
A store’s mode decides what it may connect. A live store takes live keys and monri in live only
(409 PAYMENT_OPTION.LIVE_STORE_NEEDS_LIVE_KEYS). A test store refuses them
(409 PAYMENT_OPTION.TEST_STORE_REFUSES_LIVE_KEYS) and can connect arky_stripe and arky_monri, Arky’s
simulated providers, with one keyless call, which a live store can’t
(409 PAYMENT_OPTION.ARKY_PROVIDER_NEEDS_TEST_STORE). A storefront reads stripe or monri as the option’s
type for both kinds.
/v1/stores/{store_id}/payment-options sdk.store.paymentOption.create() /v1/stores/{store_id}/payment-options/stripe sdk.store.paymentOption.stripe.connect() /v1/stores/{store_id}/payment-options/arky-stripe sdk.store.paymentOption.arkyStripe.connect() /v1/stores/{store_id}/payment-options/arky-monri sdk.store.paymentOption.arkyMonri.connect() /v1/stores/{store_id}/payment-options/stripe/{id}/webhook-secret sdk.store.paymentOption.stripe.saveWebhookSecret() /v1/stores/{store_id}/payment-options/stripe/{id}/setup sdk.store.paymentOption.stripe.checkSetup() /v1/stores/{store_id}/payment-options/monri/{id}/replace-merchant-key sdk.store.paymentOption.monri.replaceMerchantKey() /v1/stores/{store_id}/payments sdk.eshop.payment.find() /v1/stores/{store_id}/payments/{id}/refunds sdk.eshop.payment.createRefund() /v1/stores/{store_id}/payments/{id}/refunds/{refund_id}/receipts sdk.eshop.payment.recordRefundReceipt() /v1/stores/{store_id}/payments/{id}/collections sdk.eshop.payment.recordCollection() /v1/stores/{store_id}/payments/{id}/collections/{collection_id}/void sdk.eshop.payment.voidCollection() /v1/stores/{store_id}/payments/{id}/resolve-hold sdk.eshop.payment.resolveHold() /v1/stores/{store_id}/payments/{id}/resolve-charge sdk.eshop.payment.resolveCharge() /v1/stores/{store_id}/payments/{id}/refunds/{refund_id}/resolve sdk.eshop.payment.resolveRefund() /v1/stores/{store_id}/payments/{id}/refunds/made sdk.eshop.payment.recordMadeRefund() /v1/stores/{store_id}/incoming-webhooks sdk.notification.incomingWebhook.find() import type {
AccountActor,
EpochMilliseconds,
ManualPayment,
Money,
MonriCardPayment,
MonriCheckoutPayment,
RecordedPayment,
StripeCardPayment,
StripeCheckoutPayment,
} from "arky-sdk";
interface Payment {
id: string;
store_id: string;
order_id: string;
payment_option_id: string;
money: Money;
type:
| ({ type: "stripe_checkout" } & StripeCheckoutPayment)
| ({ type: "stripe_card" } & StripeCardPayment)
| ({ type: "monri_checkout" } & MonriCheckoutPayment)
| ({ type: "monri_card" } & MonriCardPayment)
| ({ type: "cash_on_delivery" } & RecordedPayment)
| ({ type: "manual" } & ManualPayment);
holds: { id: string; message: string; opened_at: EpochMilliseconds; status: { type: "open" } | { type: "resolved"; by: AccountActor; note: string; at: EpochMilliseconds } }[];
status: "pending" | "open" | "requires_action" | "paid" | "expired" | "cancelled" | "declined" | "failed" | "unknown" | "closing";
status_revision: string;
created_at: EpochMilliseconds;
updated_at: EpochMilliseconds;
}
Storefront calls (eshop.order.findPayments, getPayment) answer StorefrontPayment: no team
member, reference, note, refund request, hold message, provider claim or raw provider error; a hold
keeps its id, when it opened and whether it is open or resolved.
- Who may do what: staff with
ordersread payments and manage saved cards; onlypaymentsmoves money or records money moving (refunds, collections and their voids, settling unknown results, resolving holds), and it also reads the orders and credits its payments name. Every write needs theread_writeaccess of its permission. A pickup clerk withfulfillmentreach at the location records the cash of a cash-on-delivery handover there. - The Stripe webhook is the merchant’s. Arky never creates, replaces or deletes a webhook in a
merchant’s Stripe account. The merchant creates one at Arky’s address for store payments,
https://api.arky.io/v1/webhooks/stripe, as a Snapshot destination with the eventsstripe.checkSetuplists, on any API version: Stripe’s dashboard asks for Thin or Snapshot events and suggests Thin, and Arky reads the object a Snapshot event carries. The merchant pastes its signing secret into each store’s option withstripe.saveWebhookSecret, for the first paste and for every roll (the previous secret keeps working untilprevious_secret_expires_at). Saving reads the account’s webhooks through the key and requires exactly one at Arky’s address, switched on, with those events (409 PAYMENT_OPTION.WEBHOOK_MISSING,WEBHOOK_DUPLICATED,WEBHOOK_DISABLED,WEBHOOK_EVENTS_MISSINGorWEBHOOK_UNREADABLE). The option’swebhookisnot_configureduntil then,awaiting_first_eventonce the secret is saved, andverifiedonce a signed event proves it; card payments don’t wait for that first event.checkSetupreads the account and its webhook again and names each problem it finds. Any number of stores may share one Stripe account; inside one store an account and mode back one option (409 PAYMENT_OPTION.STRIPE_ACCOUNT_TAKEN). - Monri. The merchant enters Arky’s one Monri address,
https://api.arky.io/v1/webhooks/monri, in Monri’s dashboard, and every store sharing a Monri merchant account holds its key.monri.replaceMerchantKeygives an option a new merchant key; its environment and authenticity token stay, so cards saved under it keep working. - One record per payment. Its refunds, disputes and recorded money are entries inside it, and refunds never exceed what was paid. Refunds and recorded collections have their own commands on the payment.
- Cash and manual payments count as paid once their active recorded money reaches what is due. Cancelling the whole order closes an open one. A collection recorded by mistake is voided with a reason: it stays in the history, stops counting, moves no money and sends no email; a wrong amount is fixed by voiding it and recording the right one.
- Cash and manual refunds are one payout: a requested refund is recorded
sentwith the reference of the payout, or cancelled; money that comes back makes itreturned, and paying it again is a new refund. - Holds open when facts disagree, such as money arriving after a payment ended, and stay open until a person resolves them by id with a note; they stay in the history.
- Unknown Monri results: when Monri’s answer to a card charge or a refund never arrived, staff
check Monri and record what happened with
resolveChargeorresolveRefund:{ type: "made", transaction_id }or{ type: "not_made" }, with the payment’sexpected_updated_at. The charge or the refund then readsconfirmed_madeorconfirmed_not_made. A refund made in Monri’s back office is recorded on the Monri payment withrecordMadeRefund: Monri’stransaction_id, the money and reason, the credits it pays or the excess it returns, andnotify_customer. It passes every check a refund made in Arky passes, is savedconfirmed_madeat once, sends nothing to Monri, and postsrefund.createdandrefund.succeeded. - Saved cards are payment methods:
requestSetup,startSetup,completeSetup. A card belongs to itsowner, a customer, a company or a company location, and pays only for that buyer. Saving one records thelanguageand the exacttermsthe buyer accepted, which must be the option’s currentsaved_card_termsin that language (409 PAYMENT_METHOD.TERMS_CHANGEDorTERMS_UNAVAILABLEotherwise). A card can’t be revoked while a package member that isn’t cancelled renews with it (409 PAYMENT_METHOD.IN_USE, naming the member). Arky saves a Monri card only from a paid checkout, so this setup under a Monri option is refused (409 PAYMENT_METHOD.DEDICATED_SETUP_NEEDS_STRIPE); a member’s card is replaced as Packages describes. - Incoming webhooks are the store’s inbox for the posts of its Stripe and Monri options,
unique per provider event id:
waiting(new, retried, orunmatcheduntil its record appears),processing,applied,ignored, or inreviewuntil staff withpaymentsresolve it withapplyorignore.incomingWebhook.find({ payment_option_id, status })lists one option’s posts, for staff withordersorpayments; the store’s Resend posts are Support’s (Support). Each provider posts to one address for every store: the merchant’s Stripe webhook goes tohttps://api.arky.io/v1/webhooks/stripeand Monri’s callback tohttps://api.arky.io/v1/webhooks/monri. - A refund that succeeds sends the
order_refundedemail, once per refund, when its request said so. Webhooks postrefund.created,refund.succeededandrefund.failed, each with{ order, payment_id, refund_id };refund.succeededalso carriesnotify_customer.
Returns And Rentals
/v1/stores/{store_id}/returns sdk.eshop.return.create() /v1/stores/{store_id}/returns/{id}/execute sdk.eshop.return.execute() /v1/stores/{store_id}/returns/{id}/credit sdk.eshop.return.credit() /v1/stores/{store_id}/rentals sdk.eshop.rental.find() /v1/stores/{store_id}/rentals/{id}/execute sdk.eshop.rental.execute() A return is an order return or a rental return. A customer’s return starts requested; staff
approve it, opening it at a decided location, or decline it with a reason, and each choice carries
notify_customer to say whether the customer gets the return_approved or return_declined email.
A return staff create names the location that receives it (409 RETURN.DESTINATION_REQUIRED
without one), so creating one needs orders and fulfillment at every location. Staff move a return with one command and the expected_updated_at they read; a
receipt, disposal or missing record that closes it posts its own webhook, then return.closed. A
return never changes money by itself: once units of an order return are received, staff credit them
on the order with credit, under a credit id the app picks and the return’s expected_updated_at,
each received unit once, and refund the payment separately. Customers start returns from the storefront with
arky.eshop.return.create, using getOrderOptions and findRentalOptions to see what can go back. A
rental is one rented item of a package member, with
the terms in force. Its status says where those terms stand, so a storefront shows it as read:
waiting while they haven’t started (a first purchase until its payment activates the member, a
package change until it applies, a team amendment until its date), then active, ending while
its units come back, and closed; a rental whose terms never start (an unpaid order, a change that
ends unapplied, a withdrawn amendment or a member cancelled first) is withdrawn, never had a unit
out and opens no return. Only an active rental is picked, ships, takes a replacement or is ended:
ending, closing or replacing a waiting or withdrawn one is refused with
409 RENTAL.WRONG_STATUS. A storefront lists a withdrawn rental nowhere. Stock belongs to the job, not the rental: a rental line holds its units like
every other line of its job, so a first purchase’s order holds its machines from placement while its
rentals wait, another buyer’s checkout of the last one is refused with
409 INVENTORY_LEVEL.NOT_AVAILABLE, and a failed or expired payment frees them. Staff with orders
request a replacement unit for an active rental, whatever its member’s status, with
rental.execute({ expected_updated_at, command }); a rental’s units, a replacement’s included, are
picked and leave only while its member isn’t blocked, and picking one for a blocked member is
refused with 409 RENTAL.MEMBER_NOT_ACTIVE. Jobs, fulfillments, returns and rentals all take
their command at POST /{id}/execute as { expected_updated_at, command }.
Inventory
/v1/stores/{store_id}/inventory-items sdk.eshop.inventoryItem.create() /v1/stores/{store_id}/inventory-levels sdk.eshop.inventoryLevel.find() /v1/stores/{store_id}/inventory-movements sdk.eshop.inventoryMovement.record() /v1/stores/{store_id}/inventory-units sdk.eshop.inventoryUnit.receive() An inventory item is a stocked thing, such as one product model; variants name the items they
need. It is tracked by quantity, individual (one unit record per piece) or untracked (no
counted stock). An inventory level is its stock at one location (on_hand, reserved,
unavailable and the available rest), changed by stock actions that each carry an action_id the
app picks. A stock action names the level it reads, never the level’s version, so orders and
shipments don’t refuse warehouse work; an adjustment also names the count it corrects
(expected_count), and a count that moved is refused with 409 GENERAL.CONFLICT. Movements are the stock log with
typed reasons; a dispatched row names the fulfillment that took the goods out. Inventory units
track one serialized item through receiving, allocation, moves, returns and write-offs.
Companies
/v1/stores/{store_id}/companies sdk.companies.create() /v1/stores/{store_id}/company-locations sdk.companies.location.create() /v1/stores/{store_id}/companies/{id}/purchasing sdk.companies.setPurchasing() /v1/stores/{store_id}/company-locations/{id}/purchasing sdk.companies.location.setPurchasing() /v1/stores/{store_id}/companies/{id}/tax/registrations sdk.companies.submitTaxRegistration() /v1/stores/{store_id}/companies/{id}/tax/registrations/review sdk.companies.reviewTaxRegistration() /v1/stores/{store_id}/company-roles sdk.companies.role.create() /v1/stores/{store_id}/company-memberships sdk.companies.membership.create() await sdk.companies.location.setPurchasing({
store_id: storeId,
id: downtown.id,
expected_updated_at: downtown.updated_at,
purchasing: {
payment: { type: "on_account", terms: { type: "net_days", days: 30 }, billing_address: downtownBilling },
allowed_payment_option_ids: [bankTransfer.id],
purchase_order_number_required: true,
},
});
await sdk.companies.membership.create({
store_id: storeId,
id: crypto.randomUUID(),
company_id: northwind.id,
contact: { email: "[email protected]", language: "en" },
grants: [{ scope: { type: "company_location", company_location_id: downtown.id }, role_ids: [buyerRole.id] }],
});
- A company is a business buyer with a name, a
contact({ email, language }ornull) and blocks. A company and each of its locations have their own purchasing policy:standard_checkout, oron_accountwith payment terms such as net 30 and a billing address; the payment options they may use (an empty list allows none); and whether a purchase order number is required. A location never inherits its company’s policy. Only staff set purchasing, tax, blocks and the location a company location is served from; a new company or location pays at checkout with no payment option allowed until staff list some. - A company and each location keep their own tax registrations, which staff submit and then
verify or reject. Orders carry the buyer’s verified registrations: a
standardorexemptbuyer’s, the latter beside the exemption’s reason, and the one areverse_chargebuyer names. - Memberships add a person by their contact (
{ email, language }), with grants, each for the whole company (which covers all its locations, now and later) or for one location, with company roles for that scope. A verified customer with that email is active at once; anyone else isinvitedand becomes active the moment they verify that email by signing in, with nothing to accept. Adding someone sends the store’scompany_inviteemail to that contact, in its language, which must be one of the store’s. Permissions areplace_orders,join_packages,access_digital_products,view_own_orders,view_company_orders,view_own_packages,view_company_packages,manage_company,manage_addresses,manage_members,manage_company_packages,manage_payment_methodsandadmin. - A member with
manage_companyedits the company’s name and contact. A member withmanage_addressesedits a location’s name, shipping address and billing address; for the whole company it also edits the company’s billing address and creates and removes its locations. - While other members are active, one active membership must keep
manage_members(oradmin) for the whole company: removing, disabling or narrowing it, or editing one of its roles, is refused with409 COMPANY_MEMBERSHIP.LAST_MANAGERuntil another member holds it. Adding someone and an invite turning active are never refused by this rule, so a company’s buyers can be active before its first manager signs in. - Members read their companies, locations and grants with
arky.companieson the storefront, and members whose grants allow it manage the company there too:update(manage_company);location.create,updateanddelete(manage_addresses); andmembership.find({ company_id }),create,update,delete,resendInviteandrole.find({ company_id })(manage_members). Creates take the app’sid. Members never see company or locationblocks, and their updates keep the stored ones. Deleting a company location is one write that answers{ deleted }.
Packages, their items, prices, access rows and members are on Packages; promotions on Promotions; shipping and fulfillment on Shipping and Fulfillment.