Back to Arky

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;
}
POST /v1/stores/{store_id}/products
SDK: sdk.eshop.product.create()
POST /v1/stores/{store_id}/product-variants
SDK: sdk.eshop.productVariant.create()
POST /v1/stores/{store_id}/digital-assets
SDK: sdk.eshop.digitalAsset.upload()
POST /v1/stores/{store_id}/digital-assets/{id}/archive
SDK: 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. The sku is optional, and staff’s exact SKU filter finds a variant by it. A product holds at most 100 variants (409 PRODUCT_VARIANT.LIMIT).
  • measure says how much one unit counts toward a package’s category minimum, such as 1,000 for a 1 litre carton: not_counted, or counts with an amount of 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 deleting until 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:

GET /v1/storefront/packages
SDK: arky.eshop.package.find()
GET /v1/storefront/package-items
SDK: arky.eshop.packageItem.find()
GET /v1/storefront/package-items/by-parent
SDK: arky.eshop.packageItem.getByParent()
GET /v1/storefront/package-items/{package_item_id}/prices
SDK: arky.eshop.packageItem.findPrices()
GET /v1/storefront/products/{id_or_slug}
SDK: arky.eshop.product.get()
GET /v1/storefront/products/by-key/{key}
SDK: arky.eshop.product.getByKey()
GET /v1/storefront/products/{product_id}/variants/{id}
SDK: 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.find lists 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 its package_id; Arky never picks or merges packages.
  • One answer per priced item. packageItem.find pages the package’s priced items in the market (products, booking services and packages, each once), each with its package_item_id, package_id, market_id, the typed item, its position and the listed record’s content (key, slugs, blocks, categories). selection narrows it by types, text, categories (products and booking services), block filters on the listed record, a price with min_amount and max_amount and a price_basis, and orders it by package_order (the default), relevance (needs text) or starting_price (needs a price_basis). A filter or sort that doesn’t fit the types asked for is refused with 400.
  • Search is per item, not per variant. price and price_basis match 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: true and a level that shows prices, an answer has its currency and price_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 as price_id. A price filter or a starting-price sort without see_prices is refused with 403. 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 with 409 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 answers 409 PACKAGE.ACCESS_CHANGED: start a new search.
  • Prices. findPrices pages one item’s prices, oldest first: each names its price_id, the sellable it prices, its content (sku, blocks and the price basis) and, with include_price: true, its price. A cart line names the package, the item and the price it is bought at.
  • get reads a canonical UUID as the id and anything else as a slug in the request’s language; a miss is 404 and is never retried as a key. getByKey reads the key. Both answer the product with the package_item_id of its item in that package and market. packageItem.getByParent reads the item of one record, without prices. productVariant.get({ product_id, id }) reads one variant, with its price when you pass include_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.

POST /v1/stores/{store_id}/booking-services
SDK: sdk.eshop.bookingService.create()
POST /v1/stores/{store_id}/booking-resources
SDK: sdk.eshop.bookingResource.create()
POST /v1/stores/{store_id}/booking-offerings
SDK: sdk.eshop.bookingOffering.create()
GET /v1/storefront/booking-services/availability
SDK: 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_overrides replaces 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 (400 on hours). 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. A store_location venue books in that location’s timezone, so the offering’s resource has the same one, as the stylist and the salon here share Europe/Berlin: saving such an offering whose resource has another timezone is refused with 409 BOOKING_OFFERING.VENUE_TIMEZONE, and so is a resource or location timezone change that would part them while an offering that isn’t deleting joins them. The names are compared exactly. A not_fixed venue 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_TAKEN for 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_minutes schedules the booking_reminder email 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

POST /v1/storefront/carts
SDK: arky.eshop.cart(scope).create()
POST /v1/storefront/carts/{id}/product-items
SDK: arky.eshop.cart(scope).addProduct()
POST /v1/storefront/carts/{id}/quote
SDK: arky.eshop.cart(scope).quote()
POST /v1/storefront/carts/accept
SDK: arky.eshop.cart(scope).checkout()
POST /v1/stores/{store_id}/carts/{id}/offer/quote
SDK: 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. An update may 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 createId unless it passes one. Lines are product, booking and package, and each names the exact price it is bought at as price, { 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. ready is false while something blocks checkout; blockers says what. A shipping rate that needs a weight Arky doesn’t know is left out of a delivery’s offers and listed in its unavailable with the code SHIPPING.WEIGHT_UNKNOWN, and a selected one becomes a shipping_rate_unavailable blocker; the other rates stay. A booking line that can’t be sold reads availability: { type: "unavailable", code }, with a booking_unavailable blocker carrying the same code (Scheduled Services). A unit priced below its fixed per-unit tax in an inclusive market is a tax_unavailable blocker on its line (TAX.FIXED_ABOVE_PRICE), and a delivery that no longer fits its lines, such as a passed window, a delivery_unavailable blocker with its code (CART.DELIVERY_WINDOW_PASSED, CART.DELIVERY_PROFILE_MIXED, CART.DELIVERY_LINE_NOT_SHIPPED, CART.DELIVERY_UNITS_MISMATCH or CART.PACKAGE_DELIVERY_CHANGED). A switch or amend package line’s quote runs the change’s own checks: a delivery its move still needs is a package_delivery_required blocker on that line, and any other refusal of the change a package_change_refused blocker with that refusal’s code, which checkout answers with that refusal. The quote lists each code the cart holds in promotion_codes, with its state: applied, stopped or not_applied (Promotions).
  • Payment options. The quote’s payment_option_ids lists 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 a payment_unavailable blocker naming why (CART.DEDICATED_SETUP_NEEDS_STRIPE, CART.CARD_REQUIRED, PAYMENT_METHOD.TERMS_UNAVAILABLE or CART.PAYMENT_OPTION_UNAVAILABLE), and checkout answers that code instead of CART.NOT_READY. Checkout through an option the quote leaves out is refused with the same code.
  • Checkout carries the order_id and order_token (the SDK takes them from the app’s createId and createOrderToken unless you pass both), the cart’s expected_updated_at, the quote’s presentation_digest, the contact as { email, language } (the language the order’s emails go in, one of the store’s languages: 409 CART.LANGUAGE_NOT_SUPPORTED otherwise), an optional contact_first_name and contact_last_name, and how the order is paid: free (only at a total of zero), a payment_option the quote lists, or on_account for a company or company location whose purchasing policy is on account. At a total of zero a payment_option with save_payment_method: true saves the card a renewing package needs through Stripe’s setup; it is refused with 409 CART.NOTHING_DUE when no line saves a card and 409 CART.DEDICATED_SETUP_NEEDS_STRIPE for a Monri option. To save a card for later, set save_payment_method and send the exact saved_card_terms wording the buyer saw in payment_method_terms. The order’s language is the client’s language (X-Arky-Locale), as for the quote. A changed quote is refused with 409 COMMERCE.PRESENTATION_CHANGED and the new quote, which the SDK raises as CartPresentationChangedError.
  • 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. mountCheckoutAction in arky-sdk/storefront mounts it. A card action’s runs_on says where the payment runs: { type: "provider" }, or { type: "simulator", api_url } on a test store.
  • Retries: without order_id and order_token, checkout keeps the request across reloads before sending it, the same checkout again recovers the kept one, and a different checkout is refused until recoverCheckout settles it. With both given, use retainCheckout before posting and recoverCheckout on the next page load. The same order_id never makes a second order. A definite refusal (any 4xx except 408 and 429) 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, merged or expired. A shopper’s cart becomes abandoned an hour after its last change and expired 30 days after that change; a change or checkout of a finished cart is refused with 409 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 as X-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 with 413 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.

GET /v1/stores/{store_id}/orders
SDK: sdk.eshop.order.find()
GET /v1/stores/{store_id}/orders/{id}
SDK: sdk.eshop.order.get()
POST /v1/stores/{store_id}/orders/{id}/cancel
SDK: sdk.eshop.order.cancel()
POST /v1/stores/{store_id}/orders/{id}/product-items/{line_item_id}/cancel
SDK: sdk.eshop.order.cancelProductItem()
POST /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/cancel
SDK: sdk.eshop.order.cancelBookingItem()
POST /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/reschedule
SDK: sdk.eshop.order.rescheduleBookingItem()
POST /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/attend
SDK: sdk.eshop.order.attendBookingItem()
POST /v1/stores/{store_id}/orders/{id}/booking-items/{line_item_id}/no-show
SDK: sdk.eshop.order.markBookingItemNoShow()
POST /v1/stores/{store_id}/orders/{id}/resend-receipt
SDK: sdk.eshop.order.resendReceipt()
POST /v1/stores/{store_id}/orders/{id}/credits
SDK: sdk.eshop.order.credit.create()
  • Lines are product, booking, package and rental_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’s variant_blocks, its category_ids and its measure. 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 is pending (a card checkout waiting 30 minutes for its payment), confirmed or cancelled with a reason: store_cancelled, customer_cancelled, payment_failed or expired. The order’s status is computed from its lines.
  • Arky gives each order a number at placement, unique in its store, which never changes. An order holds at most 500 lines and 100 deliveries.
  • Lines start confirmed when 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_STARTED before), move it to another start of the same offering before it starts (rescheduleBookingItem, at most 20 moves, emailing booking_confirmed again unless notify_customer is false), or cancel it until it ends. Customers move or cancel their own booking on the storefront only as the service’s customer_changes allows. sdk.eshop.order.findBookingItems lists bookings across orders by pending, confirmed, attended, no_show or cancelled.
  • 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 preparing or ready fulfillment 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 its targets and reason) lower what the buyer owes. Each target names a line, units or a delivery with an amount: { 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 other targets or another reason is 409 GENERAL.CONFLICT. A credit that leaves nothing owed settles the order like a payment would, so goods held awaiting_payment can leave.
  • Staff with orders may 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’s blocks and attach up to 20 invoice or credit note links from the store’s accounting software.
  • Resend receipt sends the order_received email 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 recorded not_sent, for example to a blocked address, leaves the old link working. It is refused while the store has no order_received email 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.

POST /v1/stores/{store_id}/payment-options
SDK: sdk.store.paymentOption.create()
POST /v1/stores/{store_id}/payment-options/stripe
SDK: sdk.store.paymentOption.stripe.connect()
POST /v1/stores/{store_id}/payment-options/arky-stripe
SDK: sdk.store.paymentOption.arkyStripe.connect()
POST /v1/stores/{store_id}/payment-options/arky-monri
SDK: sdk.store.paymentOption.arkyMonri.connect()
POST /v1/stores/{store_id}/payment-options/stripe/{id}/webhook-secret
SDK: sdk.store.paymentOption.stripe.saveWebhookSecret()
GET /v1/stores/{store_id}/payment-options/stripe/{id}/setup
SDK: sdk.store.paymentOption.stripe.checkSetup()
POST /v1/stores/{store_id}/payment-options/monri/{id}/replace-merchant-key
SDK: sdk.store.paymentOption.monri.replaceMerchantKey()
GET /v1/stores/{store_id}/payments
SDK: sdk.eshop.payment.find()
POST /v1/stores/{store_id}/payments/{id}/refunds
SDK: sdk.eshop.payment.createRefund()
POST /v1/stores/{store_id}/payments/{id}/refunds/{refund_id}/receipts
SDK: sdk.eshop.payment.recordRefundReceipt()
POST /v1/stores/{store_id}/payments/{id}/collections
SDK: sdk.eshop.payment.recordCollection()
POST /v1/stores/{store_id}/payments/{id}/collections/{collection_id}/void
SDK: sdk.eshop.payment.voidCollection()
POST /v1/stores/{store_id}/payments/{id}/resolve-hold
SDK: sdk.eshop.payment.resolveHold()
POST /v1/stores/{store_id}/payments/{id}/resolve-charge
SDK: sdk.eshop.payment.resolveCharge()
POST /v1/stores/{store_id}/payments/{id}/refunds/{refund_id}/resolve
SDK: sdk.eshop.payment.resolveRefund()
POST /v1/stores/{store_id}/payments/{id}/refunds/made
SDK: sdk.eshop.payment.recordMadeRefund()
GET /v1/stores/{store_id}/incoming-webhooks
SDK: 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 orders read payments and manage saved cards; only payments moves 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 the read_write access of its permission. A pickup clerk with fulfillment reach 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 events stripe.checkSetup lists, 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 with stripe.saveWebhookSecret, for the first paste and for every roll (the previous secret keeps working until previous_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_MISSING or WEBHOOK_UNREADABLE). The option’s webhook is not_configured until then, awaiting_first_event once the secret is saved, and verified once a signed event proves it; card payments don’t wait for that first event. checkSetup reads 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.replaceMerchantKey gives 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 sent with the reference of the payout, or cancelled; money that comes back makes it returned, 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 resolveCharge or resolveRefund: { type: "made", transaction_id } or { type: "not_made" }, with the payment’s expected_updated_at. The charge or the refund then reads confirmed_made or confirmed_not_made. A refund made in Monri’s back office is recorded on the Monri payment with recordMadeRefund: Monri’s transaction_id, the money and reason, the credits it pays or the excess it returns, and notify_customer. It passes every check a refund made in Arky passes, is saved confirmed_made at once, sends nothing to Monri, and posts refund.created and refund.succeeded.
  • Saved cards are payment methods: requestSetup, startSetup, completeSetup. A card belongs to its owner, a customer, a company or a company location, and pays only for that buyer. Saving one records the language and the exact terms the buyer accepted, which must be the option’s current saved_card_terms in that language (409 PAYMENT_METHOD.TERMS_CHANGED or TERMS_UNAVAILABLE otherwise). 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, or unmatched until its record appears), processing, applied, ignored, or in review until staff with payments resolve it with apply or ignore. incomingWebhook.find({ payment_option_id, status }) lists one option’s posts, for staff with orders or payments; the store’s Resend posts are Support’s (Support). Each provider posts to one address for every store: the merchant’s Stripe webhook goes to https://api.arky.io/v1/webhooks/stripe and Monri’s callback to https://api.arky.io/v1/webhooks/monri.
  • A refund that succeeds sends the order_refunded email, once per refund, when its request said so. Webhooks post refund.created, refund.succeeded and refund.failed, each with { order, payment_id, refund_id }; refund.succeeded also carries notify_customer.

Returns And Rentals

POST /v1/stores/{store_id}/returns
SDK: sdk.eshop.return.create()
POST /v1/stores/{store_id}/returns/{id}/execute
SDK: sdk.eshop.return.execute()
POST /v1/stores/{store_id}/returns/{id}/credit
SDK: sdk.eshop.return.credit()
GET /v1/stores/{store_id}/rentals
SDK: sdk.eshop.rental.find()
POST /v1/stores/{store_id}/rentals/{id}/execute
SDK: 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

POST /v1/stores/{store_id}/inventory-items
SDK: sdk.eshop.inventoryItem.create()
GET /v1/stores/{store_id}/inventory-levels
SDK: sdk.eshop.inventoryLevel.find()
POST /v1/stores/{store_id}/inventory-movements
SDK: sdk.eshop.inventoryMovement.record()
POST /v1/stores/{store_id}/inventory-units
SDK: 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

POST /v1/stores/{store_id}/companies
SDK: sdk.companies.create()
POST /v1/stores/{store_id}/company-locations
SDK: sdk.companies.location.create()
PUT /v1/stores/{store_id}/companies/{id}/purchasing
SDK: sdk.companies.setPurchasing()
PUT /v1/stores/{store_id}/company-locations/{id}/purchasing
SDK: sdk.companies.location.setPurchasing()
POST /v1/stores/{store_id}/companies/{id}/tax/registrations
SDK: sdk.companies.submitTaxRegistration()
POST /v1/stores/{store_id}/companies/{id}/tax/registrations/review
SDK: sdk.companies.reviewTaxRegistration()
POST /v1/stores/{store_id}/company-roles
SDK: sdk.companies.role.create()
POST /v1/stores/{store_id}/company-memberships
SDK: 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 } or null) and blocks. A company and each of its locations have their own purchasing policy: standard_checkout, or on_account with 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 standard or exempt buyer’s, the latter beside the exemption’s reason, and the one a reverse_charge buyer 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 is invited and becomes active the moment they verify that email by signing in, with nothing to accept. Adding someone sends the store’s company_invite email to that contact, in its language, which must be one of the store’s. Permissions are place_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_methods and admin.
  • A member with manage_company edits the company’s name and contact. A member with manage_addresses edits 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 (or admin) for the whole company: removing, disabling or narrowing it, or editing one of its roles, is refused with 409 COMPANY_MEMBERSHIP.LAST_MANAGER until 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.companies on the storefront, and members whose grants allow it manage the company there too: update (manage_company); location.create, update and delete (manage_addresses); and membership.find({ company_id }), create, update, delete, resendInvite and role.find({ company_id }) (manage_members). Creates take the app’s id. Members never see company or location blocks, and their updates keep the stored ones. Deleting a company location is one write that answers { deleted }.
Note

Packages, their items, prices, access rows and members are on Packages; promotions on Promotions; shipping and fulfillment on Shipping and Fulfillment.