Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Replace the legacy returns chain with Return, Exchange and Claim

Damian Legawiecb41f9180f8ed
diff --git a/CLAUDE.md b/CLAUDE.md
index f380a7eadd..ce9b3df4cd 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -22,7 +22,7 @@ Active plans (6.0 target, work pending):
- `6.0-typed-stock-movements.md` — Replace generic StockMovement with typed kinds + concrete FKs
- `6.0-normalize-state-to-status.md` — Rename state → status on Payment, Shipment, InventoryUnit, ReturnAuthorization, GiftCard
- `6.0-fulfillment-and-delivery.md` — Shipment→Fulfillment, ShippingMethod→DeliveryMethod, drop ShippingCategory, FulfillmentProvider strategy, pickup (merchant StockLocation) + pickup_point (third-party PickupPointProvider). **Shipped to 6-0-dev (Waves 2+4+6):** renames + deprecated twins, providers (Manual/Digital/Pickup/PickupPoint), dual-emit events, store pickup discovery endpoints, admin delivery_methods/delivery_zones CRUD + dashboard settings pages, FulfillmentMailer; Wave 7 shipping→delivery data migration remains
-- `6.0-returns-exchanges-claims.md` — First-class Return, Exchange, Claim models replacing ReturnAuthorization/Reimbursement chain. **No state machines (2026-08-02):** plain `status` string + inclusion validation; all fifteen transitions are workflows (`Returns::Receive`, `Exchanges::Fulfill`, `Claims::Resolve`, …) with `validate` hooks for return-eligibility policy and refunds as `external_step`. Nothing happens in a model or transition callback. Statuses live in a `class_attribute` via the core `Spree::HasStatus` concern (`has_status` + additive `add_status(value, after:)`, generating predicates and scopes) — extensible by design, additive only, and no transition graph (that would be a state machine again). **Return eligibility is a hook, not a policy engine (2026-08-03):** no window/restocking-fee/final-sale flag in core — a `validate` handler decides, enforcing for customers while letting staff override (it reads `created_by`), and region-varying policy reads `order.market`. Medusa/Saleor/Vendure ship no policy at all; Shopify's engine has no API. A `ReturnPolicy` model can arrive later behind the same hook.
+- `6.0-returns-exchanges-claims.md` — First-class Return, Exchange, Claim models replacing ReturnAuthorization/Reimbursement chain. **COMPLETE (2026-08-05):** all three entities (+ permanent `ReturnLineItem`/`ExchangeLineItem`/`ClaimLineItem` line items), `Spree::HasStatus`, all fifteen workflows (each with a leading `validate` hook), `Refund#originator`, admin + store v3 APIs (transitions as PATCH member actions; no destroy — cancel instead), dashboard pages. Legacy chain **removed**: ReturnAuthorization/CustomerReturn/Reimbursement/ReimbursementType/legacy ReturnItem + eligibility validators + ReturnsCalculator classes all deleted, but their **tables deliberately survive to 6.1** as the data migration's source and rollback path. `spree:upgrade:migrate_returns` (`Spree::ReturnsMigrator`, defined in the rake file like its sibling upgrade tasks; anonymous-AR readers) is in the 5.6→6.0 manifest after the adjustments step; it needs no cursor because the preserved `number` is uniquely indexed on the new tables, so "what's left" is a `where.not(number: ...)` query and an interrupted run resumes for free. `ReturnAuthorizationReason`→`ReturnReason` (alias one release) + new `ClaimReason`; `Metafields` on all three. Capability replacements: `Spree::ReturnMailer#refunded_email` on `return.refunded` (replaces the reimbursement email), `Order#outstanding_balance` drops the reimbursement term (refunds already net out of `payment_total`), `Return#refunded_total` counts store credits too, `StoreCreditCategory.default_refund_category` (alias kept). **Reasons** ship admin-only CRUD (`/api/v3/admin/{return,claim,refund}_reasons`, `settings` scope) + a combined Settings → Reasons dashboard page + reason pickers on the create dialogs; `mutable` is never client-writable and the immutability guard lives on `Spree::NamedType` (`can_be_deleted?` + rename/destroy guards) because secret API keys authorize by scope and never consult CanCanCan. **No state machines (2026-08-02):** plain `status` string + inclusion validation; all fifteen transitions are workflows (`Returns::Receive`, `Exchanges::Fulfill`, `Claims::Resolve`, …) with `validate` hooks for return-eligibility policy and refunds as `external_step`. Nothing happens in a model or transition callback. Statuses live in a `class_attribute` via the core `Spree::HasStatus` concern (`has_status` + additive `add_status(value, after:)`, generating predicates and scopes) — extensible by design, additive only, and no transition graph (that would be a state machine again). **Return eligibility is a hook, not a policy engine (2026-08-03):** no window/restocking-fee/final-sale flag in core — a `validate` handler decides, enforcing for customers while letting staff override (it reads `created_by`), and region-varying policy reads `order.market`. Medusa/Saleor/Vendure ship no policy at all; Shopify's engine has no API. A `ReturnPolicy` model can arrive later behind the same hook.
- `6.0-platform-auth.md` — Drop Devise, own auth stack, User→Customer/Staff rename (RefreshToken shipped in 5.4)
- `6.0-tax-provider.md` — Per-Market TaxProvider, replaces TaxRate.adjust + Calculator; TaxRate gets direct country/state FKs (tax decoupled from Zone; Zone model dropped in 6.0 via `6.0-delivery-zones.md`); reference provider: Avalara (decisions.md 2026-07-30)
- `6.0-delivery-rate-provider.md` — Per-DeliveryMethod DeliveryRateProvider wrapping Stock::Estimator (calculators stay — 2026-07-27 reversal), `store_id` on ShippingMethod, enriched DeliveryRate (carrier/service/date/metadata); monorepo ships one reference multi-carrier provider (Shippo/EasyPost, pick pending — decisions.md 2026-07-29); method rows stay regional (no cross-market method entity)
@@ -545,7 +545,7 @@ async function handleSubmit(values: FormValues) {
- **Client validation** lives in the Zod schema (`zodResolver`).
- **Mutation hooks built on `useResourceMutation` suppress their own toast for 422 responses** — the form already shows the inline message. Non-validation errors (network, 5xx, gateway) still toast. For a plain `useMutation` you want a fallback toast on, layer the catch: try `mapSpreeErrorsToForm` first, re-throw `SpreeError`, otherwise `toast.error(...)`.
-**Form schemas** live in `packages/dashboard/src/schemas/<resource>.ts` when shared across 2+ files or non-trivial (~30+ lines, nested sub-schemas, companion constants); inline is fine for short single-file forms. The schema file owns the Zod schema, its inferred `FormValues` type, defaults, dropdown option arrays, and regex constants. **Don't add form↔API mappers to paper over field renames** — if you find yourself translating `ot.label → form.presentation`, fix the API instead (read/write symmetry, see "API Controllers" above). Mappers are only for pure frontend state (upload progress, transient UI bookkeeping).
+**Form schemas** live in `packages/dashboard/src/schemas/<resource>.ts` when shared across 2+ files or non-trivial (~30+ lines, nested sub-schemas, companion constants); inline is fine for short single-file forms. The schema file owns the Zod schema, its inferred `FormValues` type, defaults, dropdown option arrays, and regex constants. **Don't add form↔API mappers to paper over field renames** — if you find yourself translating `ot.label → form.presentation`, fix the API instead (read/write symmetry, see "API Controllers" above). Mappers are only for pure frontend state (upload progress, transient UI bookkeeping). **Never embed SDK entity types (`Customer`, `Order`, `Channel`, …) inside a form-values type** — react-hook-form's `Path<T>` enumerates every nested key, and the SDK types embed the whole object graph, which overflows TypeScript's relation cache (`RangeError: Map maximum size exceeded` killing `tsc -b`). Display-only embeds use an opaque record instead (pattern: `RuleEmbedRecord` in `schemas/price-list.ts` — full SDK records still assign into it at runtime; the form type just stays shallow). To locate this class of failure, run `@typescript/native-preview` (tsgo) — it reports the offending comparison with a line number instead of crashing; tsc stays the build compiler.
**Base UI `<Select>` does not auto-render labels.** Unlike Radix, Base UI's `<Select.Value />` renders the raw selected `value` (the slug, the ISO code, the prefixed ID) instead of the matching `<SelectItem>`'s children. Two fixes:
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yaml
index cea174e2d8..9540ddb460 100644
--- a/docs/api-reference/admin.yaml
+++ b/docs/api-reference/admin.yaml
@@ -92,16 +92,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjgxYWNjNzc3LWE5N2EtNGVmNC1iN2VhLTViMGRjMzlmOGNlYiIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1NjE4NzgwfQ.3HCAlpMKX4yORAyxSaesvZps-3No8d7b5-im4FkgRUg
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjAwMWVjNmZjLTI0ZGQtNDYyMi1iYjc2LTQ2YjQ1YmViNGY3YiIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1OTI2ODY5fQ.uiqMHCZPsF56kdI9YGP_LnQeeDb45RP1Y2gi2N7deYc
user:
- id: admin_UkLWZg9DAJ
+ id: adm_UkLWZg9DAJ
- first_name: Lulu
- last_name: Cole
- full_name: Lulu Cole
+ first_name: Carmine
+ last_name: Medhurst
+ full_name: Carmine Medhurst
selected_locale:
- created_at: '2026-08-01T21:08:00.250Z'
- updated_at: '2026-08-01T21:08:00.250Z'
+ created_at: '2026-08-05T10:42:49.223Z'
+ updated_at: '2026-08-05T10:42:49.223Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -204,16 +204,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6ImRiMmIzMmRkLWUyNTktNDdkYS04OTkwLTQxY2Q2MTRkMzczYSIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1NjE4NzgxfQ.88RboqkYoJEIPht4616uxlR5XOG2Tmsj0ZzUMbovAfE
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjVjNjA4NDRlLWQwMzgtNDU2ZS1iODU1LWM5NmE3MTQzNGYwZSIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1OTI2ODY5fQ.X056ME1CzTx6i9WvFuGmmOy5c8GtAC0jG_a26tIV4sU
user:
- id: admin_UkLWZg9DAJ
+ id: adm_UkLWZg9DAJ
- first_name: Sallie
- last_name: Pacocha
- full_name: Sallie Pacocha
+ first_name: Stephine
+ last_name: Pollich
+ full_name: Stephine Pollich
selected_locale:
- created_at: '2026-08-01T21:08:01.341Z'
- updated_at: '2026-08-01T21:08:01.341Z'
+ created_at: '2026-08-05T10:42:49.276Z'
+ updated_at: '2026-08-05T10:42:49.276Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -314,14 +314,14 @@ paths:
application/json:
example:
user:
- id: admin_UkLWZg9DAJ
- first_name: Ardith
- last_name: Kutch
- full_name: Ardith Kutch
+ id: adm_UkLWZg9DAJ
+ first_name: Kerri
+ last_name: Leannon
+ full_name: Kerri Leannon
selected_locale:
- created_at: '2026-08-01T21:08:44.627Z'
- updated_at: '2026-08-01T21:08:44.627Z'
+ created_at: '2026-08-05T10:42:53.633Z'
+ updated_at: '2026-08-05T10:42:53.633Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -368,13 +368,6 @@ paths:
subjects:
- Spree::RefundReason
has_conditions: true
- - allow: false
- actions:
- - edit
- - update
- subjects:
- - Spree::ReimbursementType
- has_conditions: true
- allow: false
actions:
- update
@@ -440,14 +433,14 @@ paths:
application/json:
example:
user:
- id: admin_UkLWZg9DAJ
- first_name: Tyesha
- last_name: Harber
- full_name: Tyesha Harber
+ id: adm_UkLWZg9DAJ
+ first_name: Arlie
+ last_name: Yost
+ full_name: Arlie Yost
selected_locale: de
- created_at: '2026-08-01T21:08:44.923Z'
- updated_at: '2026-08-01T21:08:44.937Z'
+ created_at: '2026-08-05T10:42:53.669Z'
+ updated_at: '2026-08-05T10:42:53.680Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -494,13 +487,6 @@ paths:
subjects:
- Spree::RefundReason
has_conditions: true
- - allow: false
- actions:
- - edit
- - update
- subjects:
- - Spree::ReimbursementType
- has_conditions: true
- allow: false
actions:
- update
@@ -644,16 +630,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjRmZDYzNTI1LTc4NDctNDEzYi04MWI5LTQzOGNkMzRlMmNmYSIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1NjIyMTU5fQ.uHwgeedeZpr1ww4yKqtaRH29KyBRcLtZnZA4biPtEeg
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6ImY4MzU3ZWU0LTBmYzMtNDUwZC1iZWRiLWI5YTU5NTcxZmNhNyIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzg1OTMwMTc5fQ.546CE5Idw4vQ2EjMb28Y5bTHU-afAORH0ZHZos9QBsM
user:
- id: admin_UkLWZg9DAJ
+ id: adm_UkLWZg9DAJ
- first_name: Brandie
- last_name: Fisher
- full_name: Brandie Fisher
+ first_name: Barrett
+ last_name: Lakin
+ full_name: Barrett Lakin
selected_locale:
- created_at: '2026-08-01T21:09:19.535Z'
- updated_at: '2026-08-01T21:09:19.807Z'
+ created_at: '2026-08-05T10:42:59.167Z'
+ updated_at: '2026-08-05T10:42:59.190Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -772,8 +758,8 @@ paths:
data:
- id: ao_UkLWZg9DAJ
origin: https://shop.example.com
- created_at: '2026-08-01T21:07:55.714Z'
- updated_at: '2026-08-01T21:07:55.714Z'
+ created_at: '2026-08-05T10:42:48.836Z'
+ updated_at: '2026-08-05T10:42:48.836Z'
meta:
page: 1
limit: 25
@@ -857,8 +843,8 @@ paths:
example:
id: ao_gbHJdmfrXB
origin: https://admin.example.com
- created_at: '2026-08-01T21:07:56.304Z'
- updated_at: '2026-08-01T21:07:56.304Z'
+ created_at: '2026-08-05T10:42:48.892Z'
+ updated_at: '2026-08-05T10:42:48.892Z'
schema:
"$ref": "#/components/schemas/AllowedOrigin"
'422':
@@ -945,8 +931,8 @@ paths:
example:
id: ao_UkLWZg9DAJ
origin: https://shop.example.com
- created_at: '2026-08-01T21:07:56.598Z'
- updated_at: '2026-08-01T21:07:56.598Z'
+ created_at: '2026-08-05T10:42:48.918Z'
+ updated_at: '2026-08-05T10:42:48.918Z'
schema:
"$ref": "#/components/schemas/AllowedOrigin"
'404':
@@ -1007,8 +993,8 @@ paths:
example:
id: ao_UkLWZg9DAJ
origin: https://www.example.com
- created_at: '2026-08-01T21:07:57.163Z'
- updated_at: '2026-08-01T21:07:57.442Z'
+ created_at: '2026-08-05T10:42:48.958Z'
+ updated_at: '2026-08-05T10:42:48.976Z'
schema:
"$ref": "#/components/schemas/AllowedOrigin"
'422':
@@ -1128,34 +1114,34 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-08-01T21:07:58.016Z'
- updated_at: '2026-08-01T21:07:58.016Z'
+ created_at: '2026-08-05T10:42:49.026Z'
+ updated_at: '2026-08-05T10:42:49.026Z'
revoked_at:
last_used_at:
channel_id:
- plaintext_token: pk_9zytm6cX2CXNYQFLnpf7ErKD
+ plaintext_token: pk_2SKDREhqSwNdK1XdhvgqfGFq
created_by_email:
- id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_bVXoRfgqg
+ token_prefix: sk_bptsj2rFG
scopes:
- write_all
- created_at: '2026-08-01T21:07:58.017Z'
- updated_at: '2026-08-01T21:07:58.017Z'
+ created_at: '2026-08-05T10:42:49.027Z'
+ updated_at: '2026-08-05T10:42:49.027Z'
revoked_at:
last_used_at:
channel_id:
plaintext_token:
created_by_email:
- id: key_EfhxLZ9ck8
- name: qui
+ name: neque
key_type: secret
- token_prefix: sk_59HewouP3
+ token_prefix: sk_HBesGtLiB
scopes:
- write_all
- created_at: '2026-08-01T21:07:58.018Z'
- updated_at: '2026-08-01T21:07:58.018Z'
+ created_at: '2026-08-05T10:42:49.028Z'
+ updated_at: '2026-08-05T10:42:49.028Z'
revoked_at:
last_used_at:
channel_id:
@@ -1222,16 +1208,16 @@ paths:
id: key_VqXmZF31wY
name: CI key
key_type: secret
- token_prefix: sk_gHpqnopFh
+ token_prefix: sk_VVfawJsZ8
scopes:
- read_orders
- created_at: '2026-08-01T21:07:58.570Z'
- updated_at: '2026-08-01T21:07:58.570Z'
+ created_at: '2026-08-05T10:42:49.069Z'
+ updated_at: '2026-08-05T10:42:49.069Z'
revoked_at:
last_used_at:
channel_id:
- plaintext_token: sk_gHpqnopFhKLtMjdT84Wo6qcf
- created_by_email: [email protected]
+ plaintext_token: sk_VVfawJsZ8ZKJUb4JhZzeXJTf
+ created_by_email: [email protected]
'422':
description: validation error
content:
@@ -1320,12 +1306,12 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-08-01T21:07:58.862Z'
- updated_at: '2026-08-01T21:07:58.862Z'
+ created_at: '2026-08-05T10:42:49.099Z'
+ updated_at: '2026-08-05T10:42:49.099Z'
revoked_at:
last_used_at:
channel_id:
- plaintext_token: pk_1tKMt8x7FfXvhpdDCsumAiPZ
+ plaintext_token: pk_DK8tdKa33RWJxsX5HY2pWmDB
created_by_email:
patch:
summary: Update an API key
@@ -1379,11 +1365,11 @@ paths:
id: key_gbHJdmfrXB
name: Backend integration (renamed)
key_type: secret
- token_prefix: sk_dXapWfVkL
+ token_prefix: sk_sgNuqBAB8
scopes:
- write_all
- created_at: '2026-08-01T21:07:59.142Z'
- updated_at: '2026-08-01T21:07:59.415Z'
+ created_at: '2026-08-05T10:42:49.121Z'
+ updated_at: '2026-08-05T10:42:49.163Z'
revoked_at:
last_used_at:
channel_id:
@@ -1480,13 +1466,13 @@ paths:
application/json:
example:
id: key_EfhxLZ9ck8
- name: numquam
+ name: officiis
key_type: secret
- token_prefix: sk_QUw2ET3eg
+ token_prefix: sk_BamiJ66GK
scopes:
- write_all
- created_at: '2026-08-01T21:07:59.698Z'
- updated_at: '2026-08-01T21:07:59.698Z'
+ created_at: '2026-08-05T10:42:49.193Z'
+ updated_at: '2026-08-05T10:42:49.193Z'
revoked_at:
last_used_at:
channel_id:
@@ -1544,12 +1530,12 @@ paths:
id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_U14dWkuzs
+ token_prefix: sk_53R8PRYpz
scopes:
- write_all
- created_at: '2026-08-01T21:07:59.708Z'
- updated_at: '2026-08-01T21:07:59.984Z'
- revoked_at: '2026-08-01T21:07:59.984Z'
+ created_at: '2026-08-05T10:42:49.203Z'
+ updated_at: '2026-08-05T10:42:49.217Z'
+ revoked_at: '2026-08-05T10:42:49.216Z'
last_used_at:
channel_id:
plaintext_token:
@@ -1626,8 +1612,8 @@ paths:
lft: 1
rgt: 2
products_count: 0
- created_at: '2026-08-01T21:08:01.956Z'
- updated_at: '2026-08-01T21:08:01.956Z'
+ created_at: '2026-08-05T10:42:49.344Z'
+ updated_at: '2026-08-05T10:42:49.344Z'
meta:
page: 1
limit: 25
@@ -1701,8 +1687,8 @@ paths:
lft: 2
rgt: 3
products_count: 0
- created_at: '2026-08-01T21:08:02.539Z'
- updated_at: '2026-08-01T21:08:02.546Z'
+ created_at: '2026-08-05T10:42:49.395Z'
+ updated_at: '2026-08-05T10:42:49.401Z'
schema:
"$ref": "#/components/schemas/Category"
'422':
@@ -1811,8 +1797,8 @@ paths:
lft: 1
rgt: 2
products_count: 0
- created_at: '2026-08-01T21:08:02.849Z'
- updated_at: '2026-08-01T21:08:02.849Z'
+ created_at: '2026-08-05T10:42:49.440Z'
+ updated_at: '2026-08-05T10:42:49.440Z'
schema:
"$ref": "#/components/schemas/Category"
'404':
@@ -1882,8 +1868,8 @@ paths:
lft: 1
rgt: 2
products_count: 0
- created_at: '2026-08-01T21:08:03.418Z'
- updated_at: '2026-08-01T21:08:03.700Z'
+ created_at: '2026-08-05T10:42:49.492Z'
+ updated_at: '2026-08-05T10:42:49.518Z'
schema:
"$ref": "#/components/schemas/Category"
requestBody:
@@ -2000,8 +1986,8 @@ paths:
lft: 2
rgt: 3
products_count: 0
- created_at: '2026-08-01T21:08:04.007Z'
- updated_at: '2026-08-01T21:08:04.291Z'
+ created_at: '2026-08-05T10:42:49.598Z'
+ updated_at: '2026-08-05T10:42:49.623Z'
schema:
"$ref": "#/components/schemas/Category"
requestBody:
@@ -2113,8 +2099,8 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 11850
- slug: product-11850
+ name: Product 14253
+ slug: product-14253
meta_title:
meta_description:
meta_keywords:
@@ -2126,20 +2112,22 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Numquam cum aut repellat repellendus a rerum commodi.
- Soluta nisi ut hic debitis earum impedit vero eveniet. Placeat accusamus
- ipsum quos aliquam laboriosam fugit atque. Illo distinctio provident
- aliquid accusamus neque quam. Quo dolor ex quod labore molestias.
- Ad inventore voluptatem corporis doloremque deleniti architecto
- accusamus perferendis. Sunt aut aliquam officia error sed commodi.
- Voluptates tempore dolorem nulla praesentium earum temporibus provident.
- Quos eius voluptate architecto totam. Voluptatum quas sequi cupiditate
- consectetur. Nesciunt ipsam praesentium corrupti error cumque eius
- quas ab.
+ description: Aperiam ab aut aliquid atque excepturi. Praesentium fugit
+ aliquam sapiente qui enim ducimus maxime. Eum laboriosam voluptates
+ molestias ipsa. Eius harum voluptate ipsa qui atque dolor. Sunt
+ animi repellendus quam ipsa. Illum iure quo quod tenetur. In minus
+ rem soluta dolorum a at delectus occaecati. Aliquam laborum exercitationem
+ assumenda nam possimus repellendus consectetur voluptatum. Molestias
+ dolorem ipsam labore earum quod reprehenderit totam sed. Odit cum
+ mollitia velit assumenda ex earum quod. Rem qui nemo accusantium
+ odit molestias porro commodi. Molestias blanditiis ut dolore laborum.
+ Consequatur repudiandae ea ut laboriosam quo quisquam labore. Vel
+ possimus ullam omnis amet culpa consequuntur facere optio.
description_html: |-
- Numquam cum aut repellat repellendus a rerum commodi. Soluta nisi ut hic debitis earum impedit vero eveniet. Placeat accusamus ipsum quos aliquam laboriosam fugit atque. Illo distinctio provident aliquid accusamus neque quam.
- Quo dolor ex quod labore molestias. Ad inventore voluptatem corporis doloremque deleniti architecto accusamus perferendis. Sunt aut aliquam officia error sed commodi.
- Voluptates tempore dolorem nulla praesentium earum temporibus provident. Quos eius voluptate architecto totam. Voluptatum quas sequi cupiditate consectetur. Nesciunt ipsam praesentium corrupti error cumque eius quas ab.
+ Aperiam ab aut aliquid atque excepturi. Praesentium fugit aliquam sapiente qui enim ducimus maxime. Eum laboriosam voluptates molestias ipsa.
+ Eius harum voluptate ipsa qui atque dolor. Sunt animi repellendus quam ipsa. Illum iure quo quod tenetur. In minus rem soluta dolorum a at delectus occaecati.
+ Aliquam laborum exercitationem assumenda nam possimus repellendus consectetur voluptatum. Molestias dolorem ipsam labore earum quod reprehenderit totam sed. Odit cum mollitia velit assumenda ex earum quod. Rem qui nemo accusantium odit molestias porro commodi.
+ Molestias blanditiis ut dolore laborum. Consequatur repudiandae ea ut laboriosam quo quisquam labore. Vel possimus ullam omnis amet culpa consequuntur facere optio.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -2154,14 +2142,15 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:08:04.659Z'
- updated_at: '2026-08-01T21:08:04.659Z'
+ created_at: '2026-08-05T10:42:49.728Z'
+ updated_at: '2026-08-05T10:42:49.728Z'
original_price:
status: active
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:08:04.636Z'
- updated_at: '2026-08-01T21:08:04.670Z'
+ created_at: '2026-08-05T10:42:49.704Z'
+ updated_at: '2026-08-05T10:42:49.740Z'
+ product_type_id:
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -2330,8 +2319,8 @@ paths:
preferred_order_routing_strategy:
preferred_storefront_access:
preferred_guest_checkout:
- created_at: '2026-08-01T21:07:54.375Z'
- updated_at: '2026-08-01T21:07:54.375Z'
+ created_at: '2026-08-05T10:42:48.549Z'
+ updated_at: '2026-08-05T10:42:48.549Z'
- id: ch_gbHJdmfrXB
name: Wholesale
code: wholesale
@@ -2342,8 +2331,8 @@ paths:
preferred_order_routing_strategy:
preferred_storefront_access:
preferred_guest_checkout:
- created_at: '2026-08-01T21:08:05.652Z'
- updated_at: '2026-08-01T21:08:05.652Z'
+ created_at: '2026-08-05T10:42:49.914Z'
+ updated_at: '2026-08-05T10:42:49.914Z'
meta:
page: 1
limit: 25
@@ -2428,8 +2417,8 @@ paths:
preferred_order_routing_strategy:
preferred_storefront_access:
preferred_guest_checkout:
- created_at: '2026-08-01T21:08:06.230Z'
- updated_at: '2026-08-01T21:08:06.230Z'
+ created_at: '2026-08-05T10:42:49.966Z'
+ updated_at: '2026-08-05T10:42:49.966Z'
requestBody:
content:
application/json:
@@ -2527,8 +2516,8 @@ paths:
preferred_order_routing_strategy:
preferred_storefront_access:
preferred_guest_checkout:
- created_at: '2026-08-01T21:08:06.242Z'
- updated_at: '2026-08-01T21:08:06.242Z'
+ created_at: '2026-08-05T10:42:49.993Z'
+ updated_at: '2026-08-05T10:42:49.993Z'
patch:
summary: Update a channel
tags:
@@ -2582,8 +2571,8 @@ paths:
preferred_order_routing_strategy:
preferred_storefront_access: login_required
preferred_guest_checkout: false
- created_at: '2026-08-01T21:08:06.533Z'
- updated_at: '2026-08-01T21:08:06.819Z'
+ created_at: '2026-08-05T10:42:50.024Z'
+ updated_at: '2026-08-05T10:42:50.051Z'
requestBody:
content:
application/json:
@@ -2865,8 +2854,8 @@ paths:
- id: orule_UkLWZg9DAJ
position: 1
active: true
- created_at: '2026-08-01T21:07:54.380Z'
- updated_at: '2026-08-01T21:07:54.380Z'
+ created_at: '2026-08-05T10:42:48.553Z'
+ updated_at: '2026-08-05T10:42:48.553Z'
type: preferred_location
channel_id: ch_UkLWZg9DAJ
preferences: {}
@@ -2877,8 +2866,8 @@ paths:
- id: orule_gbHJdmfrXB
position: 2
active: true
- created_at: '2026-08-01T21:07:54.384Z'
- updated_at: '2026-08-01T21:07:54.384Z'
+ created_at: '2026-08-05T10:42:48.556Z'
+ updated_at: '2026-08-05T10:42:48.556Z'
type: minimize_splits
channel_id: ch_UkLWZg9DAJ
preferences: {}
@@ -2889,8 +2878,8 @@ paths:
- id: orule_EfhxLZ9ck8
position: 3
active: true
- created_at: '2026-08-01T21:07:54.387Z'
- updated_at: '2026-08-01T21:07:54.387Z'
+ created_at: '2026-08-05T10:42:48.559Z'
+ updated_at: '2026-08-05T10:42:48.559Z'
type: default_location
channel_id: ch_UkLWZg9DAJ
preferences: {}
@@ -2955,8 +2944,8 @@ paths:
id: orule_VqXmZF31wY
position: 3
active: true
- created_at: '2026-08-01T21:08:51.787Z'
- updated_at: '2026-08-01T21:08:51.787Z'
+ created_at: '2026-08-05T10:42:54.712Z'
+ updated_at: '2026-08-05T10:42:54.712Z'
type: default_location
channel_id: ch_UkLWZg9DAJ
preferences: {}
@@ -3051,8 +3040,8 @@ paths:
id: orule_UkLWZg9DAJ
position: 2
active: false
- created_at: '2026-08-01T21:07:54.380Z'
- updated_at: '2026-08-01T21:08:52.535Z'
+ created_at: '2026-08-05T10:42:48.553Z'
+ updated_at: '2026-08-05T10:42:54.768Z'
type: preferred_location
channel_id: ch_UkLWZg9DAJ
preferences: {}
@@ -3240,8 +3229,8 @@ paths:
searchable: false
sortable: false
filter_key: cf_specs_fabric
- created_at: '2026-08-01T21:08:11.505Z'
- updated_at: '2026-08-01T21:08:11.505Z'
+ created_at: '2026-08-05T10:42:50.798Z'
+ updated_at: '2026-08-05T10:42:50.798Z'
- id: cfdef_gbHJdmfrXB
namespace: custom
key: order_notes
@@ -3252,8 +3241,8 @@ paths:
searchable: false
sortable: false
filter_key: cf_custom_order_notes
- created_at: '2026-08-01T21:08:11.507Z'
- updated_at: '2026-08-01T21:08:11.507Z'
+ created_at: '2026-08-05T10:42:50.799Z'
+ updated_at: '2026-08-05T10:42:50.799Z'
meta:
page: 1
limit: 25
@@ -3322,8 +3311,8 @@ paths:
searchable: false
sortable: false
filter_key: cf_specs_origin
- created_at: '2026-08-01T21:08:12.071Z'
- updated_at: '2026-08-01T21:08:12.071Z'
+ created_at: '2026-08-05T10:42:50.848Z'
+ updated_at: '2026-08-05T10:42:50.848Z'
requestBody:
content:
application/json:
@@ -3431,8 +3420,8 @@ paths:
searchable: false
sortable: false
filter_key: cf_specs_fabric
- created_at: '2026-08-01T21:08:12.076Z'
- updated_at: '2026-08-01T21:08:12.076Z'
+ created_at: '2026-08-05T10:42:50.853Z'
+ updated_at: '2026-08-05T10:42:50.853Z'
patch:
summary: Update a custom field definition
tags:
@@ -3492,8 +3481,8 @@ paths:
searchable: false
sortable: false
filter_key: cf_specs_fabric
- created_at: '2026-08-01T21:08:12.364Z'
- updated_at: '2026-08-01T21:08:12.647Z'
+ created_at: '2026-08-05T10:42:50.874Z'
+ updated_at: '2026-08-05T10:42:50.891Z'
requestBody:
content:
application/json:
@@ -3639,14 +3628,14 @@ paths:
name: VIPs
description: Top spenders
customers_count: 0
- created_at: '2026-08-01T21:08:12.936Z'
- updated_at: '2026-08-01T21:08:12.936Z'
+ created_at: '2026-08-05T10:42:50.917Z'
+ updated_at: '2026-08-05T10:42:50.917Z'
- id: cg_gbHJdmfrXB
name: Wholesale
description:
customers_count: 0
- created_at: '2026-08-01T21:08:12.937Z'
- updated_at: '2026-08-01T21:08:12.937Z'
+ created_at: '2026-08-05T10:42:50.918Z'
+ updated_at: '2026-08-05T10:42:50.918Z'
meta:
page: 1
limit: 25
@@ -3735,8 +3724,8 @@ paths:
name: Wholesale 2
description: B2B accounts
customers_count: 1
- created_at: '2026-08-01T21:08:13.789Z'
- updated_at: '2026-08-01T21:08:13.789Z'
+ created_at: '2026-08-05T10:42:50.982Z'
+ updated_at: '2026-08-05T10:42:50.982Z'
schema:
"$ref": "#/components/schemas/CustomerGroup"
'422':
@@ -3845,28 +3834,22 @@ paths:
name: VIPs
description: Top spenders
customers_count: 1
- created_at: '2026-08-01T21:08:14.372Z'
- updated_at: '2026-08-01T21:08:14.372Z'
+ created_at: '2026-08-05T10:42:51.032Z'
+ updated_at: '2026-08-05T10:42:51.032Z'
customers:
- - id: cus_UkLWZg9DAJ
- first_name: Jody
- last_name: Torp
+ - id: cust_UkLWZg9DAJ
+ first_name: Estella
+ last_name: Rippin
phone:
accepts_email_marketing: false
- full_name: Jody Torp
+ full_name: Estella Rippin
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
- metadata: {}
- last_sign_in_at:
- current_sign_in_at:
- created_at: '2026-08-01T21:08:14.632Z'
- updated_at: '2026-08-01T21:08:14.632Z'
- sign_in_count: 0
failed_attempts: 0
- last_sign_in_ip:
- current_sign_in_ip:
+ metadata: {}
+ created_at: '2026-08-05T10:42:51.035Z'
+ updated_at: '2026-08-05T10:42:51.035Z'
tags: []
internal_note_html:
default_billing_address_id:
@@ -3945,8 +3928,8 @@ paths:
name: VIP customers (Q1)
description: Top spenders
customers_count: 0
- created_at: '2026-08-01T21:08:15.203Z'
- updated_at: '2026-08-01T21:08:15.479Z'
+ created_at: '2026-08-05T10:42:51.084Z'
+ updated_at: '2026-08-05T10:42:51.100Z'
schema:
"$ref": "#/components/schemas/CustomerGroup"
'422':
@@ -4105,9 +4088,9 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-08-01T21:08:16.334Z'
- updated_at: '2026-08-01T21:08:16.334Z'
- customer_id: cus_UkLWZg9DAJ
+ created_at: '2026-08-05T10:42:51.174Z'
+ updated_at: '2026-08-05T10:42:51.174Z'
+ customer_id: cust_UkLWZg9DAJ
meta:
page: 1
limit: 25
@@ -4199,9 +4182,9 @@ paths:
state_name: New York
label: Office
metadata: {}
- created_at: '2026-08-01T21:08:17.697Z'
- updated_at: '2026-08-01T21:08:17.697Z'
- customer_id: cus_UkLWZg9DAJ
+ created_at: '2026-08-05T10:42:51.223Z'
+ updated_at: '2026-08-05T10:42:51.223Z'
+ customer_id: cust_UkLWZg9DAJ
requestBody:
content:
application/json:
@@ -4314,9 +4297,9 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-08-01T21:08:17.969Z'
- updated_at: '2026-08-01T21:08:18.507Z'
- customer_id: cus_UkLWZg9DAJ
+ created_at: '2026-08-05T10:42:51.234Z'
+ updated_at: '2026-08-05T10:42:51.251Z'
+ customer_id: cust_UkLWZg9DAJ
requestBody:
content:
application/json:
@@ -4451,11 +4434,11 @@ paths:
name: Spree Commerce
default: false
gateway_payment_profile_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-08-01T21:08:19.608Z'
- updated_at: '2026-08-01T21:08:19.608Z'
+ created_at: '2026-08-05T10:42:51.304Z'
+ updated_at: '2026-08-05T10:42:51.304Z'
meta:
page: 1
limit: 25
@@ -4542,11 +4525,11 @@ paths:
name: Spree Commerce
default: false
gateway_payment_profile_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-08-01T21:08:20.154Z'
- updated_at: '2026-08-01T21:08:20.154Z'
+ created_at: '2026-08-05T10:42:51.337Z'
+ updated_at: '2026-08-05T10:42:51.337Z'
delete:
summary: Delete a customer credit card
tags:
@@ -4671,10 +4654,10 @@ paths:
currency: USD
memo:
metadata: {}
- created_at: '2026-08-01T21:08:21.527Z'
- updated_at: '2026-08-01T21:08:21.527Z'
- customer_id: cus_UkLWZg9DAJ
- created_by_id: admin_UkLWZg9DAJ
+ created_at: '2026-08-05T10:42:51.407Z'
+ updated_at: '2026-08-05T10:42:51.407Z'
+ customer_id: cust_UkLWZg9DAJ
+ created_by_id: adm_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
category_name: Exchange
meta:
@@ -4751,10 +4734,10 @@ paths:
currency: USD
memo: Goodwill
metadata: {}
- created_at: '2026-08-01T21:08:22.638Z'
- updated_at: '2026-08-01T21:08:22.638Z'
- customer_id: cus_UkLWZg9DAJ
- created_by_id: admin_gbHJdmfrXB
+ created_at: '2026-08-05T10:42:51.468Z'
+ updated_at: '2026-08-05T10:42:51.468Z'
+ customer_id: cust_UkLWZg9DAJ
+ created_by_id: adm_gbHJdmfrXB
category_id: sccat_UkLWZg9DAJ
category_name: Exchange
requestBody:
@@ -4847,10 +4830,10 @@ paths:
currency: USD
memo: Updated
metadata: {}
- created_at: '2026-08-01T21:08:23.191Z'
- updated_at: '2026-08-01T21:08:23.471Z'
- customer_id: cus_UkLWZg9DAJ
- created_by_id: admin_UkLWZg9DAJ
+ created_at: '2026-08-05T10:42:51.502Z'
+ updated_at: '2026-08-05T10:42:51.526Z'
+ customer_id: cust_UkLWZg9DAJ
+ created_by_id: adm_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
category_name: Exchange
requestBody:
@@ -4996,7 +4979,7 @@ paths:
application/json:
example:
data:
- - id: cus_UkLWZg9DAJ
+ - id: cust_UkLWZg9DAJ
first_name: Jane
last_name: Doe
@@ -5005,16 +4988,10 @@ paths:
full_name: Jane Doe
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
- metadata: {}
- last_sign_in_at:
- current_sign_in_at:
- created_at: '2026-08-01T21:08:24.551Z'
- updated_at: '2026-08-01T21:08:24.551Z'
- sign_in_count: 0
failed_attempts: 0
- last_sign_in_ip:
- current_sign_in_ip:
+ metadata: {}
+ created_at: '2026-08-05T10:42:51.575Z'
+ updated_at: '2026-08-05T10:42:51.575Z'
tags: []
internal_note_html:
default_billing_address_id:
@@ -5085,7 +5062,7 @@ paths:
content:
application/json:
example:
- id: cus_gbHJdmfrXB
+ id: cust_gbHJdmfrXB
first_name: New
last_name: Customer
@@ -5094,16 +5071,10 @@ paths:
full_name: New Customer
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
- login:
- metadata: {}
- last_sign_in_at:
- current_sign_in_at:
- created_at: '2026-08-01T21:08:25.387Z'
- updated_at: '2026-08-01T21:08:25.387Z'
- sign_in_count: 0
failed_attempts: 0
- last_sign_in_ip:
- current_sign_in_ip:
+ metadata: {}
+ created_at: '2026-08-05T10:42:51.622Z'
+ updated_at: '2026-08-05T10:42:51.622Z'
tags: []
internal_note_html:
default_billing_address_id:
@@ -5206,7 +5177,7 @@ paths:
content:
application/json:
example:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
first_name: Jane
last_name: Doe
@@ -5215,16 +5186,10 @@ paths:
full_name: Jane Doe
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
- metadata: {}
- last_sign_in_at:
- current_sign_in_at:
- created_at: '2026-08-01T21:08:25.658Z'
- updated_at: '2026-08-01T21:08:25.658Z'
- sign_in_count: 0
failed_attempts: 0
- last_sign_in_ip:
- current_sign_in_ip:
+ metadata: {}
+ created_at: '2026-08-05T10:42:51.633Z'
+ updated_at: '2026-08-05T10:42:51.633Z'
tags: []
internal_note_html:
default_billing_address_id:
@@ -5285,7 +5250,7 @@ paths:
content:
application/json:
example:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
first_name: Updated
last_name: Doe
@@ -5294,16 +5259,10 @@ paths:
full_name: Updated Doe
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
- metadata: {}
- last_sign_in_at:
- current_sign_in_at:
- created_at: '2026-08-01T21:08:26.204Z'
- updated_at: '2026-08-01T21:08:26.554Z'
- sign_in_count: 0
failed_attempts: 0
- last_sign_in_ip:
- current_sign_in_ip:
+ metadata: {}
+ created_at: '2026-08-05T10:42:51.659Z'
+ updated_at: '2026-08-05T10:42:51.678Z'
tags: []
internal_note_html:
default_billing_address_id:
@@ -5748,12 +5707,12 @@ paths:
example:
data:
- id: exp_UkLWZg9DAJ
- number: EF830924997
+ number: EF383318810
format: csv
- created_at: '2026-08-01T21:08:31.914Z'
- updated_at: '2026-08-01T21:08:31.914Z'
+ created_at: '2026-08-05T10:42:52.108Z'
+ updated_at: '2026-08-05T10:42:52.108Z'
type: products
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
done: false
filename:
byte_size:
@@ -5822,12 +5781,12 @@ paths:
application/json:
example:
id: exp_gbHJdmfrXB
- number: EF230054229
+ number: EF143208832
format: csv
- created_at: '2026-08-01T21:08:32.206Z'
- updated_at: '2026-08-01T21:08:32.206Z'
+ created_at: '2026-08-05T10:42:52.141Z'
+ updated_at: '2026-08-05T10:42:52.141Z'
type: products
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
done: false
filename:
byte_size:
@@ -5922,12 +5881,12 @@ paths:
application/json:
example:
id: exp_UkLWZg9DAJ
- number: EF066926891
+ number: EF007785085
format: csv
- created_at: '2026-08-01T21:08:32.477Z'
- updated_at: '2026-08-01T21:08:32.477Z'
+ created_at: '2026-08-05T10:42:52.153Z'
+ updated_at: '2026-08-05T10:42:52.153Z'
type: products
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
done: false
filename:
byte_size:
@@ -6108,7 +6067,7 @@ paths:
example:
data:
- id: ful_UkLWZg9DAJ
- number: F89612940063
+ number: F94569922385
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6135,8 +6094,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:53.414Z'
- updated_at: '2026-08-01T21:08:53.465Z'
+ created_at: '2026-08-05T10:42:54.864Z'
+ updated_at: '2026-08-05T10:42:54.900Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
meta:
@@ -6206,7 +6165,7 @@ paths:
application/json:
example:
id: ful_gbHJdmfrXB
- number: F40544236737
+ number: F14895781030
tracking: INPOST-12345
tracking_url:
pickup_point_data:
@@ -6225,7 +6184,7 @@ paths:
display_tax_total: "$0.00"
status: fulfilled
fulfillment_type: shipping
- fulfilled_at: '2026-08-01T21:08:54Z'
+ fulfilled_at: '2026-08-05T10:42:55Z'
items:
- item_id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
@@ -6233,8 +6192,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-08-01T21:08:54.379Z'
- updated_at: '2026-08-01T21:08:54.406Z'
+ created_at: '2026-08-05T10:42:55.039Z'
+ updated_at: '2026-08-05T10:42:55.061Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
'422':
@@ -6374,7 +6333,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: F40359837271
+ number: F56157091766
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6401,8 +6360,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:55.680Z'
- updated_at: '2026-08-01T21:08:55.716Z'
+ created_at: '2026-08-05T10:42:55.284Z'
+ updated_at: '2026-08-05T10:42:55.315Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
patch:
@@ -6464,7 +6423,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: F90984698033
+ number: F76478119752
tracking: 1Z999AA10123456784
tracking_url: https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z999AA10123456784
pickup_point_data:
@@ -6491,8 +6450,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:56.322Z'
- updated_at: '2026-08-01T21:08:56.639Z'
+ created_at: '2026-08-05T10:42:55.384Z'
+ updated_at: '2026-08-05T10:42:55.438Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
requestBody:
@@ -6568,7 +6527,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: F01961194284
+ number: F94809498199
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6587,7 +6546,7 @@ paths:
display_tax_total: "$0.00"
status: fulfilled
fulfillment_type: shipping
- fulfilled_at: '2026-08-01T21:08:57Z'
+ fulfilled_at: '2026-08-05T10:42:55Z'
items:
- item_id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
@@ -6595,8 +6554,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:56.952Z'
- updated_at: '2026-08-01T21:08:57.268Z'
+ created_at: '2026-08-05T10:42:55.495Z'
+ updated_at: '2026-08-05T10:42:55.552Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":
@@ -6658,7 +6617,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: F42256084511
+ number: F30507291384
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6685,8 +6644,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:57.577Z'
- updated_at: '2026-08-01T21:08:57.900Z'
+ created_at: '2026-08-05T10:42:55.611Z'
+ updated_at: '2026-08-05T10:42:55.672Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":
@@ -6748,7 +6707,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: F07456271022
+ number: F71685846155
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6775,8 +6734,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '100.0'
- created_at: '2026-08-01T21:08:58.232Z'
- updated_at: '2026-08-01T21:08:58.565Z'
+ created_at: '2026-08-05T10:42:55.743Z'
+ updated_at: '2026-08-05T10:42:55.806Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":
@@ -6840,7 +6799,7 @@ paths:
example:
data:
- id: ful_gbHJdmfrXB
- number: F68361968657
+ number: F52804013117
tracking:
tracking_url:
pickup_point_data:
@@ -6867,8 +6826,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-08-01T21:08:59.219Z'
- updated_at: '2026-08-01T21:08:59.254Z'
+ created_at: '2026-08-05T10:42:55.932Z'
+ updated_at: '2026-08-05T10:42:55.963Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_gbHJdmfrXB
requestBody:
@@ -6967,8 +6926,8 @@ paths:
codes_count: 2
currency: USD
prefix: WELCOME
- created_at: '2026-08-01T21:08:33.082Z'
- updated_at: '2026-08-01T21:08:33.082Z'
+ created_at: '2026-08-05T10:42:52.229Z'
+ updated_at: '2026-08-05T10:42:52.229Z'
amount: '50.0'
expires_at:
created_by_id:
@@ -7052,11 +7011,11 @@ paths:
codes_count: 5
currency: USD
prefix: NEWCAMP
- created_at: '2026-08-01T21:08:33.642Z'
- updated_at: '2026-08-01T21:08:33.642Z'
+ created_at: '2026-08-05T10:42:52.277Z'
+ updated_at: '2026-08-05T10:42:52.277Z'
amount: '25.0'
expires_at: '2030-12-31'
- created_by_id: admin_UkLWZg9DAJ
+ created_by_id: adm_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/GiftCardBatch"
'422':
@@ -7157,8 +7116,8 @@ paths:
codes_count: 2
currency: USD
prefix: WELCOME
- created_at: '2026-08-01T21:08:33.933Z'
- updated_at: '2026-08-01T21:08:33.933Z'
+ created_at: '2026-08-05T10:42:52.310Z'
+ updated_at: '2026-08-05T10:42:52.310Z'
amount: '50.0'
expires_at:
created_by_id:
@@ -7264,7 +7223,7 @@ paths:
example:
data:
- id: gc_UkLWZg9DAJ
- code: 437DF2AD6DAC4819
+ code: DC37A01CB1C30084
status: active
currency: USD
amount: '50.0'
@@ -7278,12 +7237,12 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:34.504Z'
- updated_at: '2026-08-01T21:08:34.504Z'
+ created_at: '2026-08-05T10:42:52.363Z'
+ updated_at: '2026-08-05T10:42:52.363Z'
customer_id:
created_by_id:
- id: gc_gbHJdmfrXB
- code: 0453044B2E2FBF3C
+ code: 6C7AD111680A1FD5
status: active
currency: USD
amount: '25.0'
@@ -7297,8 +7256,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:34.505Z'
- updated_at: '2026-08-01T21:08:34.505Z'
+ created_at: '2026-08-05T10:42:52.364Z'
+ updated_at: '2026-08-05T10:42:52.364Z'
customer_id:
created_by_id:
meta:
@@ -7386,7 +7345,7 @@ paths:
application/json:
example:
id: gc_EfhxLZ9ck8
- code: A7B9592BA2E51417
+ code: EEF5F045619E4DF5
status: active
currency: USD
amount: '25.0'
@@ -7400,10 +7359,10 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:35.086Z'
- updated_at: '2026-08-01T21:08:35.086Z'
+ created_at: '2026-08-05T10:42:52.413Z'
+ updated_at: '2026-08-05T10:42:52.413Z'
customer_id:
- created_by_id: admin_UkLWZg9DAJ
+ created_by_id: adm_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/GiftCard"
'422':
@@ -7510,7 +7469,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: CDDA2FE8CD19D112
+ code: BDB7EDA43B8C6354
status: active
currency: USD
amount: '50.0'
@@ -7524,8 +7483,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:35.379Z'
- updated_at: '2026-08-01T21:08:35.379Z'
+ created_at: '2026-08-05T10:42:52.442Z'
+ updated_at: '2026-08-05T10:42:52.442Z'
customer_id:
created_by_id:
schema:
@@ -7588,7 +7547,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 850691DE8BFF2065
+ code: 1DD1A4477654FC30
status: active
currency: USD
amount: '75.0'
@@ -7602,8 +7561,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:35.963Z'
- updated_at: '2026-08-01T21:08:36.246Z'
+ created_at: '2026-08-05T10:42:52.509Z'
+ updated_at: '2026-08-05T10:42:52.526Z'
customer_id:
created_by_id:
schema:
@@ -7706,15 +7665,15 @@ paths:
example:
data:
- id: imp_UkLWZg9DAJ
- number: IM041914512
+ number: IM966346991
rows_count: 0
- created_at: '2026-08-01T21:08:37.092Z'
- updated_at: '2026-08-01T21:08:37.100Z'
+ created_at: '2026-08-05T10:42:52.598Z'
+ updated_at: '2026-08-05T10:42:52.604Z'
type: products
status: pending
owner_type: store
owner_id: store_UkLWZg9DAJ
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
processing_errors:
preferred_delimiter: ","
original_filename: products_import.csv
@@ -7888,15 +7847,15 @@ paths:
application/json:
example:
id: imp_gbHJdmfrXB
- number: IM333938841
+ number: IM765368905
rows_count: 0
- created_at: '2026-08-01T21:08:37.416Z'
- updated_at: '2026-08-01T21:08:37.456Z'
+ created_at: '2026-08-05T10:42:52.651Z'
+ updated_at: '2026-08-05T10:42:52.688Z'
type: products
status: mapping
owner_type: store
owner_id: store_UkLWZg9DAJ
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
processing_errors:
preferred_delimiter: ","
original_filename: import.csv
@@ -8333,15 +8292,15 @@ paths:
application/json:
example:
id: imp_UkLWZg9DAJ
- number: IM365280027
+ number: IM914678429
rows_count: 0
- created_at: '2026-08-01T21:08:38.612Z'
- updated_at: '2026-08-01T21:08:38.619Z'
+ created_at: '2026-08-05T10:42:52.810Z'
+ updated_at: '2026-08-05T10:42:52.820Z'
type: products
status: pending
owner_type: store
owner_id: store_UkLWZg9DAJ
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
processing_errors:
preferred_delimiter: ","
original_filename: products_import.csv
@@ -8573,15 +8532,15 @@ paths:
application/json:
example:
id: imp_gbHJdmfrXB
- number: IM710996630
+ number: IM014181971
rows_count: 0
- created_at: '2026-08-01T21:08:39.492Z'
- updated_at: '2026-08-01T21:08:39.629Z'
+ created_at: '2026-08-05T10:42:52.918Z'
+ updated_at: '2026-08-05T10:42:52.977Z'
type: products
status: completed_mapping
owner_type: store
owner_id: store_UkLWZg9DAJ
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
processing_errors:
preferred_delimiter: ","
original_filename: products_import.csv
@@ -8916,15 +8875,15 @@ paths:
application/json:
example:
id: imp_gbHJdmfrXB
- number: IM523342077
+ number: IM505329925
rows_count: 1
- created_at: '2026-08-01T21:08:39.943Z'
- updated_at: '2026-08-01T21:08:39.964Z'
+ created_at: '2026-08-05T10:42:53.004Z'
+ updated_at: '2026-08-05T10:42:53.023Z'
type: products
status: processing
owner_type: store
owner_id: store_UkLWZg9DAJ
- user_id: admin_UkLWZg9DAJ
+ user_id: adm_UkLWZg9DAJ
processing_errors:
preferred_delimiter: ","
original_filename: products_import.csv
@@ -9095,8 +9054,8 @@ paths:
row_number: 2
status: failed
validation_errors: boom
- created_at: '2026-08-01T21:08:40.247Z'
- updated_at: '2026-08-01T21:08:40.247Z'
+ created_at: '2026-08-05T10:42:53.046Z'
+ updated_at: '2026-08-05T10:42:53.046Z'
import_id: imp_UkLWZg9DAJ
item_type:
item_id:
@@ -9198,8 +9157,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
- id: mkt_gbHJdmfrXB
name: EU
currency: USD
@@ -9210,8 +9169,8 @@ paths:
- DE
supported_locales:
- en
- created_at: '2026-08-01T21:08:41.710Z'
- updated_at: '2026-08-01T21:08:41.710Z'
+ created_at: '2026-08-05T10:42:53.306Z'
+ updated_at: '2026-08-05T10:42:53.306Z'
meta:
page: 1
limit: 25
@@ -9304,8 +9263,8 @@ paths:
supported_locales:
- en
- fr
- created_at: '2026-08-01T21:08:42.282Z'
- updated_at: '2026-08-01T21:08:42.282Z'
+ created_at: '2026-08-05T10:42:53.361Z'
+ updated_at: '2026-08-05T10:42:53.361Z'
schema:
"$ref": "#/components/schemas/Market"
'422':
@@ -9441,8 +9400,8 @@ paths:
- DE
supported_locales:
- en
- created_at: '2026-08-01T21:08:42.596Z'
- updated_at: '2026-08-01T21:08:42.596Z'
+ created_at: '2026-08-05T10:42:53.411Z'
+ updated_at: '2026-08-05T10:42:53.411Z'
schema:
"$ref": "#/components/schemas/Market"
'404':
@@ -9521,8 +9480,8 @@ paths:
- DE
supported_locales:
- en
- created_at: '2026-08-01T21:08:43.190Z'
- updated_at: '2026-08-01T21:08:43.471Z'
+ created_at: '2026-08-05T10:42:53.484Z'
+ updated_at: '2026-08-05T10:42:53.505Z'
schema:
"$ref": "#/components/schemas/Market"
'422':
@@ -9702,8 +9661,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-08-01T21:08:44.954Z'
- updated_at: '2026-08-01T21:08:44.954Z'
+ created_at: '2026-08-05T10:42:53.696Z'
+ updated_at: '2026-08-05T10:42:53.696Z'
meta:
page: 1
limit: 25
@@ -9797,8 +9756,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-08-01T21:08:45.535Z'
- updated_at: '2026-08-01T21:08:45.535Z'
+ created_at: '2026-08-05T10:42:53.764Z'
+ updated_at: '2026-08-05T10:42:53.764Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -9922,8 +9881,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-08-01T21:08:45.823Z'
- updated_at: '2026-08-01T21:08:45.823Z'
+ created_at: '2026-08-05T10:42:53.800Z'
+ updated_at: '2026-08-05T10:42:53.800Z'
schema:
"$ref": "#/components/schemas/OptionType"
'404':
@@ -9996,8 +9955,8 @@ paths:
kind: dropdown
metadata: {}
filterable: true
- created_at: '2026-08-01T21:08:46.384Z'
- updated_at: '2026-08-01T21:08:46.661Z'
+ created_at: '2026-08-05T10:42:53.845Z'
+ updated_at: '2026-08-05T10:42:53.863Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -10157,8 +10116,8 @@ paths:
display_amount: "$1.50"
provider_id: internal
metadata: {}
- created_at: '2026-08-01T21:08:47.722Z'
- updated_at: '2026-08-01T21:08:47.722Z'
+ created_at: '2026-08-05T10:42:54.036Z'
+ updated_at: '2026-08-05T10:42:54.036Z'
meta:
page: 1
limit: 25
@@ -10232,8 +10191,8 @@ paths:
amount: "-2.0"
display_amount: "-$2.00"
metadata: {}
- created_at: '2026-08-01T21:08:48.355Z'
- updated_at: '2026-08-01T21:08:48.355Z'
+ created_at: '2026-08-05T10:42:54.131Z'
+ updated_at: '2026-08-05T10:42:54.131Z'
meta:
page: 1
limit: 25
@@ -10313,8 +10272,8 @@ paths:
amount: "-3.0"
display_amount: "-$3.00"
metadata: {}
- created_at: '2026-08-01T21:08:49.333Z'
- updated_at: '2026-08-01T21:08:49.333Z'
+ created_at: '2026-08-05T10:42:54.237Z'
+ updated_at: '2026-08-05T10:42:54.237Z'
'422':
description: invalid discount
content:
@@ -10411,8 +10370,8 @@ paths:
amount: '4.0'
display_amount: "$4.00"
metadata: {}
- created_at: '2026-08-01T21:08:50.590Z'
- updated_at: '2026-08-01T21:08:50.590Z'
+ created_at: '2026-08-05T10:42:54.557Z'
+ updated_at: '2026-08-05T10:42:54.557Z'
'422':
description: invalid fee
content:
@@ -10509,7 +10468,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 2AA44BD447EDB4FE
+ code: 860F2504F20C0CE9
status: active
currency: USD
amount: '10.0'
@@ -10523,8 +10482,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-08-01T21:08:59.595Z'
- updated_at: '2026-08-01T21:08:59.891Z'
+ created_at: '2026-08-05T10:42:56.034Z'
+ updated_at: '2026-08-05T10:42:56.066Z'
customer_id:
created_by_id:
requestBody:
@@ -10665,8 +10624,8 @@ paths:
preorder_ships_at:
quantity: 2
currency: USD
- name: Product 274994
- slug: product-274994
+ name: Product 273538
+ slug: product-273538
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -10698,12 +10657,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:00.593Z'
- updated_at: '2026-08-01T21:09:00.593Z'
+ created_at: '2026-08-05T10:42:56.210Z'
+ updated_at: '2026-08-05T10:42:56.210Z'
digital_links: []
metadata: {}
- created_at: '2026-08-01T21:09:00.872Z'
- updated_at: '2026-08-01T21:09:00.872Z'
+ created_at: '2026-08-05T10:42:56.230Z'
+ updated_at: '2026-08-05T10:42:56.230Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
meta:
@@ -10775,8 +10734,8 @@ paths:
preorder_ships_at:
quantity: 3
currency: USD
- name: Product 292780
- slug: product-292780
+ name: Product 29220
+ slug: product-29220
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -10808,12 +10767,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:01.767Z'
- updated_at: '2026-08-01T21:09:01.767Z'
+ created_at: '2026-08-05T10:42:56.365Z'
+ updated_at: '2026-08-05T10:42:56.365Z'
digital_links: []
metadata: {}
- created_at: '2026-08-01T21:09:01.787Z'
- updated_at: '2026-08-01T21:09:01.787Z'
+ created_at: '2026-08-05T10:42:56.387Z'
+ updated_at: '2026-08-05T10:42:56.387Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -10907,8 +10866,8 @@ paths:
preorder_ships_at:
quantity: 2
currency: USD
- name: Product 30995
- slug: product-30995
+ name: Product 301539
+ slug: product-301539
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -10940,12 +10899,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:01.878Z'
- updated_at: '2026-08-01T21:09:01.878Z'
+ created_at: '2026-08-05T10:42:56.457Z'
+ updated_at: '2026-08-05T10:42:56.457Z'
digital_links: []
metadata: {}
- created_at: '2026-08-01T21:09:02.161Z'
- updated_at: '2026-08-01T21:09:02.161Z'
+ created_at: '2026-08-05T10:42:56.478Z'
+ updated_at: '2026-08-05T10:42:56.478Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
patch:
@@ -11012,8 +10971,8 @@ paths:
preorder_ships_at:
quantity: 5
currency: USD
- name: Product 312138
- slug: product-312138
+ name: Product 317075
+ slug: product-317075
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -11045,12 +11004,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:02.498Z'
- updated_at: '2026-08-01T21:09:02.498Z'
+ created_at: '2026-08-05T10:42:56.625Z'
+ updated_at: '2026-08-05T10:42:56.625Z'
digital_links: []
metadata: {}
- created_at: '2026-08-01T21:09:02.784Z'
- updated_at: '2026-08-01T21:09:03.077Z'
+ created_at: '2026-08-05T10:42:56.665Z'
+ updated_at: '2026-08-05T10:42:56.704Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -11171,8 +11130,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R536491745
+ number: R080617404
customer_note:
currency: USD
locale: en
@@ -11216,8 +11175,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: draft
last_ip_address:
considered_risky: false
@@ -11228,15 +11187,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:09.419Z'
- updated_at: '2026-08-01T21:09:09.463Z'
+ created_at: '2026-08-05T10:42:57.819Z'
+ updated_at: '2026-08-05T10:42:57.867Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
requestBody:
content:
application/json:
@@ -11407,8 +11366,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R972650308
+ number: R622613838
customer_note:
currency: USD
locale: en
@@ -11452,8 +11411,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: draft
last_ip_address:
considered_risky: false
@@ -11464,15 +11423,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:11.194Z'
- updated_at: '2026-08-01T21:09:11.194Z'
+ created_at: '2026-08-05T10:42:58.061Z'
+ updated_at: '2026-08-05T10:42:58.061Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
meta:
page: 1
limit: 25
@@ -11617,7 +11576,7 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R720073873
+ number: R840216369
customer_note:
currency: USD
@@ -11662,8 +11621,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: draft
last_ip_address:
considered_risky: false
@@ -11674,8 +11633,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:12.887Z'
- updated_at: '2026-08-01T21:09:12.891Z'
+ created_at: '2026-08-05T10:42:58.185Z'
+ updated_at: '2026-08-05T10:42:58.188Z'
preferred_stock_location_id: sloc_UkLWZg9DAJ
tags: []
internal_note:
@@ -11863,8 +11822,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R797341901
+ number: R409101300
customer_note:
currency: USD
locale: en
@@ -11908,8 +11867,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: draft
last_ip_address:
considered_risky: false
@@ -11920,15 +11879,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:13.173Z'
- updated_at: '2026-08-01T21:09:13.173Z'
+ created_at: '2026-08-05T10:42:58.206Z'
+ updated_at: '2026-08-05T10:42:58.206Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
'404':
description: order not found
content:
@@ -11997,7 +11956,7 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R261243462
+ number: R230569042
customer_note:
currency: USD
@@ -12042,8 +12001,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: draft
last_ip_address:
considered_risky: false
@@ -12054,15 +12013,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:14.282Z'
- updated_at: '2026-08-01T21:09:14.566Z'
+ created_at: '2026-08-05T10:42:58.268Z'
+ updated_at: '2026-08-05T10:42:58.291Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
requestBody:
content:
application/json:
@@ -12243,8 +12202,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R321403174
+ number: R827688442
customer_note:
currency: USD
locale: en
@@ -12252,7 +12211,7 @@ paths:
coupon_code:
fulfillment_status: ready
payment_status: paid
- completed_at: '2026-08-01T21:09:15.553Z'
+ completed_at: '2026-08-05T10:42:58.414Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -12288,8 +12247,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: placed
last_ip_address:
considered_risky: false
@@ -12300,15 +12259,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:15.449Z'
- updated_at: '2026-08-01T21:09:15.572Z'
+ created_at: '2026-08-05T10:42:58.371Z'
+ updated_at: '2026-08-05T10:42:58.430Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
'422':
description: order cannot be completed
content:
@@ -12386,8 +12345,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R360008827
+ number: R559531923
customer_note:
currency: USD
locale: en
@@ -12395,7 +12354,7 @@ paths:
coupon_code:
fulfillment_status: canceled
payment_status: none
- completed_at: '2026-08-01T21:09:16.769Z'
+ completed_at: '2026-08-05T10:42:58.642Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -12431,8 +12390,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: canceled
last_ip_address:
considered_risky: false
@@ -12441,17 +12400,17 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-08-01T21:09:17.057Z'
+ canceled_at: '2026-08-05T10:42:58.671Z'
approved_at:
- created_at: '2026-08-01T21:09:16.727Z'
- updated_at: '2026-08-01T21:09:17.075Z'
+ created_at: '2026-08-05T10:42:58.567Z'
+ updated_at: '2026-08-05T10:42:58.690Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
- canceler_id: admin_UkLWZg9DAJ
+ canceler_id: adm_UkLWZg9DAJ
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
"/api/v3/admin/orders/{id}/approve":
patch:
summary: Approve an order
@@ -12507,8 +12466,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R810901357
+ number: R232966054
customer_note:
currency: USD
locale: en
@@ -12516,7 +12475,7 @@ paths:
coupon_code:
fulfillment_status:
payment_status:
- completed_at: '2026-08-01T21:09:17.411Z'
+ completed_at: '2026-08-05T10:42:58.807Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -12552,8 +12511,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: placed
last_ip_address:
considered_risky: false
@@ -12563,16 +12522,16 @@ paths:
display_payment_total: "$0.00"
metadata: {}
canceled_at:
- approved_at: '2026-08-01T21:09:17.696Z'
- created_at: '2026-08-01T21:09:17.370Z'
- updated_at: '2026-08-01T21:09:17.411Z'
+ approved_at: '2026-08-05T10:42:58.866Z'
+ created_at: '2026-08-05T10:42:58.732Z'
+ updated_at: '2026-08-05T10:42:58.806Z'
preferred_stock_location_id:
tags: []
internal_note:
- approver_id: admin_UkLWZg9DAJ
+ approver_id: adm_UkLWZg9DAJ
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
"/api/v3/admin/orders/{id}/resume":
patch:
summary: Resume a canceled order
@@ -12628,8 +12587,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R919403438
+ number: R139193647
customer_note:
currency: USD
locale: en
@@ -12637,7 +12596,7 @@ paths:
coupon_code:
fulfillment_status: pending
payment_status: none
- completed_at: '2026-08-01T21:09:18.025Z'
+ completed_at: '2026-08-05T10:42:58.982Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -12673,8 +12632,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: placed
last_ip_address:
considered_risky: false
@@ -12683,17 +12642,17 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-08-01T21:09:18.307Z'
+ canceled_at: '2026-08-05T10:42:58.999Z'
approved_at:
- created_at: '2026-08-01T21:09:17.977Z'
- updated_at: '2026-08-01T21:09:18.363Z'
+ created_at: '2026-08-05T10:42:58.929Z'
+ updated_at: '2026-08-05T10:42:59.044Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
- canceler_id: admin_UkLWZg9DAJ
+ canceler_id: adm_UkLWZg9DAJ
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
"/api/v3/admin/orders/{id}/resend_confirmation":
post:
summary: Resend confirmation email
@@ -12749,8 +12708,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R160627687
+ number: R343730758
customer_note:
currency: USD
locale: en
@@ -12758,7 +12717,7 @@ paths:
coupon_code:
fulfillment_status:
payment_status:
- completed_at: '2026-08-01T21:09:18.693Z'
+ completed_at: '2026-08-05T10:42:59.115Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -12794,8 +12753,8 @@ paths:
- US
supported_locales:
- en
- created_at: '2026-08-01T21:07:54.369Z'
- updated_at: '2026-08-01T21:07:54.369Z'
+ created_at: '2026-08-05T10:42:48.542Z'
+ updated_at: '2026-08-05T10:42:48.542Z'
status: placed
last_ip_address:
considered_risky: false
@@ -12806,15 +12765,15 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-08-01T21:09:18.647Z'
- updated_at: '2026-08-01T21:09:18.693Z'
+ created_at: '2026-08-05T10:42:59.068Z'
+ updated_at: '2026-08-05T10:42:59.115Z'
preferred_stock_location_id:
tags: []
internal_note:
approver_id:
canceler_id:
created_by_id:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
"/api/v3/admin/payment_methods":
get:
summary: List payment methods
@@ -12885,8 +12844,8 @@ paths:
auto_capture:
storefront_visible: true
position: 1
- created_at: '2026-08-01T21:09:20.096Z'
- updated_at: '2026-08-01T21:09:20.096Z'
+ created_at: '2026-08-05T10:42:59.231Z'
+ updated_at: '2026-08-05T10:42:59.231Z'
preferences: {}
preference_schema: []
meta:
@@ -13032,8 +12991,8 @@ paths:
auto_capture:
storefront_visible: true
position: 1
- created_at: '2026-08-01T21:09:20.676Z'
- updated_at: '2026-08-01T21:09:20.676Z'
+ created_at: '2026-08-05T10:42:59.286Z'
+ updated_at: '2026-08-05T10:42:59.286Z'
preferences: {}
preference_schema: []
"/api/v3/admin/orders/{order_id}/payments":
@@ -13104,8 +13063,8 @@ paths:
data:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-e23d368fd619
- number: PVDU6Q1T
+ response_code: BGS-cc21e9dea009
+ number: PV2YIKAI
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -13123,14 +13082,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-08-01T21:09:04.044Z'
- updated_at: '2026-08-01T21:09:04.047Z'
+ created_at: '2026-08-05T10:42:56.876Z'
+ updated_at: '2026-08-05T10:42:56.879Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-08-01T21:09:04.046Z'
- updated_at: '2026-08-01T21:09:04.046Z'
+ created_at: '2026-08-05T10:42:56.878Z'
+ updated_at: '2026-08-05T10:42:56.878Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
meta:
@@ -13200,7 +13159,7 @@ paths:
id: py_gbHJdmfrXB
payment_method_id: pm_EfhxLZ9ck8
response_code:
- number: P6PV4KP4
+ number: PR6Y1FBK
amount: '110.0'
display_amount: "$110.00"
status: checkout
@@ -13211,8 +13170,8 @@ paths:
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-08-01T21:09:05.296Z'
- updated_at: '2026-08-01T21:09:05.296Z'
+ created_at: '2026-08-05T10:42:57.080Z'
+ updated_at: '2026-08-05T10:42:57.080Z'
captured_amount: '0.0'
order_id: or_gbHJdmfrXB
requestBody:
@@ -13305,8 +13264,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-06034cd36bf1
- number: P78ZZHP2
+ response_code: BGS-7ea3220d145d
+ number: PYCMNGSA
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -13324,14 +13283,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-08-01T21:09:05.631Z'
- updated_at: '2026-08-01T21:09:05.633Z'
+ created_at: '2026-08-05T10:42:57.164Z'
+ updated_at: '2026-08-05T10:42:57.167Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-08-01T21:09:05.633Z'
- updated_at: '2026-08-01T21:09:05.633Z'
+ created_at: '2026-08-05T10:42:57.165Z'
+ updated_at: '2026-08-05T10:42:57.165Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/payments/{id}/capture":
@@ -13394,8 +13353,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-6e1d8fcb58e7
- number: P5EC9UAU
+ response_code: BGS-0eca7ac959c8
+ number: P47ALE9K
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -13413,14 +13372,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-08-01T21:09:06.253Z'
- updated_at: '2026-08-01T21:09:06.255Z'
+ created_at: '2026-08-05T10:42:57.274Z'
+ updated_at: '2026-08-05T10:42:57.276Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-08-01T21:09:06.254Z'
- updated_at: '2026-08-01T21:09:06.550Z'
+ created_at: '2026-08-05T10:42:57.275Z'
+ updated_at: '2026-08-05T10:42:57.312Z'
captured_amount: '110.0'
order_id: or_UkLWZg9DAJ
'422':
@@ -13492,8 +13451,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: void-BGS-561f74e095f0
- number: P6CDPUQS
+ response_code: void-BGS-b4ad7af4d9ba
+ number: P107LFYQ
amount: '110.0'
display_amount: "$110.00"
status: void
@@ -13511,14 +13470,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-08-01T21:09:07.583Z'
- updated_at: '2026-08-01T21:09:07.586Z'
+ created_at: '2026-08-05T10:42:57.522Z'
+ updated_at: '2026-08-05T10:42:57.525Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-08-01T21:09:07.585Z'
- updated_at: '2026-08-01T21:09:07.872Z'
+ created_at: '2026-08-05T10:42:57.524Z'
+ updated_at: '2026-08-05T10:42:57.552Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/price_lists":
@@ -13606,8 +13565,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:20.956Z'
- updated_at: '2026-08-01T21:09:20.956Z'
+ created_at: '2026-08-05T10:42:59.313Z'
+ updated_at: '2026-08-05T10:42:59.313Z'
currently_active: false
products_count: 0
prices_count: 0
@@ -13621,8 +13580,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:20.957Z'
- updated_at: '2026-08-01T21:09:20.957Z'
+ created_at: '2026-08-05T10:42:59.314Z'
+ updated_at: '2026-08-05T10:42:59.314Z'
currently_active: false
products_count: 0
prices_count: 0
@@ -13736,8 +13695,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:21.925Z'
- updated_at: '2026-08-01T21:09:21.927Z'
+ created_at: '2026-08-05T10:42:59.504Z'
+ updated_at: '2026-08-05T10:42:59.506Z'
currently_active: false
products_count: 1
prices_count: 2
@@ -13900,8 +13859,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:22.236Z'
- updated_at: '2026-08-01T21:09:22.236Z'
+ created_at: '2026-08-05T10:42:59.542Z'
+ updated_at: '2026-08-05T10:42:59.542Z'
currently_active: false
products_count: 0
prices_count: 0
@@ -13976,8 +13935,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:23.925Z'
- updated_at: '2026-08-01T21:09:24.209Z'
+ created_at: '2026-08-05T10:42:59.839Z'
+ updated_at: '2026-08-05T10:42:59.857Z'
currently_active: false
products_count: 0
prices_count: 0
@@ -14165,8 +14124,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:24.509Z'
- updated_at: '2026-08-01T21:09:24.792Z'
+ created_at: '2026-08-05T10:42:59.890Z'
+ updated_at: '2026-08-05T10:42:59.908Z'
currently_active: true
products_count: 0
prices_count: 0
@@ -14229,8 +14188,8 @@ paths:
starts_at:
ends_at:
deleted_at:
- created_at: '2026-08-01T21:09:24.802Z'
- updated_at: '2026-08-01T21:09:25.081Z'
+ created_at: '2026-08-05T10:42:59.917Z'
+ updated_at: '2026-08-05T10:42:59.934Z'
currently_active: false
products_count: 0
prices_count: 0
@@ -14344,8 +14303,8 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:25.111Z'
- updated_at: '2026-08-01T21:09:25.111Z'
+ created_at: '2026-08-05T10:42:59.965Z'
+ updated_at: '2026-08-05T10:42:59.965Z'
- id: price_gbHJdmfrXB
amount: '19.99'
amount_in_cents: 1999
@@ -14356,8 +14315,8 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_gbHJdmfrXB
- created_at: '2026-08-01T21:09:25.129Z'
- updated_at: '2026-08-01T21:09:25.129Z'
+ created_at: '2026-08-05T10:42:59.984Z'
+ updated_at: '2026-08-05T10:42:59.984Z'
- id: price_EfhxLZ9ck8
amount: '5.0'
amount_in_cents: 500
@@ -14368,8 +14327,8 @@ paths:
display_compare_at_amount:
price_list_id: pl_UkLWZg9DAJ
variant_id: variant_gbHJdmfrXB
- created_at: '2026-08-01T21:09:25.132Z'
- updated_at: '2026-08-01T21:09:25.132Z'
+ created_at: '2026-08-05T10:42:59.987Z'
+ updated_at: '2026-08-05T10:42:59.987Z'
meta:
page: 1
limit: 25
@@ -14451,8 +14410,8 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_EfhxLZ9ck8
- created_at: '2026-08-01T21:09:25.752Z'
- updated_at: '2026-08-01T21:09:25.752Z'
+ created_at: '2026-08-05T10:43:00.113Z'
+ updated_at: '2026-08-05T10:43:00.113Z'
schema:
"$ref": "#/components/schemas/Price"
requestBody:
@@ -14539,8 +14498,8 @@ paths:
display_compare_at_amount:
price_list_id: pl_UkLWZg9DAJ
variant_id: variant_gbHJdmfrXB
- created_at: '2026-08-01T21:09:25.807Z'
- updated_at: '2026-08-01T21:09:25.807Z'
+ created_at: '2026-08-05T10:43:00.166Z'
+ updated_at: '2026-08-05T10:43:00.166Z'
schema:
"$ref": "#/components/schemas/Price"
'404':
@@ -14605,8 +14564,8 @@ paths:
display_compare_at_amount:
price_list_id: pl_UkLWZg9DAJ
variant_id: variant_gbHJdmfrXB
- created_at: '2026-08-01T21:09:26.492Z'
- updated_at: '2026-08-01T21:09:26.769Z'
+ created_at: '2026-08-05T10:43:00.312Z'
+ updated_at: '2026-08-05T10:43:00.330Z'
schema:
"$ref": "#/components/schemas/Price"
requestBody:
@@ -14918,8 +14877,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-08-01T21:09:28.202Z'
- updated_at: '2026-08-01T21:09:28.202Z'
+ created_at: '2026-08-05T10:43:00.833Z'
+ updated_at: '2026-08-05T10:43:00.833Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
meta:
@@ -14989,8 +14948,8 @@ paths:
field_type: long_text
key: custom.description
value: A longer description
- created_at: '2026-08-01T21:09:28.819Z'
- updated_at: '2026-08-01T21:09:28.819Z'
+ created_at: '2026-08-05T10:43:00.905Z'
+ updated_at: '2026-08-05T10:43:00.905Z'
storefront_visible: true
custom_field_definition_id: cfdef_gbHJdmfrXB
'422':
@@ -15089,8 +15048,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-08-01T21:09:29.180Z'
- updated_at: '2026-08-01T21:09:29.180Z'
+ created_at: '2026-08-05T10:43:00.996Z'
+ updated_at: '2026-08-05T10:43:00.996Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
patch:
@@ -15154,8 +15113,8 @@ paths:
field_type: short_text
key: custom.title
value: cotton
- created_at: '2026-08-01T21:09:29.500Z'
- updated_at: '2026-08-01T21:09:29.777Z'
+ created_at: '2026-08-05T10:43:01.047Z'
+ updated_at: '2026-08-05T10:43:01.063Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
requestBody:
@@ -15273,9 +15232,9 @@ paths:
source: Espresso Machine
- key: description
type: html
- source: Itaque est architecto quas ea cum ipsa nemo. Molestias
- velit voluptatem accusamus a labore ullam nemo debitis. Ipsam
- aliquid soluta id expedita quibusdam animi perspiciatis.
+ source: |-
+ Ab nulla harum unde dolorem. Aperiam maiores repellat fugit similique magnam autem vel quia. Provident recusandae natus dolore ducimus aperiam nihil cumque voluptatum. Accusamus illum occaecati iusto repellendus minus commodi vero. Laborum id voluptates et eum consequatur mollitia minima molestiae.
+ Ad impedit labore commodi alias. Quas eum ratione dolore tenetur esse. Sequi sit explicabo odit minima laudantium ratione. Libero cupiditate ut quos quasi impedit. Illo totam impedit voluptatum ullam perspiciatis non eos qui.
- key: slug
type: string
source: espresso-machine
@@ -15386,8 +15345,8 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 726570
- slug: product-726570
+ name: Product 728405
+ slug: product-728405
meta_title:
meta_description:
meta_keywords:
@@ -15399,16 +15358,17 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Corrupti nesciunt dicta repudiandae omnis eligendi
- natus vero voluptatum. Iure quod fuga voluptate voluptatem fugiat
- nam. Numquam ratione cum quis qui recusandae placeat rem maxime.
- Quisquam laudantium repudiandae molestiae nemo ea. Debitis consequuntur
- delectus eaque dignissimos quasi. Minima expedita ab rem debitis
- possimus ex ut labore. Aperiam in aliquid expedita aut. Tenetur
- provident maiores qui corporis veritatis.
+ description: Dicta itaque illum ducimus dolores ratione qui quas.
+ Magnam corrupti fugiat labore quas dicta soluta. Neque molestias
+ perferendis libero dignissimos. Odio quam similique natus officia.
+ Eligendi expedita eum aliquam sunt hic ducimus libero. Omnis commodi
+ sequi fugiat amet vero cupiditate unde. Eligendi odio rem suscipit
+ nobis maxime tempora commodi. Ipsa fuga maiores dicta distinctio
+ exercitationem fugiat. Perferendis cupiditate quo a praesentium
+ veniam architecto.
description_html: |-
- Corrupti nesciunt dicta repudiandae omnis eligendi natus vero voluptatum. Iure quod fuga voluptate voluptatem fugiat nam. Numquam ratione cum quis qui recusandae placeat rem maxime. Quisquam laudantium repudiandae molestiae nemo ea.
- Debitis consequuntur delectus eaque dignissimos quasi. Minima expedita ab rem debitis possimus ex ut labore. Aperiam in aliquid expedita aut. Tenetur provident maiores qui corporis veritatis.
+ Dicta itaque illum ducimus dolores ratione qui quas. Magnam corrupti fugiat labore quas dicta soluta. Neque molestias perferendis libero dignissimos. Odio quam similique natus officia.
+ Eligendi expedita eum aliquam sunt hic ducimus libero. Omnis commodi sequi fugiat amet vero cupiditate unde. Eligendi odio rem suscipit nobis maxime tempora commodi. Ipsa fuga maiores dicta distinctio exercitationem fugiat. Perferendis cupiditate quo a praesentium veniam architecto.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -15423,14 +15383,15 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:30.446Z'
- updated_at: '2026-08-01T21:09:30.446Z'
+ created_at: '2026-08-05T10:43:01.194Z'
+ updated_at: '2026-08-05T10:43:01.194Z'
original_price:
status: active
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:09:30.434Z'
- updated_at: '2026-08-01T21:09:30.453Z'
+ created_at: '2026-08-05T10:43:01.184Z'
+ updated_at: '2026-08-05T10:43:01.200Z'
+ product_type_id:
tax_category_id: taxcat_UkLWZg9DAJ
meta:
page: 1
@@ -15564,8 +15525,9 @@ paths:
status: draft
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:09:31.151Z'
- updated_at: '2026-08-01T21:09:31.158Z'
+ created_at: '2026-08-05T10:43:01.344Z'
+ updated_at: '2026-08-05T10:43:01.350Z'
+ product_type_id:
tax_category_id:
schema:
"$ref": "#/components/schemas/Product"
@@ -15770,8 +15732,8 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 76451
- slug: product-76451
+ name: Product 765313
+ slug: product-765313
meta_title:
meta_description:
meta_keywords:
@@ -15783,23 +15745,22 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Voluptatibus excepturi porro quos nihil dolores velit.
- Provident rerum ab hic corporis possimus qui nulla. Dignissimos
- ducimus itaque alias temporibus recusandae animi dolore quam. Modi
- molestias libero impedit sint error nisi autem. Cupiditate cum nihil
- nemo laboriosam assumenda. Quo suscipit accusamus perferendis provident
- rerum. At laboriosam distinctio vero occaecati corrupti odit. Quis
- facilis necessitatibus doloribus nobis autem ad in. Veritatis nobis
- asperiores dolores consequuntur illum dolorem. Cumque commodi laboriosam
- fuga facilis. Ratione tempora dicta numquam quae pariatur iste.
- Quis aperiam nemo atque quisquam vel. Voluptatibus nam nobis voluptas
- sed recusandae magnam minus. Officiis laudantium accusantium veniam
- id. Explicabo quasi blanditiis minus natus ducimus.
+ description: Quos harum provident ipsum soluta occaecati fugiat facilis
+ magni. Temporibus aliquam eligendi minus corrupti possimus molestias
+ reprehenderit. Illum nostrum in tenetur voluptatibus. Dolores corrupti
+ quidem recusandae neque quod animi delectus placeat. Consequatur
+ tempora saepe enim asperiores. Ratione sed aut nostrum natus beatae
+ neque modi. Possimus minima tempora animi corporis quo. Occaecati
+ incidunt consectetur necessitatibus nostrum dolorum quae temporibus
+ saepe. Blanditiis magnam facere tempore culpa voluptate vero repellendus.
+ Repudiandae provident enim quaerat velit. Ipsam eum sunt iste nemo
+ soluta eaque. Mollitia expedita consequuntur unde quisquam officiis
+ magnam ad earum. Quisquam voluptatum laborum sed nam dolorum pariatur.
description_html: |-
- Voluptatibus excepturi porro quos nihil dolores velit. Provident rerum ab hic corporis possimus qui nulla. Dignissimos ducimus itaque alias temporibus recusandae animi dolore quam. Modi molestias libero impedit sint error nisi autem.
- Cupiditate cum nihil nemo laboriosam assumenda. Quo suscipit accusamus perferendis provident rerum. At laboriosam distinctio vero occaecati corrupti odit. Quis facilis necessitatibus doloribus nobis autem ad in. Veritatis nobis asperiores dolores consequuntur illum dolorem.
- Cumque commodi laboriosam fuga facilis. Ratione tempora dicta numquam quae pariatur iste. Quis aperiam nemo atque quisquam vel.
- Voluptatibus nam nobis voluptas sed recusandae magnam minus. Officiis laudantium accusantium veniam id. Explicabo quasi blanditiis minus natus ducimus.
+ Quos harum provident ipsum soluta occaecati fugiat facilis magni. Temporibus aliquam eligendi minus corrupti possimus molestias reprehenderit. Illum nostrum in tenetur voluptatibus.
+ Dolores corrupti quidem recusandae neque quod animi delectus placeat. Consequatur tempora saepe enim asperiores. Ratione sed aut nostrum natus beatae neque modi.
+ Possimus minima tempora animi corporis quo. Occaecati incidunt consectetur necessitatibus nostrum dolorum quae temporibus saepe. Blanditiis magnam facere tempore culpa voluptate vero repellendus.
+ Repudiandae provident enim quaerat velit. Ipsam eum sunt iste nemo soluta eaque. Mollitia expedita consequuntur unde quisquam officiis magnam ad earum. Quisquam voluptatum laborum sed nam dolorum pariatur.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -15814,14 +15775,15 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:31.590Z'
- updated_at: '2026-08-01T21:09:31.590Z'
+ created_at: '2026-08-05T10:43:01.464Z'
+ updated_at: '2026-08-05T10:43:01.464Z'
original_price:
status: active
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:09:31.577Z'
- updated_at: '2026-08-01T21:09:31.598Z'
+ created_at: '2026-08-05T10:43:01.453Z'
+ updated_at: '2026-08-05T10:43:01.470Z'
+ product_type_id:
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -15891,7 +15853,7 @@ paths:
example:
id: prod_UkLWZg9DAJ
name: Updated Name
- slug: product-78760
+ slug: product-782228
meta_title:
meta_description:
meta_keywords:
@@ -15903,22 +15865,25 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Numquam nesciunt aliquam porro corrupti. Nostrum excepturi
- incidunt ipsam sed. Adipisci recusandae perspiciatis perferendis
- similique consequuntur natus quia sint. Eaque unde cupiditate amet
- ducimus odio nemo numquam. Sit voluptates voluptas rem odit aliquid
- mollitia nam. Laudantium nostrum ex voluptas culpa adipisci atque
- incidunt. Quibusdam maiores quia molestias exercitationem nesciunt
- error. Deleniti ut reprehenderit qui blanditiis cumque explicabo
- rem. Consequatur commodi quam nulla illum porro veniam alias veritatis.
- Magni fugiat accusamus eaque ullam maiores unde. Laboriosam animi
- velit asperiores dolore. Quibusdam odit maiores vel expedita non
- harum. Quae quaerat fugiat earum blanditiis accusamus cumque asperiores.
- Pariatur vitae architecto ex dignissimos.
+ description: Est aliquid alias totam eveniet amet. Sequi tenetur debitis
+ accusamus perspiciatis facilis distinctio nostrum id. Corrupti nulla
+ enim voluptatum vel tempore. Delectus accusamus commodi esse natus
+ asperiores provident. Reprehenderit recusandae deserunt consectetur
+ molestias placeat nihil odit. Officiis ipsam id repudiandae impedit
+ delectus eligendi commodi quae. Voluptates autem ab vel illo accusamus
+ neque. Doloribus alias dicta maiores deserunt temporibus debitis.
+ Ullam neque atque eum quaerat. Amet quaerat nesciunt expedita deserunt
+ alias rerum totam tempore. Molestias officiis temporibus in consectetur
+ deserunt ipsam non. Blanditiis voluptate accusamus ab id pariatur
+ provident laudantium. Ad molestias temporibus voluptates ullam.
+ Consequuntur quas quisquam impedit magni. Autem consequatur quo
+ dignissimos at atque ipsa reprehenderit. Suscipit occaecati excepturi
+ explicabo voluptates.
description_html: |-
- Numquam nesciunt aliquam porro corrupti. Nostrum excepturi incidunt ipsam sed. Adipisci recusandae perspiciatis perferendis similique consequuntur natus quia sint. Eaque unde cupiditate amet ducimus odio nemo numquam. Sit voluptates voluptas rem odit aliquid mollitia nam.
- Laudantium nostrum ex voluptas culpa adipisci atque incidunt. Quibusdam maiores quia molestias exercitationem nesciunt error. Deleniti ut reprehenderit qui blanditiis cumque explicabo rem. Consequatur commodi quam nulla illum porro veniam alias veritatis. Magni fugiat accusamus eaque ullam maiores unde.
- Laboriosam animi velit asperiores dolore. Quibusdam odit maiores vel expedita non harum. Quae quaerat fugiat earum blanditiis accusamus cumque asperiores. Pariatur vitae architecto ex dignissimos.
+ Est aliquid alias totam eveniet amet. Sequi tenetur debitis accusamus perspiciatis facilis distinctio nostrum id. Corrupti nulla enim voluptatum vel tempore.
+ Delectus accusamus commodi esse natus asperiores provident. Reprehenderit recusandae deserunt consectetur molestias placeat nihil odit. Officiis ipsam id repudiandae impedit delectus eligendi commodi quae. Voluptates autem ab vel illo accusamus neque. Doloribus alias dicta maiores deserunt temporibus debitis.
+ Ullam neque atque eum quaerat. Amet quaerat nesciunt expedita deserunt alias rerum totam tempore. Molestias officiis temporibus in consectetur deserunt ipsam non. Blanditiis voluptate accusamus ab id pariatur provident laudantium.
+ Ad molestias temporibus voluptates ullam. Consequuntur quas quisquam impedit magni. Autem consequatur quo dignissimos at atque ipsa reprehenderit. Suscipit occaecati excepturi explicabo voluptates.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -15933,14 +15898,15 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:32.279Z'
- updated_at: '2026-08-01T21:09:32.279Z'
+ created_at: '2026-08-05T10:43:01.590Z'
+ updated_at: '2026-08-05T10:43:01.590Z'
original_price:
status: active
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:09:32.267Z'
- updated_at: '2026-08-01T21:09:32.581Z'
+ created_at: '2026-08-05T10:43:01.581Z'
+ updated_at: '2026-08-05T10:43:01.620Z'
+ product_type_id:
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -16870,15 +16836,15 @@ paths:
- id: coupon_UkLWZg9DAJ
code: AAA111
state: unused
- created_at: '2026-08-01T21:08:11.192Z'
- updated_at: '2026-08-01T21:08:11.192Z'
+ created_at: '2026-08-05T10:42:50.768Z'
+ updated_at: '2026-08-05T10:42:50.768Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
- id: coupon_gbHJdmfrXB
code: BBB222
state: unused
- created_at: '2026-08-01T21:08:11.193Z'
- updated_at: '2026-08-01T21:08:11.193Z'
+ created_at: '2026-08-05T10:42:50.769Z'
+ updated_at: '2026-08-05T10:42:50.769Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
meta:
@@ -16940,8 +16906,8 @@ paths:
example:
data:
- id: pact_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:37.179Z'
- updated_at: '2026-08-01T21:09:37.179Z'
+ created_at: '2026-08-05T10:43:02.588Z'
+ updated_at: '2026-08-05T10:43:02.588Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -17005,8 +16971,8 @@ paths:
application/json:
example:
id: pact_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:37.743Z'
- updated_at: '2026-08-01T21:09:37.743Z'
+ created_at: '2026-08-05T10:43:02.630Z'
+ updated_at: '2026-08-05T10:43:02.630Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -17134,8 +17100,8 @@ paths:
example:
data:
- id: prorule_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:38.342Z'
- updated_at: '2026-08-01T21:09:38.342Z'
+ created_at: '2026-08-05T10:43:02.685Z'
+ updated_at: '2026-08-05T10:43:02.685Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -17205,8 +17171,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:38.913Z'
- updated_at: '2026-08-01T21:09:38.913Z'
+ created_at: '2026-08-05T10:43:02.724Z'
+ updated_at: '2026-08-05T10:43:02.724Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -17297,8 +17263,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-08-01T21:09:39.199Z'
- updated_at: '2026-08-01T21:09:39.473Z'
+ created_at: '2026-08-05T10:43:02.752Z'
+ updated_at: '2026-08-05T10:43:02.769Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -17406,7 +17372,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-08-01T21:09:39.759Z'
+ starts_at: '2026-08-05T10:43:02.798Z'
expires_at:
usage_limit:
match_policy: all
@@ -17417,8 +17383,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-08-01T21:09:39.759Z'
- updated_at: '2026-08-01T21:09:39.759Z'
+ created_at: '2026-08-05T10:43:02.799Z'
+ updated_at: '2026-08-05T10:43:02.799Z'
action_ids: []
rule_ids: []
meta:
@@ -17525,7 +17491,7 @@ paths:
name: Black Friday
description:
code: blackfriday-os
- starts_at: '2026-08-01T21:09:40.676Z'
+ starts_at: '2026-08-05T10:43:02.906Z'
expires_at:
usage_limit:
match_policy: all
@@ -17536,8 +17502,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-08-01T21:09:40.676Z'
- updated_at: '2026-08-01T21:09:40.694Z'
+ created_at: '2026-08-05T10:43:02.906Z'
+ updated_at: '2026-08-05T10:43:02.924Z'
action_ids:
- pact_UkLWZg9DAJ
- pact_gbHJdmfrXB
@@ -17703,7 +17669,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-08-01T21:09:40.986Z'
+ starts_at: '2026-08-05T10:43:02.953Z'
expires_at:
usage_limit:
match_policy: all
@@ -17714,8 +17680,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-08-01T21:09:40.986Z'
- updated_at: '2026-08-01T21:09:40.986Z'
+ created_at: '2026-08-05T10:43:02.953Z'
+ updated_at: '2026-08-05T10:43:02.953Z'
action_ids: []
rule_ids: []
patch:
@@ -17812,7 +17778,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-08-01T21:09:41.859Z'
+ starts_at: '2026-08-05T10:43:03.045Z'
expires_at:
usage_limit:
match_policy: all
@@ -17823,8 +17789,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-08-01T21:09:41.860Z'
- updated_at: '2026-08-01T21:09:42.145Z'
+ created_at: '2026-08-05T10:43:03.046Z'
+ updated_at: '2026-08-05T10:43:03.065Z'
action_ids: []
rule_ids: []
requestBody:
@@ -18296,14 +18262,15 @@ paths:
application/json:
example:
id: re_UkLWZg9DAJ
- transaction_id: BGS-951b00f88609
+ transaction_id: BGS-335f6c5d9543
amount: '5.0'
payment_id: py_UkLWZg9DAJ
refund_reason_id: rr_UkLWZg9DAJ
- reimbursement_id:
+ originator_id:
+ originator_type:
metadata: {}
- created_at: '2026-08-01T21:09:09.137Z'
- updated_at: '2026-08-01T21:09:09.137Z'
+ created_at: '2026-08-05T10:42:57.794Z'
+ updated_at: '2026-08-05T10:42:57.794Z'
requestBody:
content:
application/json:
@@ -18447,8 +18414,8 @@ paths:
data:
- id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-08-01T21:09:45.591Z'
- updated_at: '2026-08-01T21:09:45.591Z'
+ created_at: '2026-08-05T10:43:03.393Z'
+ updated_at: '2026-08-05T10:43:03.393Z'
non_expiring: false
meta:
page: 1
@@ -18542,8 +18509,8 @@ paths:
example:
id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-08-01T21:09:45.879Z'
- updated_at: '2026-08-01T21:09:45.879Z'
+ created_at: '2026-08-05T10:43:03.425Z'
+ updated_at: '2026-08-05T10:43:03.425Z'
non_expiring: false
schema:
"$ref": "#/components/schemas/StoreCreditCategory"
@@ -18620,8 +18587,8 @@ paths:
preferred_storefront_access: public
preferred_guest_checkout: true
preferred_order_routing_strategy: Spree::OrderRouting::Strategy::Rules
- created_at: '2026-08-01T21:07:54.329Z'
- updated_at: '2026-08-01T21:09:46.443Z'
+ created_at: '2026-08-05T10:42:48.517Z'
+ updated_at: '2026-08-05T10:43:03.496Z'
url: http://www.example.com:3000
api_url: http://www.example.com:3000
setup_tasks:
@@ -18918,8 +18885,8 @@ paths:
preferred_storefront_access: public
preferred_guest_checkout: true
preferred_order_routing_strategy: Spree::OrderRouting::Strategy::Rules
- created_at: '2026-08-01T21:07:54.329Z'
- updated_at: '2026-08-01T21:09:47.048Z'
+ created_at: '2026-08-05T10:42:48.517Z'
+ updated_at: '2026-08-05T10:43:03.584Z'
url: http://www.example.com:3000
api_url: http://www.example.com:3000
setup_tasks:
@@ -19244,7 +19211,7 @@ paths:
error:
code: invalid_taggable_type
message: taggable_type must be one of Spree::Product, Spree::Order,
- Spree::LegacyUser
+ Spree::Customer
"/api/v3/admin/translatable_resources":
get:
summary: List translatable resources
@@ -19496,14 +19463,14 @@ paths:
application/json:
example:
data:
- - id: admin_UkLWZg9DAJ
- first_name: Karri
- last_name: Zboncak
- full_name: Karri Zboncak
+ - id: adm_UkLWZg9DAJ
+ first_name: Jazmin
+ last_name: Toy
+ full_name: Jazmin Toy
selected_locale:
- created_at: '2026-08-01T21:07:54.728Z'
- updated_at: '2026-08-01T21:07:54.728Z'
+ created_at: '2026-08-05T10:42:48.675Z'
+ updated_at: '2026-08-05T10:42:48.675Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -19568,14 +19535,14 @@ paths:
content:
application/json:
example:
- id: admin_UkLWZg9DAJ
- first_name: Rhona
- last_name: Pfannerstill
- full_name: Rhona Pfannerstill
+ id: adm_UkLWZg9DAJ
+ first_name: Hildegard
+ last_name: Rice
+ full_name: Hildegard Rice
selected_locale:
- created_at: '2026-08-01T21:07:55.082Z'
- updated_at: '2026-08-01T21:07:55.082Z'
+ created_at: '2026-08-05T10:42:48.760Z'
+ updated_at: '2026-08-05T10:42:48.760Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -19635,14 +19602,14 @@ paths:
content:
application/json:
example:
- id: admin_UkLWZg9DAJ
+ id: adm_UkLWZg9DAJ
first_name: Renamed
- last_name: Kuphal
- full_name: Renamed Kuphal
+ last_name: Gulgowski
+ full_name: Renamed Gulgowski
selected_locale:
- created_at: '2026-08-01T21:07:55.392Z'
- updated_at: '2026-08-01T21:07:55.414Z'
+ created_at: '2026-08-05T10:42:48.784Z'
+ updated_at: '2026-08-05T10:42:48.801Z'
avatar_url:
roles:
- id: role_UkLWZg9DAJ
@@ -19758,15 +19725,15 @@ paths:
example:
data:
- id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-08-01T21:08:40.539Z'
- updated_at: '2026-08-01T21:08:40.539Z'
- expires_at: '2026-08-15T21:08:40.537Z'
+ created_at: '2026-08-05T10:42:53.106Z'
+ updated_at: '2026-08-05T10:42:53.106Z'
+ expires_at: '2026-08-19T10:42:53.101Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=u9JMqhoWJx3mD59yAvPUfJwp"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=kfDsqFwZGH2yTNCLY6QBw7mH"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
@@ -19830,13 +19797,13 @@ paths:
id: inv_gbHJdmfrXB
status: pending
- created_at: '2026-08-01T21:08:40.841Z'
- updated_at: '2026-08-01T21:08:40.841Z'
- expires_at: '2026-08-15T21:08:40.839Z'
+ created_at: '2026-08-05T10:42:53.180Z'
+ updated_at: '2026-08-05T10:42:53.180Z'
+ expires_at: '2026-08-19T10:42:53.176Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=mAG6YeQ42gssENN8hLWP7TZk"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=UtPkHp98BdXZYvE356ge94Ym"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
@@ -19949,15 +19916,15 @@ paths:
application/json:
example:
id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-08-01T21:08:41.395Z'
- updated_at: '2026-08-01T21:08:41.395Z'
- expires_at: '2026-08-15T21:08:41.393Z'
+ created_at: '2026-08-05T10:42:53.247Z'
+ updated_at: '2026-08-05T10:42:53.247Z'
+ expires_at: '2026-08-19T10:42:53.245Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=htkhCQ4EsXN2cqot5bk44PCg"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=GMbcnXrRWBCwJHxdQVy7kujL"
invitee_exists: false
store:
id: store_UkLWZg9DAJ
@@ -20009,8 +19976,8 @@ paths:
data:
- id: role_UkLWZg9DAJ
name: admin
- created_at: '2026-08-01T21:09:43.043Z'
- updated_at: '2026-08-01T21:09:43.043Z'
+ created_at: '2026-08-05T10:43:03.155Z'
+ updated_at: '2026-08-05T10:43:03.155Z'
meta:
page: 1
limit: 25
@@ -20148,8 +20115,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-08-01T21:09:43.323Z'
- updated_at: '2026-08-01T21:09:43.323Z'
+ created_at: '2026-08-05T10:43:03.178Z'
+ updated_at: '2026-08-05T10:43:03.178Z'
meta:
page: 1
limit: 25
@@ -20263,8 +20230,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 30
pickup_instructions:
- created_at: '2026-08-01T21:09:43.898Z'
- updated_at: '2026-08-01T21:09:43.898Z'
+ created_at: '2026-08-05T10:43:03.234Z'
+ updated_at: '2026-08-05T10:43:03.234Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -20441,8 +20408,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-08-01T21:09:44.187Z'
- updated_at: '2026-08-01T21:09:44.187Z'
+ created_at: '2026-08-05T10:43:03.270Z'
+ updated_at: '2026-08-05T10:43:03.270Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'404':
@@ -20531,8 +20498,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 45
pickup_instructions:
- created_at: '2026-08-01T21:09:44.749Z'
- updated_at: '2026-08-01T21:09:45.022Z'
+ created_at: '2026-08-05T10:43:03.321Z'
+ updated_at: '2026-08-05T10:43:03.337Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -20775,14 +20742,14 @@ paths:
dimensions_unit:
backorder_limit:
deleted_at:
- created_at: '2026-08-01T21:09:49.357Z'
- updated_at: '2026-08-01T21:09:49.367Z'
+ created_at: '2026-08-05T10:43:03.792Z'
+ updated_at: '2026-08-05T10:43:03.801Z'
preorderable: false
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 968882
+ product_name: Product 963396
- id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
sku: SKU-116
@@ -20795,10 +20762,10 @@ paths:
in_stock: false
backorderable: true
preorder: false
- weight: 92.16
- height: 139.42
- width: 11.68
- depth: 84.32
+ weight: 5.7
+ height: 130.23
+ width: 100.0
+ depth: 108.94
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -20821,8 +20788,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:49.383Z'
- updated_at: '2026-08-01T21:09:49.383Z'
+ created_at: '2026-08-05T10:43:03.815Z'
+ updated_at: '2026-08-05T10:43:03.815Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -20832,14 +20799,14 @@ paths:
dimensions_unit:
backorder_limit:
deleted_at:
- created_at: '2026-08-01T21:09:49.380Z'
- updated_at: '2026-08-01T21:09:49.391Z'
+ created_at: '2026-08-05T10:43:03.812Z'
+ updated_at: '2026-08-05T10:43:03.822Z'
preorderable: false
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 968882
+ product_name: Product 963396
meta:
page: 1
limit: 25
@@ -20953,8 +20920,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:50.073Z'
- updated_at: '2026-08-01T21:09:50.073Z'
+ created_at: '2026-08-05T10:43:03.944Z'
+ updated_at: '2026-08-05T10:43:03.944Z'
metadata: {}
position: 3
cost_price:
@@ -20964,14 +20931,14 @@ paths:
dimensions_unit:
backorder_limit:
deleted_at:
- created_at: '2026-08-01T21:09:50.077Z'
- updated_at: '2026-08-01T21:09:50.079Z'
+ created_at: '2026-08-05T10:43:03.948Z'
+ updated_at: '2026-08-05T10:43:03.950Z'
preorderable: false
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 975990
+ product_name: Product 97453
'422':
description: validation error
content:
@@ -21158,10 +21125,10 @@ paths:
in_stock: false
backorderable: true
preorder: false
- weight: 54.26
- height: 192.8
- width: 31.45
- depth: 56.96
+ weight: 45.74
+ height: 137.54
+ width: 46.81
+ depth: 18.38
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -21184,8 +21151,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:50.515Z'
- updated_at: '2026-08-01T21:09:50.515Z'
+ created_at: '2026-08-05T10:43:04.093Z'
+ updated_at: '2026-08-05T10:43:04.093Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -21195,14 +21162,14 @@ paths:
dimensions_unit:
backorder_limit:
deleted_at:
- created_at: '2026-08-01T21:09:50.512Z'
- updated_at: '2026-08-01T21:09:50.523Z'
+ created_at: '2026-08-05T10:43:04.090Z'
+ updated_at: '2026-08-05T10:43:04.100Z'
preorderable: false
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 997720
+ product_name: Product 9911
'404':
description: variant not found
content:
@@ -21286,10 +21253,10 @@ paths:
in_stock: false
backorderable: true
preorder: false
- weight: 69.66
- height: 20.72
- width: 53.57
- depth: 152.49
+ weight: 52.84
+ height: 67.77
+ width: 66.97
+ depth: 108.6
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -21312,8 +21279,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-08-01T21:09:51.282Z'
- updated_at: '2026-08-01T21:09:51.282Z'
+ created_at: '2026-08-05T10:43:04.238Z'
+ updated_at: '2026-08-05T10:43:04.238Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -21323,14 +21290,14 @@ paths:
dimensions_unit:
backorder_limit:
deleted_at:
- created_at: '2026-08-01T21:09:51.277Z'
- updated_at: '2026-08-01T21:09:51.579Z'
+ created_at: '2026-08-05T10:43:04.236Z'
+ updated_at: '2026-08-05T10:43:04.262Z'
preorderable: false
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 1018747
+ product_name: Product 1017534
requestBody:
content:
application/json:
@@ -21575,9 +21542,9 @@ paths:
request_errors:
response_body:
success: false
- created_at: '2026-08-01T21:09:51.967Z'
- updated_at: '2026-08-01T21:09:51.967Z'
- delivered_at: '2026-08-01T21:09:51.967Z'
+ created_at: '2026-08-05T10:43:04.401Z'
+ updated_at: '2026-08-05T10:43:04.401Z'
+ delivered_at: '2026-08-05T10:43:04.401Z'
payload:
event: order.created
data:
@@ -21593,9 +21560,9 @@ paths:
request_errors:
response_body:
success: true
- created_at: '2026-08-01T21:09:51.966Z'
- updated_at: '2026-08-01T21:09:51.966Z'
- delivered_at: '2026-08-01T21:09:51.966Z'
+ created_at: '2026-08-05T10:43:04.400Z'
+ updated_at: '2026-08-05T10:43:04.400Z'
+ delivered_at: '2026-08-05T10:43:04.400Z'
payload:
event: order.created
data:
@@ -21698,9 +21665,9 @@ paths:
request_errors:
response_body:
success: false
- created_at: '2026-08-01T21:09:52.943Z'
- updated_at: '2026-08-01T21:09:52.943Z'
- delivered_at: '2026-08-01T21:09:52.943Z'
+ created_at: '2026-08-05T10:43:04.584Z'
+ updated_at: '2026-08-05T10:43:04.584Z'
+ delivered_at: '2026-08-05T10:43:04.584Z'
payload:
event: order.created
data:
@@ -21789,8 +21756,8 @@ paths:
request_errors:
response_body:
success:
- created_at: '2026-08-01T21:09:53.940Z'
- updated_at: '2026-08-01T21:09:53.940Z'
+ created_at: '2026-08-05T10:43:04.802Z'
+ updated_at: '2026-08-05T10:43:04.802Z'
delivered_at:
payload:
event: order.created
@@ -21893,8 +21860,8 @@ paths:
- order.completed
- product.created
disabled_reason:
- created_at: '2026-08-01T21:09:54.015Z'
- updated_at: '2026-08-01T21:09:54.015Z'
+ created_at: '2026-08-05T10:43:04.838Z'
+ updated_at: '2026-08-05T10:43:04.838Z'
disabled_at:
secret_key:
last_delivery_at:
@@ -21989,10 +21956,10 @@ paths:
subscriptions:
- order.placed
disabled_reason:
- created_at: '2026-08-01T21:09:54.703Z'
- updated_at: '2026-08-01T21:09:54.703Z'
+ created_at: '2026-08-05T10:43:05.008Z'
+ updated_at: '2026-08-05T10:43:05.008Z'
disabled_at:
- secret_key: 69cd449535f507631deb19b430e9d92148a98d9bdf69a1ca1c614ff0a60db19b
+ secret_key: fa141c927d5d2405a0092b2718c64fb8ee37dcfb42b47893743d8c6c89f07f98
last_delivery_at:
recent_delivery_count: 0
recent_failure_count: 0
@@ -22115,8 +22082,8 @@ paths:
- order.completed
- product.created
disabled_reason:
- created_at: '2026-08-01T21:09:55.231Z'
- updated_at: '2026-08-01T21:09:55.231Z'
+ created_at: '2026-08-05T10:43:05.099Z'
+ updated_at: '2026-08-05T10:43:05.099Z'
disabled_at:
secret_key:
last_delivery_at:
@@ -22195,8 +22162,8 @@ paths:
- order.completed
- product.created
disabled_reason:
- created_at: '2026-08-01T21:09:55.891Z'
- updated_at: '2026-08-01T21:09:56.173Z'
+ created_at: '2026-08-05T10:43:05.318Z'
+ updated_at: '2026-08-05T10:43:05.348Z'
disabled_at:
secret_key:
last_delivery_at:
@@ -22353,17 +22320,17 @@ paths:
request_errors:
response_body:
success:
- created_at: '2026-08-01T21:09:57.256Z'
- updated_at: '2026-08-01T21:09:57.256Z'
+ created_at: '2026-08-05T10:43:05.514Z'
+ updated_at: '2026-08-05T10:43:05.514Z'
delivered_at:
payload:
- id: 478ffca9-5c04-4401-9b8c-6e2ee8d8561e
+ id: 30d8e3c5-3fe2-452d-b3d7-b6007b9585c3
name: webhook.test
- created_at: '2026-08-01T21:09:57Z'
+ created_at: '2026-08-05T10:43:05Z'
data:
message: This is a test webhook from Spree.
metadata:
- spree_version: 5.6.1
+ spree_version: 6.0.0.alpha
webhook_endpoint_id: whe_UkLWZg9DAJ
webhook_endpoint_url: https://shop.example.com/webhooks/orders
"/api/v3/admin/webhook_endpoints/{id}/enable":
@@ -22428,8 +22395,8 @@ paths:
- order.completed
- product.created
disabled_reason:
- created_at: '2026-08-01T21:09:57.286Z'
- updated_at: '2026-08-01T21:09:57.568Z'
+ created_at: '2026-08-05T10:43:05.552Z'
+ updated_at: '2026-08-05T10:43:05.573Z'
disabled_at:
secret_key:
last_delivery_at:
@@ -22506,9 +22473,9 @@ paths:
- order.completed
- product.created
disabled_reason: Investigating
- created_at: '2026-08-01T21:09:57.710Z'
- updated_at: '2026-08-01T21:09:57.999Z'
- disabled_at: '2026-08-01T21:09:57.999Z'
+ created_at: '2026-08-05T10:43:05.612Z'
+ updated_at: '2026-08-05T10:43:05.630Z'
+ disabled_at: '2026-08-05T10:43:05.630Z'
secret_key:
last_delivery_at:
recent_delivery_count: 0
@@ -22591,8 +22558,8 @@ paths:
automatic: false
rules_match_policy: all
metadata: {}
- created_at: '2026-08-01T21:08:07.835Z'
- updated_at: '2026-08-01T21:08:07.835Z'
+ created_at: '2026-08-05T10:42:50.249Z'
+ updated_at: '2026-08-05T10:42:50.249Z'
rules: []
meta:
page: 1
@@ -22661,8 +22628,8 @@ paths:
automatic: true
rules_match_policy: any
metadata: {}
- created_at: '2026-08-01T21:08:08.424Z'
- updated_at: '2026-08-01T21:08:08.426Z'
+ created_at: '2026-08-05T10:42:50.304Z'
+ updated_at: '2026-08-05T10:42:50.306Z'
rules:
- id: crule_UkLWZg9DAJ
type: Spree::CollectionRules::Tag
@@ -22794,8 +22761,8 @@ paths:
automatic: false
rules_match_policy: all
metadata: {}
- created_at: '2026-08-01T21:08:08.737Z'
- updated_at: '2026-08-01T21:08:08.737Z'
+ created_at: '2026-08-05T10:42:50.386Z'
+ updated_at: '2026-08-05T10:42:50.386Z'
rules: []
schema:
"$ref": "#/components/schemas/Collection"
@@ -22860,8 +22827,8 @@ paths:
automatic: false
rules_match_policy: all
metadata: {}
- created_at: '2026-08-01T21:08:09.315Z'
- updated_at: '2026-08-01T21:08:09.600Z'
+ created_at: '2026-08-05T10:42:50.482Z'
+ updated_at: '2026-08-05T10:42:50.501Z'
rules: []
schema:
"$ref": "#/components/schemas/Collection"
@@ -23037,8 +23004,8 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 66030
- slug: product-66030
+ name: Product 62108
+ slug: product-62108
meta_title:
meta_description:
meta_keywords:
@@ -23050,29 +23017,16 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Dicta tempore beatae laudantium itaque voluptate. Omnis
- cum id quidem iure corporis eligendi consequuntur. Officiis repudiandae
- ipsum eligendi excepturi fugiat pariatur expedita. Sit reiciendis
- dolor natus culpa perferendis minima. Sint ullam eos aperiam autem
- accusantium praesentium. Est animi et eaque qui dolor veniam aliquid.
- Dignissimos ratione exercitationem reprehenderit possimus commodi
- eum. Sit impedit suscipit aperiam voluptatem veniam. Quo repellendus
- magnam doloribus possimus. Commodi enim voluptates totam nihil temporibus
- sit saepe optio. Alias possimus beatae velit reiciendis enim minima
- itaque. Molestias eligendi qui ipsam magni ipsum fuga dolorem natus.
- Laboriosam fugit ullam quibusdam excepturi assumenda cum. Assumenda
- officiis veniam repellendus dolores. Illo nulla voluptatum fugit
- incidunt odit eius sit dolore. Maxime hic consequuntur deleniti
- illo illum numquam accusantium at. Nemo animi suscipit quas quibusdam
- quo. Quia hic aperiam perspiciatis occaecati incidunt ut. Quam libero
- in odio dolore error nam magni. Ratione ad repellendus magnam atque.
- Optio ad placeat quia esse.
- description_html: |-
- Dicta tempore beatae laudantium itaque voluptate. Omnis cum id quidem iure corporis eligendi consequuntur. Officiis repudiandae ipsum eligendi excepturi fugiat pariatur expedita. Sit reiciendis dolor natus culpa perferendis minima.
- Sint ullam eos aperiam autem accusantium praesentium. Est animi et eaque qui dolor veniam aliquid. Dignissimos ratione exercitationem reprehenderit possimus commodi eum. Sit impedit suscipit aperiam voluptatem veniam. Quo repellendus magnam doloribus possimus.
- Commodi enim voluptates totam nihil temporibus sit saepe optio. Alias possimus beatae velit reiciendis enim minima itaque. Molestias eligendi qui ipsam magni ipsum fuga dolorem natus. Laboriosam fugit ullam quibusdam excepturi assumenda cum.
- Assumenda officiis veniam repellendus dolores. Illo nulla voluptatum fugit incidunt odit eius sit dolore. Maxime hic consequuntur deleniti illo illum numquam accusantium at.
- Nemo animi suscipit quas quibusdam quo. Quia hic aperiam perspiciatis occaecati incidunt ut. Quam libero in odio dolore error nam magni. Ratione ad repellendus magnam atque. Optio ad placeat quia esse.
+ description: Sapiente aliquam porro ipsa quidem. Autem ea ipsa mollitia
+ perferendis quasi vero labore. Deserunt accusamus animi sit magnam
+ atque natus corrupti. Ex doloribus ducimus sapiente perferendis
+ sint sequi. Ducimus sapiente unde facere cumque voluptatem deserunt
+ officia.
+ description_html: Sapiente aliquam porro ipsa quidem. Autem ea ipsa
+ mollitia perferendis quasi vero labore. Deserunt accusamus animi
+ sit magnam atque natus corrupti. Ex doloribus ducimus sapiente perferendis
+ sint sequi. Ducimus sapiente unde facere cumque voluptatem deserunt
+ officia.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -23087,14 +23041,15 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-08-01T21:08:10.229Z'
- updated_at: '2026-08-01T21:08:10.229Z'
+ created_at: '2026-08-05T10:42:50.598Z'
+ updated_at: '2026-08-05T10:42:50.598Z'
original_price:
status: active
metadata: {}
deleted_at:
- created_at: '2026-08-01T21:08:10.215Z'
- updated_at: '2026-08-01T21:08:10.236Z'
+ created_at: '2026-08-05T10:42:50.587Z'
+ updated_at: '2026-08-05T10:42:50.605Z'
+ product_type_id:
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -23254,8 +23209,8 @@ paths:
pickup_point_provider:
storefront_visible: true
tracking_url:
- created_at: '2026-08-01T21:08:30.483Z'
- updated_at: '2026-08-01T21:08:30.484Z'
+ created_at: '2026-08-05T10:42:51.974Z'
+ updated_at: '2026-08-05T10:42:51.975Z'
deleted_at:
tax_category_id:
delivery_zone_ids: []
@@ -23334,8 +23289,8 @@ paths:
pickup_point_provider:
storefront_visible: true
tracking_url:
- created_at: '2026-08-01T21:08:31.054Z'
- updated_at: '2026-08-01T21:08:31.056Z'
+ created_at: '2026-08-05T10:42:52.022Z'
+ updated_at: '2026-08-05T10:42:52.023Z'
deleted_at:
tax_category_id:
delivery_zone_ids: []
@@ -23571,8 +23526,8 @@ paths:
country_iso: US
state_abbr:
state_name:
- created_at: '2026-08-01T21:08:31.636Z'
- updated_at: '2026-08-01T21:08:31.636Z'
+ created_at: '2026-08-05T10:42:52.088Z'
+ updated_at: '2026-08-05T10:42:52.088Z'
- id: dzm_gbHJdmfrXB
member_type: postal_code
postal_code_prefix: '10'
@@ -23581,10 +23536,10 @@ paths:
country_iso: US
state_abbr:
state_name:
- created_at: '2026-08-01T21:08:31.636Z'
- updated_at: '2026-08-01T21:08:31.636Z'
- created_at: '2026-08-01T21:08:31.635Z'
- updated_at: '2026-08-01T21:08:31.635Z'
+ created_at: '2026-08-05T10:42:52.088Z'
+ updated_at: '2026-08-05T10:42:52.088Z'
+ created_at: '2026-08-05T10:42:52.087Z'
+ updated_at: '2026-08-05T10:42:52.087Z'
delivery_method_ids: []
requestBody:
content:
@@ -24267,6 +24222,9 @@ components:
channel_id:
type: string
nullable: true
+ preferred_stock_location_id:
+ type: string
+ nullable: true
number:
type: string
token:
@@ -24402,6 +24360,7 @@ components:
- id
- market_id
- channel_id
+ - preferred_stock_location_id
- number
- token
- email
@@ -24590,6 +24549,159 @@ components:
- created_at
- updated_at
x-typelizer: true
+ ClaimLineItem:
+ type: object
+ properties:
+ id:
+ type: string
+ quantity:
+ type: number
+ send_replacement:
+ type: boolean
+ description:
+ type: string
+ nullable: true
+ refund_amount:
+ type: string
+ paid_amount:
+ type: string
+ display_refund_amount:
+ type: string
+ variant_id:
+ type: string
+ nullable: true
+ replacement_variant_id:
+ type: string
+ nullable: true
+ line_item_id:
+ type: string
+ nullable: true
+ variant:
+ "$ref": "#/components/schemas/Variant"
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ replacement_variant:
+ "$ref": "#/components/schemas/Variant"
+ required:
+ - id
+ - quantity
+ - send_replacement
+ - description
+ - refund_amount
+ - paid_amount
+ - display_refund_amount
+ - variant_id
+ - replacement_variant_id
+ - line_item_id
+ - created_at
+ - updated_at
+ x-typelizer: true
+ ClaimReason:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ active:
+ type: boolean
+ mutable:
+ type: boolean
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ can_be_deleted:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ - mutable
+ - created_at
+ - updated_at
+ - can_be_deleted
+ x-typelizer: true
+ Claim:
+ type: object
+ properties:
+ id:
+ type: string
+ number:
+ type: string
+ status:
+ type: string
+ claim_type:
+ type: string
+ resolution:
+ type: string
+ nullable: true
+ order_id:
+ type: string
+ nullable: true
+ reason_id:
+ type: string
+ nullable: true
+ refund_total:
+ type: string
+ display_refund_total:
+ type: string
+ approved_at:
+ type: string
+ nullable: true
+ resolved_at:
+ type: string
+ nullable: true
+ denied_at:
+ type: string
+ nullable: true
+ canceled_at:
+ type: string
+ nullable: true
+ claim_line_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/ClaimLineItem"
+ memo:
+ type: string
+ nullable: true
+ metadata:
+ type: object
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ created_by_id:
+ type: string
+ nullable: true
+ order:
+ "$ref": "#/components/schemas/Order"
+ refunds:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Refund"
+ required:
+ - id
+ - number
+ - status
+ - claim_type
+ - resolution
+ - order_id
+ - reason_id
+ - refund_total
+ - display_refund_total
+ - approved_at
+ - resolved_at
+ - denied_at
+ - canceled_at
+ - memo
+ - metadata
+ - created_at
+ - updated_at
+ - created_by_id
+ x-typelizer: true
CollectionRule:
type: object
properties:
@@ -24956,31 +25068,14 @@ components:
type: array
items:
"$ref": "#/components/schemas/CustomerGroup"
- login:
- type: string
- nullable: true
+ failed_attempts:
+ type: number
metadata:
type: object
- last_sign_in_at:
- type: string
- nullable: true
- current_sign_in_at:
- type: string
- nullable: true
created_at:
type: string
updated_at:
type: string
- sign_in_count:
- type: number
- failed_attempts:
- type: number
- last_sign_in_ip:
- type: string
- nullable: true
- current_sign_in_ip:
- type: string
- nullable: true
tags:
type: array
items:
@@ -25025,16 +25120,10 @@ components:
- full_name
- available_store_credit_total
- display_available_store_credit_total
- - login
+ - failed_attempts
- metadata
- - last_sign_in_at
- - current_sign_in_at
- created_at
- updated_at
- - sign_in_count
- - failed_attempts
- - last_sign_in_ip
- - current_sign_in_ip
- tags
- internal_note_html
- default_billing_address_id
@@ -25367,6 +25456,135 @@ components:
- created_at
- updated_at
x-typelizer: true
+ ExchangeLineItem:
+ type: object
+ properties:
+ id:
+ type: string
+ quantity:
+ type: number
+ received_quantity:
+ type: number
+ resellable:
+ type: boolean
+ original_price:
+ type: string
+ new_variant_price:
+ type: string
+ price_difference:
+ type: string
+ original_variant_id:
+ type: string
+ nullable: true
+ new_variant_id:
+ type: string
+ nullable: true
+ line_item_id:
+ type: string
+ nullable: true
+ fulfillment_item_id:
+ type: string
+ nullable: true
+ original_variant:
+ "$ref": "#/components/schemas/Variant"
+ new_variant:
+ "$ref": "#/components/schemas/Variant"
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ required:
+ - id
+ - quantity
+ - received_quantity
+ - resellable
+ - original_price
+ - new_variant_price
+ - price_difference
+ - original_variant_id
+ - new_variant_id
+ - line_item_id
+ - fulfillment_item_id
+ - created_at
+ - updated_at
+ x-typelizer: true
+ Exchange:
+ type: object
+ properties:
+ id:
+ type: string
+ number:
+ type: string
+ status:
+ type: string
+ order_id:
+ type: string
+ nullable: true
+ reason_id:
+ type: string
+ nullable: true
+ price_difference:
+ type: string
+ display_price_difference:
+ type: string
+ approved_at:
+ type: string
+ nullable: true
+ received_at:
+ type: string
+ nullable: true
+ fulfilled_at:
+ type: string
+ nullable: true
+ canceled_at:
+ type: string
+ nullable: true
+ exchange_line_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/ExchangeLineItem"
+ memo:
+ type: string
+ nullable: true
+ metadata:
+ type: object
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ stock_location_id:
+ type: string
+ nullable: true
+ created_by_id:
+ type: string
+ nullable: true
+ order:
+ "$ref": "#/components/schemas/Order"
+ stock_location:
+ "$ref": "#/components/schemas/StockLocation"
+ refunds:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Refund"
+ required:
+ - id
+ - number
+ - status
+ - order_id
+ - reason_id
+ - price_difference
+ - display_price_difference
+ - approved_at
+ - received_at
+ - fulfilled_at
+ - canceled_at
+ - memo
+ - metadata
+ - created_at
+ - updated_at
+ - stock_location_id
+ - created_by_id
+ x-typelizer: true
Export:
type: object
properties:
@@ -25449,6 +25667,36 @@ components:
- created_at
- updated_at
x-typelizer: true
+ FulfillmentItem:
+ type: object
+ properties:
+ id:
+ type: string
+ quantity:
+ type: number
+ status:
+ type: string
+ variant_id:
+ type: string
+ nullable: true
+ line_item_id:
+ type: string
+ nullable: true
+ name:
+ type: string
+ nullable: true
+ options_text:
+ type: string
+ nullable: true
+ required:
+ - id
+ - quantity
+ - status
+ - variant_id
+ - line_item_id
+ - name
+ - options_text
+ x-typelizer: true
Fulfillment:
type: object
properties:
@@ -25527,6 +25775,10 @@ components:
stock_location_id:
type: string
nullable: true
+ fulfillment_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/FulfillmentItem"
order:
"$ref": "#/components/schemas/Order"
required:
@@ -26440,14 +26692,18 @@ components:
"$ref": "#/components/schemas/Customer"
created_by:
"$ref": "#/components/schemas/Customer"
- return_authorizations:
+ returns:
type: array
items:
- "$ref": "#/components/schemas/ReturnAuthorization"
- reimbursements:
+ "$ref": "#/components/schemas/Return"
+ exchanges:
type: array
items:
- "$ref": "#/components/schemas/Reimbursement"
+ "$ref": "#/components/schemas/Exchange"
+ claims:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Claim"
required:
- id
- market_id
@@ -26994,6 +27250,9 @@ components:
type: string
updated_at:
type: string
+ product_type_id:
+ type: string
+ nullable: true
tax_category_id:
type: string
nullable: true
@@ -27032,8 +27291,34 @@ components:
- deleted_at
- created_at
- updated_at
+ - product_type_id
- tax_category_id
x-typelizer: true
+ ProductType:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ fulfillment_types:
+ type: array
+ items:
+ type: string
+ products_count:
+ type: number
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ required:
+ - id
+ - name
+ - fulfillment_types
+ - products_count
+ - created_at
+ - updated_at
+ x-typelizer: true
PromotionAction:
type: object
properties:
@@ -27234,6 +27519,32 @@ components:
- action_ids
- rule_ids
x-typelizer: true
+ RefundReason:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ active:
+ type: boolean
+ mutable:
+ type: boolean
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ can_be_deleted:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ - mutable
+ - created_at
+ - updated_at
+ - can_be_deleted
+ x-typelizer: true
Refund:
type: object
properties:
@@ -27251,7 +27562,10 @@ components:
refund_reason_id:
type: string
nullable: true
- reimbursement_id:
+ originator_id:
+ type: string
+ nullable: true
+ originator_type:
type: string
nullable: true
metadata:
@@ -27262,55 +27576,90 @@ components:
type: string
payment:
"$ref": "#/components/schemas/Payment"
- reimbursement:
- "$ref": "#/components/schemas/Reimbursement"
required:
- id
- transaction_id
- amount
- payment_id
- refund_reason_id
- - reimbursement_id
+ - originator_id
+ - originator_type
- metadata
- created_at
- updated_at
x-typelizer: true
- Reimbursement:
+ ReturnLineItem:
type: object
properties:
id:
type: string
- number:
+ quantity:
+ type: number
+ received_quantity:
+ type: number
+ resellable:
+ type: boolean
+ pre_tax_amount:
type: string
- reimbursement_status:
+ display_pre_tax_amount:
type: string
- nullable: true
- total:
+ variant_id:
type: string
nullable: true
- order_id:
+ line_item_id:
type: string
nullable: true
- customer_return_id:
+ fulfillment_item_id:
type: string
nullable: true
+ variant:
+ "$ref": "#/components/schemas/Variant"
created_at:
type: string
updated_at:
type: string
- order:
- "$ref": "#/components/schemas/Order"
+ line_item:
+ "$ref": "#/components/schemas/LineItem"
required:
- id
- - number
- - reimbursement_status
- - total
- - order_id
- - customer_return_id
+ - quantity
+ - received_quantity
+ - resellable
+ - pre_tax_amount
+ - display_pre_tax_amount
+ - variant_id
+ - line_item_id
+ - fulfillment_item_id
- created_at
- updated_at
x-typelizer: true
- ReturnAuthorization:
+ ReturnReason:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ active:
+ type: boolean
+ mutable:
+ type: boolean
+ created_at:
+ type: string
+ updated_at:
+ type: string
+ can_be_deleted:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ - mutable
+ - created_at
+ - updated_at
+ - can_be_deleted
+ x-typelizer: true
+ Return:
type: object
properties:
id:
@@ -27319,32 +27668,83 @@ components:
type: string
status:
type: string
+ return_label_url:
+ type: string
+ nullable: true
order_id:
type: string
nullable: true
- stock_location_id:
+ reason_id:
type: string
nullable: true
- return_authorization_reason_id:
+ refund_total:
+ type: string
+ display_refund_total:
+ type: string
+ approved_at:
+ type: string
+ nullable: true
+ received_at:
+ type: string
+ nullable: true
+ refunded_at:
+ type: string
+ nullable: true
+ canceled_at:
type: string
nullable: true
+ return_line_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/ReturnLineItem"
+ memo:
+ type: string
+ nullable: true
+ metadata:
+ type: object
created_at:
type: string
updated_at:
type: string
+ stock_location_id:
+ type: string
+ nullable: true
+ created_by_id:
+ type: string
+ nullable: true
+ refunded_total:
+ type: string
+ refundable_total:
+ type: string
order:
"$ref": "#/components/schemas/Order"
stock_location:
"$ref": "#/components/schemas/StockLocation"
+ refunds:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Refund"
required:
- id
- number
- status
+ - return_label_url
- order_id
- - stock_location_id
- - return_authorization_reason_id
+ - reason_id
+ - refund_total
+ - display_refund_total
+ - approved_at
+ - received_at
+ - refunded_at
+ - canceled_at
+ - memo
+ - metadata
- created_at
- updated_at
+ - stock_location_id
+ - created_by_id
+ - refunded_total
+ - refundable_total
x-typelizer: true
Role:
type: object
diff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yaml
index f73bff88f8..8521e39ae5 100644
--- a/docs/api-reference/store.yaml
+++ b/docs/api-reference/store.yaml
@@ -87,16 +87,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImNiNmExMDhjLWU0MDgtNDYwZC1hY2Q2LWM3ZjBkMzJhYmI3YiIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1Njg5NTQwfQ.Kf0_wruSOfek_CzG54sWQkMQKYydm69S_sSuqW41rKY
- refresh_token: 7ZvuLmhuiz39K2yy6GeD95ka
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImM4MTczZmY3LTZjYzctNGE2NC1iMjkzLTJmZDEyZjE1ZjhiNSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1OTMwMTg1fQ.tuGEcNlbFIZtyek1WJLJ4e5UT319k07pC7159-cl_fI
+ refresh_token: rW9BFN4fi877FatJqqupKxvG
user:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
- first_name: Wilbur
- last_name: Anderson
+ first_name: Anamaria
+ last_name: Wiza
phone:
accepts_email_marketing: false
- full_name: Wilbur Anderson
+ full_name: Anamaria Wiza
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
addresses: []
@@ -194,16 +194,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6IjRjMmM0ZmJjLWE0OGUtNDcyMi04NzA1LTNiZjkyYzI0ZGE5ZSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1Njg5NTQxfQ.-h7xkGieDvKHg4YEzxHOVfHFY10a0nRzheeOdPDNf78
- refresh_token: 2zG2gncedPHeHaRu7xCWJ9x9
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImFiODIyMDA1LTcyZDMtNDM4MC04ZTkxLWE2OWU2ODA2MDRjMiIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1OTMwMTg1fQ.OLtKSDLS8pyjKZ_2XbfYqdZSrpjZpdhVJgZwUhdgmEo
+ refresh_token: LLHRUCGnpq6pJTfC2EXGg2gc
user:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
- first_name: Sharri
- last_name: Bartoletti
+ first_name: Frieda
+ last_name: Welch
phone:
accepts_email_marketing: false
- full_name: Sharri Bartoletti
+ full_name: Frieda Welch
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
addresses: []
@@ -393,16 +393,16 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImU5ZGI3OTUzLWMyZjEtNGVjMC1iZjYzLWVmMzNmN2E2MWM2NyIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1Njg5NTU0fQ.sIIkYyUUxv24SPNgnVGnqZ2jC0UsF4YwV1GDq9GlYRc
- refresh_token: uSCGGTtw72n1tjoUAgqBeFp2
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6Ijg4MGE3YzUxLWI0ZDMtNGVmMy1iYjVjLTMxMjM0Y2U3OTdlNyIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1OTMwMTg5fQ.ysLT8qakDl1X19WwCxDfQ54pNojXcvrSXxFjmh5Z2Pk
+ refresh_token: XtRLzbnweGCswmwF1pAZfHY9
user:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
- first_name: Cleotilde
- last_name: Becker
+ first_name: Salvador
+ last_name: Halvorson
phone:
accepts_email_marketing: false
- full_name: Cleotilde Becker
+ full_name: Salvador Halvorson
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
addresses: []
@@ -879,8 +879,8 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 1296942
- slug: product-1296942
+ name: Product 1294749
+ slug: product-1294749
meta_title:
meta_description:
meta_keywords:
@@ -892,21 +892,23 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Blanditiis nesciunt laborum voluptatibus voluptas voluptate.
- Debitis voluptatibus consequuntur error assumenda totam doloremque.
- Maxime fugit tempore cupiditate ipsam earum voluptas aperiam nemo.
- Saepe mollitia fugit iure minus neque iste quam. Error nam sequi
- repellendus necessitatibus sit. Ipsum deleniti labore amet culpa.
- Totam aut neque quibusdam maxime nihil magni laboriosam molestias.
- Incidunt architecto quibusdam atque accusantium veniam perspiciatis
- recusandae nisi. Nam temporibus in odio harum atque suscipit fugiat.
- Placeat pariatur laboriosam voluptates fuga. Ut accusantium saepe
- architecto aperiam. Necessitatibus nesciunt enim atque quia. Quos
- voluptas eveniet quasi labore.
+ description: Minima soluta omnis voluptas explicabo. Pariatur cupiditate
+ soluta eveniet ad. Nisi dignissimos alias id porro. Tempore quibusdam
+ quam praesentium optio dolore cumque. Repellendus atque illum
+ doloribus debitis aliquid corporis numquam dolor. Velit provident
+ illo vero maxime. Aspernatur ab facere quas dolor. Quisquam provident
+ quibusdam corrupti ipsa earum eos. Sit consequatur error maxime
+ ad. Ipsum nobis deserunt reiciendis exercitationem mollitia sapiente.
+ Quis accusantium fugit nesciunt delectus ab. A eos eveniet quia
+ non adipisci hic esse laborum. Commodi quos ratione perspiciatis
+ tempora. Delectus quos voluptates nisi est. Iste distinctio nihil
+ sequi officiis fugit voluptas. A cupiditate possimus delectus
+ ullam culpa quidem.
description_html: |-
- Blanditiis nesciunt laborum voluptatibus voluptas voluptate. Debitis voluptatibus consequuntur error assumenda totam doloremque. Maxime fugit tempore cupiditate ipsam earum voluptas aperiam nemo. Saepe mollitia fugit iure minus neque iste quam. Error nam sequi repellendus necessitatibus sit.
- Ipsum deleniti labore amet culpa. Totam aut neque quibusdam maxime nihil magni laboriosam molestias. Incidunt architecto quibusdam atque accusantium veniam perspiciatis recusandae nisi. Nam temporibus in odio harum atque suscipit fugiat. Placeat pariatur laboriosam voluptates fuga.
- Ut accusantium saepe architecto aperiam. Necessitatibus nesciunt enim atque quia. Quos voluptas eveniet quasi labore.
+ Minima soluta omnis voluptas explicabo. Pariatur cupiditate soluta eveniet ad. Nisi dignissimos alias id porro. Tempore quibusdam quam praesentium optio dolore cumque.
+ Repellendus atque illum doloribus debitis aliquid corporis numquam dolor. Velit provident illo vero maxime. Aspernatur ab facere quas dolor.
+ Quisquam provident quibusdam corrupti ipsa earum eos. Sit consequatur error maxime ad. Ipsum nobis deserunt reiciendis exercitationem mollitia sapiente. Quis accusantium fugit nesciunt delectus ab.
+ A eos eveniet quia non adipisci hic esse laborum. Commodi quos ratione perspiciatis tempora. Delectus quos voluptates nisi est. Iste distinctio nihil sequi officiis fugit voluptas. A cupiditate possimus delectus ullam culpa quidem.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -1061,8 +1063,8 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 1718168
- slug: product-1718168
+ name: Product 1717680
+ slug: product-1717680
meta_title:
meta_description:
meta_keywords:
@@ -1091,8 +1093,8 @@ paths:
price_list_id:
original_price:
- id: prod_gbHJdmfrXB
- name: Product 1725738
- slug: product-1725738
+ name: Product 1726285
+ slug: product-1726285
meta_title:
meta_description:
meta_keywords:
@@ -1104,24 +1106,22 @@ paths:
in_stock: false
backorderable: true
available: true
- description: Tempora esse nulla dolorum earum labore ipsa culpa.
- Id dolorem minus assumenda ut. Ipsa iste nostrum quia veniam eveniet
- qui expedita nobis. Velit neque fugit odio modi fuga. Illum atque
- tenetur culpa ducimus maiores earum voluptatum odio. Cumque facilis
- a eos quis maxime provident sunt. Nobis ratione architecto et
- doloremque adipisci. Veritatis architecto eveniet quibusdam tenetur
- eius aspernatur quaerat. Repellendus velit dolorem deleniti alias
- hic pariatur illum. Veritatis impedit voluptate nulla quis saepe.
- Itaque maxime sed pariatur mollitia impedit. Voluptate vero quidem
- qui omnis natus. Officia quibusdam delectus nemo ipsum quo aliquid
- voluptatum. Doloremque consequuntur ea voluptatem dignissimos.
- Quos unde suscipit quasi quae ipsam. Iusto aperiam praesentium
- earum deleniti est maiores. Esse qui dignissimos commodi eos.
+ description: Placeat libero accusamus deserunt voluptatem exercitationem
+ maiores odio nobis. Reiciendis dolores doloremque quos officia
+ blanditiis. Asperiores in occaecati sed perspiciatis porro accusantium
+ minus placeat. Occaecati a aut voluptatibus eum exercitationem
+ repellat harum quod. Quis est expedita sit dolorem dolorum magnam
+ saepe illum. Quaerat ipsa et illum harum. Fuga numquam harum officiis
+ a dolorem quis ratione sed. Consectetur exercitationem perferendis
+ cumque ea veniam. Id ducimus debitis nihil iusto. Libero molestiae
+ quam doloremque sint inventore. Inventore reiciendis asperiores
+ ex eaque incidunt corrupti nemo placeat. Assumenda perferendis
+ quam id aliquam nostrum architecto laboriosam. Reiciendis ipsam
+ atque unde qui quo veritatis optio.
description_html: |-
- Tempora esse nulla dolorum earum labore ipsa culpa. Id dolorem minus assumenda ut. Ipsa iste nostrum quia veniam eveniet qui expedita nobis. Velit neque fugit odio modi fuga. Illum atque tenetur culpa ducimus maiores earum voluptatum odio.
- Cumque facilis a eos quis maxime provident sunt. Nobis ratione architecto et doloremque adipisci. Veritatis architecto eveniet quibusdam tenetur eius aspernatur quaerat. Repellendus velit dolorem deleniti alias hic pariatur illum. Veritatis impedit voluptate nulla quis saepe.
- Itaque maxime sed pariatur mollitia impedit. Voluptate vero quidem qui omnis natus. Officia quibusdam delectus nemo ipsum quo aliquid voluptatum. Doloremque consequuntur ea voluptatem dignissimos.
- Quos unde suscipit quasi quae ipsam. Iusto aperiam praesentium earum deleniti est maiores. Esse qui dignissimos commodi eos.
+ Placeat libero accusamus deserunt voluptatem exercitationem maiores odio nobis. Reiciendis dolores doloremque quos officia blanditiis. Asperiores in occaecati sed perspiciatis porro accusantium minus placeat. Occaecati a aut voluptatibus eum exercitationem repellat harum quod.
+ Quis est expedita sit dolorem dolorum magnam saepe illum. Quaerat ipsa et illum harum. Fuga numquam harum officiis a dolorem quis ratione sed. Consectetur exercitationem perferendis cumque ea veniam.
+ Id ducimus debitis nihil iusto. Libero molestiae quam doloremque sint inventore. Inventore reiciendis asperiores ex eaque incidunt corrupti nemo placeat. Assumenda perferendis quam id aliquam nostrum architecto laboriosam. Reiciendis ipsam atque unde qui quo veritatis optio.
default_variant_id: variant_EfhxLZ9ck8
thumbnail_url:
tags: []
@@ -1223,8 +1223,8 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 1992472
- slug: product-1992472
+ name: Product 1997343
+ slug: product-1997343
meta_title:
meta_description:
meta_keywords:
@@ -1258,7 +1258,7 @@ paths:
amount_in_cents: 999
currency: USD
display_amount: "$9.99"
- recorded_at: '2026-07-18T15:53:13Z'
+ recorded_at: '2026-07-21T10:43:15Z'
schema:
"$ref": "#/components/schemas/Product"
'404':
@@ -1508,7 +1508,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_gbHJdmfrXB
- token: M8ZCMLQqoQuxuwp9ejYcHwaM
+ token: w8Fm8Lo8Bg31czAjpD2UhQkJ
email:
customer_note:
currency: USD
@@ -1567,8 +1567,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1043676
- slug: product-1043676
+ name: Product 1042166
+ slug: product-1042166
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -1613,7 +1613,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: YacMCCRLwubB7A1efKsJLQiV
+ token: p9fUiprk3koG3xhPpExmhBup
email:
customer_note:
currency: USD
@@ -1672,8 +1672,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1032165
- slug: product-1032165
+ name: Product 1031431
+ slug: product-1031431
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -1791,7 +1791,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: jeF9EAJtimKwRY3ZNZjioqrC
+ token: JuWt7BKYHvMXxGeia3DYmpFY
email:
customer_note:
currency: USD
@@ -1956,7 +1956,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: xKE2yijxuYf7LKfEkUQ7QepM
+ token: Ln4WEKaFb5mDJRQjc3YLp3cL
email:
customer_note:
currency: USD
@@ -1964,7 +1964,7 @@ paths:
total_quantity: 0
warnings:
- code: line_item_removed
- message: Product 1084189 was removed because it was sold out
+ message: Product 1089265 was removed because it was sold out
line_item_id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
coupon_code:
@@ -2106,7 +2106,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: Qbf1sYyBXrJASA1oX3Smizjh
+ token: tukuqQHBx6MpSs2zqMwQ2XNJ
email:
customer_note: Leave at door
currency: USD
@@ -2161,8 +2161,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1096752
- slug: product-1096752
+ name: Product 109110
+ slug: product-109110
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -2381,8 +2381,8 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: W69Lk7NSMgJpQDSKZtjaYGpL
+ token: iy8quCEEXq2zfGo3XWsfNh5R
customer_note:
currency: USD
locale: en
@@ -2433,8 +2433,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1113151
- slug: product-1113151
+ name: Product 1113850
+ slug: product-1113850
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -2588,8 +2588,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id: cart_UkLWZg9DAJ
channel_id: ch_UkLWZg9DAJ
- number: R723930495
+ number: R800076412
customer_note:
currency: USD
locale: en
@@ -2597,7 +2597,7 @@ paths:
coupon_code:
fulfillment_status: backorder
payment_status: paid
- completed_at: '2026-08-02T15:52:26.477Z'
+ completed_at: '2026-08-05T10:43:06.899Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -2629,8 +2629,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1142075
- slug: product-1142075
+ name: Product 1142675
+ slug: product-1142675
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -2655,7 +2655,7 @@ paths:
digital_links: []
fulfillments:
- id: ful_gbHJdmfrXB
- number: F35697571850
+ number: F79116258792
tracking:
tracking_url:
pickup_point_data:
@@ -2689,7 +2689,7 @@ paths:
stock_location:
id: sloc_UkLWZg9DAJ
state_abbr: NY
- name: Cecilia Wolff
+ name: Kraig Graham
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
@@ -2721,8 +2721,8 @@ paths:
payments:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-c05fdddc07bd
- number: PS50A10G
+ response_code: BGS-73ef2bccbb29
+ number: PQ90B4N1
amount: '20.0'
display_amount: "$20.00"
status: completed
@@ -2878,7 +2878,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: Zdby4vYgmmgMzfoGwWFo2X5D
+ token: oQPe75GQHR1QkCY2eQGMQCvQ
email:
customer_note:
currency: USD
@@ -2936,8 +2936,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 140284
- slug: product-140284
+ name: Product 1403135
+ slug: product-1403135
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3066,7 +3066,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: b895qS1guEhczxpJaPnL1gAs
+ token: Bd4QvJs8quKACXtYLYZFjUEy
email:
customer_note:
currency: USD
@@ -3121,8 +3121,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1424036
- slug: product-1424036
+ name: Product 1421339
+ slug: product-1421339
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3240,8 +3240,8 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: ev7uws7dAHNdVD9iCeEwC95F
+ token: LkwXsmcZTtXHpjFXmHMfGDXh
customer_note:
currency: USD
locale: en
@@ -3289,8 +3289,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1443241
- slug: product-1443241
+ name: Product 1449731
+ slug: product-1449731
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3315,7 +3315,7 @@ paths:
digital_links: []
fulfillments:
- id: ful_UkLWZg9DAJ
- number: F96156119158
+ number: F33452401672
tracking:
tracking_url:
pickup_point_data:
@@ -3349,7 +3349,7 @@ paths:
stock_location:
id: sloc_UkLWZg9DAJ
state_abbr: NY
- name: Shawn Deckow
+ name: Forest Lebsack
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
@@ -3504,7 +3504,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: pUzi2ZKFBkY6HAdFqUXudMsr
+ token: Bk3Vn9foFka4iPkYy6DxbyrB
email:
customer_note:
currency: USD
@@ -3555,8 +3555,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1461925
- slug: product-1461925
+ name: Product 1468689
+ slug: product-1468689
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3583,8 +3583,8 @@ paths:
payments:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: 1-SC-20260802155247025534
- number: PKCSTMZV
+ response_code: 1-SC-20260805104310905567
+ number: PQUJ2XD1
amount: '10.0'
display_amount: "$10.00"
status: checkout
@@ -3740,7 +3740,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: DV1AEBmKcY6EHa2SEGT96LPb
+ token: BrRUjNxthTQM4UcuGbE7ifvD
email:
customer_note:
currency: USD
@@ -3795,8 +3795,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1503963
- slug: product-1503963
+ name: Product 1505232
+ slug: product-1505232
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3823,8 +3823,8 @@ paths:
payments:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: 1-SC-20260802155249558897
- number: PXJWX1K6
+ response_code: 1-SC-20260805104311200588
+ number: P29M2BGA
amount: '10.0'
display_amount: "$10.00"
status: invalid
@@ -3931,7 +3931,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: scCHtyUPv6EbMqf8RrQzQsWL
+ token: QS4B574xdKzDDUKk6MXE3Bm1
email:
customer_note:
currency: USD
@@ -3939,10 +3939,10 @@ paths:
total_quantity: 2
warnings:
- code: delivery_unavailable
- message: Product 1533455 cannot be delivered to the selected address
+ message: Product 1534661 cannot be delivered to the selected address
line_item_id: li_UkLWZg9DAJ
- code: delivery_unavailable
- message: Product 1544895 cannot be delivered to the selected address
+ message: Product 1541685 cannot be delivered to the selected address
line_item_id: li_gbHJdmfrXB
coupon_code:
item_total: '29.99'
@@ -3992,8 +3992,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1533455
- slug: product-1533455
+ name: Product 1534661
+ slug: product-1534661
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -4022,8 +4022,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1544895
- slug: product-1544895
+ name: Product 1541685
+ slug: product-1541685
options_text: ''
price: '19.99'
display_price: "$19.99"
@@ -4161,7 +4161,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: BFy2af9khZmgGjmjB9Rcgyv9
+ token: UwwF41Udf8XBGwPSqN6DK8qB
email:
customer_note:
currency: USD
@@ -4212,8 +4212,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 157125
- slug: product-157125
+ name: Product 157992
+ slug: product-157992
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -4331,7 +4331,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: DHW9eLpepbaQP6y2G1poDLuR
+ token: H2auNWJszidif3pnZtrS7UQQ
email:
customer_note:
currency: USD
@@ -4471,9 +4471,9 @@ paths:
id: ps_gbHJdmfrXB
status: pending
currency: USD
- external_id: bogus_9bafc6836694b545af8631e4
+ external_id: bogus_fd4347fbb51463da885e9815
external_data:
- client_secret: bogus_secret_4bf077ada4b9798e
+ client_secret: bogus_secret_83170bd64ac290cc
customer_external_id:
expires_at:
amount: '10.0'
@@ -4572,7 +4572,7 @@ paths:
id: ps_UkLWZg9DAJ
status: pending
currency: USD
- external_id: bogus_517198bad7366d11635637cd
+ external_id: bogus_da09dcc7ffb9cbc2cec7660c
external_data:
client_secret: secret_123
customer_external_id:
@@ -4635,7 +4635,7 @@ paths:
id: ps_UkLWZg9DAJ
status: pending
currency: USD
- external_id: bogus_93fdfd4312cced1d46ecf89d
+ external_id: bogus_69bf114a07d7f066dc19478a
external_data:
client_secret: secret_123
customer_external_id:
@@ -4738,7 +4738,7 @@ paths:
id: ps_UkLWZg9DAJ
status: completed
currency: USD
- external_id: bogus_64cbc509a0d2c624c09ba075
+ external_id: bogus_db193cde53dd25c7d0da3a27
external_data:
client_secret: secret_123
customer_external_id:
@@ -4837,7 +4837,7 @@ paths:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
response_code:
- number: PRE0CVBT
+ number: PEE069F9
amount: '10.0'
display_amount: "$10.00"
status: checkout
@@ -4946,7 +4946,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: XzSDDRewu7YWcnFbxRK1gZUX
+ token: S96iTwgT3D6BBwXd9itKkSg3
email:
customer_note:
currency: USD
@@ -4997,8 +4997,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 219654
- slug: product-219654
+ name: Product 2198214
+ slug: product-2198214
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -5025,8 +5025,8 @@ paths:
payments:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: 1-SC-20260802155318675007
- number: PIQG4YHH
+ response_code: 1-SC-20260805104316879194
+ number: PQ6B5ZHN
amount: '10.0'
display_amount: "$10.00"
status: checkout
@@ -5146,7 +5146,7 @@ paths:
channel_id: ch_UkLWZg9DAJ
preferred_stock_location_id:
number: cart_UkLWZg9DAJ
- token: wsQsrMWYnzGuMEw7xLbyJtjY
+ token: xvk9rN4TfzvN1mKryRKrAWFN
email:
customer_note:
currency: USD
@@ -5201,8 +5201,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 2212559
- slug: product-2212559
+ name: Product 2213312
+ slug: product-2213312
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -5317,7 +5317,7 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R346932621
+ number: R910257340
customer_note:
currency: USD
@@ -5326,7 +5326,7 @@ paths:
coupon_code:
fulfillment_status:
payment_status:
- completed_at: '2026-08-02T15:53:01.938Z'
+ completed_at: '2026-08-05T10:43:12.940Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -5358,8 +5358,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1616147
- slug: product-1616147
+ name: Product 16165
+ slug: product-16165
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -5384,7 +5384,7 @@ paths:
digital_links: []
fulfillments:
- id: ful_UkLWZg9DAJ
- number: F11951108951
+ number: F23516743067
tracking: U10000
tracking_url:
pickup_point_data:
@@ -5418,7 +5418,7 @@ paths:
stock_location:
id: sloc_UkLWZg9DAJ
state_abbr: NY
- name: Roy Zieme
+ name: Adriana Beer
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
@@ -6370,8 +6370,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R420642829
+ number: R533041032
customer_note:
currency: USD
locale: en
@@ -6379,7 +6379,7 @@ paths:
coupon_code:
fulfillment_status:
payment_status:
- completed_at: '2026-08-02T15:52:35.065Z'
+ completed_at: '2026-08-05T10:43:09.178Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -6411,8 +6411,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1303266
- slug: product-1303266
+ name: Product 1309765
+ slug: product-1309765
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -6437,7 +6437,7 @@ paths:
digital_links: []
fulfillments:
- id: ful_UkLWZg9DAJ
- number: F03224906213
+ number: F54225916586
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6471,7 +6471,7 @@ paths:
stock_location:
id: sloc_UkLWZg9DAJ
state_abbr: NY
- name: Marti Schoen
+ name: Kellye Quigley
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
@@ -6648,8 +6648,8 @@ paths:
market_id: mkt_UkLWZg9DAJ
cart_id:
channel_id: ch_UkLWZg9DAJ
- number: R343951215
+ number: R857213027
customer_note:
currency: USD
locale: en
@@ -6657,7 +6657,7 @@ paths:
coupon_code:
fulfillment_status:
payment_status:
- completed_at: '2026-08-02T15:52:36.278Z'
+ completed_at: '2026-08-05T10:43:09.454Z'
item_total: '10.0'
display_item_total: "$10.00"
adjustment_total: '0.0'
@@ -6689,8 +6689,8 @@ paths:
preorder_ships_at:
quantity: 1
currency: USD
- name: Product 1327942
- slug: product-1327942
+ name: Product 1326942
+ slug: product-1326942
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -6715,7 +6715,7 @@ paths:
digital_links: []
fulfillments:
- id: ful_UkLWZg9DAJ
- number: F14879759522
+ number: F51385428152
tracking: U10000
tracking_url:
pickup_point_data:
@@ -6749,7 +6749,7 @@ paths:
stock_location:
id: sloc_UkLWZg9DAJ
state_abbr: NY
- name: Thurman Mante
+ name: Lupe Smitham
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
@@ -6882,10 +6882,10 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6Ijc2MmMxZjE3LTlkYTUtNGI5NS05YTMzLTg2YmVhNzg0YmI3NSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1Njg5NTU4fQ.OUwdrG80xkRWcYOF29Hi7pFKNi_4P5YG-IMUTDn07j4
- refresh_token: kcxnihfMtLi3CoWGDAyTmzPD
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImEwMjE4OWQ4LTMzYWEtNGY5My05MDRiLTNmNmYxODM2NWYxNiIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzg1OTMwMTg5fQ.rekDFkulZU7U3nb_Gm5Yn81T8nB3wcnKhmq5rpyJkvU
+ refresh_token: X4YyRSJ2BuF4r6v2JZbLT5Py
user:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
first_name: John
last_name: Doe
@@ -6900,11 +6900,11 @@ paths:
newsletter_subscriber:
id: sub_UkLWZg9DAJ
- created_at: '2026-08-02T15:52:37.939Z'
- updated_at: '2026-08-02T15:52:37.940Z'
+ created_at: '2026-08-05T10:43:09.612Z'
+ updated_at: '2026-08-05T10:43:09.614Z'
verified: true
- verified_at: '2026-08-02T15:52:37Z'
- customer_id: cus_UkLWZg9DAJ
+ verified_at: '2026-08-05T10:43:09Z'
+ customer_id: cust_UkLWZg9DAJ
customer_groups: []
schema:
"$ref": "#/components/schemas/AuthResponse"
@@ -7005,13 +7005,13 @@ paths:
content:
application/json:
example:
- id: cus_UkLWZg9DAJ
- first_name: Suzi
- last_name: Murray
+ id: cust_UkLWZg9DAJ
+ first_name: Charlene
+ last_name: Schroeder
phone: 555-555-0199
accepts_email_marketing: false
- full_name: Suzi Murray
+ full_name: Charlene Schroeder
available_store_credit_total: '0'
display_available_store_credit_total: "$0.00"
addresses:
@@ -7146,8 +7146,8 @@ paths:
content:
application/json:
example:
- id: cus_UkLWZg9DAJ
+ id: cust_UkLWZg9DAJ
first_name: Updated
last_name: Name
phone: 555-555-0199
@@ -7338,7 +7338,7 @@ paths:
example:
data:
- id: gc_UkLWZg9DAJ
- code: 1D8F6731E0FC883B
+ code: 4553E89E3837C720
status: active
currency: USD
amount: '10.0'
@@ -7434,7 +7434,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 3BBF158BE9B1C5A7
+ code: D0F24E0C22653D77
status: active
currency: USD
amount: '10.0'
@@ -7506,13 +7506,13 @@ paths:
example:
id: pss_gbHJdmfrXB
status: pending
- external_id: bogus_seti_d9625a63ebe5532d4417b5fb
- external_client_secret: bogus_seti_secret_e2e52280f633bc71
+ external_id: bogus_seti_672888deb92cb1a9de7569f5
+ external_client_secret: bogus_seti_secret_7abce3f01ac6d2b0
external_data: {}
payment_method_id: pm_UkLWZg9DAJ
payment_source_id:
payment_source_type:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
payment_method:
id: pm_UkLWZg9DAJ
name: Credit Card
@@ -7606,14 +7606,14 @@ paths:
example:
id: pss_UkLWZg9DAJ
status: pending
- external_id: seti_test_f5e816a9bf9173b606d77af1
- external_client_secret: seti_secret_2324ae62ce1b4563baaab757
+ external_id: seti_test_b7cb4f5cbe976592aee99bca
+ external_client_secret: seti_secret_b3801c485429b5663a79719a
external_data:
client_secret: secret_123
payment_method_id: pm_UkLWZg9DAJ
payment_source_id:
payment_source_type:
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
payment_method:
id: pm_UkLWZg9DAJ
name: Credit Card
@@ -7683,14 +7683,14 @@ paths:
example:
id: pss_UkLWZg9DAJ
status: completed
- external_id: seti_test_f26b6475254366fa7f6cebf1
- external_client_secret: seti_secret_1ae363c67cc007de1f518808
+ external_id: seti_test_f917295563b40fd4b0e7877e
+ external_client_secret: seti_secret_5b330b63907aa4932eb97dda
external_data:
client_secret: secret_123
payment_method_id: pm_UkLWZg9DAJ
payment_source_id: card_UkLWZg9DAJ
payment_source_type: Spree::CreditCard
- customer_id: cus_UkLWZg9DAJ
+ customer_id: cust_UkLWZg9DAJ
payment_method:
id: pm_UkLWZg9DAJ
name: Credit Card
@@ -8628,7 +8628,7 @@ paths:
data:
- id: wl_UkLWZg9DAJ
name: My Wishlist
- token: Br6az3cu1vKdH5A4c3ZX5Bfk
+ token: AZHVjFDTQfZsFT2jEK5Uqvvr
is_default: false
is_private: true
meta:
@@ -8704,7 +8704,7 @@ paths:
example:
id: wl_gbHJdmfrXB
name: Birthday Ideas
- token: FzjUXtCBU84GauR6bAZA8qU4
+ token: V78cHaFYUJLqTULXteB6mALz
is_default: false
is_private: true
schema:
@@ -8805,7 +8805,7 @@ paths:
example:
id: wl_UkLWZg9DAJ
name: My Wishlist
- token: UEaWB2gMn9fgmNhm2kVHxbAb
+ token: D6wdgHDKfXGjjSfZeZZrXxhU
is_default: false
is_private: true
schema:
@@ -8867,7 +8867,7 @@ paths:
example:
id: wl_UkLWZg9DAJ
name: Updated Name
- token: rjoDScyCB8Pr631VNhkxd3dK
+ token: 3eVLX64Y5spXpHrhrtLfirJR
is_default: false
is_private: true
schema:
@@ -9149,12 +9149,12 @@ paths:
application/json:
example:
id: sub_UkLWZg9DAJ
- created_at: '2026-08-02T15:52:57.223Z'
- updated_at: '2026-08-02T15:52:57.223Z'
+ created_at: '2026-08-05T10:43:12.353Z'
+ updated_at: '2026-08-05T10:43:12.354Z'
verified: true
- verified_at: '2026-08-02T15:52:57Z'
- customer_id: cus_UkLWZg9DAJ
+ verified_at: '2026-08-05T10:43:12Z'
+ customer_id: cust_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/NewsletterSubscriber"
'422':
@@ -9232,10 +9232,10 @@ paths:
example:
id: sub_UkLWZg9DAJ
- created_at: '2026-08-02T15:52:57.244Z'
- updated_at: '2026-08-02T15:52:57.249Z'
+ created_at: '2026-08-05T10:43:12.373Z'
+ updated_at: '2026-08-05T10:43:12.377Z'
verified: true
- verified_at: '2026-08-02T15:52:57Z'
+ verified_at: '2026-08-05T10:43:12Z'
customer_id:
schema:
"$ref": "#/components/schemas/NewsletterSubscriber"
@@ -9405,7 +9405,7 @@ paths:
body_html: ''
- id: pol_OIJLhNcSbf
name: Privacy Policy
- slug: privacy-policy-d4072c17-a87b-475c-82cd-e7b9a0791da0
+ slug: privacy-policy-ad5099fe-dbda-4796-b66f-ffebf9e0e3ab
body: We respect your privacy.
body_html: |
<div class="trix-content">
@@ -10526,6 +10526,116 @@ components:
- storefront_access
- guest_checkout
x-typelizer: true
+ ClaimLineItem:
+ type: object
+ properties:
+ id:
+ type: string
+ quantity:
+ type: number
+ send_replacement:
+ type: boolean
+ description:
+ type: string
+ nullable: true
+ refund_amount:
+ type: string
+ paid_amount:
+ type: string
+ display_refund_amount:
+ type: string
+ variant_id:
+ type: string
+ nullable: true
+ replacement_variant_id:
+ type: string
+ nullable: true
+ line_item_id:
+ type: string
+ nullable: true
+ variant:
+ "$ref": "#/components/schemas/Variant"
+ required:
+ - id
+ - quantity
+ - send_replacement
+ - description
+ - refund_amount
+ - paid_amount
+ - display_refund_amount
+ - variant_id
+ - replacement_variant_id
+ - line_item_id
+ x-typelizer: true
+ ClaimReason:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ active:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ x-typelizer: true
+ Claim:
+ type: object
+ properties:
+ id:
+ type: string
+ number:
+ type: string
+ status:
+ type: string
+ claim_type:
+ type: string
+ resolution:
+ type: string
+ nullable: true
+ order_id:
+ type: string
+ nullable: true
+ reason_id:
+ type: string
+ nullable: true
+ refund_total:
+ type: string
+ display_refund_total:
+ type: string
+ approved_at:
+ type: string
+ nullable: true
+ resolved_at:
+ type: string
+ nullable: true
+ denied_at:
+ type: string
+ nullable: true
+ canceled_at:
+ type: string
+ nullable: true
+ claim_line_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/ClaimLineItem"
+ required:
+ - id
+ - number
+ - status
+ - claim_type
+ - resolution
+ - order_id
+ - reason_id
+ - refund_total
+ - display_refund_total
+ - approved_at
+ - resolved_at
+ - denied_at
+ - canceled_at
+ x-typelizer: true
Collection:
type: object
properties:
@@ -12371,6 +12481,20 @@ components:
- description
- code
x-typelizer: true
+ RefundReason:
+ type: object
+ properties:
+ id:
+ type: string
+ name:
+ type: string
+ active:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ x-typelizer: true
Refund:
type: object
properties:
@@ -12388,7 +12512,10 @@ components:
refund_reason_id:
type: string
nullable: true
- reimbursement_id:
+ originator_id:
+ type: string
+ nullable: true
+ originator_type:
type: string
nullable: true
required:
@@ -12397,87 +12524,111 @@ components:
- amount
- payment_id
- refund_reason_id
- - reimbursement_id
+ - originator_id
+ - originator_type
x-typelizer: true
- ReturnAuthorization:
+ ReturnLineItem:
type: object
properties:
id:
type: string
- number:
+ quantity:
+ type: number
+ received_quantity:
+ type: number
+ resellable:
+ type: boolean
+ pre_tax_amount:
type: string
- status:
+ display_pre_tax_amount:
type: string
- order_id:
+ variant_id:
type: string
nullable: true
- stock_location_id:
+ line_item_id:
type: string
nullable: true
- return_authorization_reason_id:
+ fulfillment_item_id:
type: string
nullable: true
+ variant:
+ "$ref": "#/components/schemas/Variant"
required:
- id
- - number
- - status
- - order_id
- - stock_location_id
- - return_authorization_reason_id
+ - quantity
+ - received_quantity
+ - resellable
+ - pre_tax_amount
+ - display_pre_tax_amount
+ - variant_id
+ - line_item_id
+ - fulfillment_item_id
x-typelizer: true
- ReturnItem:
+ ReturnReason:
type: object
properties:
id:
type: string
- reception_status:
+ name:
type: string
- nullable: true
- acceptance_status:
+ active:
+ type: boolean
+ required:
+ - id
+ - name
+ - active
+ x-typelizer: true
+ Return:
+ type: object
+ properties:
+ id:
type: string
- nullable: true
- created_at:
+ number:
type: string
- updated_at:
+ status:
type: string
- pre_tax_amount:
+ return_label_url:
type: string
nullable: true
- included_tax_total:
+ order_id:
type: string
nullable: true
- additional_tax_total:
+ reason_id:
type: string
nullable: true
- inventory_unit_id:
+ refund_total:
type: string
- nullable: true
- return_authorization_id:
+ display_refund_total:
+ type: string
+ approved_at:
type: string
nullable: true
- customer_return_id:
+ received_at:
type: string
nullable: true
- reimbursement_id:
+ refunded_at:
type: string
nullable: true
- exchange_variant_id:
+ canceled_at:
type: string
nullable: true
+ return_line_items:
+ type: array
+ items:
+ "$ref": "#/components/schemas/ReturnLineItem"
required:
- id
- - reception_status
- - acceptance_status
- - created_at
- - updated_at
- - pre_tax_amount
- - included_tax_total
- - additional_tax_total
- - inventory_unit_id
- - return_authorization_id
- - customer_return_id
- - reimbursement_id
- - exchange_variant_id
+ - number
+ - status
+ - return_label_url
+ - order_id
+ - reason_id
+ - refund_total
+ - display_refund_total
+ - approved_at
+ - received_at
+ - refunded_at
+ - canceled_at
x-typelizer: true
State:
type: object
diff --git a/docs/docs.json b/docs/docs.json
index ef8f77bf10..5b1db4bf6e 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -1635,8 +1635,8 @@
{
"group": "Returns",
"pages": [
- "user/settings/returns-configuration",
- "user/returns/returns-processing"
+ "v6/user/settings/returns-configuration",
+ "v6/user/returns/returns-processing"
]
},
{
diff --git a/docs/plans/6.0-returns-exchanges-claims.md b/docs/plans/6.0-returns-exchanges-claims.md
index a3334252b9..c8139f9849 100644
--- a/docs/plans/6.0-returns-exchanges-claims.md
+++ b/docs/plans/6.0-returns-exchanges-claims.md
@@ -1,11 +1,11 @@
# Returns, Exchanges & Claims as First-Class Entities
-**Status:** Draft
+**Status:** Complete — legacy chain removed
**Target:** Spree 6.0
**Depends on:** Fulfillment & Delivery rework (6.0-fulfillment-and-delivery.md), Split Adjustments (6.0-split-adjustments.md), Normalize state→status (6.0-normalize-state-to-status.md), Service Workflows (6.0-service-workflows.md)
**Successor:** 6.1-order-change-substrate.md — the mutation half of these flows moves onto the shared OrderChange substrate in 6.1 (additive; the models and statuses below do not change)
**Author:** Damian + Claude
-**Last updated:** 2026-08-02
+**Last updated:** 2026-08-05
## Summary
@@ -17,6 +17,93 @@ Replace the deeply nested return/reimbursement chain (ReturnAuthorization → Re
Each is a top-level model on Order with its own line items, status, and resolution. No more 6-model-deep nesting. No more exchanges-as-a-reimbursement-type hack.
+## Implementation Status (2026-08-05)
+
+**Complete.** The new system is live end to end and the legacy chain is gone.
+Core, API and emails suites are green (7478 / 2639 / 95 examples, 0 failures),
+as are the dashboard's typecheck, lint and 44 unit tests.
+
+Shipped earlier to 6-0-dev:
+
+- Models: `Spree::Return`, `Spree::Exchange`, `Spree::Claim` with
+ `Spree::ReturnLineItem`, `Spree::ExchangeLineItem`, `Spree::ClaimLineItem`
+ (naming note below), plus the `Spree::HasStatus` concern.
+- All fifteen workflows in `spree/core/app/workflows/spree/{returns,exchanges,claims}/`,
+ each with a leading `validate` hook (shipped on every workflow, not just the
+ Create ones), lifecycle events (`return.requested` … `claim.resolved`), and
+ the internal-vs-gateway refund branch.
+- `Spree::Refund#originator` (polymorphic), `return_label_url` +
+ `Returns::Approve`'s `generate_label:` seam, per-transition timestamp
+ columns (`approved_at`, `received_at`, …), `received_quantity` on line items
+ (partial receipt), `SingleStoreResource` + `store_id` on all three entities.
+- Admin API v3 (nested under orders: index/show/create/update + PATCH member
+ transitions), Store API v3 (returns + claims: index/show/create), admin +
+ store serializers, dashboard pages (`returns.tsx`, `exchanges.tsx`,
+ `claims.tsx`, order returns card), model/workflow/controller specs, and the
+ developer doc (`docs/v6/developer/core-concepts/returns-exchanges-claims.mdx`).
+
+Landed on `feature/cleanup-old-returns-system`:
+
+1. **Legacy drop.** `ReturnAuthorization`, `CustomerReturn`, `Reimbursement`,
+ `ReimbursementType` (+ all subtypes, `ReimbursementPerformer`,
+ `ReimbursementTaxCalculator`, the type engine/validator), the legacy
+ `ReturnItem` with its eligibility validators, `ReturnsCalculator` and
+ `Calculator::Returns::DefaultRefundAmount`, the v3 legacy serializers and
+ their dependency registrations, the reimbursement mailer, and every
+ reference across `Order`, `Store`, `FulfillmentItem`, permission sets,
+ seeds, permitted attributes, factories and locales. Legacy **tables** stay
+ as a safety net (dropped in 6.1).
+2. **Data migration** `spree:upgrade:migrate_returns`
+ (`Spree::ReturnsMigrator`, defined in the rake file alongside its sibling
+ upgrade tasks) — reads the legacy tables by name through throwaway AR
+ classes,
+ converting authorizations into Returns or Exchanges and re-pointing
+ reimbursement-era refunds via `originator`. **Resumable by construction:**
+ the legacy `number` is copied onto the new record and uniquely indexed
+ there, so the task scopes itself to authorizations whose number isn't
+ present yet — an interrupted run picks up where it stopped and a re-run is
+ a no-op, with no cursor or job state to manage. Registered in the 5.6→6.0
+ upgrade manifest after the adjustments step that freezes returns-bearing
+ orders.
+3. **Reason models.** `ReturnAuthorizationReason` → `ReturnReason` (table
+ renamed, constant alias kept for one release) plus a new `ClaimReason`;
+ the three `reason` associations repointed.
+4. **`Spree::Metafields`** on Return, Exchange and Claim (with the three added
+ to the engine's `metafields.enabled_resources`).
+
+Replacements built where the drop would otherwise have removed capability:
+
+- **`Spree::ReturnMailer#refunded_email`** + `ReturnEmailSubscriber` on
+ `return.refunded`, replacing the reimbursement email (the legacy expedited-
+ exchange section had no equivalent in the new model and was dropped).
+- **`Order#outstanding_balance`** lost its `reimbursement_paid_total` term:
+ refunds are already netted out of `payment_total` by
+ `Carts::RecalculateTotals`, so the legacy term was the only payout sitting
+ outside that sum. `Refund#return_items` became `#return_line_items` reading
+ through `originator`.
+- **`Return#refunded_total`** now sums refunds **and** store credits — store
+ credit is its own ledger and never creates a `Spree::Refund` row, so the
+ old sum reported zero for a store-credit refund.
+- **`StoreCreditCategory.default_reimbursement_category`** →
+ `.default_refund_category` (deprecated alias kept).
+- **`OrderStatusSubscriber`** now listens to `return.received/refunded/canceled`
+ instead of the `return_item.*` events.
+- Sample data creates a real Return through `Returns::Create`; user docs
+ rewritten for 6.0 under `docs/v6/user/` and the v6 nav repointed.
+
+**Reason management (closed 2026-08-05).** The legacy Rails admin was the only
+place reasons could be edited, so its removal left `ReturnReason`,
+`ClaimReason` and `RefundReason` seed-only and every record created reasonless.
+Now shipped: admin-only CRUD at `/api/v3/admin/{return,claim,refund}_reasons`
+(plain `ResourceController` subclasses, `settings` scope), a combined
+**Settings → Reasons** page holding all three lists, and a reason picker on all
+three create dialogs. `mutable` is not writable through the API — a client must
+not be able to unlock a record core depends on — and the guard moved onto
+`Spree::NamedType` itself (`can_be_deleted?`, a rename validation and a destroy
+guard), because the previous `cannot [:edit, :update], …, mutable: false`
+ability rule is never consulted on the secret-key path, which authorizes by
+scope. Reason serializers are admin-only and excluded from the Store SDK.
+
## Problem
### 1. Six models for a simple return
@@ -54,8 +141,8 @@ Total: ~825 lines across 6+ models for return handling.
## Key Decisions (do not deviate without discussion)
-- **Three first-class models:** `Return`, `Exchange`, `Claim`. Each belongs directly to Order.
-- **Each has its own line items:** `ReturnItem`, `ExchangeItem`, `ClaimItem`. No shared polymorphic item model — each type has different fields.
+- **Three first-class models:** `Return`, `Exchange`, `Claim`. Each belongs directly to Order (and to Store via `SingleStoreResource`).
+- **Each has its own line items:** `ReturnLineItem`, `ExchangeLineItem`, `ClaimLineItem`. No shared polymorphic item model — each type has different fields. **Naming settled 2026-08-05:** the `*LineItem` names — chosen during implementation because legacy `Spree::ReturnItem` was still in service — are permanent. They mirror `Spree::LineItem`, and renaming to the shorter `*Item` after the legacy drop would cost a table rename plus serializer/SDK/dashboard churn for nothing.
- **No state machines. Workflows own every transition.** Each entity carries a
plain `status` string column with an inclusion validation. Moving a return to
`received` is `Spree::Returns::Receive.call(...)`, not `return.receive!`. See
@@ -76,8 +163,9 @@ Total: ~825 lines across 6+ models for return handling.
enforce for customers and let staff override; policy that varies by region
reads from `order.market`, not the store.
- **Refund stays.** `Spree::Refund` is the payment-level reversal — it stays as-is. Returns and Claims link to Refunds when money needs to go back.
-- **Drop:** `CustomerReturn`, `Reimbursement`, `ReimbursementType` (all four subtypes), `ReturnAuthorization`. Their functionality is absorbed into the three new models.
-- **ReturnItem is reused** (renamed from the current model, simplified). ExchangeItem and ClaimItem are new.
+- **Drop:** `CustomerReturn`, `Reimbursement`, `ReimbursementType` (all four subtypes), `ReturnAuthorization`, and the legacy `ReturnItem` with its eligibility validators. Their functionality is absorbed into the three new models.
+- **Reasons (2026-08-05):** all three entities share one reason model. The legacy drop renames `ReturnAuthorizationReason` → `ReturnReason` (table included; deprecated `Spree::ReturnAuthorizationReason` alias for one release per the deprecation-bridge rule) and adds a separate `ClaimReason` — claim reasons ("arrived damaged", "never arrived") are a different vocabulary from return reasons ("wrong size", "changed mind"). `RefundReason` stays as-is.
+- **A balance the customer owes is never auto-charged (as shipped).** When an exchange's replacements cost more, `Exchanges::Fulfill` records the difference and leaves collection to the merchant — charging a stored card without a fresh authorization is not something core does silently. Only a credit due back branches into store-credit/gateway settlement.
## Why workflows, not state machines
@@ -201,7 +289,7 @@ end
## Design Details
-### Return
+### Return (as shipped)
A customer returns items and gets a refund (to original payment, store credit, or gift card).
@@ -211,11 +299,16 @@ class Spree::Return < Spree.base_class
include Spree::Core::NumberGenerator.new(prefix: 'RET', length: 9)
include Spree::NumberIdentifier
- include Spree::Metafields
+ include Spree::SingleStoreResource
+ include Spree::HasStatus
+ include Spree::Metafields # ships with the legacy-drop branch
include Spree::Metadata
publishes_lifecycle_events
+ has_status :requested, :approved, :received, :refunded, :canceled, default: :requested
+
+ belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :returns
belongs_to :stock_location, class_name: 'Spree::StockLocation'
belongs_to :reason, class_name: 'Spree::ReturnReason', optional: true
@@ -223,61 +316,59 @@ class Spree::Return < Spree.base_class
# the requester is always order.customer, so no second FK is needed.
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
- has_many :return_items, class_name: 'Spree::ReturnItem', dependent: :destroy, inverse_of: :return
- has_many :refunds, class_name: 'Spree::Refund', as: :originator
-
- include Spree::HasStatus
- has_status :requested, :approved, :received, :refunded, :canceled, default: :requested
+ has_many :return_line_items, class_name: 'Spree::ReturnLineItem',
+ dependent: :destroy, inverse_of: :return
+ has_many :refunds, class_name: 'Spree::Refund', as: :originator, dependent: :nullify
validates :order, :stock_location, presence: true
- validates :return_items, presence: true
+ validates :return_line_items, presence: true, on: :create
- accepts_nested_attributes_for :return_items, allow_destroy: true
+ accepts_nested_attributes_for :return_line_items, allow_destroy: true
# Predicates (#received?) and scopes (.received) are generated by has_status.
- # Total refund amount. A pure read — safe on the model.
+ # What the customer is owed; #refunded_total sums actual refunds —
+ # a return can be refunded in more than one step.
def refund_total
- return_items.sum(:pre_tax_amount)
+ return_line_items.sum(&:pre_tax_amount)
end
end
```
The model holds associations, validations, scopes and pure reads. Restocking
and refunding live in `Spree::Returns::Receive` and `Spree::Returns::Refund`
-(below).
+(below). The record also carries per-transition timestamps (`approved_at`,
+`received_at`, `refunded_at`, `canceled_at`) written by the workflows, plus
+`memo` and `return_label_url`.
-### ReturnItem (simplified)
+### ReturnLineItem (as shipped)
```ruby
-class Spree::ReturnItem < Spree.base_class
- has_prefix_id :ri
+class Spree::ReturnLineItem < Spree.base_class
+ has_prefix_id :rli
- belongs_to :return, class_name: 'Spree::Return', inverse_of: :return_items
+ belongs_to :return, class_name: 'Spree::Return', inverse_of: :return_line_items
belongs_to :fulfillment_item, class_name: 'Spree::FulfillmentItem' # renamed from InventoryUnit
belongs_to :line_item, class_name: 'Spree::LineItem'
- belongs_to :variant, class_name: 'Spree::Variant'
+ belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
- validates :fulfillment_item, :quantity, presence: true
+ validates :fulfillment_item, :line_item, :variant, presence: true
validates :quantity, numericality: { greater_than: 0 }
+ validates :received_quantity, numericality: { greater_than_or_equal_to: 0 }
+ validates :pre_tax_amount, numericality: { greater_than_or_equal_to: 0 }
- attribute :pre_tax_amount, :decimal, default: 0
- attribute :resellable, :boolean, default: true
- attribute :quantity, :integer, default: 1
-
- before_create :set_default_pre_tax_amount
-
- delegate :order, to: :return
-
- private
+ # quantity (default 1), received_quantity (default 0, written by
+ # Returns::Receive), pre_tax_amount and resellable carry DB defaults.
+ # pre_tax_amount defaults to this item's share of what the customer
+ # actually paid after discounts — refunding list price would give back
+ # more than was taken.
+ before_validation :set_defaults_from_line_item, on: :create
- def set_default_pre_tax_amount
- self.pre_tax_amount ||= line_item.pre_tax_amount / line_item.quantity * quantity
- end
+ delegate :order, :currency, to: :return
end
```
-### Exchange
+### Exchange (as shipped)
A customer returns items and gets different items in return (different size, different product).
@@ -287,68 +378,72 @@ class Spree::Exchange < Spree.base_class
include Spree::Core::NumberGenerator.new(prefix: 'EX', length: 9)
include Spree::NumberIdentifier
- include Spree::Metafields
+ include Spree::SingleStoreResource
+ include Spree::HasStatus
+ include Spree::Metafields # ships with the legacy-drop branch
include Spree::Metadata
publishes_lifecycle_events
+ has_status :requested, :approved, :received, :fulfilled, :canceled, default: :requested
+
+ belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :exchanges
belongs_to :stock_location, class_name: 'Spree::StockLocation'
belongs_to :reason, class_name: 'Spree::ReturnReason', optional: true
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
- has_many :exchange_items, class_name: 'Spree::ExchangeItem', dependent: :destroy, inverse_of: :exchange
- has_one :exchange_fulfillment, class_name: 'Spree::Fulfillment', as: :originator # the new shipment
-
- # If there's a price difference, link to a refund or additional payment
- has_many :refunds, class_name: 'Spree::Refund', as: :originator
-
- include Spree::HasStatus
- has_status :requested, :approved, :received, :fulfilled, :canceled, default: :requested
+ has_many :exchange_line_items, class_name: 'Spree::ExchangeLineItem',
+ dependent: :destroy, inverse_of: :exchange
+ has_many :refunds, class_name: 'Spree::Refund', as: :originator, dependent: :nullify
validates :order, :stock_location, presence: true
- validates :exchange_items, presence: true
+ validates :exchange_line_items, presence: true, on: :create
- accepts_nested_attributes_for :exchange_items, allow_destroy: true
+ accepts_nested_attributes_for :exchange_line_items, allow_destroy: true
- # Price difference: positive = customer owes more, negative = refund due
+ # Positive = customer owes more, negative = refund due.
def price_difference
- exchange_items.sum { |ei| ei.new_variant_price - ei.original_price }
+ exchange_line_items.sum(&:price_difference)
end
end
```
+There is **no `has_one :exchange_fulfillment` association** (the plan's
+earlier sketch had one): `Exchanges::Fulfill` builds replacement
+fulfillment items on the order and routes them through
+`Spree::Stock::Coordinator`, which may legitimately produce several
+fulfillments; they attach to the order like any other. Only the money records
+(`Refund`, `StoreCredit`) carry the `originator` back-reference.
+
Restocking and replacement-fulfillment creation live in
-`Spree::Exchanges::Receive` and `Spree::Exchanges::Fulfill`. The price
-difference is settled through the internal-vs-gateway branch (see "Refunding:
-internal vs gateway" below) — a gateway capture or refund runs as an
-`external_step` outside the transaction that writes the status; store-credit
-settlement stays inside it.
+`Spree::Exchanges::Receive` and `Spree::Exchanges::Fulfill`. A credit due back
+is settled through the internal-vs-gateway branch (see "Refunding: internal vs
+gateway" below); a balance the customer owes is recorded but never
+auto-charged (Key Decisions).
-### ExchangeItem
+### ExchangeLineItem (as shipped)
```ruby
-class Spree::ExchangeItem < Spree.base_class
- has_prefix_id :ei
+class Spree::ExchangeLineItem < Spree.base_class
+ has_prefix_id :eli
- belongs_to :exchange, class_name: 'Spree::Exchange', inverse_of: :exchange_items
+ belongs_to :exchange, class_name: 'Spree::Exchange', inverse_of: :exchange_line_items
belongs_to :fulfillment_item, class_name: 'Spree::FulfillmentItem' # the original item being returned
- belongs_to :line_item, class_name: 'Spree::LineItem' # original line item
- belongs_to :original_variant, class_name: 'Spree::Variant'
- belongs_to :new_variant, class_name: 'Spree::Variant'
+ belongs_to :line_item, class_name: 'Spree::LineItem' # original line item
+ belongs_to :original_variant, -> { with_deleted }, class_name: 'Spree::Variant'
+ belongs_to :new_variant, -> { with_deleted }, class_name: 'Spree::Variant'
- validates :fulfillment_item, :original_variant, :new_variant, :quantity, presence: true
+ validates :fulfillment_item, :line_item, :original_variant, :new_variant, presence: true
validates :quantity, numericality: { greater_than: 0 }
+ validates :received_quantity, numericality: { greater_than_or_equal_to: 0 }
+ validate :replacement_must_differ # swapping a variant for itself is a return
- attribute :quantity, :integer, default: 1
- attribute :resellable, :boolean, default: true
-
- def original_price
- line_item.price * quantity
- end
-
- def new_variant_price
- new_variant.price_in(exchange.order.currency)&.amount.to_d * quantity
+ # original_price reads what the customer actually paid after discounts
+ # (line_item.amount / quantity), not the list price — the same
+ # over-crediting guard as ReturnLineItem#pre_tax_amount.
+ def price_difference
+ new_variant_price - original_price
end
end
```
@@ -363,11 +458,15 @@ class Spree::Claim < Spree.base_class
include Spree::Core::NumberGenerator.new(prefix: 'CLM', length: 9)
include Spree::NumberIdentifier
- include Spree::Metafields
+ include Spree::SingleStoreResource
+ include Spree::HasStatus
+ include Spree::Metafields # ships with the legacy-drop branch
include Spree::Metadata
publishes_lifecycle_events
+ has_status :open, :approved, :resolved, :denied, :canceled, default: :open
+
# Configuration, not a frozen constant (same ruling as statuses) — a
# merchant adds a claim type without reopening core:
# Spree::Claim.claim_types += ['late_delivery']
@@ -375,57 +474,64 @@ class Spree::Claim < Spree.base_class
# list needs no accompanying workflow.
class_attribute :claim_types, default: %w[damaged missing wrong_item other]
+ # Unlike claim types, each resolution drives real behaviour in
+ # Spree::Claims::Resolve, so this stays closed.
+ RESOLUTIONS = %w[refund replacement refund_and_replacement].freeze
+
+ belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :claims
belongs_to :reason, class_name: 'Spree::ClaimReason', optional: true
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
- has_many :claim_items, class_name: 'Spree::ClaimItem', dependent: :destroy, inverse_of: :claim
- has_many :refunds, class_name: 'Spree::Refund', as: :originator
- has_one :replacement_fulfillment, class_name: 'Spree::Fulfillment', as: :originator
-
- include Spree::HasStatus
- has_status :open, :approved, :resolved, :denied, :canceled, default: :open
-
- RESOLUTIONS = %w[refund replacement refund_and_replacement].freeze
+ has_many :claim_line_items, class_name: 'Spree::ClaimLineItem',
+ dependent: :destroy, inverse_of: :claim
+ has_many :refunds, class_name: 'Spree::Refund', as: :originator, dependent: :nullify
validates :order, :claim_type, presence: true
- validates :claim_items, presence: true
+ validates :claim_line_items, presence: true, on: :create
validates :claim_type, inclusion: { in: -> (record) { record.class.claim_types } }
validates :resolution, inclusion: { in: RESOLUTIONS }, allow_nil: true
- accepts_nested_attributes_for :claim_items, allow_destroy: true
+ accepts_nested_attributes_for :claim_line_items, allow_destroy: true
def refund_total
- claim_items.sum(:refund_amount)
+ claim_line_items.sum(&:refund_amount)
end
end
```
+As with Exchange, there is no `has_one :replacement_fulfillment` association —
+`Claims::Resolve` routes replacements through `Spree::Stock::Coordinator` onto
+the order.
+
`Spree::Claims::Resolve` takes the resolution as an argument rather than
reading it off the record, so the caller's intent is explicit; refunds settle
through the internal-vs-gateway branch (see "Refunding: internal vs gateway").
-### ClaimItem
+### ClaimLineItem (as shipped)
```ruby
-class Spree::ClaimItem < Spree.base_class
- has_prefix_id :ci
+class Spree::ClaimLineItem < Spree.base_class
+ has_prefix_id :cli
- belongs_to :claim, class_name: 'Spree::Claim', inverse_of: :claim_items
+ belongs_to :claim, class_name: 'Spree::Claim', inverse_of: :claim_line_items
belongs_to :line_item, class_name: 'Spree::LineItem'
- belongs_to :variant, class_name: 'Spree::Variant'
- belongs_to :replacement_variant, class_name: 'Spree::Variant', optional: true
+ belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
+ # Nil means "send the same thing again"; a different variant swaps it.
+ belongs_to :replacement_variant, -> { with_deleted }, class_name: 'Spree::Variant', optional: true
- # Optional images of damage
+ # Photographic evidence of damage, supplied by the customer.
has_many_attached :images
- validates :line_item, :variant, :quantity, presence: true
+ validates :line_item, :variant, presence: true
validates :quantity, numericality: { greater_than: 0 }
+ validates :refund_amount, numericality: { greater_than_or_equal_to: 0 }
- attribute :quantity, :integer, default: 1
- attribute :send_replacement, :boolean, default: false
- attribute :refund_amount, :decimal, default: 0
- attribute :description, :text # customer's description of the problem
+ # quantity (1), send_replacement (false) and refund_amount (0) carry DB
+ # defaults; description holds the customer's account of the problem.
+ # #paid_amount (what was actually paid after discounts) is the ceiling
+ # for a refund on this line; #variant_to_send is what ships on a
+ # replacement resolution.
end
```
@@ -433,13 +539,15 @@ end
```ruby
class Spree::Order < Spree.base_class
- has_many :returns, class_name: 'Spree::Return', dependent: :destroy
- has_many :exchanges, class_name: 'Spree::Exchange', dependent: :destroy
- has_many :claims, class_name: 'Spree::Claim', dependent: :destroy
+ # Shipped (ordered by created_at for the order page's post-sale view):
+ has_many :returns, -> { order(:created_at) }, class_name: 'Spree::Return', inverse_of: :order
+ has_many :exchanges, -> { order(:created_at) }, class_name: 'Spree::Exchange', inverse_of: :order
+ has_many :claims, -> { order(:created_at) }, class_name: 'Spree::Claim', inverse_of: :order
- # Remove:
+ # Removed by the legacy drop:
# has_many :return_authorizations
# has_many :reimbursements
+ # has_many :customer_returns, through: :return_authorizations
end
```
@@ -463,15 +571,20 @@ workflow tier under `6.0-service-workflows.md` on all three counts: they carry
extension hooks, they perform gateway I/O that must sit outside a transaction,
and they need compensation.
+**As shipped, every workflow carries a leading `validate` hook** — not just
+the Create ones. An extension can veto any transition (block a refund, gate an
+approval), which is strictly more capable than the plan's original hook set
+and costs nothing.
+
### Returns
| Workflow | Arguments | Hooks | Notes |
|---|---|---|---|
| `Returns::Create` | `order:`, `items:`, `reason:`, `stock_location:`, `created_by:` | `validate`, `after_create` | `validate` is where a store rejects out-of-window returns |
-| `Returns::Approve` | `return:`, `approver:`, `note:` | `after_approve` | Optionally generates the return label (`external_step` — carrier API) |
-| `Returns::Receive` | `return:`, `items:`, `received_by:` | `before_restock`, `after_receive` | Partial receipt is the normal case: `items:` carries actual quantities and per-item resellable flags |
-| `Returns::Refund` | `return:`, `amount:`, `refund_method:` | `before_refund`, `after_refund` | Branches on refund method (below); `on_flow_failure:` reverses the status |
-| `Returns::Cancel` | `return:`, `reason:` | `after_cancel` | Restocks nothing; only valid from requested/approved |
+| `Returns::Approve` | `return_record:`, `approver:`, `generate_label:` | `validate`, `after_approve` | `generate_label: true` requests a carrier label via `external_step` through the `Spree.return_label_provider` seam (soft-guarded; no provider registered in core yet) and stores it in `return_label_url` |
+| `Returns::Receive` | `return_record:`, `items:`, `received_by:` | `validate`, `before_restock`, `after_receive` | Partial receipt is the normal case: `items:` carries actual quantities and per-item resellable flags, written to `received_quantity` |
+| `Returns::Refund` | `return_record:`, `amount:`, `refund_method:` | `validate`, `before_refund`, `after_refund` | Branches on refund method (below); `on_flow_failure:` reverses the status |
+| `Returns::Cancel` | `return_record:`, `reason:` | `validate`, `after_cancel` | Restocks nothing; only valid from requested/approved |
```ruby
module Spree
@@ -480,16 +593,18 @@ module Spree
# from the warehouse, not from what the customer said they would send —
# partial and damaged receipt is the normal case, not an edge case.
class Receive < Spree::Workflow
- hooks :before_restock, :after_receive
+ hooks :validate, :before_restock, :after_receive
# @param return_record [Spree::Return]
- # @param items [Array<Hash>] `[{ return_item:, quantity:, resellable: }]`
+ # @param items [Array<Hash>, nil] `[{ return_line_item:, quantity:,
+ # resellable: }]`; nil receives everything as requested and resellable
# @param received_by [Object, nil]
- def perform(return_record:, items:, received_by: nil)
+ def perform(return_record:, items: nil, received_by: nil)
super
step :ensure_receivable
- step :validate_quantities
+ step :normalize_items
+ run_hooks :validate
ApplicationRecord.transaction do
step :record_receipt
@@ -509,15 +624,8 @@ module Spree
failure(return_record, :not_approved) unless return_record.approved?
end
- def restock_resellable_items
- items.each do |item|
- next unless item[:resellable]
-
- return_record.stock_location.restock(
- item[:return_item].variant, item[:quantity], return_record
- )
- end
- end
+ # ... restocks each resellable received quantity at the return's
+ # stock location and writes received_quantity on each line item.
end
end
end
@@ -551,20 +659,20 @@ payments differently from gateway payments. `Claims::Resolve` and
| Workflow | Hooks | Notes |
|---|---|---|
| `Exchanges::Create` | `validate`, `after_create` | Validates replacement variants are purchasable |
-| `Exchanges::Approve` | `after_approve` | |
-| `Exchanges::Receive` | `before_restock`, `after_receive` | Same partial-receipt shape as returns |
-| `Exchanges::Fulfill` | `before_settle`, `after_fulfill` | Creates the replacement fulfillment, then settles `price_difference` as an `external_step` |
-| `Exchanges::Cancel` | `after_cancel` | |
+| `Exchanges::Approve` | `validate`, `after_approve` | |
+| `Exchanges::Receive` | `validate`, `before_restock`, `after_receive` | Same partial-receipt shape as returns |
+| `Exchanges::Fulfill` | `validate`, `before_settle`, `after_fulfill` | Builds replacement fulfillments via `Stock::Coordinator` (only for quantities actually received; fails on out-of-stock replacements), then settles a credit due back as an `external_step`; a balance owed is never auto-charged |
+| `Exchanges::Cancel` | `validate`, `after_cancel` | |
### Claims
| Workflow | Hooks | Notes |
|---|---|---|
| `Claims::Create` | `validate`, `after_create` | Store API entry point; `validate` gates self-service claims |
-| `Claims::Approve` | `after_approve` | |
-| `Claims::Resolve` | `before_settle`, `after_resolve` | Takes `resolution:` explicitly; refund settles via the internal-vs-gateway branch, replacement fulfillment is in-transaction |
-| `Claims::Deny` | `after_deny` | |
-| `Claims::Cancel` | `after_cancel` | |
+| `Claims::Approve` | `validate`, `after_approve` | |
+| `Claims::Resolve` | `validate`, `before_settle`, `after_resolve` | Takes `resolution:` explicitly; refund settles via the internal-vs-gateway branch, replacement fulfillment is in-transaction |
+| `Claims::Deny` | `validate`, `after_deny` | |
+| `Claims::Cancel` | `validate`, `after_cancel` | |
### Return eligibility policy: the hook, not a policy engine
@@ -660,213 +768,150 @@ records where it belongs when a store or `spree_enterprise` adds one.
## Migration Path
-### Phase 1: Create new tables
-
-Per CLAUDE.md migration rules: no foreign key constraints, `null: false` on
-required columns, JSON columns guarded with `respond_to?(:jsonb)`. Defaults
-(refined 2026-08-02): **status/string columns get no database default** — the
-creating workflow sets the status; **integer and decimal columns do carry
-defaults** (`quantity` 1, amounts 0), so a raw insert can never produce a null
-quantity or amount. Metadata is a **single `metadata` column** — the new 6.0
-tables drop the legacy public/private split (`metadata` is already the primary
-API param on carts).
+### Phase 1: Create new tables — SHIPPED
+
+Landed as `spree/core/db/migrate/20260802190001_create_spree_returns.rb` and
+`20260802210001_create_spree_exchanges_and_claims.rb`. Follows the CLAUDE.md
+migration rules (no FK constraints, `null: false` on required columns,
+`respond_to?(:jsonb)` guard, no defaults on status columns, defaults on
+integer/decimal columns, single `metadata` column). As-built differences from
+the original sketch:
+
+- Tables are `spree_return_line_items`, `spree_exchange_line_items`,
+ `spree_claim_line_items`. **The legacy `spree_return_items` table was never
+ renamed** — it keeps its name until dropped, and the `_legacy` rename is off
+ the table.
+- Every entity table carries `store_id` (`SingleStoreResource`) and
+ per-transition timestamps (`approved_at`, `received_at`, `refunded_at` /
+ `fulfilled_at` / `resolved_at`, `canceled_at`, `denied_at`).
+- `spree_returns` carries `return_label_url`; return and exchange line items
+ carry `received_quantity` (default 0) for partial receipt.
+- `spree_refunds.originator_{type,id}` + index shipped in the returns
+ migration.
+
+### Phase 2: Data migration (rake task) — SHIPPED
+
+`Spree::ReturnsMigrator`, invoked by `rake spree:upgrade:migrate_returns` and
+registered in the 5.6→6.0 upgrade manifest (after `migrate_adjustments_to_typed_rows`, which freezes
+returns-bearing orders for exactly this step). Historical rows are written
+with `save(validate: false)` — they can reference deleted variants and stock
+locations that today's validations reject, and refusing to copy history is
+worse than copying it imperfectly.
+
+**Resumption needs no cursor.** The legacy `number` carries onto the new
+record and is uniquely indexed there, so "what is left to migrate" is a query
+(`where.not(number: already_migrated)`) rather than tracked state. That makes
+an interrupted run resume at exactly the right place, a re-run a no-op, and a
+partial failure retryable — without a job, a checkpoint table, or a cursor to
+get out of sync with reality.
```ruby
-class CreateReturnsExchangesClaims < ActiveRecord::Migration[8.1]
- def change
- create_table :spree_returns do |t|
- t.string :number, null: false
- t.references :order, null: false
- t.references :stock_location, null: false
- t.references :reason
- t.references :created_by
- t.string :status, null: false
- t.text :memo
- if t.respond_to?(:jsonb)
- t.jsonb :metadata
- else
- t.json :metadata
- end
- t.timestamps
- end
- add_index :spree_returns, :number, unique: true
- add_index :spree_returns, :status
-
- create_table :spree_exchanges do |t|
- t.string :number, null: false
- t.references :order, null: false
- t.references :stock_location, null: false
- t.references :reason
- t.references :created_by
- t.string :status, null: false
- t.text :memo
- if t.respond_to?(:jsonb)
- t.jsonb :metadata
- else
- t.json :metadata
- end
- t.timestamps
- end
- add_index :spree_exchanges, :number, unique: true
- add_index :spree_exchanges, :status
-
- create_table :spree_claims do |t|
- t.string :number, null: false
- t.references :order, null: false
- t.references :reason
- t.references :created_by
- t.string :status, null: false
- t.string :claim_type, null: false
- t.string :resolution
- t.text :memo
- if t.respond_to?(:jsonb)
- t.jsonb :metadata
- else
- t.json :metadata
- end
- t.timestamps
- end
- add_index :spree_claims, :number, unique: true
- add_index :spree_claims, :status
-
- # Rename old return_items to legacy, create new simplified table
- rename_table :spree_return_items, :spree_return_items_legacy
-
- create_table :spree_return_items do |t|
- t.references :return, null: false
- t.references :fulfillment_item, null: false
- t.references :line_item, null: false
- t.references :variant, null: false
- t.integer :quantity, null: false, default: 1
- t.decimal :pre_tax_amount, precision: 10, scale: 2, null: false, default: 0
- t.boolean :resellable, null: false, default: true
- t.timestamps
- end
-
- create_table :spree_exchange_items do |t|
- t.references :exchange, null: false
- t.references :fulfillment_item, null: false
- t.references :line_item, null: false
- t.references :original_variant, null: false
- t.references :new_variant, null: false
- t.integer :quantity, null: false, default: 1
- t.boolean :resellable, null: false, default: true
- t.timestamps
- end
-
- create_table :spree_claim_items do |t|
- t.references :claim, null: false
- t.references :line_item, null: false
- t.references :variant, null: false
- t.references :replacement_variant
- t.integer :quantity, null: false, default: 1
- t.boolean :send_replacement, null: false, default: false
- t.decimal :refund_amount, precision: 10, scale: 2, null: false, default: 0
- t.text :description
- t.timestamps
- end
-
- # Refund: add polymorphic originator
- add_column :spree_refunds, :originator_type, :string
- add_column :spree_refunds, :originator_id, :bigint
- add_index :spree_refunds, [:originator_type, :originator_id]
- end
-end
-```
-
-### Phase 2: Data migration (rake task)
-
-```ruby
-# rake spree:migrate_returns
+# rake spree:upgrade:migrate_returns
+#
+# Reads the legacy tables via lightweight anonymous AR classes (pattern:
+# migrate_users_to_customers.rake) — NOT the legacy models, which are being
+# deleted in the same release. Decision 2026-08-05: the task and the drop
+# ship together so the drop is never blocked waiting on Wave 7.
#
# For each ReturnAuthorization + its ReturnItems:
# If any ReturnItem has exchange_variant_id:
-# → Create Exchange with ExchangeItems
+# → Create Exchange with ExchangeLineItems
# Else:
-# → Create Return with ReturnItems (new table)
+# → Create Return with ReturnLineItems
+# Status mapping: authorized → approved (or received/refunded when the
+# chain progressed), canceled → canceled
#
# For each Reimbursement:
# Link its Refunds to the new Return/Exchange via originator
#
# Claims: no migration needed (didn't exist before)
-#
-# ReturnAuthorizationReason → ReturnReason (rename or alias)
-# RefundReason stays as-is
-# New: ClaimReason
```
-### Phase 3: Model migration
+### Phase 3: Model migration — SHIPPED
-- Create Return, Exchange, Claim models + line items — associations,
- validations, scopes and pure reads only
-- Add the `Spree::HasStatus` concern
-- Update Order associations
-- Update Refund with originator
-- Create ReturnReason, ClaimReason models (or reuse existing reason tables)
-- Update FulfillmentItem (was InventoryUnit) to remove return-specific methods
-- Wire into events system (lifecycle events for each entity)
+Models + line items, `Spree::HasStatus`, Order associations, Refund
+originator and lifecycle events shipped first; the legacy-drop branch
+completed the phase with the `ReturnAuthorizationReason` → `ReturnReason`
+rename (+ `ClaimReason`), `Spree::Metafields` on all three entities, and the
+removal of the return-specific methods on `FulfillmentItem`
+(`current_or_new_return_item`, `current_return_item`, `exchanged_unit?`, and
+the `original_return_item` association — `required_quantity` survives for
+`Stock::Adjuster` with its exchange branch collapsed).
-### Phase 3b: Workflows
+### Phase 3b: Workflows — SHIPPED
The fifteen workflows above, in `app/workflows/spree/{returns,exchanges,claims}/`.
No transition is reachable except through one of them — there is no
`return.receive!`. Admin and Store API controllers call the workflow and render
-its `Result`.
-
-Ordering note: Phase 3b lands with Phase 3, not after it. A model shipped with
-a status column and no way to move it is not usable, and shipping a temporary
-state machine "just to unblock" would defeat the purpose.
-
-### Phase 4: Drop legacy models
-
-- Drop: ReturnAuthorization, CustomerReturn, Reimbursement, ReimbursementType (all subtypes)
-- Drop: `spree_return_authorizations`, `spree_customer_returns`, `spree_reimbursements`, `spree_reimbursement_types`
-- Keep: `spree_return_items_legacy` (renamed in Phase 1) for historical reference, drop in 6.1
-- Drop: `Spree::Exchange` service class (replaced by model)
-
-### Phase 5: API
+its `Result`. Covered by lifecycle specs
+(`spree/core/spec/workflows/spree/{returns,exchanges,claims}/lifecycle_spec.rb`).
+
+### Phase 4: Drop legacy models — SHIPPED
+
+- Drop models: `ReturnAuthorization`, `CustomerReturn`, `Reimbursement`,
+ `ReimbursementType` (all subtypes), `ReimbursementPerformer`,
+ `ReimbursementTaxCalculator`, `Reimbursement::Credit`, the
+ `reimbursement_type_engine`/`validator`, legacy `ReturnItem` + its
+ eligibility validators, `ReturnsCalculator`, and the `Spree::Exchange`
+ service class (replaced by the model)
+- **Tables are deliberately NOT dropped.** Every legacy table
+ (`spree_return_authorizations`, `spree_return_items`,
+ `spree_customer_returns`, `spree_reimbursements`,
+ `spree_reimbursement_types`, `spree_reimbursement_credits`) survives 6.0 as
+ the data migration's source and rollback safety net; they are dropped in
+ 6.1 once installs have run `spree:upgrade:migrate_returns`. Only the Ruby
+ classes go.
+- Swept the referencing surface: v3 legacy serializers
+ (`return_authorization_serializer`, `customer_return_serializer`,
+ `reimbursement_serializer` + admin twins) and their
+ `Spree::Api::Dependencies` registrations, permission sets, seeds
+ (`Seeds::ReturnsEnvironment`), `Order`/`Store`/`FulfillmentItem`
+ associations and methods, `PermittedAttributes`, factories, locale keys,
+ sample data, the emails engine, and the SDK type barrels
+
+### Phase 5: API — SHIPPED
+
+As built, transitions are `PATCH` member actions (matching the house style of
+`orders/:id/approve` etc.), records are updatable but not deletable — a
+mistaken return is `cancel`ed, never destroyed — and top-level read-only
+index/show endpoints exist alongside the order-nested ones:
```
-# Returns
-POST /api/v3/admin/orders/:order_id/returns
+# Admin — same shape for returns / exchanges / claims
GET /api/v3/admin/orders/:order_id/returns
-PATCH /api/v3/admin/returns/:id
-DELETE /api/v3/admin/returns/:id
-POST /api/v3/admin/returns/:id/approve
-POST /api/v3/admin/returns/:id/receive
-POST /api/v3/admin/returns/:id/refund
-POST /api/v3/admin/returns/:id/cancel
-
-# Exchanges
-POST /api/v3/admin/orders/:order_id/exchanges
-GET /api/v3/admin/orders/:order_id/exchanges
-PATCH /api/v3/admin/exchanges/:id
-POST /api/v3/admin/exchanges/:id/approve
-POST /api/v3/admin/exchanges/:id/receive
-POST /api/v3/admin/exchanges/:id/fulfill
-POST /api/v3/admin/exchanges/:id/cancel
-
-# Claims
-POST /api/v3/admin/orders/:order_id/claims
-GET /api/v3/admin/orders/:order_id/claims
-PATCH /api/v3/admin/claims/:id
-POST /api/v3/admin/claims/:id/approve
-POST /api/v3/admin/claims/:id/resolve
-POST /api/v3/admin/claims/:id/deny
-POST /api/v3/admin/claims/:id/cancel
-
-# Store API: customers can initiate returns/claims
-POST /api/v3/store/orders/:order_id/returns
-POST /api/v3/store/orders/:order_id/claims
+GET /api/v3/admin/orders/:order_id/returns/:id
+POST /api/v3/admin/orders/:order_id/returns
+PATCH /api/v3/admin/orders/:order_id/returns/:id
+PATCH /api/v3/admin/orders/:order_id/returns/:id/approve
+PATCH /api/v3/admin/orders/:order_id/returns/:id/receive
+PATCH /api/v3/admin/orders/:order_id/returns/:id/refund # fulfill on exchanges; resolve/deny on claims
+PATCH /api/v3/admin/orders/:order_id/returns/:id/cancel
+GET /api/v3/admin/returns # + /exchanges, /claims — cross-order listing
+GET /api/v3/admin/returns/:id
+
+# Store API — customers initiate returns and claims (exchanges are admin-only)
GET /api/v3/store/orders/:order_id/returns
+GET /api/v3/store/orders/:order_id/returns/:id
+POST /api/v3/store/orders/:order_id/returns
GET /api/v3/store/orders/:order_id/claims
+GET /api/v3/store/orders/:order_id/claims/:id
+POST /api/v3/store/orders/:order_id/claims
+
+# Reasons — admin only (back-office vocabulary, no storefront surface)
+GET /api/v3/admin/return_reasons # + /claim_reasons, /refund_reasons
+POST /api/v3/admin/return_reasons
+PATCH /api/v3/admin/return_reasons/:id
+DELETE /api/v3/admin/return_reasons/:id
```
## Constraints on Current Work
-- **Don't add new features to ReturnAuthorization, CustomerReturn, or Reimbursement.** They're being replaced.
+- **The legacy chain is frozen and being deleted this cycle.** Don't add
+ features to ReturnAuthorization, CustomerReturn, or Reimbursement, and don't
+ build anything new on top of them — they won't exist after the
+ `feature/cleanup-old-returns-system` branch lands.
- **Don't add new ReimbursementType subtypes.** The STI hierarchy is being dropped.
-- **New return/exchange logic should be designed for the three-model pattern.** Think "Return with ReturnItems" not "ReturnAuthorization with ReturnItems through CustomerReturn."
+- **New return/exchange logic uses the three-model pattern.** Think "Return with ReturnLineItems" not "ReturnAuthorization with ReturnItems through CustomerReturn."
- **Refund stays as-is.** It's the payment-level primitive. Returns, Exchanges, and Claims create Refunds when money needs to go back.
- **No state machine on any new model in this area.** Plain `status` string,
inclusion validation, transitions through workflows. This generalizes beyond
@@ -883,18 +928,30 @@ GET /api/v3/store/orders/:order_id/claims
1. **Store API return initiation.** Both Store API (self-service) and Admin API. Customers can initiate returns and claims; exchanges may require admin approval depending on store config. Self-service returns are the modern standard — backoffice-only is legacy.
-2. **Return shipping labels.** Yes. Return gains `generate_label` which delegates to the FulfillmentProvider interface (from 6.0-fulfillment-and-delivery.md). E.g., `return.generate_label` calls EasyPost to create a prepaid return label. The label URL is stored on the Return record. Add `return_label_url` column.
+2. **Return shipping labels.** Yes — as built, label generation lives on the workflow, not the model: `Returns::Approve` takes `generate_label:` and requests the label as an `external_step` through the `Spree.return_label_provider` seam, storing the URL in the shipped `return_label_url` column. Core registers no provider yet (the step is soft-guarded); a carrier gem (EasyPost/Shippo, see 6.0-delivery-rate-provider.md) supplies one.
3. **Partial returns/exchanges.** No separate "case" or "ticket" model. All three entities belong to Order — `order.returns`, `order.exchanges`, `order.claims` gives the full picture. The admin UI shows a unified "Post-sale" tab on the order page listing all three chronologically. If correlation is needed (e.g., "this claim was filed because the exchange arrived damaged"), use the `metadata` JSON column.
+4. **Line-item naming (2026-08-05).** `ReturnLineItem` / `ExchangeLineItem` / `ClaimLineItem` are permanent, not a coexistence workaround. They mirror `Spree::LineItem` and a post-drop rename to `*Item` would cost table + serializer + SDK + dashboard churn for a shorter name.
+
+5. **Reason models (2026-08-05).** `ReturnAuthorizationReason` is renamed to `ReturnReason` (deprecated alias one release) and a separate `ClaimReason` is added — claim vocabulary ("arrived damaged") differs from return vocabulary ("wrong size"). All three entities' `reason` associations repoint on the legacy-drop branch.
+
+6. **Data migration timing (2026-08-05).** `spree:migrate_returns` ships on the legacy-drop branch, reading legacy tables through lightweight anonymous AR classes so it survives the model deletion. Riding Wave 7 would have blocked the drop.
+
+7. **Balance owed on exchanges.** Never auto-charged — recorded for the merchant to collect. Charging a stored card without a fresh authorization is not something core does silently.
+
## Open Questions
None at this time.
## References
-- Current return models: `spree/core/app/models/spree/return_authorization.rb`, `return_item.rb`, `customer_return.rb`, `reimbursement.rb`
-- Current ReimbursementType hierarchy: `spree/core/app/models/spree/reimbursement_type/`
+- New models: `spree/core/app/models/spree/{return,exchange,claim}.rb` + `*_line_item.rb`
+- Workflows: `spree/core/app/workflows/spree/{returns,exchanges,claims}/`
+- Status concern: `spree/core/app/models/concerns/spree/has_status.rb`
+- Developer doc: `docs/v6/developer/core-concepts/returns-exchanges-claims.mdx`
+- Legacy models being dropped: `spree/core/app/models/spree/return_authorization.rb`, `return_item.rb`, `customer_return.rb`, `reimbursement.rb`
+- Legacy ReimbursementType hierarchy: `spree/core/app/models/spree/reimbursement_type/`
- Related plan: `6.0-service-workflows.md` (the workflow tier; no-state-machines rule)
- Related plan: `6.0-fulfillment-and-delivery.md` (FulfillmentItem replaces InventoryUnit, Fulfillment replaces Shipment)
- Related plan: `6.0-split-adjustments.md` (return credits removed from adjustment system)
diff --git a/docs/plans/decisions.md b/docs/plans/decisions.md
index 5f64c59154..cebda42136 100644
--- a/docs/plans/decisions.md
+++ b/docs/plans/decisions.md
@@ -1,3 +1,127 @@
+## 2026-08-05: Dashboard form values must not embed SDK entity types
+
+The returns rework regenerated the admin SDK types, and the new `Order`
+embeds (`returns`/`exchanges`/`claims`, each carrying line items →
+variants and refunds → payments) enlarged Order's transitive type
+closure. That pushed TypeScript 6 over its relation-cache ceiling
+("RangeError: Map maximum size exceeded") — killing `tsc -b` for the
+whole dashboard — because the price-list form's rule drafts embedded
+`Customer[]` (→ `orders` → the enlarged graph) inside the react-hook-form
+values, and RHF's `Path<T>` enumerates every nested key of the form type.
+The old types were merely under the ceiling; the API embeds themselves
+are legitimate surface and were not changed.
+
+The rule this settles: **form-values types carry opaque display records,
+never SDK entity types.** `RuleEmbedRecord` (`{ id, name?, email?,
+code? }`) in `schemas/price-list.ts` is the pattern — full SDK records
+still flow in at runtime (covariant assignment), but the form type stays
+shallow, so path expansion is O(form fields) instead of O(SDK graph).
+`PromotionRuleFormDraft` embeds seven SDK types the same way and is one
+graph-growth away from the same failure — apply the pattern there when
+touched. Diagnostic note: `@typescript/native-preview` (tsgo) has no V8
+Map ceiling, so it *reports* the offending comparison with a line number
+instead of crashing — use it to locate this class of failure; keep tsc
+as the build compiler.
+
+
+## 2026-08-05: Reason CRUD ships admin-only; immutability moves onto the model
+
+Dropping the legacy Rails admin left return, claim and refund reasons with
+no editing surface at all, and the dashboard's create dialogs sent no
+`reason_id` as a result — every return, claim and refund was created
+reasonless, which quietly wasted the point of splitting return vocabulary
+from claim vocabulary. Closed with three `ResourceController` subclasses
+(`settings` scope), one combined **Settings → Reasons** page, and a reason
+picker on the three create dialogs.
+
+Two decisions worth recording:
+
+- **`mutable` is not a writable attribute.** Core seeds reasons it looks
+ up by name — `RefundReason.return_processing_reason` is attached to
+ every refund a return issues — so letting a client flip the flag would
+ hand it the ability to rename or delete the record the lookup depends
+ on. `permitted_params` covers `name` and `active` only.
+- **The immutability guard belongs on `Spree::NamedType`, not the ability
+ layer.** The existing `cannot [:edit, :update], …, mutable: false` rule
+ only fires for JWT users; secret API keys authorize by scope and never
+ consult CanCanCan, so that path could rename a locked reason freely.
+ The concern now carries `can_be_deleted?`, a rename validation and a
+ destroy guard, keyed off `has_attribute?(:mutable)` so NamedTypes
+ without the column are unaffected. This is the RBAC Axis A/B split
+ applied as intended: capabilities in permission sets, record-state
+ rules on the model.
+
+Reasons have no Store API surface — they are back-office vocabulary — so
+the serializers are admin-only and excluded from Store SDK generation.
+
+
+## 2026-08-05: Legacy returns chain removed — tables kept, three capability replacements
+
+The drop landed. Four decisions came out of doing it, each because
+deleting the legacy code would otherwise have quietly removed working
+behaviour:
+
+- **The legacy tables stay through 6.0.** Only the Ruby classes are
+ deleted. `spree_return_authorizations`, `spree_return_items`,
+ `spree_customer_returns`, `spree_reimbursements`,
+ `spree_reimbursement_types` and `spree_reimbursement_credits` remain as
+ the data migration's source and its rollback path; they drop in 6.1
+ once installs have run `spree:upgrade:migrate_returns`. A migration
+ that deletes its own source in the same release has no way back.
+- **`Order#outstanding_balance` drops the reimbursement term rather than
+ replacing it.** `payment_total` is already computed net of refunds by
+ `Carts::RecalculateTotals`, so returns and claims need no term of their
+ own — the legacy reimbursement payout was the only money movement that
+ sat outside that sum. A fully refunded order therefore shows its
+ balance as outstanding again, which is what the pre-existing
+ "refund without a reimbursement" test already asserted.
+- **`Return#refunded_total` counts store credit as well as refunds.**
+ Store credit is a separate ledger and never creates a `Spree::Refund`
+ row, so summing refunds alone reported zero for a store-credit refund —
+ wrong on the record, in the API, and in the customer's email.
+- **The reimbursement email is replaced, not dropped.**
+ `Spree::ReturnMailer#refunded_email` fires on `return.refunded`. The
+ legacy template's expedited-exchange section has no counterpart in the
+ new model and was not carried over.
+
+Also renamed `StoreCreditCategory.default_reimbursement_category` to
+`.default_refund_category` (deprecated alias kept one release), and
+repointed `OrderStatusSubscriber` from the `return_item.*` events to
+`return.received/refunded/canceled`.
+
+
+## 2026-08-05: Returns/exchanges/claims — legacy drop scope, permanent *LineItem names, reason renames
+
+The new returns system (`6.0-returns-exchanges-claims.md`) shipped to
+6-0-dev: three entities, fifteen workflows, admin + store v3 APIs,
+dashboard pages. Reviewing what remains settled four things:
+
+- **`ReturnLineItem` / `ExchangeLineItem` / `ClaimLineItem` are the
+ permanent names.** Chosen during implementation because legacy
+ `Spree::ReturnItem` was still in service, they stay after the drop:
+ they mirror `Spree::LineItem`, and renaming to the plan's shorter
+ `*Item` would cost a table rename plus serializer/SDK/dashboard churn
+ for nothing.
+- **Reasons:** `ReturnAuthorizationReason` → `ReturnReason` (model +
+ table rename, deprecated alias one release) plus a new `ClaimReason`
+ model — claim vocabulary ("arrived damaged", "never arrived") is a
+ different list from return vocabulary ("wrong size", "changed mind").
+ `RefundReason` stays.
+- **`spree:upgrade:migrate_returns` ships together with the legacy drop**,
+ on the same branch, reading legacy tables via lightweight anonymous AR
+ classes (the `migrate_users_to_customers` pattern) so it works after
+ the models are deleted. Riding Wave 7 would have blocked the drop.
+ Resumption needs no cursor, job or checkpoint table: the legacy
+ `number` carries onto the new record and is uniquely indexed there, so
+ the remaining work is a query rather than tracked state — which cannot
+ drift out of sync with what was actually written.
+- The drop scope: legacy models + STI reimbursement types + eligibility
+ validators + v3 legacy serializers + seeds + permission-set grants +
+ legacy tables (except `spree_return_items`, kept under its original
+ name for historical reference until 6.1). `Spree::Metafields` lands on
+ the three entities on the same branch.
+
+
## 2026-08-04: Commerce-behavior globals move to Store preferences; app configuration stays global
A full usage audit of `Spree::Config` (multi-agent trace with adversarial
diff --git a/docs/v6/user/returns/returns-processing.mdx b/docs/v6/user/returns/returns-processing.mdx
new file mode 100644
index 0000000000..01d0bd45b3
--- /dev/null
+++ b/docs/v6/user/returns/returns-processing.mdx
@@ -0,0 +1,83 @@
+---
+title: "Returns Processing"
+description: "Learn how to process returns, exchanges, and claims in Spree Commerce."
+---
+
+Spree 6 handles everything that happens after a sale with three records, each covering a different situation:
+
+- **Return** — the customer sends items back and gets their money back.
+- **Exchange** — the customer sends items back and gets different items instead, such as another size or colour.
+- **Claim** — something went wrong with the delivery. The item arrived damaged, never arrived, or was the wrong product. You can send a replacement, refund the customer, or both, without asking for the original item back.
+
+Each one belongs directly to an order, so opening an order shows you everything that has happened to it.
+
+<Note>
+ This replaces the older three-step flow of Return Authorization, Customer Return, and Reimbursement. One record now covers the whole operation from request through to refund.
+</Note>
+
+## Returns
+
+### 1. Open the return
+
+Find the order and create a return against it, choosing the items coming back and how many units of each. You can also record the reason for the return, which stock location the goods are returning to, and an internal memo.
+
+Customers can also open returns themselves from their account, if your storefront offers it. Those arrive with the status **requested**.
+
+### 2. Approve it
+
+Approving a return tells the customer it is authorised. If you use a carrier that supports it, you can generate a prepaid return label at this point, and the label is stored on the return for the customer to use.
+
+### 3. Receive the goods
+
+When the parcel arrives, record what actually turned up. Partial returns are normal, so you enter the quantity received for each line rather than assuming everything the customer said they would send has arrived.
+
+You also mark each line as resellable or not. Resellable items go back into stock automatically at the return's stock location; damaged items do not.
+
+### 4. Refund the customer
+
+Refund the return to either the original payment method or store credit. You can refund the full amount or part of it, and you can refund in more than one step — part to store credit and part back to the card, for example.
+
+Once the refund goes through, the customer receives an email confirming it.
+
+<Note>
+ A return can be cancelled at any point before the goods are received. Cancelling restocks nothing.
+</Note>
+
+## Exchanges
+
+An exchange follows the same path as a return — open, approve, receive — but instead of refunding the customer at the end, you fulfil the replacement items.
+
+When you fulfil an exchange, Spree creates the replacement shipment for the quantities that were actually received, and checks the replacements are in stock first.
+
+If the replacement items are worth less than what came back, the difference is returned to the customer as store credit or refunded to their original payment method. If the replacements are worth more, Spree records the difference but does not charge the customer automatically — collecting that balance is up to you, so nobody's card is charged without them agreeing to it.
+
+## Claims
+
+A claim starts when a customer reports a problem. Claims record what went wrong — damaged, missing, wrong item, or another reason you define — and the customer can attach photographs as evidence.
+
+When you resolve a claim you choose what to do:
+
+- **Refund** — money back, with no items required in return.
+- **Replacement** — ship the item again, either the same variant or a different one.
+- **Refund and replacement** — both.
+
+You can also deny a claim if it does not hold up, or cancel it.
+
+## Where to find them
+
+Returns, exchanges, and claims each have their own section in the dashboard, so you can see everything in progress across all orders. Individual records also appear on the order they belong to, giving you the full history of that order in one place.
+
+## Reasons
+
+Spree keeps two separate lists of reasons, managed under **Settings → Returns** and seeded when your store is created:
+
+- **Return reasons** explain why a customer is sending something back — "wrong size", "changed my mind", "no longer needed". These apply to both returns and exchanges.
+- **Claim reasons** explain what went wrong on your end — "arrived damaged", "never arrived", "wrong item sent".
+
+They are kept separate because they answer different questions, and mixing them makes reporting less useful. See [Settings → Returns Configuration](https://spreecommerce.org/docs/user/settings/returns-configuration) for how to manage them.
+
+## Return policy
+
+Spree does not enforce a return window, restocking fee, or final-sale rule out of the box. Every merchant's policy differs, and the rules often vary by country for legal reasons.
+
+Instead, your developers can attach your policy to the point where a return is created. A common setup enforces the policy for customers opening returns themselves, while still letting your staff override it — so a supervisor can accept a return outside the window for a good customer without needing a code change.
diff --git a/docs/v6/user/settings/returns-configuration.mdx b/docs/v6/user/settings/returns-configuration.mdx
new file mode 100644
index 0000000000..eb2843ae4e
--- /dev/null
+++ b/docs/v6/user/settings/returns-configuration.mdx
@@ -0,0 +1,67 @@
+---
+title: "Returns Configuration"
+description: "Learn how to define return reasons, claim reasons, and refund reasons."
+---
+
+Returns management is a crucial part of ecommerce operations. It builds customer trust, streamlines support workflows, and helps maintain clarity around inventory and financial adjustments.
+
+Not all ecommerce platforms offer built-in tools for managing returns, but fortunately Spree does — no extra plugins or custom development needed.
+
+Before you start processing returns, it is worth setting up the three lists of reasons Spree uses. Each answers a different question, which is why they are kept apart: mixing them together makes your reporting far less useful.
+
+## Return Reasons
+
+Return reasons record why a customer is sending something back. They apply to both returns and exchanges.
+
+Typical examples are "Wrong size", "No longer needed", "Different from description", and "Arrived too late".
+
+Each reason has two fields:
+
+- **Name**: the reason itself, as your team and customers will see it.
+- **Status**: whether the reason is available for use. Setting a reason to inactive hides it from new returns without deleting the history of returns that already used it.
+
+## Claim Reasons
+
+Claim reasons record what went wrong with a delivery — problems on your end rather than a customer changing their mind.
+
+Typical examples are "Arrived damaged", "Never arrived", "Wrong item sent", and "Missing item from order".
+
+They have the same two fields as return reasons: a name and a status.
+
+<Note>
+ Claims also have a separate **type** field — damaged, missing, wrong item, or other — which is a broader grouping than the reason. Your developers can add more types if the standard four do not fit your business.
+</Note>
+
+## Refund Reasons
+
+Refund reasons explain why money was sent back. They are used internally for tracking, reporting, and communication across teams, and they apply to any refund, whether or not a return was involved.
+
+Typical examples are "Return processing" and "Order cancelled".
+
+Refund reasons have an extra setting:
+
+- **Mutable**: when set to no, the reason is locked and cannot be edited or deleted. Spree uses this to protect the built-in reasons it relies on, such as "Return processing", so that an accidental edit cannot break your returns flow.
+
+## Managing reasons
+
+All three lists live together under **Settings → Returns**. Spree seeds a starting set when your store is created, so returns, claims, and refunds work out of the box, and you can add, rename, deactivate, or delete entries from there.
+
+Each reason has two fields: its **name**, and whether it is **available on new records**. Turning that switch off retires a reason — it stops appearing when staff open a new return, claim, or refund, while every record that already used it keeps its explanation.
+
+A reason that is already attached to a record cannot be deleted, for exactly that reason. Deactivate it instead.
+
+<Note>
+ Some reasons are marked **Built in**. Spree looks these up by name — "Return processing" is attached to every refund issued through a return — so they cannot be renamed or deleted. You can still deactivate them.
+</Note>
+
+## What about return windows and restocking fees?
+
+Spree does not ship with a fixed return window, restocking fee, or final-sale setting. Return policy varies enormously between merchants, and often has to differ by country for legal reasons — the European Union, for example, requires a minimum withdrawal period that many other markets do not.
+
+Rather than guessing, Spree gives your developers a place to attach your own policy when a return is created. A common arrangement enforces the policy for customers opening returns themselves, while letting your staff override it, so a supervisor can accept a late return for a loyal customer without needing any code changes.
+
+## Processing Returns
+
+Once your reasons are set up, you are ready to handle returns, exchanges, and claims.
+
+To learn how, see [Returns → Returns Processing](https://spreecommerce.org/docs/user/returns/returns-processing).
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index 15b3082b20..b51d1c8ed5 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -173,6 +173,8 @@ import type {
PromotionRuleCreateParams,
PromotionRuleUpdateParams,
PromotionUpdateParams,
+ ReasonCreateParams,
+ ReasonUpdateParams,
ResourceTypeDefinition,
ReturnCreateParams,
ReturnReceiveParams,
@@ -200,6 +202,7 @@ import type {
Category,
Channel,
Claim,
+ ClaimReason,
Country,
CouponCode,
CreditCard,
@@ -238,9 +241,11 @@ import type {
PromotionAction,
PromotionRule,
Refund,
+ RefundReason,
ResourceTranslations,
ResourceTranslationsNode,
Return,
+ ReturnReason,
Role,
StockItem,
StockLocation,
@@ -2637,6 +2642,91 @@ export class AdminClient {
this.request<void>('DELETE', `/tax_categories/${id}`, options),
}
+ // ============================================
+ // Reasons — why a return, claim or refund happened
+ // ============================================
+
+ readonly returnReasons = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<ReturnReason>> =>
+ this.request<PaginatedResponse<ReturnReason>>('GET', '/return_reasons', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, options?: RequestOptions): Promise<ReturnReason> =>
+ this.request<ReturnReason>('GET', `/return_reasons/${id}`, options),
+
+ create: (params: ReasonCreateParams, options?: RequestOptions): Promise<ReturnReason> =>
+ this.request<ReturnReason>('POST', '/return_reasons', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: ReasonUpdateParams,
+ options?: RequestOptions,
+ ): Promise<ReturnReason> =>
+ this.request<ReturnReason>('PATCH', `/return_reasons/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/return_reasons/${id}`, options),
+ }
+
+ readonly claimReasons = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<ClaimReason>> =>
+ this.request<PaginatedResponse<ClaimReason>>('GET', '/claim_reasons', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, options?: RequestOptions): Promise<ClaimReason> =>
+ this.request<ClaimReason>('GET', `/claim_reasons/${id}`, options),
+
+ create: (params: ReasonCreateParams, options?: RequestOptions): Promise<ClaimReason> =>
+ this.request<ClaimReason>('POST', '/claim_reasons', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: ReasonUpdateParams,
+ options?: RequestOptions,
+ ): Promise<ClaimReason> =>
+ this.request<ClaimReason>('PATCH', `/claim_reasons/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/claim_reasons/${id}`, options),
+ }
+
+ readonly refundReasons = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<RefundReason>> =>
+ this.request<PaginatedResponse<RefundReason>>('GET', '/refund_reasons', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, options?: RequestOptions): Promise<RefundReason> =>
+ this.request<RefundReason>('GET', `/refund_reasons/${id}`, options),
+
+ create: (params: ReasonCreateParams, options?: RequestOptions): Promise<RefundReason> =>
+ this.request<RefundReason>('POST', '/refund_reasons', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: ReasonUpdateParams,
+ options?: RequestOptions,
+ ): Promise<RefundReason> =>
+ this.request<RefundReason>('PATCH', `/refund_reasons/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/refund_reasons/${id}`, options),
+ }
+
// ============================================
// Channels (per-store distribution surfaces — online, POS, wholesale)
// ============================================
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index df9e940142..fcc2fa9695 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -909,6 +909,22 @@ export interface TaxCategoryUpdateParams {
is_default?: boolean
}
+/**
+ * Return, claim and refund reasons share the same shape — a name and whether
+ * it is offered on new records. `mutable` is deliberately absent: core seeds
+ * reasons it looks up by name and marks immutable, and a client must not be
+ * able to unlock one.
+ */
+export interface ReasonCreateParams {
+ name: string
+ active?: boolean
+}
+
+export interface ReasonUpdateParams {
+ name?: string
+ active?: boolean
+}
+
export interface MarketCreateParams {
/** Display name (unique per store, e.g. "Europe"). */
name: string
diff --git a/packages/admin-sdk/src/types/generated/ClaimReason.ts b/packages/admin-sdk/src/types/generated/ClaimReason.ts
new file mode 100644
index 0000000000..45b3119cd3
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/ClaimReason.ts
@@ -0,0 +1,15 @@
+// Typelizer digest d3adcd7f9f79cbb1c09ac2949c20fa71
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface ClaimReason {
+ id: string;
+ name: string;
+ active: boolean;
+ mutable: boolean;
+ created_at: string;
+ updated_at: string;
+ can_be_deleted: boolean;
+}
+
+export default ClaimReason;
diff --git a/packages/admin-sdk/src/types/generated/Customer.ts b/packages/admin-sdk/src/types/generated/Customer.ts
index 7f874736c9..c376d27d60 100644
--- a/packages/admin-sdk/src/types/generated/Customer.ts
+++ b/packages/admin-sdk/src/types/generated/Customer.ts
@@ -1,4 +1,4 @@
-// Typelizer digest df0607c7c9fc1b2a4a828aad989af2f8
+// Typelizer digest 6fba848fcffc083056d92227119da72f
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {Address, NewsletterSubscriber, CustomerGroup, Order, StoreCredit} from '@/types'
@@ -18,16 +18,10 @@ interface Customer {
default_shipping_address?: Address | null;
newsletter_subscriber?: NewsletterSubscriber | null;
customer_groups?: Array<CustomerGroup>;
- login: string | null;
+ failed_attempts: number;
metadata: Record<string, unknown>;
- last_sign_in_at: string | null;
- current_sign_in_at: string | null;
created_at: string;
updated_at: string;
- sign_in_count: number;
- failed_attempts: number;
- last_sign_in_ip: string | null;
- current_sign_in_ip: string | null;
tags: Array<string>;
internal_note_html: string | null;
default_billing_address_id: string | null;
diff --git a/packages/admin-sdk/src/types/generated/GiftCard.ts b/packages/admin-sdk/src/types/generated/GiftCard.ts
index fc55f20151..9a3b6266b3 100644
--- a/packages/admin-sdk/src/types/generated/GiftCard.ts
+++ b/packages/admin-sdk/src/types/generated/GiftCard.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 0b47215f8a7f358a702d0676fb1c66cb
+// Typelizer digest 02bbe826b5361df5675975d4ae3c12de
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {Customer, AdminUser, GiftCardBatch, Order} from '@/types'
diff --git a/packages/admin-sdk/src/types/generated/Order.ts b/packages/admin-sdk/src/types/generated/Order.ts
index 22cfeb99e7..99b2103f13 100644
--- a/packages/admin-sdk/src/types/generated/Order.ts
+++ b/packages/admin-sdk/src/types/generated/Order.ts
@@ -1,7 +1,7 @@
-// Typelizer digest d9432cdb6e4d1af419ef6cdb32c8b0c9
+// Typelizer digest 2367359de0e1fef1d82e130df6c964a9
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {LineItem, Fulfillment, Payment, Address, GiftCard, Market, AppliedPromotion, Cart, Channel, StockLocation, PaymentMethod, Customer, ReturnAuthorization, Reimbursement} from '@/types'
+import type {LineItem, Fulfillment, Payment, Address, GiftCard, Market, AppliedPromotion, Cart, Channel, StockLocation, PaymentMethod, Customer, Return, Exchange, Claim} from '@/types'
interface Order {
id: string;
@@ -76,8 +76,9 @@ interface Order {
approver?: Customer;
canceler?: Customer;
created_by?: Customer;
- return_authorizations?: Array<ReturnAuthorization>;
- reimbursements?: Array<Reimbursement>;
+ returns?: Array<Return>;
+ exchanges?: Array<Exchange>;
+ claims?: Array<Claim>;
}
export default Order;
diff --git a/packages/admin-sdk/src/types/generated/Refund.ts b/packages/admin-sdk/src/types/generated/Refund.ts
index d96faa2971..5718e3a824 100644
--- a/packages/admin-sdk/src/types/generated/Refund.ts
+++ b/packages/admin-sdk/src/types/generated/Refund.ts
@@ -1,7 +1,7 @@
-// Typelizer digest 84cd1e71b4e7e9483ab8d9bb26209317
+// Typelizer digest 44fa06f55f14e37f245449db070a6c75
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Payment, Reimbursement} from '@/types'
+import type {Payment} from '@/types'
interface Refund {
id: string;
@@ -9,12 +9,12 @@ interface Refund {
amount: string | null;
payment_id: string | null;
refund_reason_id: string | null;
- reimbursement_id: string | null;
+ originator_id: string | null;
+ originator_type: string | null;
metadata: Record<string, unknown>;
created_at: string;
updated_at: string;
payment?: Payment;
- reimbursement?: Reimbursement;
}
export default Refund;
diff --git a/packages/admin-sdk/src/types/generated/RefundReason.ts b/packages/admin-sdk/src/types/generated/RefundReason.ts
new file mode 100644
index 0000000000..24b0cd6305
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/RefundReason.ts
@@ -0,0 +1,15 @@
+// Typelizer digest e7433be3a1cdec6e8418fccb86c22aa5
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface RefundReason {
+ id: string;
+ name: string;
+ active: boolean;
+ mutable: boolean;
+ created_at: string;
+ updated_at: string;
+ can_be_deleted: boolean;
+}
+
+export default RefundReason;
diff --git a/packages/admin-sdk/src/types/generated/Reimbursement.ts b/packages/admin-sdk/src/types/generated/Reimbursement.ts
deleted file mode 100644
index 2fce106c9d..0000000000
--- a/packages/admin-sdk/src/types/generated/Reimbursement.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-// Typelizer digest 7f0c99245ccf647eed4193deb010b427
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Order} from '@/types'
-
-interface Reimbursement {
- id: string;
- number: string;
- reimbursement_status: string | null;
- total: string | null;
- order_id: string | null;
- customer_return_id: string | null;
- created_at: string;
- updated_at: string;
- order?: Order;
-}
-
-export default Reimbursement;
diff --git a/packages/admin-sdk/src/types/generated/ReturnAuthorization.ts b/packages/admin-sdk/src/types/generated/ReturnAuthorization.ts
deleted file mode 100644
index 3ed2385600..0000000000
--- a/packages/admin-sdk/src/types/generated/ReturnAuthorization.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-// Typelizer digest 192376f59dbdd08a9bb6cb9747f7ffc9
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Order, StockLocation} from '@/types'
-
-interface ReturnAuthorization {
- id: string;
- number: string;
- status: string;
- order_id: string | null;
- stock_location_id: string | null;
- return_authorization_reason_id: string | null;
- created_at: string;
- updated_at: string;
- order?: Order;
- stock_location?: StockLocation;
-}
-
-export default ReturnAuthorization;
diff --git a/packages/admin-sdk/src/types/generated/ReturnReason.ts b/packages/admin-sdk/src/types/generated/ReturnReason.ts
new file mode 100644
index 0000000000..813450d8c4
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/ReturnReason.ts
@@ -0,0 +1,15 @@
+// Typelizer digest 4ae7bb6dc7c232a59d9f9449d5ce3e36
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface ReturnReason {
+ id: string;
+ name: string;
+ active: boolean;
+ mutable: boolean;
+ created_at: string;
+ updated_at: string;
+ can_be_deleted: boolean;
+}
+
+export default ReturnReason;
diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.ts
index a6bf38737e..5534bb8c52 100644
--- a/packages/admin-sdk/src/types/generated/index.ts
+++ b/packages/admin-sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest c2ebf5ea871438ad65f0e28411f2e858
+// Typelizer digest b14aa69286e8ad77f8c17915ec3fcc9f
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -10,6 +10,7 @@ export type { default as Cart } from './Cart'
export type { default as Category } from './Category'
export type { default as Channel } from './Channel'
export type { default as ClaimLineItem } from './ClaimLineItem'
+export type { default as ClaimReason } from './ClaimReason'
export type { default as Claim } from './Claim'
export type { default as CollectionRule } from './CollectionRule'
export type { default as Collection } from './Collection'
@@ -60,10 +61,10 @@ export type { default as ProductType } from './ProductType'
export type { default as PromotionAction } from './PromotionAction'
export type { default as PromotionRule } from './PromotionRule'
export type { default as Promotion } from './Promotion'
+export type { default as RefundReason } from './RefundReason'
export type { default as Refund } from './Refund'
-export type { default as Reimbursement } from './Reimbursement'
-export type { default as ReturnAuthorization } from './ReturnAuthorization'
export type { default as ReturnLineItem } from './ReturnLineItem'
+export type { default as ReturnReason } from './ReturnReason'
export type { default as Return } from './Return'
export type { default as Role } from './Role'
export type { default as SetupTask } from './SetupTask'
diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.ts
index 7d622ae55d..31a4792629 100644
--- a/packages/admin-sdk/src/types/index.ts
+++ b/packages/admin-sdk/src/types/index.ts
@@ -19,6 +19,7 @@ export type { default as Category } from './generated/Category'
export type { default as Channel } from './generated/Channel'
export type { default as Claim } from './generated/Claim'
export type { default as ClaimLineItem } from './generated/ClaimLineItem'
+export type { default as ClaimReason } from './generated/ClaimReason'
export type { default as Country } from './generated/Country'
export type { default as CouponCode } from './generated/CouponCode'
export type { default as CreditCard } from './generated/CreditCard'
@@ -66,10 +67,10 @@ export type { default as Promotion } from './generated/Promotion'
export type { default as PromotionAction } from './generated/PromotionAction'
export type { default as PromotionRule } from './generated/PromotionRule'
export type { default as Refund } from './generated/Refund'
-export type { default as Reimbursement } from './generated/Reimbursement'
+export type { default as RefundReason } from './generated/RefundReason'
export type { default as Return } from './generated/Return'
-export type { default as ReturnAuthorization } from './generated/ReturnAuthorization'
export type { default as ReturnLineItem } from './generated/ReturnLineItem'
+export type { default as ReturnReason } from './generated/ReturnReason'
export type { default as Role } from './generated/Role'
export type { default as SetupTask } from './generated/SetupTask'
export type { default as State } from './generated/State'
diff --git a/packages/cli/src/generated/admin-spec.json b/packages/cli/src/generated/admin-spec.json
index 1e9f18787f..61724627ff 100644
--- a/packages/cli/src/generated/admin-spec.json
+++ b/packages/cli/src/generated/admin-spec.json
@@ -1 +1 @@
-{"info":{"title":"Admin API","contact":{"name":"Spree Commerce","url":"https://spreecommerce.org","email":"[email protected]"},"description":"Spree Admin API v3 - Administrative API for managing products, orders, and store settings.\n\n## Authentication\n\nThe Admin API requires a secret API key passed in the `x-spree-api-key` header.\nSecret API keys can be generated in the Spree admin dashboard.\n\n## Response Format\n\nAll responses are JSON. List endpoints return paginated responses with `data` and `meta` keys.\nSingle resource endpoints return a flat JSON object.\n\n## Resource IDs\n\nEvery resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,\n`variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,\nrequest bodies, and Ransack filters all accept them directly.\n\n## Error Handling\n\nErrors return a consistent format:\n```json\n{\n \"error\": {\n \"code\": \"validation_error\",\n \"message\": \"Validation failed\",\n \"details\": { \"name\": [\"can't be blank\"] }\n }\n}\n```\n","version":"v3"},"paths":{"/api/v3/admin/auth/login":{"post":{"summary":"Login","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Authenticates an admin user and returns a short-lived JWT access token.\nThe rotatable refresh token is set in an HttpOnly cookie — it is not\nincluded in the response body.\n\nThe `provider` field selects the authentication method. When omitted it\ndefaults to `email`, the built-in email/password login.\n\nTo authenticate against a third-party identity provider (Okta, Azure AD,\nGoogle Workspace SSO, a custom JWT issuer, SAML, etc.), send\n`{ \"provider\": \"<your_key>\", ... }` with the fields that provider\nrequires. The endpoint returns the same JWT regardless of which provider\nauthenticated the request. See\n[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication)\nfor the list of configured providers and their required fields.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"title":"EmailPasswordLogin","description":"Built-in email/password authentication (default when `provider` is omitted).","type":"object","properties":{"provider":{"type":"string","enum":["email"],"default":"email"},"email":{"type":"string","format":"email"},"password":{"type":"string"}},"required":["email","password"]},{"title":"ProviderLogin","description":"Provider-dispatched login. The `provider` key selects a configured\nauthentication provider; the remaining fields are forwarded to it.\nRequired fields depend on the provider — see\n[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication).\n","type":"object","properties":{"provider":{"type":"string","description":"Registered provider key (anything other than `email`).","not":{"enum":["email"]}}},"required":["provider"],"additionalProperties":true}]}}}}}},"/api/v3/admin/auth/refresh":{"post":{"summary":"Refresh token","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Exchanges the HttpOnly refresh-token cookie for a new access JWT and a\nrotated refresh token cookie. No request body or Authorization header\nis required — the cookie alone authenticates the call.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"refresh successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"missing or invalid refresh-token cookie","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/auth/logout":{"post":{"summary":"Logout","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Revokes the refresh-token cookie, effectively logging the admin out.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"logout successful"}}}},"/api/v3/admin/me":{"get":{"summary":"Get current admin user and permissions","tags":["Authentication"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the current admin user profile and a serialized list of permissions (CanCanCan rules). The SPA uses these to drive UI permission checks.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"current admin user and permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update the current admin profile","tags":["Authentication"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Self-service update of the signed-in admin's own profile, such as their admin UI display language (`selected_locale`).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"profile updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"selected_locale":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"}}}}}}}},"/api/v3/admin/auth/password_resets":{"post":{"summary":"Request password reset","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Requests a password reset email for an admin user. Always returns `202`\nwhether or not the email matches an account, to prevent enumeration.\n\n`redirect_url` is where the emailed link should point (the reset token\nis appended as a `token` query param). It must match one of the store's\nallowed origins — otherwise it is silently ignored and the server-side\ndefault is used. The email is delivered by Spree itself via the\n`admin_user.password_reset_requested` event; this event is never\nforwarded to webhook endpoints.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"202":{"description":"reset requested","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"redirect_url":{"type":"string","description":"Must match an allowed origin of the store; ignored otherwise."}},"required":["email"]}}}}}},"/api/v3/admin/auth/password_resets/{id}":{"patch":{"summary":"Reset password","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Consumes a password reset token (the `token` query param from the\nemailed link), sets the new password, and signs the admin in: the\nresponse carries a JWT access token and the rotatable refresh token is\nset in an HttpOnly cookie. The token is single-use — it invalidates as\nsoon as the password changes.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","description":"The reset token from the emailed link","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"password reset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"422":{"description":"invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"password":{"type":"string"},"password_confirmation":{"type":"string"}},"required":["password","password_confirmation"]}}}}}},"/api/v3/admin/allowed_origins":{"get":{"summary":"List allowed origins","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the CORS allowlist for the current store. Each entry is a\nbare `scheme://host[:port]` permitted to call the admin API from a\nbrowser. Backs the `Rack::Cors` allowlist and the CSRF boundary of\nthe admin cookie session (see\n`docs/plans/5.5-admin-auth-cookie-refresh.md`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[origin_cont]","in":"query","required":false,"description":"Filter by origin (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origins found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AllowedOrigin"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds an origin to the admin CORS allowlist. The value must be a bare\n`scheme://host[:port]` (no path, query, or fragment) and use `http` or\n`https`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"allowed origin created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"origin":{"type":"string"}},"required":["origin"]}}}}}},"/api/v3/admin/allowed_origins/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Allowed origin ID","schema":{"type":"string"}}],"get":{"summary":"Get an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single allowed origin by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origin found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"404":{"description":"allowed origin not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing allowed origin.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origin updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"origin":{"type":"string"}}}}}}},"delete":{"summary":"Delete an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes an origin from the admin CORS allowlist. After deletion the\nadmin SPA running at that origin will no longer be able to call the\nadmin API from a browser.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"allowed origin deleted"}}}},"/api/v3/admin/api_keys":{"get":{"summary":"List API keys","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns publishable and secret API keys for the current store. Secret keys are listed by `token_prefix` only — the plaintext token is delivered exactly once on create.\n\n**Required scope:** `read_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API keys found","content":{"application/json":{}}}}},"post":{"summary":"Create an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a publishable or secret API key. The plaintext token is included in the response **once** for secret keys; publishable keys expose their token on every read since they are intended for client-side use.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"secret key created — plaintext token returned once","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name","key_type"],"properties":{"name":{"type":"string"},"key_type":{"type":"string","enum":["publishable","secret"]},"scopes":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/api_keys/{id}":{"get":{"summary":"Show an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key found","content":{"application/json":{}}}}},"patch":{"summary":"Update an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Renames a key. `key_type` and `scopes` are fixed at creation — to change a key's authority, create a new key and revoke the old one.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key renamed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}}}}}},"delete":{"summary":"Delete an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"API key deleted"}}}},"/api/v3/admin/api_keys/current":{"get":{"summary":"Describe the current API key","tags":["API Keys"],"security":[{"api_key":[]}],"description":"Returns the secret key that authenticated this request, including its live scopes. Useful to confirm a key's real, current authority. Only secret-key principals have a single key to describe.\n\n**Required scope:** none — any key can describe itself (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"current API key","content":{"application/json":{}}}}}},"/api/v3/admin/api_keys/{id}/revoke":{"patch":{"summary":"Revoke an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Marks the key revoked. Future requests using its token will fail; the row is preserved for audit.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key revoked","content":{"application/json":{}}}}}},"/api/v3/admin/categories":{"get":{"summary":"List categories","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of the store's categories (manual hierarchical taxons; rule-based collections are excluded).\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., children, parent, ancestors).","schema":{"type":"string"}}],"responses":{"200":{"description":"categories found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a category. Nests under the parent when parent_id is given, otherwise creates a top-level category.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"category created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"parent_id":{"type":"string","description":"Prefixed ID of the parent category"},"description":{"type":"string"},"permalink":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"hide_from_nav":{"type":"boolean"}},"required":["name"]}}}}}},"/api/v3/admin/categories/{id}":{"get":{"summary":"Get a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single category by ID.\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., children, parent, ancestors).","schema":{"type":"string"}}],"responses":{"200":{"description":"category found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}},"404":{"description":"category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a category.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"category updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"parent_id":{"type":"string","description":"Prefixed ID of the parent category"},"description":{"type":"string"},"permalink":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"hide_from_nav":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a category and its descendants.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"204":{"description":"category deleted"}}}},"/api/v3/admin/categories/{id}/reposition":{"patch":{"summary":"Reposition a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a category to a new parent and/or index within the tree.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"category repositioned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_parent_id":{"type":"string","description":"Prefixed ID of the new parent (omit for top level)"},"new_position":{"type":"integer","description":"0-based index among the new parent's children"}},"required":["new_position"]}}}}}},"/api/v3/admin/categories/{category_id}/products":{"get":{"summary":"List category products","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Products classified under the category, ordered by their classification position.\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Add a product to a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Classifies a product under the category (appended to the end).\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"201":{"description":"product added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"product_id":{"type":"string"}},"required":["product_id"]}}}}}},"/api/v3/admin/categories/{category_id}/products/{id}":{"delete":{"summary":"Remove a product from a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes a product from the category's manual classification.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product removed"}}}},"/api/v3/admin/categories/{category_id}/products/{id}/reposition":{"patch":{"summary":"Reposition a category product","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a product to a new index among the category's products.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product repositioned"}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_position":{"type":"integer","description":"0-based index among the category's products"}},"required":["new_position"]}}}}}},"/api/v3/admin/channels":{"get":{"summary":"List channels","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the channels configured for the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"channels found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new channel on the current store. `code` is normalized to a\nURL-safe slug (`Point of Sale` → `point-of-sale`); when omitted it's\nderived from `name`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"channel created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"code":{"type":"string","description":"Slug — auto-derived from `name` when blank."},"active":{"type":"boolean","default":true},"default":{"type":"boolean","default":false},"preferred_order_routing_strategy":{"type":"string","nullable":true,"description":"Routing strategy class name. `null` inherits the store setting."},"preferred_storefront_access":{"type":"string","nullable":true,"enum":["public","prices_hidden","login_required"],"description":"Anonymous-visitor access posture. `null` inherits the store setting."},"preferred_guest_checkout":{"type":"boolean","nullable":true,"description":"Whether guests can check out without an account. `null` inherits the store setting."}}}}}}}},"/api/v3/admin/channels/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"channel found","content":{"application/json":{}}}}},"patch":{"summary":"Update a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"channel updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"active":{"type":"boolean"},"default":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string","nullable":true,"description":"Routing strategy class name. `null` inherits the store setting."},"preferred_storefront_access":{"type":"string","nullable":true,"enum":["public","prices_hidden","login_required"],"description":"Anonymous-visitor access posture. `null` inherits the store setting."},"preferred_guest_checkout":{"type":"boolean","nullable":true,"description":"Whether guests can check out without an account. `null` inherits the store setting."}}}}}}},"delete":{"summary":"Delete a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"channel deleted"}}}},"/api/v3/admin/channels/{id}/add_products":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"summary":"Publish products on a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes the listed products on this channel. Idempotent — re-publishing\nan already-published product updates its publication window. Products from\nsibling stores are silently dropped.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products published","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["product_ids"],"properties":{"product_ids":{"type":"array","items":{"type":"string"}},"published_at":{"type":"string","format":"date-time","nullable":true,"description":"When the publications go live. `null` means immediately."},"unpublished_at":{"type":"string","format":"date-time","nullable":true,"description":"When the publications come down. `null` means never."}}}}}}}},"/api/v3/admin/channels/{id}/remove_products":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"summary":"Unpublish products from a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Unpublishes the listed products from this channel.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products unpublished","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["product_ids"],"properties":{"product_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/channels/{channel_id}/order_routing_rules":{"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List order routing rules for a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the channel's routing rules in priority order. The rules engine walks them top-down; see the Order Routing guide.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules found","content":{"application/json":{}}}}},"post":{"summary":"Create an order routing rule on a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a rule to the channel's routing list. The `type` is the wire shorthand from `GET /order_routing_rules/types` (e.g. `preferred_location`). Omitting `position` appends the rule at the end of the list. Each rule kind can appear at most once per channel — a duplicate `type` is rejected with a validation error.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"rule created","content":{"application/json":{}}},"422":{"description":"unknown rule type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"active":{"type":"boolean"},"position":{"type":"integer"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/channels/{channel_id}/order_routing_rules/{id}":{"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Update an order routing rule","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a rule's `active` flag, `position` (the list reorders around it), or `preferences`. The rule kind cannot be changed — delete and re-create instead.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"active":{"type":"boolean"},"position":{"type":"integer"},"preferences":{"type":"object","additionalProperties":true}}}}}}},"delete":{"summary":"Delete an order routing rule","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"rule deleted"}}}},"/api/v3/admin/order_routing_rules/types":{"get":{"summary":"List available order routing rule types","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Enumerates the registered rule kinds with their labels, descriptions and preference schemas — drives the \"Add rule\" picker in the admin dashboard. Plugins extend the list by registering `Spree::OrderRoutingRule` subclasses via `Spree.order_routing.rules`.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"types found","content":{"application/json":{}}}}}},"/api/v3/admin/custom_field_definitions":{"get":{"summary":"List custom field definitions","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all defined custom fields. Filter by `?q[resource_type_eq]=Spree::Product` to narrow to one parent type.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"definitions returned","content":{"application/json":{}}}}},"post":{"summary":"Create a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"definition created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["key","field_type","resource_type"],"properties":{"namespace":{"type":"string","description":"Defaults to `custom`"},"key":{"type":"string"},"label":{"type":"string","description":"Human-readable name; defaults to titleized `key`"},"field_type":{"type":"string","description":"Custom field type identifier (one of the registered field-type class names)."},"resource_type":{"type":"string","description":"Owner class, e.g. `Spree::Product`"},"storefront_visible":{"type":"boolean","description":"When false, definition is admin-only (was `display_on: back_end`)"},"searchable":{"type":"boolean","description":"When true, values are included in storefront product text search"},"sortable":{"type":"boolean","description":"When true, storefront product listings can sort by this field"}}}}}}}},"/api/v3/admin/custom_field_definitions/{id}":{"get":{"summary":"Show a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"definition found","content":{"application/json":{}}}}},"patch":{"summary":"Update a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"definition updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"storefront_visible":{"type":"boolean"},"searchable":{"type":"boolean"},"sortable":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes the definition and cascades to all custom field values referencing it.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"definition deleted"}}}},"/api/v3/admin/customer_groups":{"get":{"summary":"List customer groups","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer groups configured for the current store. Groups\nsegment customers for targeted promotions (see the `customer_group`\npromotion rule) and reporting. The list endpoint never embeds the\nmember list — fetch a single group with `?expand=customers` if you\nneed them inline, or query `/admin/customers?customer_group_id_in=…`\nfor paginated membership.\n\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer groups found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a customer group in the current store. `customer_ids` is\noptional; when present, customers are attached at create time.\nPass prefixed IDs (e.g. `cus_…`) — the server decodes them\nautomatically.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"customer group created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"customer_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customer_groups/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Customer group prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single customer group. Pass `?expand=customers` to embed\nthe full member list inline (recommended only for single-record\nreads — embed cost scales with membership size).\n\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `customers`.","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer group with embedded customers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"404":{"description":"customer group not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name, description, or membership. `customer_ids` is a\nfull-set replacement — the server reconciles the membership to\nmatch the array, adding new IDs and removing ones not present.\nSend `customer_ids: []` to clear all members.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customer group updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"customer_ids":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"customer group deleted"}}}},"/api/v3/admin/customers/{customer_id}/addresses":{"get":{"summary":"List customer addresses","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer's saved addresses.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"addresses found","content":{"application/json":{}}}}},"post":{"summary":"Create a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new address to the customer's address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default — the previous default loses its flag in the same transaction.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"address created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"address2":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string","description":"ISO-2 country code (e.g. US)"},"state_abbr":{"type":"string","description":"State/province abbreviation (e.g. NY)"},"phone":{"type":"string"},"company":{"type":"string"},"label":{"type":"string"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"}}}}}}}},"/api/v3/admin/customers/{customer_id}/addresses/{id}":{"patch":{"summary":"Update a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a customer address.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"address updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"city":{"type":"string"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes the address. If it was a default, the customer loses that default (no auto-promotion).\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"address deleted"}}}},"/api/v3/admin/customers/{customer_id}/credit_cards":{"get":{"summary":"List customer credit cards","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer's saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"credit cards found","content":{"application/json":{}}}}}},"/api/v3/admin/customers/{customer_id}/credit_cards/{id}":{"get":{"summary":"Show a customer credit card","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a saved credit card by ID.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"credit card found","content":{"application/json":{}}}}},"delete":{"summary":"Delete a customer credit card","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a saved credit card.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"credit card deleted"}}}},"/api/v3/admin/customers/{customer_id}/store_credits":{"get":{"summary":"List customer store credits","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns store credits issued to the customer.\n\n**Required scope:** `read_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credits found","content":{"application/json":{}}}}},"post":{"summary":"Issue a store credit to a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"`created_by` is set automatically from the authenticated admin.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"store credit created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["amount","currency","category_id"],"properties":{"amount":{"type":"string"},"currency":{"type":"string"},"category_id":{"type":"string","description":"StoreCreditCategory ID"},"memo":{"type":"string"}}}}}}}},"/api/v3/admin/customers/{customer_id}/store_credits/{id}":{"patch":{"summary":"Update a store credit","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Update memo / category / amount. The amount can only be changed if `amount_used == 0`.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"store credit updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string"},"category_id":{"type":"string"},"memo":{"type":"string"}}}}}}},"delete":{"summary":"Delete a store credit","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an unused store credit (amount_used == 0). Returns 422 otherwise.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"store credit deleted"}}}},"/api/v3/admin/customers":{"get":{"summary":"List customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of customers. Supports Ransack search/filters.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[search]","in":"query","required":false,"description":"Email + name full-text-ish search","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., addresses, store_credits). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customers found","content":{"application/json":{}}}}},"post":{"summary":"Create a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a customer. No welcome email is sent automatically.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"customer created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"phone":{"type":"string"},"accepts_email_marketing":{"type":"boolean"},"internal_note":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}}}}}}},"/api/v3/admin/customers/{id}":{"get":{"summary":"Show a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns full customer details including computed order stats (orders_count, total_spent, last_order_completed_at).\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Customer ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations: addresses, orders, store_credits, default_billing_address, default_shipping_address","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer found","content":{"application/json":{}}}}},"patch":{"summary":"Update a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates customer attributes. `tags` replaces the full set.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customer updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"phone":{"type":"string"},"accepts_email_marketing":{"type":"boolean"},"internal_note":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}}}}}},"delete":{"summary":"Delete a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a customer. Returns 422 if the customer has any orders.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"customer deleted"}}}},"/api/v3/admin/customers/bulk_add_to_groups":{"post":{"summary":"Bulk-add customers to groups","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each customer in `ids` to every group in `customer_group_ids`.\nIdempotent — customers already in a group are skipped server-side.\nGroups from sibling stores are silently ignored. Returns counts of\ncustomers and groups that were processed (post store-scoping).\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customers added to groups","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"customer_group_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","customer_group_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_from_groups":{"post":{"summary":"Bulk-remove customers from groups","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each customer in `ids` from every group in `customer_group_ids`.\nNo-op for non-members. Groups from sibling stores are silently ignored.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customers removed from groups","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"customer_group_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","customer_group_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_add_tags":{"post":{"summary":"Bulk-add tags to customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds each tag name in `tags` to every customer in `ids`. Tags are\nupserted by name; re-adding an existing tag is a no-op.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags added","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_tags":{"post":{"summary":"Bulk-remove tags from customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes each tag name in `tags` from every customer in `ids`. No-op\nfor customers that don't carry the tag.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags removed","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/exports":{"get":{"summary":"List exports","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"exports found","content":{"application/json":{}}}}},"post":{"summary":"Create an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Queues a CSV export. The `type` selects the dataset; `search_params` is an\noptional Ransack query (same shape used by the `q[...]` params on list endpoints)\nthat filters which records are exported. Pass `record_selection: \"all\"` to\nclear the filter server-side and export everything in scope.\n\nGeneration is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,\nthen redirect the browser to `download_url` to fetch the file.\n\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"export queued","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["products","orders","customers","product_translations","gift_cards","coupon_codes","newsletter_subscribers"]},"record_selection":{"type":"string","enum":["filtered","all"],"description":"Set to \"all\" to ignore search_params and export everything in scope."},"search_params":{"type":"object","description":"Ransack query hash. Same predicates accepted by the list endpoint.","additionalProperties":true},"results_url":{"type":"string","description":"Absolute URL of your admin exports view; the export-done email uses it as the download button target. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/exports/{id}":{"get":{"summary":"Show an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns export status. While `done` is `false`, the SPA continues polling.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"export found","content":{"application/json":{}}}}},"delete":{"summary":"Delete an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the export and purges its attachment.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"export deleted"}}}},"/api/v3/admin/exports/{id}/download":{"get":{"summary":"Download an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL — a top-level navigation cannot carry the JWT.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"CSV file","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments":{"get":{"summary":"List fulfillments","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all shipments for an order.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillments found","content":{"application/json":{}}}}},"post":{"summary":"Create a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Manually creates a fulfillment on a completed order, bypassing order routing — for example to mirror a shipment handled by an external carrier or 3PL. Moves the requested line item quantities out of their current fulfillments; when `items` is omitted, every not-yet-shipped unit is moved. Pass `status: 'shipped'` to register an already-shipped fulfillment (fires shipped webhooks and freezes cost/carrier). When `delivery_method_id` is omitted, the fulfillment inherits the delivery method and cost of the source fulfillment(s) it fully drains — keeping the order total unchanged; partially drained splits get no carrier when shipped, and pending fulfillments are otherwise (re)priced by the standard rate engine, which selects the lowest-cost available rate. Pass `cost` to set an explicit shipping cost instead (e.g. the 3PL price) — note this changes the order total and payment state, and is guaranteed to persist only with `status: 'shipped'` (pending fulfillments are re-priced by the rate engine).\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"fulfillment created","content":{"application/json":{}}},"422":{"description":"order not completed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["stock_location_id"],"properties":{"stock_location_id":{"type":"string","description":"Stock location the fulfillment ships from"},"tracking":{"type":"string","description":"Carrier tracking number, or a full https:// tracking link — a full URL is served back as tracking_url unchanged instead of being templated into the delivery method tracking URL"},"delivery_method_id":{"type":"string","description":"Delivery method (carrier) to attach as the selected rate. Defaults to the delivery method of the fully drained source fulfillment(s)"},"cost":{"type":"string","description":"Explicit shipping cost. Defaults to the summed cost of the fully drained source fulfillment(s), which keeps the order total unchanged; an explicit cost changes the order total and payment state. Guaranteed to persist only with status: 'shipped' — pending fulfillments are re-priced by the rate engine"},"status":{"type":"string","enum":["shipped"],"description":"Pass 'shipped' to register the fulfillment as already shipped"},"items":{"type":"array","description":"Line item quantities to fulfill. Omit to fulfill every not-yet-shipped unit.","items":{"type":"object","required":["item_id","quantity"],"properties":{"item_id":{"type":"string","description":"Line item ID"},"quantity":{"type":"integer"}}}},"metadata":{"type":"object","additionalProperties":true}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}":{"get":{"summary":"Show a shipment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific shipment.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"shipment found","content":{"application/json":{}}}}},"patch":{"summary":"Update a shipment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a fulfillment (tracking, delivery rate).\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"shipment updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tracking":{"type":"string","description":"Carrier tracking number, or a full https:// tracking link served back as tracking_url unchanged"},"selected_delivery_rate_id":{"type":"string","description":"Delivery rate ID (dr_...) to select"}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/fulfill":{"patch":{"summary":"Fulfill a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Marks a fulfillment as fulfilled.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment fulfilled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":{"patch":{"summary":"Cancel a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Cancels a fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment canceled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":{"patch":{"summary":"Resume a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Resumes a canceled fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment resumed","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":{"patch":{"summary":"Split a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Transfers items from this shipment to a new shipment at a different stock location.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment split","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id","quantity"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"stock_location_id":{"type":"string","description":"Target stock location ID"}}}}}}}},"/api/v3/admin/gift_card_batches":{"get":{"summary":"List gift card batches","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the gift card batches issued by the current store. Each batch\ngroups the cards generated together for a campaign or bulk-issuance\n— the cards themselves live under `/admin/gift_cards` and reference\nthe batch via `gift_card_batch_id`.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Records per page","schema":{"type":"integer"}},{"name":"q[prefix_cont]","in":"query","required":false,"description":"Filter by prefix (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift card batches found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GiftCardBatch"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a gift card batch","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a batch of gift cards in a single call. The server generates\n`codes_count` cards inline for small batches (configurable via\n`Spree.config.gift_card_batch_web_limit`, default 500) or enqueues\na background job for larger ones. Each card's code is the batch\n`prefix` followed by random hex.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"gift card batch created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCardBatch"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["prefix","amount","codes_count"],"properties":{"prefix":{"type":"string","description":"Lowercased and prepended to every generated code."},"amount":{"type":"string","description":"Decimal amount per card, greater than zero."},"currency":{"type":"string","description":"ISO 4217 currency code. Defaults to the store currency."},"codes_count":{"type":"integer","description":"Number of cards to generate. Capped at `gift_card_batch_limit`."},"expires_at":{"type":"string","nullable":true}}}}}}}},"/api/v3/admin/gift_card_batches/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Gift card batch prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a gift card batch","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single batch.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"gift card batch found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCardBatch"}}}},"404":{"description":"gift card batch not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/gift_cards":{"get":{"summary":"List gift cards","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the gift cards issued by the current store. Filter by\n`q[code_cont]` for code search, `q[user_id_eq]` for cards issued\nto a specific customer, or `q[state_eq]` for status filtering.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[code_cont]","in":"query","required":false,"description":"Filter by gift card code (contains)","schema":{"type":"string"}},{"name":"q[state_eq]","in":"query","required":false,"description":"Filter by status (active, redeemed, partially_redeemed, canceled)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift cards found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GiftCard"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a gift card scoped to the current store. The code is\nauto-generated when omitted. `currency` defaults to the store's\nconfigured currency. Pass `user_id` (prefixed ID) to attach the\ncard to a specific customer.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"gift card created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["amount"],"properties":{"amount":{"type":"string","description":"Decimal amount, greater than zero."},"currency":{"type":"string","description":"ISO 4217 currency code. Defaults to the store currency."},"code":{"type":"string","description":"Optional caller-supplied code. Auto-generated when omitted."},"expires_at":{"type":"string","description":"ISO 8601 date.","nullable":true},"user_id":{"type":"string","description":"Optional customer prefixed ID.","nullable":true}}}}}}}},"/api/v3/admin/gift_cards/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Gift card prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single gift card.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift card found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}},"404":{"description":"gift card not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an active gift card's editable attributes. Redeemed or\npartially-redeemed cards cannot be edited.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"gift card updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string"},"expires_at":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an unused gift card. Cards that have been redeemed or\npartially redeemed cannot be deleted and return 422.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"gift card deleted"},"422":{"description":"redeemed gift card cannot be deleted","content":{"application/json":{}}}}}},"/api/v3/admin/imports":{"get":{"summary":"List imports","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns CSV imports queued or completed for the current store.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"imports found","content":{"application/json":{}}}}},"post":{"summary":"Create an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Queues a CSV import. Upload the file first via `POST /api/v3/admin/direct_uploads`\nand pass the returned `signed_id` as `attachment`. On success the import is in the\n`mapping` state and the response carries the mapping payload: `schema_fields`\n(the canonical columns for the type), `csv_headers`, a `sample_row`, and the\nauto-assigned `mappings`.\n\nAdjust mappings if needed, then call `PATCH /admin/imports/{id}/complete_mapping`\nto start processing. Poll `GET /admin/imports/{id}` while `status` is\n`completed_mapping`/`processing`; terminal statuses are `completed` and `failed`.\n\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"import created in mapping state","content":{"application/json":{}}},"422":{"description":"unknown import type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["type","attachment"],"properties":{"type":{"type":"string","enum":["products","customers","product_translations"]},"attachment":{"type":"string","description":"ActiveStorage signed blob id from POST /api/v3/admin/direct_uploads."},"preferred_delimiter":{"type":"string","enum":[",",";","|","\t"],"description":"CSV column separator. Defaults to a comma."},"results_url":{"type":"string","description":"Absolute URL of your admin imports view; the import-done email links back to it with `?import=<id>` appended. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/imports/template":{"get":{"summary":"Download an import template","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a CSV header row for the given import type, including the custom field columns available for the model.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"type","in":"query","required":true,"description":"Registered import type, e.g. products.","schema":{"type":"string"}}],"responses":{"200":{"description":"CSV template","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/imports/example":{"get":{"summary":"Download an example import file","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Redirects to a populated example CSV for the given import type — the same sample data `rake spree:load_sample_data` uses, pinned to the installed Spree version. Returns 404 for a type that ships no example file.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"type","in":"query","required":true,"description":"Registered import type, e.g. products.","schema":{"type":"string"}}],"responses":{"302":{"description":"Redirect to the example CSV"}}}},"/api/v3/admin/imports/{id}":{"get":{"summary":"Show an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns import status and row counters. The admin dashboard polls this endpoint while `status` is `completed_mapping` or `processing`; `rows_count`, `completed_rows_count` and `failed_rows_count` drive the progress bar. The mapping payload (`csv_headers`, `sample_row`) is only present while `status` is `mapping`.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"import found","content":{"application/json":{}}}}},"delete":{"summary":"Delete an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the import, its rows and the uploaded file. Returns 422 while the import is being processed.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"import deleted"}}}},"/api/v3/admin/imports/{id}/download":{"get":{"summary":"Download the originally uploaded file","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Streams the CSV exactly as it was uploaded — the audit trail for what was imported. JWT/API-key protected; SPA clients fetch it with the Authorization header and trigger the browser download via a Blob URL.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"CSV file","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/imports/{id}/complete_mapping":{"patch":{"summary":"Complete mapping and start processing","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies the submitted column mappings, then starts row processing. Omit `mappings`\nto accept the auto-assigned ones from the create response. Returns 422 when a\nrequired schema field is left unmapped (`details.missing_required_fields`) or a\nfile column is assigned twice.\n\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"mapping completed, processing queued","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"mappings":{"type":"array","description":"Column assignments to apply before starting. `file_column: null` unmaps a field.","items":{"type":"object","required":["schema_field"],"properties":{"schema_field":{"type":"string"},"file_column":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/imports/{id}/retry_failed_rows":{"patch":{"summary":"Retry failed rows","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Re-processes the rows that failed. The import re-enters `processing`; poll `GET /admin/imports/{id}` until it completes again. Returns 422 when the import is not `completed` or has no failed rows.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"retry queued","content":{"application/json":{}}}}}},"/api/v3/admin/imports/{import_id}/rows":{"get":{"summary":"List import rows","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Paginated rows of an import — the failure report. Filter with `q[status_eq]=failed` to list only rows that could not be imported; each row carries the raw CSV `data` and its `validation_errors`.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"import_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"description":"Filter rows by status: pending, processing, completed, failed.","schema":{"type":"string"}}],"responses":{"200":{"description":"rows found","content":{"application/json":{}}}}}},"/api/v3/admin/markets":{"get":{"summary":"List markets","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the markets configured for the current store. Markets are\nstore-scoped and ordered by `position` (an `acts_as_list` column —\nupdate the order via `PATCH /markets/{id}` with `position`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `countries`.","schema":{"type":"string"}}],"responses":{"200":{"description":"markets found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Market"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new market for the current store.\n\n- `country_isos` accepts 2-letter ISO country codes (e.g. `[\"DE\", \"FR\"]`);\n the market must contain at least one country. Unknown codes are\n silently dropped.\n- `supported_locales` accepts an array of locale codes; the\n `default_locale` is always implicitly included.\n- Setting `default: true` automatically demotes the previous default\n market in the store.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"market created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"currency":{"type":"string","description":"ISO 4217 currency code."},"default_locale":{"type":"string","description":"IETF locale tag used as the market default."},"supported_locales":{"type":"array","items":{"type":"string"},"description":"Locale codes available in this market. The default is always implicitly included."},"tax_inclusive":{"type":"boolean","default":false,"description":"Display prices with tax included."},"default":{"type":"boolean","default":false,"description":"Setting to true demotes the previous default."},"position":{"type":"integer","description":"Sort order within the store; lower = first."},"country_isos":{"type":"array","items":{"type":"string"},"description":"2-letter ISO country codes assigned to this market. At least one is required."}},"required":["name","currency","default_locale","country_isos"]}}}}}},"/api/v3/admin/markets/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"market found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"404":{"description":"market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing market. Pass `country_isos` to replace the\nmarket's country list (full-set update), `supported_locales` to\nreplace the supported locales, or `position` to reorder the market\nwithin the store.\n\nSetting `default: true` automatically demotes the previous default.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"market updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"currency":{"type":"string"},"default_locale":{"type":"string"},"supported_locales":{"type":"array","items":{"type":"string"}},"tax_inclusive":{"type":"boolean"},"default":{"type":"boolean"},"position":{"type":"integer"},"country_isos":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the market (sets `deleted_at`). The default market and\nthe last remaining market in a store cannot be deleted — both return\n422 with a `validation_error`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"market deleted"},"422":{"description":"cannot delete default or last market","content":{"application/json":{}}}}}},"/api/v3/admin/option_types":{"get":{"summary":"List option types","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of option types.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,label,position). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"option types found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/OptionType"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new option type. Supports nested option values.\n\nOption values can be provided inline and will be created or updated by name.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"option type created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"},"filterable":{"type":"boolean"},"option_values":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"}}}}},"required":["name","label"]}}}}}},"/api/v3/admin/option_types/{id}":{"get":{"summary":"Get an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single option type by ID, including its option values.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,label,position). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"option type found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"404":{"description":"option type not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an option type. Supports updating nested option values.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}}],"responses":{"200":{"description":"option type updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"},"filterable":{"type":"boolean"},"option_values":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"Existing option value ID to update"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"}}}}}}}}}},"delete":{"summary":"Delete an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an option type.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}}],"responses":{"204":{"description":"option type deleted"}}}},"/api/v3/admin/orders/{order_id}/tax_lines":{"get":{"summary":"List tax lines","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Typed tax rows on the order. Read-only — written exclusively by the tax provider.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"200":{"description":"tax lines found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/discounts":{"get":{"summary":"List discounts","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Typed discount rows (promotion-sourced and manual) on the order.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"200":{"description":"discounts found","content":{"application/json":{}}}}},"post":{"summary":"Create manual discount","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a manual discount. With line_item_id a single row is created; without it the amount is distributed across line items (largest remainder). This is the sanctioned post-placement discount path and works on completed orders.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"201":{"description":"discount created","content":{"application/json":{}}},"422":{"description":"invalid discount","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"value":{"type":"number"},"value_type":{"type":"string","enum":["flat","percent"]},"line_item_id":{"type":"string","nullable":true,"description":"Target line item; omit to distribute order-level"}},"required":["label","value"]}}}}}},"/api/v3/admin/orders/{order_id}/fees":{"post":{"summary":"Create fee","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a fee (surcharge, handling, gift wrap, COD, payment fee). Order-level when no target is given. Works on completed orders.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"201":{"description":"fee created","content":{"application/json":{}}},"422":{"description":"invalid fee","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"amount":{"type":"number"},"kind":{"type":"string","enum":["surcharge","handling","gift_wrap","cod","payment"],"description":"Defaults to 'surcharge'"},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true}},"required":["label","amount"]}}}}}},"/api/v3/admin/orders/{order_id}/gift_cards":{"post":{"summary":"Apply a gift card to an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies a gift card by code to the order. Returns the gift card.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"gift card applied","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["code"],"properties":{"code":{"type":"string","description":"Gift card code"}}}}}}}},"/api/v3/admin/orders/{order_id}/gift_cards/{id}":{"delete":{"summary":"Remove a gift card from an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the gift card from the order.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Gift card ID","schema":{"type":"string"}}],"responses":{"204":{"description":"gift card removed"}}}},"/api/v3/admin/orders/{order_id}/items":{"get":{"summary":"List order items","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all line items for an order.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"items found","content":{"application/json":{}}}}},"post":{"summary":"Add an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new line item to the order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"item added","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id"],"properties":{"variant_id":{"type":"string","description":"Prefixed variant ID"},"quantity":{"type":"integer","default":1}}}}}}}},"/api/v3/admin/orders/{order_id}/items/{id}":{"get":{"summary":"Show an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific line item.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"item found","content":{"application/json":{}}}}},"patch":{"summary":"Update an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an order item quantity or metadata.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}}],"responses":{"200":{"description":"item updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"quantity":{"type":"integer"}}}}}}},"delete":{"summary":"Remove an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes an item from the order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}}],"responses":{"204":{"description":"line item removed"}}}},"/api/v3/admin/orders/{order_id}/store_credits":{"post":{"summary":"Apply customer's store credit to an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies the order customer's available store credit. When `amount` is omitted, applies up to the order outstanding balance.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"store credit applied","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string","description":"Optional explicit amount; defaults to order outstanding balance"}}}}}}},"delete":{"summary":"Remove store credit from an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes any applied store credit from the order.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"204":{"description":"store credit removed"}}}},"/api/v3/admin/orders":{"get":{"summary":"List orders","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of orders for the current store.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"sort","in":"query","required":false,"description":"Sort field (e.g., created_at, -created_at, completed_at)","schema":{"type":"string"}},{"name":"q[state_eq]","in":"query","required":false,"description":"Filter by state (cart, address, delivery, payment, confirm, complete, canceled)","schema":{"type":"string"}},{"name":"q[email_cont]","in":"query","required":false,"description":"Filter by email (contains)","schema":{"type":"string"}},{"name":"q[number_eq]","in":"query","required":false,"description":"Filter by order number","schema":{"type":"string"}},{"name":"q[completed_at_gt]","in":"query","required":false,"description":"Filter by completed after date","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"orders found","content":{"application/json":{}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a draft order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new draft order in one shot. Customer, items, addresses, currency,\nmarket, channel, locale, notes, metadata, and a coupon code can all be\nprovided inline.\n\nSetting `preferred_stock_location_id` pins the order's preferred fulfillment\nlocation — Order Routing's built-in `PreferredLocation` rule consumes it\nwhen picking which stock location ships each shipment.\n\nInvalid coupon codes are non-fatal — the order is created and the failure\nis reported on the service result (not in the API response body for now).\n\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"order created with preferred_stock_location_id","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"customer_id":{"type":"string","description":"Customer ID. Alias: user_id (legacy)."},"use_customer_default_address":{"type":"boolean","description":"When true with customer_id, copies the customer's saved billing/shipping addresses onto the order."},"currency":{"type":"string"},"market_id":{"type":"string","description":"Market ID"},"channel_id":{"type":"string","description":"Channel ID. Defaults to the store primary channel when omitted."},"preferred_stock_location_id":{"type":"string","description":"Stock Location ID to prefer for fulfillment. Order Routing's built-in PreferredLocation rule reads this and ranks the location first; routing falls back to the next rule when the preferred location can't cover the cart."},"locale":{"type":"string"},"customer_note":{"type":"string","description":"Public, customer-visible note"},"internal_note":{"type":"string","description":"Staff-only note"},"metadata":{"type":"object","description":"Arbitrary key/value metadata"},"shipping_address":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"shipping_address_id":{"type":"string","description":"Existing customer address ID"},"billing_address":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"billing_address_id":{"type":"string","description":"Existing customer address ID"},"items":{"type":"array","items":{"type":"object","required":["variant_id","quantity"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"metadata":{"type":"object"}}}},"coupon_code":{"type":"string","description":"Optional. Applied non-fatally; invalid codes do not block creation."}}}}}}}},"/api/v3/admin/orders/{id}":{"get":{"summary":"Show an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns full order details including admin-only fields.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID (e.g., or_xxx)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"order found","content":{"application/json":{}}},"404":{"description":"order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an order. Supports updating email, addresses, special instructions, and line items.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"customer_note":{"type":"string"},"internal_note":{"type":"string"},"channel_id":{"type":"string","description":"Channel ID"},"preferred_stock_location_id":{"type":"string","description":"Stock Location ID to prefer for fulfillment. Re-runs Order Routing's PreferredLocation rule on subsequent shipment rebuilds."},"ship_address":{"type":"object","properties":{"firstname":{"type":"string"},"lastname":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"zipcode":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"bill_address":{"type":"object","properties":{"firstname":{"type":"string"},"lastname":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"zipcode":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"items":{"type":"array","items":{"type":"object","required":["variant_id"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"metadata":{"type":"object"}}}}}}}}}},"delete":{"summary":"Delete a draft order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a draft order. Completed orders cannot be deleted.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"204":{"description":"order deleted"}}}},"/api/v3/admin/orders/{id}/complete":{"patch":{"summary":"Complete an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Completes an order in the `confirm` state, marking it as placed.\n\nSet `notify_customer: true` to send the order confirmation email.\n\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order completed","content":{"application/json":{}}},"422":{"description":"order cannot be completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"notify_customer":{"type":"boolean","description":"Send the order confirmation email after completion."}}}}}}}},"/api/v3/admin/orders/{id}/cancel":{"patch":{"summary":"Cancel an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Cancels a completed order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order canceled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/approve":{"patch":{"summary":"Approve an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Approves an order (e.g., for fraud review).\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order approved","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resume":{"patch":{"summary":"Resume a canceled order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Resumes a previously canceled order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order resumed","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resend_confirmation":{"post":{"summary":"Resend confirmation email","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes the order.completed event to trigger confirmation email delivery.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"confirmation resent","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods":{"get":{"summary":"List payment methods","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the store's configured payment methods. Use `source_required: true` to know which methods need a saved source.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,type,active). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment methods found","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods/types":{"get":{"summary":"List available payment provider types","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PaymentMethod subclasses that can be used to create new payment methods. Useful for populating a \"Provider\" dropdown in admin UIs.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"provider types found","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods/{id}":{"get":{"summary":"Show a payment method","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a payment method by ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,type,active). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment method found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments":{"get":{"summary":"List payments","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all payments for an order.\n\n**Required scope:** `read_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payments found","content":{"application/json":{}}}}},"post":{"summary":"Create a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new payment for the order.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"payment created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["payment_method_id"],"properties":{"payment_method_id":{"type":"string","description":"Payment method ID"},"amount":{"type":"string"},"source_id":{"type":"string","description":"Payment source ID"}}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}":{"get":{"summary":"Show a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific payment.\n\n**Required scope:** `read_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/capture":{"patch":{"summary":"Capture a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Captures a pending payment.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"payment captured","content":{"application/json":{}}},"422":{"description":"capture failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/void":{"patch":{"summary":"Void a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Voids a payment.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"payment voided","content":{"application/json":{}}}}}},"/api/v3/admin/price_lists":{"get":{"summary":"List price lists","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the price lists configured for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `price_rules`.","schema":{"type":"string"}}],"responses":{"200":{"description":"price lists found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PriceList"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new draft price list.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"price list created (server-to-server — rules + prices, no product_ids)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer"},"product_ids":{"type":"array","items":{"type":"string"},"description":"Prefixed product ids to seed the list with."},"rules":{"type":"array","description":"STI-typed price rules to attach on create. Existing rules on the same payload via PATCH reconcile by id.","items":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"prices":{"type":"array","description":"Server-to-server alternative to `product_ids`: ship the exact per-variant prices the list should contain. Each row upserts on the unique key `(variant_id, currency, price_list_id)`. Mix-and-match with `product_ids` is supported but typically unnecessary — `prices` alone tells the server which variants belong to the list and what the override amount is.","items":{"type":"object","required":["variant_id","currency"],"properties":{"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/price_lists/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}},"404":{"description":"price list not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a price list. The optional `rules:` array reconciles nested\nSTI-typed price rules in a single round-trip — existing rules update\nby `id`, new rules build, missing rules destroy. Mirrors the\npromotion editor's \"save the whole thing on Save\" pattern.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list updated with nested rules","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer"},"product_ids":{"type":"array","items":{"type":"string"},"description":"Prefixed product ids — reconciles list membership (adds + removes)."},"rules":{"type":"array","items":{"type":"object","required":["type"],"properties":{"id":{"type":"string","nullable":true},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"prices":{"type":"array","description":"Individual price overrides (the spreadsheet payload). Each row updates by `id` if shipped, otherwise upserts on the unique key `(variant_id, currency, price_list_id)`.","items":{"type":"object","oneOf":[{"required":["id"]},{"required":["variant_id","currency"]}],"properties":{"id":{"type":"string"},"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}},"delete":{"summary":"Delete a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the price list. Associated prices are removed asynchronously.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"price list deleted"}}}},"/api/v3/admin/price_lists/{id}/activate":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Activate a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Transitions a draft / inactive list to `active`. If `starts_at` is\nin the future the list is marked `scheduled` instead, matching the\nlegacy admin behaviour.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list activated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/price_lists/{id}/deactivate":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Deactivate a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list deactivated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/prices":{"get":{"summary":"List prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Generic prices endpoint covering both base prices and price-list\noverrides. Filter with Ransack: `q[price_list_id_eq]=…`,\n`q[currency_eq]=USD`, `q[price_list_id_null]=true` (base prices only).\n\nThe admin spreadsheet uses this with server-side pagination so it\nscales past the metadata-PATCH path on `/price_lists/:id`.\n\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[price_list_id_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[price_list_id_null]","in":"query","required":false,"schema":{"type":"boolean"}},{"name":"q[currency_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[variant_id_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Comma-separated sort keys. Supports e.g. `variant_product_name,variant_id`.","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `variant`.","schema":{"type":"string"}}],"responses":{"200":{"description":"prices found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Price"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a single price. Omit `price_list_id` to create a base price.\nFor more than a handful of rows, prefer `POST /admin/prices/bulk_upsert`.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"price created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id","currency"],"properties":{"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"price_list_id":{"type":"string","nullable":true}}}}}}}},"/api/v3/admin/prices/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}},"404":{"description":"price not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the price (acts_as_paranoid).\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"price deleted"}}}},"/api/v3/admin/prices/bulk_upsert":{"post":{"summary":"Bulk-upsert prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Upserts a batch of prices in a single SQL round trip.\n\nEach row either:\n* targets an existing price by `id`, OR\n* matches on the unique key `(variant_id, currency, price_list_id)` —\n updating the existing row if one exists, creating one otherwise.\n\nModel callbacks (e.g. PriceHistory) are bypassed; this is a\nbulk-write fast path for the admin spreadsheet. The response\ncarries `price_count` — the number of rows touched.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"prices upserted","content":{"application/json":{"schema":{"type":"object","properties":{"price_count":{"type":"integer"}}}}}},"422":{"description":"missing prices key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["prices"],"properties":{"prices":{"type":"array","items":{"type":"object","required":["variant_id","currency"],"properties":{"id":{"type":"string","nullable":true},"variant_id":{"type":"string"},"currency":{"type":"string"},"price_list_id":{"type":"string","nullable":true},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/prices/bulk_destroy":{"delete":{"summary":"Bulk-delete prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes each price in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"prices deleted","content":{"application/json":{"schema":{"type":"object","properties":{"price_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields":{"get":{"summary":"List product custom fields","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the product's custom field values.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"custom fields found","content":{"application/json":{}}}}},"post":{"summary":"Create a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Sets a custom field value on the product. Requires an existing CustomFieldDefinition; pass its prefixed `cfdef_…` id.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"custom field created","content":{"application/json":{}}},"422":{"description":"duplicate definition for the same product","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["custom_field_definition_id","value"],"properties":{"custom_field_definition_id":{"type":"string","description":"Prefixed `cfdef_…` id"},"value":{"description":"Value matching the definition's `field_type`"}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields/{id}":{"get":{"summary":"Show a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"custom field found","content":{"application/json":{}}}}},"patch":{"summary":"Update a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates the custom field's `value`. The linked definition cannot be changed — delete and recreate to switch.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"custom field updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["value"],"properties":{"value":{"description":"New value"}}}}}}},"delete":{"summary":"Delete a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"custom field deleted"}}}},"/api/v3/admin/products/{product_id}/translations":{"get":{"summary":"List product translations","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the full translation matrix for the product: the source value and content type per translatable field, plus the translated value for every supported locale.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translations found","content":{"application/json":{}}}}}},"/api/v3/admin/products":{"get":{"summary":"List products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of products for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"sort","in":"query","required":false,"description":"Sort field (e.g., name, -name, price, -price, best_selling)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.","schema":{"type":"string"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"description":"Filter by status","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new product. Supports nested variants with prices and option types.\n\nOption types and values are auto-created if they don't exist.\nPrices are upserted by currency. Stock items are upserted by stock location.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"product created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string","enum":["draft","active","archived"]},"tax_category_id":{"type":"string","description":"Tax category ID"},"category_ids":{"type":"array","items":{"type":"string"},"description":"Array of category IDs"},"tags":{"type":"array","items":{"type":"string"}},"prices":{"type":"array","description":"Shorthand for a simple (no-options) product: per-currency prices that forward to the product's sole variant. For products with options, set prices per variant under `variants:` instead.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"variants":{"type":"array","description":"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).","items":{"type":"object","properties":{"sku":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}},"required":["name"]}}}}}},"/api/v3/admin/products/{id}":{"get":{"summary":"Get a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single product by ID.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID (e.g., prod_xxx)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"product found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"description":"product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a product. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"200":{"description":"product updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string","enum":["draft","active","archived"]},"tax_category_id":{"type":"string","description":"Tax category ID"},"category_ids":{"type":"array","items":{"type":"string"},"description":"Array of category IDs"},"tags":{"type":"array","items":{"type":"string"}},"prices":{"type":"array","description":"Shorthand for a simple (no-options) product: per-currency prices that forward to the product's sole variant. For products with options, set prices per variant under `variants:` instead.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"variants":{"type":"array","description":"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).","items":{"type":"object","properties":{"sku":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}}}}},"delete":{"summary":"Delete a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes a product.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product deleted"}}}},"/api/v3/admin/products/bulk_status_update":{"post":{"summary":"Bulk-update product status","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Sets `status` on each product in `ids`. Reindexes the affected products\nfor search. Cross-store IDs are silently dropped. Returns counts.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"cross-store products silently dropped","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"status":{"type":"string"}}}}}},"422":{"description":"invalid status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","status"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["draft","active","archived"]}}}}}}}},"/api/v3/admin/products/bulk_add_to_categories":{"post":{"summary":"Bulk-add products to categories","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each product in `ids` to every category (taxon) in `category_ids`.\nCategories from sibling stores are silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products added to categories","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"category_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","category_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_categories":{"post":{"summary":"Bulk-remove products from categories","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each product in `ids` from every category in `category_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products removed from categories","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","category_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_to_collections":{"post":{"summary":"Bulk-add products to collections","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each product in `ids` to every manual collection in `collection_ids`.\nAutomatic (rule-based) and sibling-store collections are silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products added to collections","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"collection_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","collection_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"collection_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_collections":{"post":{"summary":"Bulk-remove products from collections","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each product in `ids` from every collection in `collection_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products removed from collections","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","collection_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"collection_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_to_channels":{"post":{"summary":"Bulk-add products to channels","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes each product in `ids` on every channel in `channel_ids`. Idempotent —\nre-publishing on an existing channel is a no-op. Channels from sibling stores\nare silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products published on channels","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"channel_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","channel_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"channel_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_channels":{"post":{"summary":"Bulk-remove products from channels","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Unpublishes each product in `ids` from every channel in `channel_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products unpublished from channels","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"channel_count":{"type":"integer"},"removed":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","channel_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"channel_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_tags":{"post":{"summary":"Bulk-add tags to products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds each tag name in `tags` to every product in `ids`. Tags are upserted by name.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags added","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_tags":{"post":{"summary":"Bulk-remove tags from products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes each tag in `tags` from every product in `ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags removed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_destroy":{"delete":{"summary":"Bulk-delete products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes each product in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products deleted","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/promotions/{promotion_id}/coupon_codes":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List coupon codes for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the auto-generated coupon codes for a multi-code promotion. Single-code promotions store the code on the promotion itself; this endpoint returns an empty list for them.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"coupon codes found","content":{"application/json":{}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List actions for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"actions found","content":{"application/json":{}}}}},"post":{"summary":"Create an action on a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new action to a promotion. The `type` is the wire shorthand from `GET /promotion_actions/types` (e.g. `free_shipping`, `create_item_adjustments`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"action created","content":{"application/json":{}}},"422":{"description":"unknown action type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions/{id}":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"delete":{"summary":"Delete an action from a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"action deleted"}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List rules for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules found","content":{"application/json":{}}}}},"post":{"summary":"Create a rule on a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new rule to a promotion. The `type` is the wire shorthand from `GET /promotion_rules/types` (e.g. `currency`, `item_total`, `product`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"rule created with preferences","content":{"application/json":{}}},"422":{"description":"unknown rule type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules/{id}":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Update a rule's preferences","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"preferences":{"type":"object","additionalProperties":true}}}}}}},"delete":{"summary":"Delete a rule from a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"rule deleted"}}}},"/api/v3/admin/promotions":{"get":{"summary":"List promotions","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the store's promotions, including manual coupon and automatic promotions.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"promotions found","content":{"application/json":{}}}}},"post":{"summary":"Create a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new promotion. `code` is required for single-code coupon promotions;\npass `multi_codes: true` with `number_of_codes` to auto-generate a batch.\n\nRules and actions can be created in the same request by passing arrays of\n`{ type, preferences, ... }` rows. The server reconciles to the desired set:\nnew rows are built, existing rows (by `id`) are updated, omitted rows are removed.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"promotion created with rules and actions","content":{"application/json":{}}},"422":{"description":"invalid params","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","format":"date-time","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"usage_limit":{"type":"integer","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"kind":{"type":"string","enum":["coupon_code","automatic"]},"multi_codes":{"type":"boolean"},"number_of_codes":{"type":"integer","nullable":true},"code_prefix":{"type":"string","nullable":true},"promotion_category_id":{"type":"string","nullable":true},"rules":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"product_ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}},"customer_ids":{"type":"array","items":{"type":"string"}}},"required":["type"]}},"actions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"calculator":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"required":["type"]}}},"required":["name"]}}}}}},"/api/v3/admin/promotions/{id}":{"get":{"summary":"Show a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"promotion found","content":{"application/json":{}}}}},"patch":{"summary":"Update a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a promotion. The `rules` and `actions` arrays are treated as\na *desired set* — rows with `id` update in place, rows without `id` are\nbuilt fresh, and any existing row not present in the array is destroyed.\nPass `rules: []` or `actions: []` to clear them.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules and actions cleared with empty arrays","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"starts_at":{"type":"string","format":"date-time","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"usage_limit":{"type":"integer","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"kind":{"type":"string","enum":["coupon_code","automatic"]},"promotion_category_id":{"type":"string","nullable":true},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","nullable":true,"description":"Pass to update an existing rule; omit to build a new one"},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"product_ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}},"customer_ids":{"type":"array","items":{"type":"string"}}},"required":["type"]}},"actions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","nullable":true},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"calculator":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"required":["type"]}}}}}}}},"delete":{"summary":"Delete a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"promotion deleted"}}}},"/api/v3/admin/promotion_actions/types":{"get":{"summary":"List available promotion action types","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PromotionAction subclasses with their preference schemas. Used by admin UIs to populate the \"Add action\" picker and render generic preference forms.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"action types found","content":{"application/json":{}}}}}},"/api/v3/admin/promotion_rules/types":{"get":{"summary":"List available promotion rule types","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PromotionRule subclasses with their preference schemas.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule types found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/refunds":{"get":{"summary":"List refunds","tags":["Refunds"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all refunds for an order.\n\n**Required scope:** `read_refunds` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment, refund_reason). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,reason,transaction_id). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"refunds found","content":{"application/json":{}}}}},"post":{"summary":"Create a refund","tags":["Refunds"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a refund for a payment on the order. The refund is automatically processed via the payment gateway.\n\n**Required scope:** `write_refunds` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"refund created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["payment_id","amount"],"properties":{"payment_id":{"type":"string","description":"Payment ID"},"amount":{"type":"string"},"refund_reason_id":{"type":"string","description":"Refund reason ID"}}}}}}}},"/api/v3/admin/locales":{"get":{"summary":"List supported locales","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the locales a merchant can translate content into for the current store, with the default and right-to-left flags.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"locales found","content":{"application/json":{}}}}}},"/api/v3/admin/store_credit_categories":{"get":{"summary":"List store credit categories","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the configured store credit categories. Categories classify\nstore credits (e.g., \"Goodwill\", \"Gift Card\", \"Refund\") and surface\nin the admin UI as a dropdown when issuing or editing a store\ncredit. Category names matching `Spree::Config[:non_expiring_credit_types]`\nare flagged via `non_expiring: true`.\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credit categories found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StoreCreditCategory"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store_credit_categories/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Store credit category ID","schema":{"type":"string"}}],"get":{"summary":"Get a store credit category","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single store credit category by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credit category found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreCreditCategory"}}}},"404":{"description":"store credit category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store":{"get":{"summary":"Get the current store","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the current store configuration. The store is resolved from the request context (host or admin selection); there is no `id` parameter.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"current store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Store"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update the current store","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates the current store configuration.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"store updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Store"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"preferred_admin_locale":{"type":"string"},"preferred_timezone":{"type":"string"},"preferred_weight_unit":{"type":"string"},"preferred_unit_system":{"type":"string"}}}}}}}},"/api/v3/admin/tags":{"get":{"summary":"List tags","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns tag names for a given taggable type. Used for autocomplete in tag inputs on products, orders, and customers.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"taggable_type","in":"query","required":true,"description":"Taggable type (`Spree::Product`, `Spree::Order`, or `Spree::User`)","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"Optional case-insensitive substring filter","schema":{"type":"string"}}],"responses":{"200":{"description":"tags found","content":{"application/json":{}}},"422":{"description":"invalid taggable type","content":{"application/json":{}}}}}},"/api/v3/admin/translatable_resources":{"get":{"summary":"List translatable resources","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns every translatable resource type and its translatable fields (key + content type), so clients can render translation editors generically.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translatable resources found","content":{"application/json":{}}}}}},"/api/v3/admin/translations/batch":{"post":{"summary":"Batch upsert translations","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Atomically upserts translations across many records of (possibly) different translatable resource types in one request — e.g. an option type and all its option values in one save. A flat list of independent registry writes; all entries succeed or none do.\n\n**Required scope:** `write_<resource>` for every resource type in the batch (for API-key authentication) (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translations upserted","content":{"application/json":{}}},"422":{"description":"unsupported locale rolls back the whole batch","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["translations"],"properties":{"translations":{"type":"array","items":{"type":"object","required":["resource_type","resource_id","values"],"properties":{"resource_type":{"type":"string","description":"Translatable resource type token, e.g. `option_type`"},"resource_id":{"type":"string","description":"Prefixed id of the record"},"values":{"type":"object","description":"Map of locale code to { field: value }","additionalProperties":{"type":"object","additionalProperties":true}}}}}}}}}}}},"/api/v3/admin/admin_users":{"get":{"summary":"List staff","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns admin users with at least one role assignment on the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff found","content":{"application/json":{}}}}}},"/api/v3/admin/admin_users/{id}":{"get":{"summary":"Show a staff member","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff member found","content":{"application/json":{}}}}},"patch":{"summary":"Update a staff member","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name fields and reassigns roles for the current store. `role_ids` is a complete replacement — roles not in the array are removed for this store.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff member updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"role_ids":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Remove a staff member from this store","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the user's role assignments on the current store. The account is preserved — the user keeps access to any other stores.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"staff removed from store"}}}},"/api/v3/admin/invitations":{"get":{"summary":"List invitations","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns invitations for the current store, including pending and accepted.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"invitations found","content":{"application/json":{}}}}},"post":{"summary":"Create an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Invites a teammate by email. The invitation is scoped to the current store and carries the chosen role; on accept, a `RoleUser` is created via the invitation's `after_accept` callback.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"invitation created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["email","role_id"],"properties":{"email":{"type":"string"},"role_id":{"type":"string"}}}}}}}},"/api/v3/admin/invitations/{id}":{"delete":{"summary":"Revoke an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"invitation revoked"}}}},"/api/v3/admin/invitations/{id}/resend":{"patch":{"summary":"Resend an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a fresh token and dispatches the invitation email again.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"invitation resent","content":{"application/json":{}}}}}},"/api/v3/admin/roles":{"get":{"summary":"List roles","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the roles available for staff role pickers. Roles are global, not per-store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"roles found","content":{"application/json":{}}}}}},"/api/v3/admin/stock_locations":{"get":{"summary":"List stock locations","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the configured stock locations. Stock locations are global\n(shared across stores). Filter with Ransack predicates such as\n`q[active_eq]`, `q[kind_eq]`, `q[pickup_enabled_eq]`, or\n`q[name_cont]`.\n\nPickup-related attributes (`kind`, `pickup_enabled`,\n`pickup_stock_policy`, `pickup_ready_in_minutes`,\n`pickup_instructions`) drive merchant pickup support at checkout —\ncustomers can collect orders from any active location with\n`pickup_enabled: true`.\n\n\n**Required scope:** `read_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[active_eq]","in":"query","required":false,"description":"Filter by active status","schema":{"type":"boolean"}},{"name":"q[kind_eq]","in":"query","required":false,"description":"Filter by kind (built-in: 'warehouse', 'store', 'fulfillment_center')","schema":{"type":"string"}},{"name":"q[pickup_enabled_eq]","in":"query","required":false,"description":"Filter by pickup-enabled flag","schema":{"type":"boolean"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"stock locations found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockLocation"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new stock location.\n\nSetting `default: true` automatically demotes the previous default\nlocation.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"stock location created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true,"description":"Internal name shown only in the admin"},"active":{"type":"boolean"},"default":{"type":"boolean","description":"Setting to true demotes the previous default."},"kind":{"type":"string","enum":["warehouse","store","fulfillment_center"],"description":"Categorizes the location."},"propagate_all_variants":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true,"description":"ISO-3166 alpha-2 country code (e.g. \"US\")."},"state_abbr":{"type":"string","nullable":true,"description":"State / province abbreviation (e.g. \"NY\"). Resolved against the selected country."},"state_name":{"type":"string","nullable":true,"description":"Free-text state for countries without a states list."},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string","enum":["local","any"],"description":"'local' = items at this location only; 'any' = transfer-eligible (ship-to-store)."},"pickup_ready_in_minutes":{"type":"number","nullable":true,"minimum":0},"pickup_instructions":{"type":"string","nullable":true}},"required":["name"]}}}}}},"/api/v3/admin/stock_locations/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Stock location ID","schema":{"type":"string"}}],"get":{"summary":"Get a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single stock location by prefixed ID.\n\n**Required scope:** `read_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"stock location found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"404":{"description":"stock location not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing stock location. Same address-field conventions as\nthe create endpoint.\n\nSetting `default: true` automatically demotes the previous default.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"stock location updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true},"active":{"type":"boolean"},"default":{"type":"boolean"},"kind":{"type":"string","enum":["warehouse","store","fulfillment_center"]},"propagate_all_variants":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string","enum":["local","any"]},"pickup_ready_in_minutes":{"type":"number","nullable":true,"minimum":0},"pickup_instructions":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the stock location (sets `deleted_at`). Existing\nfulfillments that referenced it keep the historical record via\n`Spree::StockLocation.with_deleted`.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"stock location deleted"}}}},"/api/v3/admin/products/{product_id}/variants":{"get":{"summary":"List product variants","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of variants for a product, including the default variant.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"variants found","content":{"application/json":{}}}}},"post":{"summary":"Create a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new variant for a product. Supports nested prices and stock items.\n\nOption types and values are auto-created if they don't exist.\nPrices are upserted by currency. Stock items are upserted by stock location.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"201":{"description":"variant created","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"cost_price":{"type":"string"},"cost_currency":{"type":"string"},"weight":{"type":"number"},"height":{"type":"number"},"width":{"type":"number"},"depth":{"type":"number"},"weight_unit":{"type":"string"},"dimensions_unit":{"type":"string"},"track_inventory":{"type":"boolean"},"tax_category_id":{"type":"string"},"options":{"type":"array","description":"A variant on a product with option types should declare its option pairs (e.g. size + color) — one per option type it participates in. Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"position":{"type":"integer"},"barcode":{"type":"string"},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}}},"/api/v3/admin/products/{product_id}/variants/{id}":{"get":{"summary":"Get a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single variant by ID.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"variant found","content":{"application/json":{}}},"404":{"description":"variant not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a variant. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}}],"responses":{"200":{"description":"variant updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"cost_price":{"type":"string"},"cost_currency":{"type":"string"},"weight":{"type":"number"},"height":{"type":"number"},"width":{"type":"number"},"depth":{"type":"number"},"weight_unit":{"type":"string"},"dimensions_unit":{"type":"string"},"track_inventory":{"type":"boolean"},"tax_category_id":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"position":{"type":"integer"},"barcode":{"type":"string"},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}},"delete":{"summary":"Delete a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes a variant.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}}],"responses":{"204":{"description":"variant deleted"}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}}],"get":{"summary":"List webhook deliveries","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns delivery attempts for the given endpoint, most recent first.\nEach row carries the original request payload, the response code\n(when the receiver replied), the execution time, and any transport\nerror — everything needed to audit failures and decide whether to\nredeliver.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[event_name_eq]","in":"query","required":false,"description":"Filter by event name (exact)","schema":{"type":"string"}},{"name":"q[success_eq]","in":"query","required":false,"description":"Filter by success flag","schema":{"type":"boolean"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-delivered_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"deliveries found","content":{"application/json":{}}},"404":{"description":"parent webhook endpoint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Webhook delivery ID","schema":{"type":"string"}}],"get":{"summary":"Get a webhook delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single delivery attempt with the full request payload and\nthe response body the receiver returned. Use this for ad-hoc debug\nof failed deliveries.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"delivery found","content":{"application/json":{}}},"404":{"description":"delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}/redeliver":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Webhook delivery ID to redeliver","schema":{"type":"string"}}],"post":{"summary":"Redeliver a webhook delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new delivery row with the same payload + event_name and\nqueues it. The original row is preserved for audit history.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"redelivery queued","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints":{"get":{"summary":"List webhook endpoints","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns outbound webhook subscriptions for the current store. Each\nendpoint receives a signed POST when any subscribed event fires.\n`secret_key` is `null` on list reads — the plaintext is delivered\nexactly once on create.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[url_cont]","in":"query","required":false,"description":"Filter by URL (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoints found","content":{"application/json":{}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new outbound webhook subscription. The plaintext\n`secret_key` is returned **once** in this response — persist it\nimmediately to verify incoming webhook signatures. Subsequent reads\nreturn `null` for the secret. Pass an empty `subscriptions` array or\nomit it to receive every event.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"webhook endpoint created — secret_key returned once","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"name":{"type":"string"},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/webhook_endpoints/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"get":{"summary":"Get a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single webhook endpoint by prefixed ID.\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint found","content":{"application/json":{}}},"404":{"description":"webhook endpoint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name, URL, active flag, or the event subscription list.\nToggling `active` here is equivalent to calling `disable`/`enable`\nwithout an audit reason.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint updated","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the endpoint and stops future deliveries.\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"webhook endpoint deleted"}}}},"/api/v3/admin/webhook_endpoints/{id}/send_test":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"post":{"summary":"Send a test delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a `webhook.test` delivery record and queues it. Use this to\nverify the endpoint is reachable and your signature verification\naccepts Spree's payloads.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"test delivery queued","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/enable":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"patch":{"summary":"Re-enable a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Re-enables an endpoint that was manually or automatically disabled.\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint enabled","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/disable":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"patch":{"summary":"Disable a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Manually pauses an endpoint. Unlike auto-disable (triggered after\nrepeated delivery failures), no notification email is sent.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint disabled","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string"}}}}}}}},"/api/v3/admin/collections":{"get":{"summary":"List collections","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of the store's collections.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_fields, translations).","schema":{"type":"string"}}],"responses":{"200":{"description":"collections found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Collection"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a manual or automatic (rule-based) collection. For automatic collections, send the full desired rule set under `rules`.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"collection created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string","enum":["all","any"]},"sort_order":{"type":"string"},"permalink":{"type":"string"},"description":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"rules":{"type":"array","description":"Full desired rule set. Entries with an id update, id-less entries create, omitted rules are removed.","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"match_policy":{"type":"string"}}}}},"required":["name"]}}}}}},"/api/v3/admin/collections/{id}":{"get":{"summary":"Get a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single collection by ID, including its rules.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_fields, translations).","schema":{"type":"string"}}],"responses":{"200":{"description":"collection found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}},"404":{"description":"collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a collection. Send `position` to reorder it within the flat list; send the full `rules` set to sync automatic rules.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"200":{"description":"collection updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"permalink":{"type":"string"},"description":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"sort_order":{"type":"string"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer","description":"Reorders the collection within the flat list (acts_as_list)"},"rules":{"type":"array","description":"Full desired rule set (see create).","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"match_policy":{"type":"string"}}}}}}}}}},"delete":{"summary":"Delete a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a collection.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"204":{"description":"collection deleted"}}}},"/api/v3/admin/collections/{collection_id}/products":{"get":{"summary":"List collection products","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Products curated in the collection, ordered by their membership position.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Add a product to a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Curates a product into the collection (appended to the end).\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"201":{"description":"product added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"product_id":{"type":"string"}},"required":["product_id"]}}}}}},"/api/v3/admin/collections/{collection_id}/products/{id}":{"delete":{"summary":"Remove a product from a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes a product from the collection's manual curation.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product removed"}}}},"/api/v3/admin/collections/{collection_id}/products/{id}/reposition":{"patch":{"summary":"Reposition a collection product","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a product to a new index among the collection's products.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product repositioned"}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_position":{"type":"integer","description":"0-based index among the collection's products"}},"required":["new_position"]}}}}}},"/api/v3/admin/delivery_methods":{"get":{"summary":"List delivery methods","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all delivery methods with calculator and zone configuration.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"delivery methods found","content":{"application/json":{}}}}},"post":{"summary":"Create delivery method","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a delivery method. fulfillment_type is one of shipping, digital, pickup, pickup_point.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"delivery method created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"fulfillment_type":{"type":"string","enum":["shipping","digital","pickup","pickup_point"]},"storefront_visible":{"type":"boolean"},"tracking_url":{"type":"string","nullable":true},"estimated_transit_business_days_min":{"type":"integer","nullable":true},"estimated_transit_business_days_max":{"type":"integer","nullable":true},"tax_category_id":{"type":"string","nullable":true},"calculator_type":{"type":"string"},"calculator_preferences":{"type":"object"},"delivery_zone_ids":{"type":"array","items":{"type":"string"}}},"required":["name"]}}}}}},"/api/v3/admin/delivery_methods/calculators":{"get":{"summary":"List delivery calculators","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Registered delivery calculator classes with preference schemas for building configuration forms.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"calculators found","content":{"application/json":{}}}}}},"/api/v3/admin/delivery_zones":{"post":{"summary":"Create delivery zone","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a delivery zone with typed members: country, state, or postal_code (prefix or from/to range).\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed, e.g. `members`","schema":{"type":"string"}}],"responses":{"201":{"description":"delivery zone created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"members":{"type":"array","items":{"type":"object","properties":{"member_type":{"type":"string","enum":["country","state","postal_code"]},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"postal_code_prefix":{"type":"string","nullable":true},"postal_code_from":{"type":"string","nullable":true},"postal_code_to":{"type":"string","nullable":true}},"required":["member_type"]}}},"required":["name"]}}}}}}},"components":{"schemas":{"PaginationMeta":{"type":"object","properties":{"page":{"type":"integer"},"limit":{"type":"integer"},"count":{"type":"integer","description":"Total number of records"},"pages":{"type":"integer","description":"Total number of pages"},"from":{"type":"integer","description":"Index of first record on this page"},"to":{"type":"integer","description":"Index of last record on this page"},"in":{"type":"integer","description":"Number of records on this page"},"previous":{"type":"integer","nullable":true,"description":"Previous page number"},"next":{"type":"integer","nullable":true,"description":"Next page number"}},"required":["page","limit","count","pages","from","to","in"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","description":"Field-specific validation errors","nullable":true}},"required":["code","message"]}},"required":["error"]},"AuthResponse":{"type":"object","properties":{"token":{"type":"string","description":"JWT access token"},"user":{"$ref":"#/components/schemas/AdminUser"}},"required":["token","user"]},"PermissionRule":{"type":"object","description":"A single permission rule (CanCanCan rule). Rules are applied in order, last-matching-wins.","properties":{"allow":{"type":"boolean","description":"true for `can`, false for `cannot`"},"actions":{"type":"array","items":{"type":"string"},"description":"Action names, e.g. [\"read\", \"update\"] or [\"manage\"]"},"subjects":{"type":"array","items":{"type":"string"},"description":"Subject class names, e.g. [\"Spree::Product\"] or [\"all\"]"},"has_conditions":{"type":"boolean","description":"True if the server-side rule has per-record conditions. The SPA shows the action optimistically and handles 403 from the API."}},"required":["allow","actions","subjects","has_conditions"]},"MeResponse":{"type":"object","description":"Current admin user profile and serialized permissions","properties":{"user":{"$ref":"#/components/schemas/AdminUser"},"permissions":{"type":"array","items":{"$ref":"#/components/schemas/PermissionRule"}}},"required":["user","permissions"]},"ImportSchemaField":{"type":"object","description":"A canonical column of an import type, including per-store custom field columns","properties":{"name":{"type":"string","description":"Canonical field name used in mappings"},"label":{"type":"string","description":"Human-readable label"},"required":{"type":"boolean","description":"Whether the field must be mapped before processing"}},"required":["name","label","required"]},"CheckoutRequirement":{"type":"object","properties":{"step":{"type":"string","description":"Checkout step this requirement belongs to"},"field":{"type":"string","description":"Field that needs to be satisfied"},"message":{"type":"string","description":"Human-readable requirement message"}},"required":["step","field","message"]},"CartWarning":{"type":"object","description":"A warning about a cart issue (e.g., item removed due to stock change)","properties":{"code":{"type":"string","description":"Machine-readable warning code"},"message":{"type":"string","description":"Human-readable warning message"},"line_item_id":{"type":"string","nullable":true,"description":"Prefixed line item ID (when applicable)"},"variant_id":{"type":"string","nullable":true,"description":"Prefixed variant ID (when applicable)"}},"required":["code","message"]},"FulfillmentManifestItem":{"type":"object","description":"An item within a fulfillment — which line item and how many units are in this fulfillment","properties":{"item_id":{"type":"string","description":"Line item ID"},"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer","description":"Quantity in this fulfillment"}},"required":["item_id","variant_id","quantity"]},"AdminUserRoleAssignment":{"type":"object","description":"A role assignment for the current store on a staff member","properties":{"id":{"type":"string","description":"Prefixed role ID"},"name":{"type":"string","description":"Role name"}},"required":["id","name"]},"AdminUserStore":{"type":"object","description":"A store the staff member can access through a role assignment","properties":{"id":{"type":"string","description":"Prefixed store ID"},"name":{"type":"string","description":"Store name"},"code":{"type":"string","description":"Store code"}},"required":["id","name","code"]},"PreferenceField":{"type":"object","description":"A single configurable preference on a payment method, promotion rule/action, or calculator. The frontend uses `type` + `default` to render a sensible input.","properties":{"key":{"type":"string"},"type":{"type":"string","description":"string | text | password | integer | decimal | boolean | array | hash"},"default":{"description":"Default value (any JSON type), null when there is no default","nullable":true}},"required":["key","type"]},"PromotionActionCalculator":{"type":"object","description":"The action's nested calculator (when the action carries one — null for actions like `free_shipping`)","properties":{"type":{"type":"string","description":"Wire shorthand for the calculator subclass"},"label":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}}},"required":["type","label","preferences","preference_schema"]},"PromotionActionLineItem":{"type":"object","description":"One row in a `create_line_items` action — the variant added to the order and how many","properties":{"variant_id":{"type":"string"},"quantity":{"type":"integer"}},"required":["variant_id","quantity"]},"Address":{"type":"object","properties":{"id":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"full_name":{"type":"string"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"postal_code":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_name":{"type":"string"},"country_iso":{"type":"string"},"state_text":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"quick_checkout":{"type":"boolean"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"},"state_name":{"type":"string","nullable":true},"label":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true}},"required":["id","first_name","last_name","full_name","address1","address2","postal_code","city","phone","company","country_name","country_iso","state_text","state_abbr","quick_checkout","is_default_billing","is_default_shipping","state_name","label","metadata","created_at","updated_at","customer_id"],"x-typelizer":true},"AdminUser":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"full_name":{"type":"string","nullable":true},"selected_locale":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"avatar_url":{"type":"string","nullable":true},"roles":{"type":"array","items":{"$ref":"#/components/schemas/AdminUserRoleAssignment"}},"stores":{"type":"array","items":{"$ref":"#/components/schemas/AdminUserStore"}}},"required":["id","email","first_name","last_name","full_name","selected_locale","created_at","updated_at","avatar_url","roles","stores"],"x-typelizer":true},"AllowedOrigin":{"type":"object","properties":{"id":{"type":"string"},"origin":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","origin","created_at","updated_at"],"x-typelizer":true},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"key_type":{"type":"string"},"token_prefix":{"type":"string","nullable":true},"scopes":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string"},"updated_at":{"type":"string"},"revoked_at":{"type":"string","nullable":true},"last_used_at":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"plaintext_token":{"type":"string","nullable":true},"created_by_email":{"type":"string","nullable":true}},"required":["id","name","key_type","token_prefix","scopes","created_at","updated_at","revoked_at","last_used_at","channel_id","plaintext_token","created_by_email"],"x-typelizer":true},"AppliedPromotion":{"type":"object","properties":{"id":{"type":"string"},"promotion_id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","promotion_id","name","description","code","amount","display_amount","created_at","updated_at"],"x-typelizer":true},"Cart":{"type":"object","properties":{"id":{"type":"string"},"market_id":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"number":{"type":"string"},"token":{"type":"string"},"email":{"type":"string","nullable":true},"customer_note":{"type":"string","nullable":true},"currency":{"type":"string"},"locale":{"type":"string","nullable":true},"total_quantity":{"type":"number"},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/CartWarning"}},"coupon_code":{"type":"string","nullable":true},"item_total":{"type":"string","nullable":true},"display_item_total":{"type":"string","nullable":true},"adjustment_total":{"type":"string","nullable":true},"display_adjustment_total":{"type":"string","nullable":true},"discount_total":{"type":"string","nullable":true},"display_discount_total":{"type":"string","nullable":true},"tax_total":{"type":"string","nullable":true},"display_tax_total":{"type":"string","nullable":true},"included_tax_total":{"type":"string","nullable":true},"display_included_tax_total":{"type":"string","nullable":true},"additional_tax_total":{"type":"string","nullable":true},"display_additional_tax_total":{"type":"string","nullable":true},"total":{"type":"string","nullable":true},"display_total":{"type":"string","nullable":true},"gift_card_total":{"type":"string","nullable":true},"display_gift_card_total":{"type":"string","nullable":true},"amount_due":{"type":"string","nullable":true},"display_amount_due":{"type":"string","nullable":true},"delivery_total":{"type":"string","nullable":true},"display_delivery_total":{"type":"string","nullable":true},"store_credit_total":{"type":"string","nullable":true},"display_store_credit_total":{"type":"string","nullable":true},"covered_by_store_credit":{"type":"boolean"},"current_step":{"type":"string"},"completed_steps":{"type":"array","items":{"type":"string"}},"requirements":{"type":"array","items":{"$ref":"#/components/schemas/CheckoutRequirement"}},"shipping_eq_billing_address":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"}},"billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"completed_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"applied_promotions":{"type":"array","items":{"$ref":"#/components/schemas/AppliedPromotion"}}},"required":["id","market_id","channel_id","number","token","email","customer_note","currency","locale","total_quantity","warnings","coupon_code","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","current_step","completed_steps","requirements","shipping_eq_billing_address","items","billing_address","shipping_address","market","completed_at","created_at","updated_at","applied_promotions"],"x-typelizer":true},"Category":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"permalink":{"type":"string"},"position":{"type":"number"},"depth":{"type":"number"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"children_count":{"type":"number"},"parent_id":{"type":"string","nullable":true},"description":{"type":"string"},"description_html":{"type":"string"},"image_url":{"type":"string","nullable":true},"square_image_url":{"type":"string","nullable":true},"is_root":{"type":"boolean"},"is_child":{"type":"boolean"},"is_leaf":{"type":"boolean"},"parent":{"$ref":"#/components/schemas/Category"},"children":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"ancestors":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"translations":{"type":"object"},"metadata":{"type":"object"},"pretty_name":{"type":"string"},"lft":{"type":"number"},"rgt":{"type":"number"},"products_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","permalink","position","depth","meta_title","meta_description","meta_keywords","children_count","parent_id","description","description_html","image_url","square_image_url","is_root","is_child","is_leaf","metadata","pretty_name","lft","rgt","products_count","created_at","updated_at"],"x-typelizer":true},"Channel":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string"},"active":{"type":"boolean"},"default":{"type":"boolean"},"storefront_access":{"type":"string"},"guest_checkout":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string","nullable":true},"preferred_storefront_access":{"type":"string","nullable":true},"preferred_guest_checkout":{"type":"boolean","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","code","active","default","storefront_access","guest_checkout","preferred_order_routing_strategy","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at"],"x-typelizer":true},"CollectionRule":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string","nullable":true},"match_policy":{"type":"string"}},"required":["id","type","value","match_policy"],"x-typelizer":true},"Collection":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"permalink":{"type":"string"},"position":{"type":"number"},"sort_order":{"type":"string"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"products_count":{"type":"number"},"description":{"type":"string"},"description_html":{"type":"string"},"image_url":{"type":"string","nullable":true},"square_image_url":{"type":"string","nullable":true},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"translations":{"type":"object"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string"},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"rules":{"type":"array","items":{"$ref":"#/components/schemas/CollectionRule"}}},"required":["id","name","permalink","position","sort_order","meta_title","meta_description","meta_keywords","products_count","description","description_html","image_url","square_image_url","automatic","rules_match_policy","metadata","created_at","updated_at","rules"],"x-typelizer":true},"Country":{"type":"object","properties":{"iso":{"type":"string"},"iso3":{"type":"string"},"name":{"type":"string"},"states_required":{"type":"boolean"},"zipcode_required":{"type":"boolean"},"states":{"type":"array","items":{"$ref":"#/components/schemas/State"}},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["iso","iso3","name","states_required","zipcode_required","created_at","updated_at"],"x-typelizer":true},"CouponCode":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string"},"state":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"promotion_id":{"type":"string"},"order_id":{"type":"string","nullable":true}},"required":["id","code","state","created_at","updated_at","promotion_id","order_id"],"x-typelizer":true},"CreditCard":{"type":"object","properties":{"id":{"type":"string"},"brand":{"type":"string"},"last4":{"type":"string"},"month":{"type":"number"},"year":{"type":"number"},"name":{"type":"string","nullable":true},"default":{"type":"boolean"},"gateway_payment_profile_id":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true},"payment_method_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","brand","last4","month","year","name","default","gateway_payment_profile_id","customer_id","payment_method_id","metadata","created_at","updated_at"],"x-typelizer":true},"CustomFieldDefinition":{"type":"object","properties":{"id":{"type":"string"},"namespace":{"type":"string"},"key":{"type":"string"},"label":{"type":"string"},"field_type":{"type":"string","enum":["short_text","long_text","rich_text","number","boolean","json"]},"resource_type":{"type":"string"},"storefront_visible":{"type":"boolean"},"searchable":{"type":"boolean"},"sortable":{"type":"boolean"},"filter_key":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","namespace","key","label","field_type","resource_type","storefront_visible","searchable","sortable","filter_key","created_at","updated_at"],"x-typelizer":true},"CustomField":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"type":{"type":"string","deprecated":true},"field_type":{"type":"string","enum":["short_text","long_text","rich_text","number","boolean","json"]},"key":{"type":"string"},"value":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"storefront_visible":{"type":"boolean"},"custom_field_definition_id":{"type":"string"}},"required":["id","label","type","field_type","key","value","created_at","updated_at","storefront_visible","custom_field_definition_id"],"x-typelizer":true},"CustomerGroup":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"customers_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}},"required":["id","name","description","customers_count","created_at","updated_at"],"x-typelizer":true},"Customer":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"accepts_email_marketing":{"type":"boolean"},"full_name":{"type":"string"},"available_store_credit_total":{"type":"string"},"display_available_store_credit_total":{"type":"string"},"addresses":{"type":"array","items":{"$ref":"#/components/schemas/Address"}},"default_billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"default_shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"newsletter_subscriber":{"allOf":[{"$ref":"#/components/schemas/NewsletterSubscriber"}],"nullable":true},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"login":{"type":"string","nullable":true},"metadata":{"type":"object"},"last_sign_in_at":{"type":"string","nullable":true},"current_sign_in_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"sign_in_count":{"type":"number"},"failed_attempts":{"type":"number"},"last_sign_in_ip":{"type":"string","nullable":true},"current_sign_in_ip":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"internal_note_html":{"type":"string","nullable":true},"default_billing_address_id":{"type":"string","nullable":true},"default_shipping_address_id":{"type":"string","nullable":true},"orders_count":{"type":"number"},"total_spent":{"type":"string"},"display_total_spent":{"type":"string"},"last_order_completed_at":{"type":"string","nullable":true},"orders":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"store_credits":{"type":"array","items":{"$ref":"#/components/schemas/StoreCredit"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}},"required":["id","email","first_name","last_name","phone","accepts_email_marketing","full_name","available_store_credit_total","display_available_store_credit_total","login","metadata","last_sign_in_at","current_sign_in_at","created_at","updated_at","sign_in_count","failed_attempts","last_sign_in_ip","current_sign_in_ip","tags","internal_note_html","default_billing_address_id","default_shipping_address_id","orders_count","total_spent","display_total_spent","last_order_completed_at","customer_group_ids"],"x-typelizer":true},"DeliveryMethodRule":{"type":"object","properties":{"id":{"type":"string"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"}},"required":["id","active","created_at","updated_at","type","name","description","preferences","preference_schema"],"x-typelizer":true},"DeliveryMethod":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string","nullable":true},"fulfillment_type":{"type":"string"},"estimated_transit_business_days_min":{"type":"number","nullable":true},"estimated_transit_business_days_max":{"type":"number","nullable":true},"admin_name":{"type":"string","nullable":true},"fulfillment_provider":{"type":"string"},"pickup_point_provider":{"type":"string","nullable":true},"storefront_visible":{"type":"boolean"},"tracking_url":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"deleted_at":{"type":"string"},"tax_category_id":{"type":"string","nullable":true},"delivery_zone_ids":{"type":"array","items":{"type":"string"}},"stock_location_ids":{"type":"array","items":{"type":"string"}},"calculator_type":{"type":"string","nullable":true},"calculator_preferences":{"type":"object","nullable":true}},"required":["id","name","code","fulfillment_type","estimated_transit_business_days_min","estimated_transit_business_days_max","admin_name","fulfillment_provider","pickup_point_provider","storefront_visible","tracking_url","created_at","updated_at","deleted_at","tax_category_id","delivery_zone_ids","stock_location_ids","calculator_type","calculator_preferences"],"x-typelizer":true},"DeliveryRate":{"type":"object","properties":{"id":{"type":"string"},"delivery_method_id":{"type":"string"},"name":{"type":"string"},"selected":{"type":"boolean"},"cost":{"type":"string"},"total":{"type":"string"},"additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"tax_total":{"type":"string"},"display_cost":{"type":"string"},"display_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"delivery_method":{"$ref":"#/components/schemas/DeliveryMethod"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","delivery_method_id","name","selected","cost","total","additional_tax_total","included_tax_total","tax_total","display_cost","display_total","display_additional_tax_total","display_included_tax_total","display_tax_total","created_at","updated_at"],"x-typelizer":true},"DeliveryZoneMember":{"type":"object","properties":{"id":{"type":"string"},"member_type":{"type":"string"},"postal_code_prefix":{"type":"string","nullable":true},"postal_code_from":{"type":"string","nullable":true},"postal_code_to":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","member_type","postal_code_prefix","postal_code_from","postal_code_to","country_iso","state_abbr","state_name","created_at","updated_at"],"x-typelizer":true},"DeliveryZone":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"members":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryZoneMember"}},"created_at":{"type":"string"},"updated_at":{"type":"string"},"delivery_method_ids":{"type":"array","items":{"type":"string"}}},"required":["id","name","description","created_at","updated_at","delivery_method_ids"],"x-typelizer":true},"DigitalLink":{"type":"object","properties":{"id":{"type":"string"},"access_counter":{"type":"number"},"filename":{"type":"string"},"content_type":{"type":"string"},"download_url":{"type":"string"},"authorizable":{"type":"boolean"},"expired":{"type":"boolean"},"access_limit_exceeded":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","access_counter","filename","content_type","download_url","authorizable","expired","access_limit_exceeded","created_at","updated_at"],"x-typelizer":true},"Discount":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"kind":{"type":"string"},"code":{"type":"string","nullable":true},"value_type":{"type":"string","nullable":true},"value":{"type":"string","nullable":true},"promotion_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","kind","code","value_type","value","promotion_id","line_item_id","fulfillment_id","amount","display_amount","metadata","created_at","updated_at"],"x-typelizer":true},"Export":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"format":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true},"done":{"type":"boolean"},"filename":{"type":"string","nullable":true},"byte_size":{"type":"number","nullable":true},"download_url":{"type":"string","nullable":true}},"required":["id","number","format","created_at","updated_at","type","user_id","done","filename","byte_size","download_url"],"x-typelizer":true},"Fee":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"kind":{"type":"string"},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","kind","line_item_id","fulfillment_id","amount","display_amount","metadata","created_at","updated_at"],"x-typelizer":true},"Fulfillment":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"tracking":{"type":"string","nullable":true},"tracking_url":{"type":"string","nullable":true},"pickup_point_data":{"type":"object","nullable":true},"selected_delivery_rate_id":{"type":"string","nullable":true},"cost":{"type":"string"},"display_cost":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"status":{"type":"string"},"fulfillment_type":{"type":"string"},"fulfilled_at":{"type":"string","nullable":true},"items":{"type":"array","items":{"$ref":"#/components/schemas/FulfillmentManifestItem"}},"delivery_method":{"$ref":"#/components/schemas/DeliveryMethod"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"delivery_rates":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryRate"}},"metadata":{"type":"object"},"adjustment_total":{"type":"string"},"pre_tax_amount":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"order_id":{"type":"string","nullable":true},"stock_location_id":{"type":"string","nullable":true},"order":{"$ref":"#/components/schemas/Order"}},"required":["id","number","tracking","tracking_url","pickup_point_data","selected_delivery_rate_id","cost","display_cost","total","display_total","discount_total","display_discount_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","tax_total","display_tax_total","status","fulfillment_type","fulfilled_at","items","metadata","adjustment_total","pre_tax_amount","created_at","updated_at","order_id","stock_location_id"],"x-typelizer":true},"GiftCardBatch":{"type":"object","properties":{"id":{"type":"string"},"codes_count":{"type":"number"},"currency":{"type":"string","nullable":true},"prefix":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"amount":{"type":"string","nullable":true},"expires_at":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true}},"required":["id","codes_count","currency","prefix","created_at","updated_at","amount","expires_at","created_by_id"],"x-typelizer":true},"GiftCard":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string"},"status":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string"},"amount_used":{"type":"string"},"amount_authorized":{"type":"string"},"amount_remaining":{"type":"string"},"display_amount":{"type":"string"},"display_amount_used":{"type":"string"},"display_amount_remaining":{"type":"string"},"expires_at":{"type":"string","nullable":true},"redeemed_at":{"type":"string","nullable":true},"expired":{"type":"boolean"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"customer":{"$ref":"#/components/schemas/Customer"},"created_by":{"$ref":"#/components/schemas/AdminUser"},"gift_card_batch":{"$ref":"#/components/schemas/GiftCardBatch"},"orders":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}},"required":["id","code","status","currency","amount","amount_used","amount_authorized","amount_remaining","display_amount","display_amount_used","display_amount_remaining","expires_at","redeemed_at","expired","active","created_at","updated_at","customer_id","created_by_id"],"x-typelizer":true},"ImportMapping":{"type":"object","properties":{"id":{"type":"string"},"schema_field":{"type":"string"},"file_column":{"type":"string","nullable":true},"required":{"type":"boolean"}},"required":["id","schema_field","file_column","required"],"x-typelizer":true},"ImportRow":{"type":"object","properties":{"id":{"type":"string"},"row_number":{"type":"number"},"status":{"type":"string"},"validation_errors":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"import_id":{"type":"string","nullable":true},"item_type":{"type":"string","nullable":true},"item_id":{"type":"string","nullable":true},"data":{"type":"object"}},"required":["id","row_number","status","validation_errors","created_at","updated_at","import_id","item_type","item_id","data"],"x-typelizer":true},"Import":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"rows_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string","nullable":true},"status":{"type":"string"},"owner_type":{"type":"string","nullable":true},"owner_id":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true},"processing_errors":{"type":"string","nullable":true},"preferred_delimiter":{"type":"string"},"original_filename":{"type":"string","nullable":true},"original_byte_size":{"type":"number","nullable":true},"original_file_url":{"type":"string","nullable":true},"completed_rows_count":{"type":"number"},"failed_rows_count":{"type":"number"},"schema_fields":{"type":"array","items":{"$ref":"#/components/schemas/ImportSchemaField"}},"csv_headers":{"type":"array","items":{"type":"string"}},"sample_row":{"type":"object"},"mappings":{"type":"array","items":{"$ref":"#/components/schemas/ImportMapping"}}},"required":["id","number","rows_count","created_at","updated_at","type","status","owner_type","owner_id","user_id","processing_errors","preferred_delimiter","original_filename","original_byte_size","original_file_url","completed_rows_count","failed_rows_count","schema_fields","csv_headers","sample_row","mappings"],"x-typelizer":true},"Invitation":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"status":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"expires_at":{"type":"string"},"role_id":{"type":"string"},"role_name":{"type":"string"},"inviter_email":{"type":"string"},"acceptance_url":{"type":"string"},"invitee_exists":{"type":"boolean"},"store":{"type":"object"}},"required":["id","email","status","created_at","updated_at","expires_at","role_id","role_name","inviter_email","acceptance_url","invitee_exists","store"],"x-typelizer":true},"LineItem":{"type":"object","properties":{"id":{"type":"string"},"variant_id":{"type":"string"},"preorder":{"type":"boolean"},"preorder_ships_at":{"type":"string","nullable":true},"quantity":{"type":"number"},"currency":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"options_text":{"type":"string"},"price":{"type":"string"},"display_price":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"adjustment_total":{"type":"string"},"display_adjustment_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"pre_tax_amount":{"type":"string"},"display_pre_tax_amount":{"type":"string"},"discounted_amount":{"type":"string"},"display_discounted_amount":{"type":"string"},"display_compare_at_amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"thumbnail_url":{"type":"string","nullable":true},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"digital_links":{"type":"array","items":{"$ref":"#/components/schemas/DigitalLink"}},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"cost_price":{"type":"string","nullable":true},"tax_category_id":{"type":"string","nullable":true},"variant":{"$ref":"#/components/schemas/Variant"},"tax_category":{"$ref":"#/components/schemas/TaxCategory"}},"required":["id","variant_id","preorder","preorder_ships_at","quantity","currency","name","slug","options_text","price","display_price","total","display_total","adjustment_total","display_adjustment_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","discount_total","display_discount_total","pre_tax_amount","display_pre_tax_amount","discounted_amount","display_discounted_amount","display_compare_at_amount","compare_at_amount","thumbnail_url","option_values","digital_links","metadata","created_at","updated_at","cost_price","tax_category_id"],"x-typelizer":true},"Market":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"currency":{"type":"string"},"default_locale":{"type":"string"},"tax_inclusive":{"type":"boolean"},"default":{"type":"boolean"},"country_isos":{"type":"array","items":{"type":"string"}},"supported_locales":{"type":"array","items":{"type":"string"}},"countries":{"type":"array","items":{"$ref":"#/components/schemas/Country"}},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","currency","default_locale","tax_inclusive","default","country_isos","supported_locales","created_at","updated_at"],"x-typelizer":true},"Media":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string","nullable":true},"variant_ids":{"type":"array","items":{"type":"string"}},"position":{"type":"number"},"alt":{"type":"string","nullable":true},"media_type":{"type":"string"},"focal_point_x":{"type":"number","nullable":true},"focal_point_y":{"type":"number","nullable":true},"external_video_url":{"type":"string","nullable":true},"original_url":{"type":"string","nullable":true},"mini_url":{"type":"string","nullable":true},"small_url":{"type":"string","nullable":true},"medium_url":{"type":"string","nullable":true},"large_url":{"type":"string","nullable":true},"xlarge_url":{"type":"string","nullable":true},"og_image_url":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"viewable_id":{"type":"string"},"download_url":{"type":"string","nullable":true},"metadata":{"type":"object"},"viewable_type":{"type":"string"}},"required":["id","product_id","variant_ids","position","alt","media_type","focal_point_x","focal_point_y","external_video_url","original_url","mini_url","small_url","medium_url","large_url","xlarge_url","og_image_url","created_at","updated_at","viewable_id","download_url","metadata","viewable_type"],"x-typelizer":true},"NewsletterSubscriber":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"verified":{"type":"boolean"},"verified_at":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true}},"required":["id","email","created_at","updated_at","verified","verified_at","customer_id"],"x-typelizer":true},"OptionType":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"number"},"kind":{"type":"string"},"translations":{"type":"object"},"metadata":{"type":"object"},"filterable":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}}},"required":["id","name","label","position","kind","metadata","filterable","created_at","updated_at"],"x-typelizer":true},"OptionValue":{"type":"object","properties":{"id":{"type":"string"},"option_type_id":{"type":"string"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"number"},"color_code":{"type":"string","nullable":true},"option_type_name":{"type":"string"},"option_type_label":{"type":"string"},"image_url":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"option_type":{"$ref":"#/components/schemas/OptionType"}},"required":["id","option_type_id","name","label","position","color_code","option_type_name","option_type_label","image_url","metadata","created_at","updated_at"],"x-typelizer":true},"OrderRoutingRule":{"type":"object","properties":{"id":{"type":"string"},"position":{"type":"number"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"channel_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"},"label":{"type":"string"},"description":{"type":"string"}},"required":["id","position","active","created_at","updated_at","type","channel_id","preferences","preference_schema","label","description"],"x-typelizer":true},"Order":{"type":"object","properties":{"id":{"type":"string"},"market_id":{"type":"string","nullable":true},"cart_id":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"number":{"type":"string"},"email":{"type":"string"},"customer_note":{"type":"string","nullable":true},"currency":{"type":"string"},"locale":{"type":"string","nullable":true},"total_quantity":{"type":"number"},"coupon_code":{"type":"string","nullable":true},"fulfillment_status":{"type":"string","nullable":true},"payment_status":{"type":"string","nullable":true},"completed_at":{"type":"string","nullable":true},"item_total":{"type":"string"},"display_item_total":{"type":"string"},"adjustment_total":{"type":"string"},"display_adjustment_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"gift_card_total":{"type":"string"},"display_gift_card_total":{"type":"string"},"amount_due":{"type":"string"},"display_amount_due":{"type":"string"},"delivery_total":{"type":"string"},"display_delivery_total":{"type":"string"},"store_credit_total":{"type":"string"},"display_store_credit_total":{"type":"string"},"covered_by_store_credit":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"}},"fulfillments":{"type":"array","items":{"$ref":"#/components/schemas/Fulfillment"}},"payments":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"gift_card":{"allOf":[{"$ref":"#/components/schemas/GiftCard"}],"nullable":true},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"status":{"type":"string"},"last_ip_address":{"type":"string","nullable":true},"considered_risky":{"type":"boolean"},"confirmation_delivered":{"type":"boolean"},"store_owner_notification_delivered":{"type":"boolean"},"payment_total":{"type":"string"},"display_payment_total":{"type":"string"},"metadata":{"type":"object"},"canceled_at":{"type":"string","nullable":true},"approved_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preferred_stock_location_id":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"internal_note":{"type":"string","nullable":true},"approver_id":{"type":"string","nullable":true},"canceler_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true},"applied_promotions":{"type":"array","items":{"$ref":"#/components/schemas/AppliedPromotion"}},"cart":{"$ref":"#/components/schemas/Cart"},"channel":{"$ref":"#/components/schemas/Channel"},"preferred_stock_location":{"$ref":"#/components/schemas/StockLocation"},"payment_methods":{"type":"array","items":{"$ref":"#/components/schemas/PaymentMethod"}},"customer":{"$ref":"#/components/schemas/Customer"},"approver":{"$ref":"#/components/schemas/Customer"},"canceler":{"$ref":"#/components/schemas/Customer"},"created_by":{"$ref":"#/components/schemas/Customer"},"return_authorizations":{"type":"array","items":{"$ref":"#/components/schemas/ReturnAuthorization"}},"reimbursements":{"type":"array","items":{"$ref":"#/components/schemas/Reimbursement"}}},"required":["id","market_id","cart_id","channel_id","number","email","customer_note","currency","locale","total_quantity","coupon_code","fulfillment_status","payment_status","completed_at","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","gift_card","market","status","last_ip_address","considered_risky","confirmation_delivered","store_owner_notification_delivered","payment_total","display_payment_total","metadata","canceled_at","approved_at","created_at","updated_at","preferred_stock_location_id","tags","internal_note","approver_id","canceler_id","created_by_id","customer_id"],"x-typelizer":true},"PaymentMethod":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"type":{"type":"string"},"session_required":{"type":"boolean"},"source_required":{"type":"boolean"},"metadata":{"type":"object"},"active":{"type":"boolean"},"auto_capture":{"type":"boolean","nullable":true},"storefront_visible":{"type":"boolean"},"position":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"}},"required":["id","name","description","type","session_required","source_required","metadata","active","auto_capture","storefront_visible","position","created_at","updated_at","preferences","preference_schema"],"x-typelizer":true},"Payment":{"type":"object","properties":{"id":{"type":"string"},"payment_method_id":{"type":"string"},"response_code":{"type":"string","nullable":true},"number":{"type":"string"},"amount":{"type":"string"},"display_amount":{"type":"string"},"status":{"type":"string"},"source_type":{"type":"string","nullable":true,"enum":["credit_card","store_credit","payment_source"]},"source_id":{"type":"string","nullable":true},"source":{"anyOf":[{"$ref":"#/components/schemas/CreditCard"},{"$ref":"#/components/schemas/StoreCredit"},{"$ref":"#/components/schemas/PaymentSource"}],"nullable":true},"payment_method":{"$ref":"#/components/schemas/PaymentMethod"},"metadata":{"type":"object"},"avs_response":{"type":"string","nullable":true},"cvv_response_code":{"type":"string","nullable":true},"cvv_response_message":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"captured_amount":{"type":"string"},"order_id":{"type":"string","nullable":true},"order":{"$ref":"#/components/schemas/Order"},"refunds":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}},"required":["id","payment_method_id","response_code","number","amount","display_amount","status","source_type","source_id","source","metadata","avs_response","cvv_response_code","cvv_response_message","created_at","updated_at","captured_amount","order_id"],"x-typelizer":true},"PaymentSource":{"type":"object","properties":{"id":{"type":"string"},"gateway_payment_profile_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","gateway_payment_profile_id","metadata","created_at","updated_at"],"x-typelizer":true},"PriceHistory":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string"},"amount_in_cents":{"type":"number"},"currency":{"type":"string"},"display_amount":{"type":"string"},"recorded_at":{"type":"string"},"variant_id":{"type":"string"},"price_id":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true},"created_at":{"type":"string"}},"required":["id","amount","amount_in_cents","currency","display_amount","recorded_at","variant_id","price_id","compare_at_amount","created_at"],"x-typelizer":true},"PriceList":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"status":{"type":"string"},"position":{"type":"number"},"match_policy":{"type":"string"},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"currently_active":{"type":"boolean"},"products_count":{"type":"number"},"prices_count":{"type":"number"},"product_ids":{"type":"array","items":{"type":"string"}},"price_rules":{"type":"array","items":{"$ref":"#/components/schemas/PriceRule"}}},"required":["id","name","description","status","position","match_policy","starts_at","ends_at","deleted_at","created_at","updated_at","currently_active","products_count","prices_count","product_ids"],"x-typelizer":true},"PriceRule":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"price_list_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"description":{"type":"string","nullable":true},"markets":{"type":"array","items":{"$ref":"#/components/schemas/Market"}},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}},"required":["id","created_at","updated_at","type","price_list_id","preferences","preference_schema","label","description"],"x-typelizer":true},"Price":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string","nullable":true},"amount_in_cents":{"type":"number","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"compare_at_amount_in_cents":{"type":"number","nullable":true},"currency":{"type":"string","nullable":true},"display_amount":{"type":"string","nullable":true},"display_compare_at_amount":{"type":"string","nullable":true},"price_list_id":{"type":"string","nullable":true},"variant_id":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"variant":{"$ref":"#/components/schemas/Variant"}},"required":["id","amount","amount_in_cents","compare_at_amount","compare_at_amount_in_cents","currency","display_amount","display_compare_at_amount","price_list_id","variant_id","created_at","updated_at"],"x-typelizer":true},"ProductPublication":{"type":"object","properties":{"id":{"type":"string"},"published_at":{"type":"string","nullable":true},"unpublished_at":{"type":"string","nullable":true},"product_id":{"type":"string"},"channel_id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","published_at","unpublished_at","product_id","channel_id","created_at","updated_at"],"x-typelizer":true},"Product":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"variant_count":{"type":"number"},"available_on":{"type":"string","nullable":true},"preorder_ships_at":{"type":"string","nullable":true},"purchasable":{"type":"boolean"},"preorder":{"type":"boolean"},"in_stock":{"type":"boolean"},"backorderable":{"type":"boolean"},"available":{"type":"boolean"},"description":{"type":"string","nullable":true},"description_html":{"type":"string","nullable":true},"default_variant_id":{"type":"string"},"thumbnail_url":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"original_price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"primary_media":{"$ref":"#/components/schemas/Media"},"media":{"type":"array","items":{"$ref":"#/components/schemas/Media"}},"variants":{"type":"array","items":{"$ref":"#/components/schemas/Variant"}},"default_variant":{"$ref":"#/components/schemas/Variant"},"option_types":{"type":"array","items":{"$ref":"#/components/schemas/OptionType"}},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"categories":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"prior_price":{"allOf":[{"$ref":"#/components/schemas/PriceHistory"}],"nullable":true},"translations":{"type":"object"},"status":{"type":"string"},"metadata":{"type":"object"},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"tax_category_id":{"type":"string","nullable":true},"product_publications":{"type":"array","items":{"$ref":"#/components/schemas/ProductPublication"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}}},"required":["id","name","slug","meta_title","meta_description","meta_keywords","variant_count","available_on","preorder_ships_at","purchasable","preorder","in_stock","backorderable","available","description","description_html","default_variant_id","thumbnail_url","tags","price","original_price","status","metadata","deleted_at","created_at","updated_at","tax_category_id"],"x-typelizer":true},"PromotionAction":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"promotion_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"calculator":{"allOf":[{"$ref":"#/components/schemas/PromotionActionCalculator"}],"nullable":true},"line_items":{"type":"array","items":{"$ref":"#/components/schemas/PromotionActionLineItem"},"nullable":true}},"required":["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","calculator","line_items"],"x-typelizer":true},"PromotionRule":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"promotion_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"product_ids":{"type":"array","items":{"type":"string"},"nullable":true},"category_ids":{"type":"array","items":{"type":"string"},"nullable":true},"customer_ids":{"type":"array","items":{"type":"string"},"nullable":true},"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"categories":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"countries":{"type":"array","items":{"$ref":"#/components/schemas/Country"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"markets":{"type":"array","items":{"$ref":"#/components/schemas/Market"}}},"required":["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","product_ids","category_ids","customer_ids"],"x-typelizer":true},"Promotion":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"expires_at":{"type":"string","nullable":true},"usage_limit":{"type":"number","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"path":{"type":"string","nullable":true},"kind":{"type":"string","enum":["coupon_code","automatic"]},"multi_codes":{"type":"boolean"},"number_of_codes":{"type":"number","nullable":true},"code_prefix":{"type":"string","nullable":true},"promotion_category_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"action_ids":{"type":"array","items":{"type":"string"}},"rule_ids":{"type":"array","items":{"type":"string"}}},"required":["id","name","description","code","starts_at","expires_at","usage_limit","match_policy","path","kind","multi_codes","number_of_codes","code_prefix","promotion_category_id","metadata","created_at","updated_at","action_ids","rule_ids"],"x-typelizer":true},"Refund":{"type":"object","properties":{"id":{"type":"string"},"transaction_id":{"type":"string","nullable":true},"amount":{"type":"string","nullable":true},"payment_id":{"type":"string","nullable":true},"refund_reason_id":{"type":"string","nullable":true},"reimbursement_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"payment":{"$ref":"#/components/schemas/Payment"},"reimbursement":{"$ref":"#/components/schemas/Reimbursement"}},"required":["id","transaction_id","amount","payment_id","refund_reason_id","reimbursement_id","metadata","created_at","updated_at"],"x-typelizer":true},"Reimbursement":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"reimbursement_status":{"type":"string","nullable":true},"total":{"type":"string","nullable":true},"order_id":{"type":"string","nullable":true},"customer_return_id":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"order":{"$ref":"#/components/schemas/Order"}},"required":["id","number","reimbursement_status","total","order_id","customer_return_id","created_at","updated_at"],"x-typelizer":true},"ReturnAuthorization":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"order_id":{"type":"string","nullable":true},"stock_location_id":{"type":"string","nullable":true},"return_authorization_reason_id":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"order":{"$ref":"#/components/schemas/Order"},"stock_location":{"$ref":"#/components/schemas/StockLocation"}},"required":["id","number","status","order_id","stock_location_id","return_authorization_reason_id","created_at","updated_at"],"x-typelizer":true},"Role":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","created_at","updated_at"],"x-typelizer":true},"SetupTask":{"type":"object","properties":{"name":{"type":"string"},"done":{"type":"boolean"}},"required":["name","done"],"x-typelizer":true},"State":{"type":"object","properties":{"abbr":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["abbr","name","created_at","updated_at"],"x-typelizer":true},"StockItem":{"type":"object","properties":{"id":{"type":"string"},"count_on_hand":{"type":"number"},"backorderable":{"type":"boolean"},"stock_location_id":{"type":"string","nullable":true},"variant_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"allocated_count":{"type":"number"},"available_count":{"type":"number"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"variant":{"$ref":"#/components/schemas/Variant"}},"required":["id","count_on_hand","backorderable","stock_location_id","variant_id","metadata","created_at","updated_at","allocated_count","available_count"],"x-typelizer":true},"StockLocation":{"type":"object","properties":{"id":{"type":"string"},"state_abbr":{"type":"string","nullable":true},"name":{"type":"string"},"address1":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"country_name":{"type":"string","nullable":true},"state_text":{"type":"string","nullable":true},"admin_name":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"active":{"type":"boolean"},"default":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"propagate_all_variants":{"type":"boolean"},"kind":{"type":"string"},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string"},"pickup_ready_in_minutes":{"type":"number","nullable":true},"pickup_instructions":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","state_abbr","name","address1","city","zipcode","country_iso","country_name","state_text","admin_name","address2","state_name","phone","company","active","default","backorderable_default","propagate_all_variants","kind","pickup_enabled","pickup_stock_policy","pickup_ready_in_minutes","pickup_instructions","created_at","updated_at"],"x-typelizer":true},"StockReservation":{"type":"object","properties":{"id":{"type":"string"},"stock_item_id":{"type":"string"},"line_item_id":{"type":"string"},"order_id":{"type":"string"},"variant_id":{"type":"string","nullable":true},"stock_location_id":{"type":"string","nullable":true},"quantity":{"type":"number"},"expires_at":{"type":"string"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","stock_item_id","line_item_id","order_id","variant_id","stock_location_id","quantity","expires_at","active","created_at","updated_at"],"x-typelizer":true},"StockTransfer":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"reference":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"source_location_id":{"type":"string","nullable":true},"destination_location_id":{"type":"string","nullable":true},"source_location":{"$ref":"#/components/schemas/StockLocation"},"destination_location":{"$ref":"#/components/schemas/StockLocation"}},"required":["id","number","reference","metadata","created_at","updated_at","source_location_id","destination_location_id"],"x-typelizer":true},"StoreCreditCategory":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"non_expiring":{"type":"boolean"}},"required":["id","name","created_at","updated_at","non_expiring"],"x-typelizer":true},"StoreCredit":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string"},"amount_used":{"type":"string"},"amount_remaining":{"type":"string"},"display_amount":{"type":"string"},"display_amount_used":{"type":"string"},"display_amount_remaining":{"type":"string"},"currency":{"type":"string"},"memo":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"category_id":{"type":"string","nullable":true},"category_name":{"type":"string","nullable":true}},"required":["id","amount","amount_used","amount_remaining","display_amount","display_amount_used","display_amount_remaining","currency","memo","metadata","created_at","updated_at","customer_id","created_by_id","category_id","category_name"],"x-typelizer":true},"Store":{"type":"object","properties":{"id":{"type":"string"},"metadata":{"type":"object"},"name":{"type":"string"},"code":{"type":"string"},"preferred_storefront_url":{"type":"string","nullable":true},"default_currency":{"type":"string"},"default_locale":{"type":"string"},"mail_from_address":{"type":"string","nullable":true},"customer_support_email":{"type":"string","nullable":true},"new_order_notifications_email":{"type":"string","nullable":true},"preferred_send_consumer_transactional_emails":{"type":"boolean"},"preferred_admin_locale":{"type":"string","nullable":true},"preferred_timezone":{"type":"string"},"preferred_weight_unit":{"type":"string"},"preferred_unit_system":{"type":"string"},"preferred_storefront_access":{"type":"string"},"preferred_guest_checkout":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"url":{"type":"string"},"api_url":{"type":"string"},"setup_tasks":{"type":"array","items":{"$ref":"#/components/schemas/SetupTask"}},"supported_currencies":{"type":"array","items":{"type":"string"}},"supported_locales":{"type":"array","items":{"type":"string"}},"available_locales":{"type":"array","items":{"type":"string"}},"logo_url":{"type":"string","nullable":true},"mailer_logo_url":{"type":"string","nullable":true}},"required":["id","metadata","name","code","preferred_storefront_url","default_currency","default_locale","mail_from_address","customer_support_email","new_order_notifications_email","preferred_send_consumer_transactional_emails","preferred_admin_locale","preferred_timezone","preferred_weight_unit","preferred_unit_system","preferred_storefront_access","preferred_guest_checkout","preferred_order_routing_strategy","created_at","updated_at","url","api_url","setup_tasks","supported_currencies","supported_locales","available_locales","logo_url","mailer_logo_url"],"x-typelizer":true},"TaxCategory":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"tax_code":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"is_default":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","tax_code","description","is_default","created_at","updated_at"],"x-typelizer":true},"TaxLine":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"included":{"type":"boolean"},"rate":{"type":"string"},"tax_rate_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"fee_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"provider_id":{"type":"string","nullable":true},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","included","rate","tax_rate_id","line_item_id","fulfillment_id","fee_id","amount","display_amount","provider_id","metadata","created_at","updated_at"],"x-typelizer":true},"Variant":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string"},"sku":{"type":"string","nullable":true},"options_text":{"type":"string"},"track_inventory":{"type":"boolean"},"media_count":{"type":"number"},"preorder_ships_at":{"type":"string","nullable":true},"thumbnail_url":{"type":"string","nullable":true},"purchasable":{"type":"boolean"},"in_stock":{"type":"boolean"},"backorderable":{"type":"boolean"},"preorder":{"type":"boolean"},"weight":{"type":"number","nullable":true},"height":{"type":"number","nullable":true},"width":{"type":"number","nullable":true},"depth":{"type":"number","nullable":true},"price":{"$ref":"#/components/schemas/Price"},"original_price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"primary_media":{"$ref":"#/components/schemas/Media"},"media":{"type":"array","items":{"$ref":"#/components/schemas/Media"}},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"prior_price":{"allOf":[{"$ref":"#/components/schemas/PriceHistory"}],"nullable":true},"metadata":{"type":"object"},"position":{"type":"number"},"cost_price":{"type":"string","nullable":true},"cost_currency":{"type":"string","nullable":true},"barcode":{"type":"string","nullable":true},"weight_unit":{"type":"string","nullable":true},"dimensions_unit":{"type":"string","nullable":true},"backorder_limit":{"type":"number","nullable":true},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preorderable":{"type":"boolean"},"tax_category_id":{"type":"string","nullable":true},"available_stock":{"type":"number","nullable":true},"reserved_quantity":{"type":"number"},"total_on_hand":{"type":"number","nullable":true},"product_name":{"type":"string"},"prices":{"type":"array","items":{"$ref":"#/components/schemas/Price"}},"stock_items":{"type":"array","items":{"$ref":"#/components/schemas/StockItem"}}},"required":["id","product_id","sku","options_text","track_inventory","media_count","preorder_ships_at","thumbnail_url","purchasable","in_stock","backorderable","preorder","weight","height","width","depth","price","original_price","option_values","metadata","position","cost_price","cost_currency","barcode","weight_unit","dimensions_unit","backorder_limit","deleted_at","created_at","updated_at","preorderable","tax_category_id","available_stock","reserved_quantity","total_on_hand","product_name"],"x-typelizer":true},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string"},"event_name":{"type":"string"},"event_id":{"type":"string","nullable":true},"response_code":{"type":"number","nullable":true},"execution_time":{"type":"number","nullable":true},"error_type":{"type":"string","nullable":true},"request_errors":{"type":"string","nullable":true},"response_body":{"type":"string","nullable":true},"success":{"type":"boolean","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"delivered_at":{"type":"string","nullable":true},"payload":{"type":"object"},"webhook_endpoint_id":{"type":"string"},"webhook_endpoint_url":{"type":"string"}},"required":["id","event_name","event_id","response_code","execution_time","error_type","request_errors","response_body","success","created_at","updated_at","delivered_at","payload","webhook_endpoint_id","webhook_endpoint_url"],"x-typelizer":true},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","nullable":true},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}},"disabled_reason":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"disabled_at":{"type":"string","nullable":true},"secret_key":{"type":"string","nullable":true},"last_delivery_at":{"type":"string","nullable":true},"recent_delivery_count":{"type":"number"},"recent_failure_count":{"type":"number"},"total_delivery_count":{"type":"number"},"successful_delivery_count":{"type":"number"},"failed_delivery_count":{"type":"number"}},"required":["id","name","url","active","subscriptions","disabled_reason","created_at","updated_at","disabled_at","secret_key","last_delivery_at","recent_delivery_count","recent_failure_count","total_delivery_count","successful_delivery_count","failed_delivery_count"],"x-typelizer":true}}}}
\ No newline at end of file
+{"info":{"title":"Admin API","contact":{"name":"Spree Commerce","url":"https://spreecommerce.org","email":"[email protected]"},"description":"Spree Admin API v3 - Administrative API for managing products, orders, and store settings.\n\n## Authentication\n\nThe Admin API requires a secret API key passed in the `x-spree-api-key` header.\nSecret API keys can be generated in the Spree admin dashboard.\n\n## Response Format\n\nAll responses are JSON. List endpoints return paginated responses with `data` and `meta` keys.\nSingle resource endpoints return a flat JSON object.\n\n## Resource IDs\n\nEvery resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,\n`variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,\nrequest bodies, and Ransack filters all accept them directly.\n\n## Error Handling\n\nErrors return a consistent format:\n```json\n{\n \"error\": {\n \"code\": \"validation_error\",\n \"message\": \"Validation failed\",\n \"details\": { \"name\": [\"can't be blank\"] }\n }\n}\n```\n","version":"v3"},"paths":{"/api/v3/admin/auth/login":{"post":{"summary":"Login","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Authenticates an admin user and returns a short-lived JWT access token.\nThe rotatable refresh token is set in an HttpOnly cookie — it is not\nincluded in the response body.\n\nThe `provider` field selects the authentication method. When omitted it\ndefaults to `email`, the built-in email/password login.\n\nTo authenticate against a third-party identity provider (Okta, Azure AD,\nGoogle Workspace SSO, a custom JWT issuer, SAML, etc.), send\n`{ \"provider\": \"<your_key>\", ... }` with the fields that provider\nrequires. The endpoint returns the same JWT regardless of which provider\nauthenticated the request. See\n[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication)\nfor the list of configured providers and their required fields.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"title":"EmailPasswordLogin","description":"Built-in email/password authentication (default when `provider` is omitted).","type":"object","properties":{"provider":{"type":"string","enum":["email"],"default":"email"},"email":{"type":"string","format":"email"},"password":{"type":"string"}},"required":["email","password"]},{"title":"ProviderLogin","description":"Provider-dispatched login. The `provider` key selects a configured\nauthentication provider; the remaining fields are forwarded to it.\nRequired fields depend on the provider — see\n[Custom API Authentication](https://spreecommerce.org/docs/developer/how-to/custom-api-authentication).\n","type":"object","properties":{"provider":{"type":"string","description":"Registered provider key (anything other than `email`).","not":{"enum":["email"]}}},"required":["provider"],"additionalProperties":true}]}}}}}},"/api/v3/admin/auth/refresh":{"post":{"summary":"Refresh token","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Exchanges the HttpOnly refresh-token cookie for a new access JWT and a\nrotated refresh token cookie. No request body or Authorization header\nis required — the cookie alone authenticates the call.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"refresh successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"missing or invalid refresh-token cookie","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/auth/logout":{"post":{"summary":"Logout","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Revokes the refresh-token cookie, effectively logging the admin out.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"logout successful"}}}},"/api/v3/admin/me":{"get":{"summary":"Get current admin user and permissions","tags":["Authentication"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the current admin user profile and a serialized list of permissions (CanCanCan rules). The SPA uses these to drive UI permission checks.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"current admin user and permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update the current admin profile","tags":["Authentication"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Self-service update of the signed-in admin's own profile, such as their admin UI display language (`selected_locale`).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"profile updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"selected_locale":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"}}}}}}}},"/api/v3/admin/auth/password_resets":{"post":{"summary":"Request password reset","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Requests a password reset email for an admin user. Always returns `202`\nwhether or not the email matches an account, to prevent enumeration.\n\n`redirect_url` is where the emailed link should point (the reset token\nis appended as a `token` query param). It must match one of the store's\nallowed origins — otherwise it is silently ignored and the server-side\ndefault is used. The email is delivered by Spree itself via the\n`admin_user.password_reset_requested` event; this event is never\nforwarded to webhook endpoints.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"202":{"description":"reset requested","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"redirect_url":{"type":"string","description":"Must match an allowed origin of the store; ignored otherwise."}},"required":["email"]}}}}}},"/api/v3/admin/auth/password_resets/{id}":{"patch":{"summary":"Reset password","tags":["Authentication"],"security":[{"api_key":[]}],"description":"Consumes a password reset token (the `token` query param from the\nemailed link), sets the new password, and signs the admin in: the\nresponse carries a JWT access token and the rotatable refresh token is\nset in an HttpOnly cookie. The token is single-use — it invalidates as\nsoon as the password changes.\n","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","description":"The reset token from the emailed link","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"password reset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"422":{"description":"invalid or expired token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"password":{"type":"string"},"password_confirmation":{"type":"string"}},"required":["password","password_confirmation"]}}}}}},"/api/v3/admin/allowed_origins":{"get":{"summary":"List allowed origins","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the CORS allowlist for the current store. Each entry is a\nbare `scheme://host[:port]` permitted to call the admin API from a\nbrowser. Backs the `Rack::Cors` allowlist and the CSRF boundary of\nthe admin cookie session (see\n`docs/plans/5.5-admin-auth-cookie-refresh.md`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[origin_cont]","in":"query","required":false,"description":"Filter by origin (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origins found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AllowedOrigin"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds an origin to the admin CORS allowlist. The value must be a bare\n`scheme://host[:port]` (no path, query, or fragment) and use `http` or\n`https`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"allowed origin created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"origin":{"type":"string"}},"required":["origin"]}}}}}},"/api/v3/admin/allowed_origins/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Allowed origin ID","schema":{"type":"string"}}],"get":{"summary":"Get an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single allowed origin by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origin found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"404":{"description":"allowed origin not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing allowed origin.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"allowed origin updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOrigin"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"origin":{"type":"string"}}}}}}},"delete":{"summary":"Delete an allowed origin","tags":["Allowed Origins"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes an origin from the admin CORS allowlist. After deletion the\nadmin SPA running at that origin will no longer be able to call the\nadmin API from a browser.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"allowed origin deleted"}}}},"/api/v3/admin/api_keys":{"get":{"summary":"List API keys","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns publishable and secret API keys for the current store. Secret keys are listed by `token_prefix` only — the plaintext token is delivered exactly once on create.\n\n**Required scope:** `read_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API keys found","content":{"application/json":{}}}}},"post":{"summary":"Create an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a publishable or secret API key. The plaintext token is included in the response **once** for secret keys; publishable keys expose their token on every read since they are intended for client-side use.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"secret key created — plaintext token returned once","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name","key_type"],"properties":{"name":{"type":"string"},"key_type":{"type":"string","enum":["publishable","secret"]},"scopes":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/api_keys/{id}":{"get":{"summary":"Show an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key found","content":{"application/json":{}}}}},"patch":{"summary":"Update an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Renames a key. `key_type` and `scopes` are fixed at creation — to change a key's authority, create a new key and revoke the old one.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key renamed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"}}}}}}},"delete":{"summary":"Delete an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"API key deleted"}}}},"/api/v3/admin/api_keys/current":{"get":{"summary":"Describe the current API key","tags":["API Keys"],"security":[{"api_key":[]}],"description":"Returns the secret key that authenticated this request, including its live scopes. Useful to confirm a key's real, current authority. Only secret-key principals have a single key to describe.\n\n**Required scope:** none — any key can describe itself (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"current API key","content":{"application/json":{}}}}}},"/api/v3/admin/api_keys/{id}/revoke":{"patch":{"summary":"Revoke an API key","tags":["API Keys"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Marks the key revoked. Future requests using its token will fail; the row is preserved for audit.\n\n**Required scope:** `write_api_keys` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"API key revoked","content":{"application/json":{}}}}}},"/api/v3/admin/categories":{"get":{"summary":"List categories","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of the store's categories (manual hierarchical taxons; rule-based collections are excluded).\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., children, parent, ancestors).","schema":{"type":"string"}}],"responses":{"200":{"description":"categories found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a category. Nests under the parent when parent_id is given, otherwise creates a top-level category.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"category created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"parent_id":{"type":"string","description":"Prefixed ID of the parent category"},"description":{"type":"string"},"permalink":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"hide_from_nav":{"type":"boolean"}},"required":["name"]}}}}}},"/api/v3/admin/categories/{id}":{"get":{"summary":"Get a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single category by ID.\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., children, parent, ancestors).","schema":{"type":"string"}}],"responses":{"200":{"description":"category found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}},"404":{"description":"category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a category.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"category updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"parent_id":{"type":"string","description":"Prefixed ID of the parent category"},"description":{"type":"string"},"permalink":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"hide_from_nav":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a category and its descendants.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"204":{"description":"category deleted"}}}},"/api/v3/admin/categories/{id}/reposition":{"patch":{"summary":"Reposition a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a category to a new parent and/or index within the tree.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"category repositioned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Category"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_parent_id":{"type":"string","description":"Prefixed ID of the new parent (omit for top level)"},"new_position":{"type":"integer","description":"0-based index among the new parent's children"}},"required":["new_position"]}}}}}},"/api/v3/admin/categories/{category_id}/products":{"get":{"summary":"List category products","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Products classified under the category, ordered by their classification position.\n\n**Required scope:** `read_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Add a product to a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Classifies a product under the category (appended to the end).\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}}],"responses":{"201":{"description":"product added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"product_id":{"type":"string"}},"required":["product_id"]}}}}}},"/api/v3/admin/categories/{category_id}/products/{id}":{"delete":{"summary":"Remove a product from a category","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes a product from the category's manual classification.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product removed"}}}},"/api/v3/admin/categories/{category_id}/products/{id}/reposition":{"patch":{"summary":"Reposition a category product","tags":["Categories"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a product to a new index among the category's products.\n\n**Required scope:** `write_categories` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"category_id","in":"path","required":true,"description":"Category ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product repositioned"}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_position":{"type":"integer","description":"0-based index among the category's products"}},"required":["new_position"]}}}}}},"/api/v3/admin/channels":{"get":{"summary":"List channels","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the channels configured for the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"channels found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new channel on the current store. `code` is normalized to a\nURL-safe slug (`Point of Sale` → `point-of-sale`); when omitted it's\nderived from `name`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"channel created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"code":{"type":"string","description":"Slug — auto-derived from `name` when blank."},"active":{"type":"boolean","default":true},"default":{"type":"boolean","default":false},"preferred_order_routing_strategy":{"type":"string","nullable":true,"description":"Routing strategy class name. `null` inherits the store setting."},"preferred_storefront_access":{"type":"string","nullable":true,"enum":["public","prices_hidden","login_required"],"description":"Anonymous-visitor access posture. `null` inherits the store setting."},"preferred_guest_checkout":{"type":"boolean","nullable":true,"description":"Whether guests can check out without an account. `null` inherits the store setting."}}}}}}}},"/api/v3/admin/channels/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"channel found","content":{"application/json":{}}}}},"patch":{"summary":"Update a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"channel updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string"},"active":{"type":"boolean"},"default":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string","nullable":true,"description":"Routing strategy class name. `null` inherits the store setting."},"preferred_storefront_access":{"type":"string","nullable":true,"enum":["public","prices_hidden","login_required"],"description":"Anonymous-visitor access posture. `null` inherits the store setting."},"preferred_guest_checkout":{"type":"boolean","nullable":true,"description":"Whether guests can check out without an account. `null` inherits the store setting."}}}}}}},"delete":{"summary":"Delete a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"channel deleted"}}}},"/api/v3/admin/channels/{id}/add_products":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"summary":"Publish products on a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes the listed products on this channel. Idempotent — re-publishing\nan already-published product updates its publication window. Products from\nsibling stores are silently dropped.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products published","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["product_ids"],"properties":{"product_ids":{"type":"array","items":{"type":"string"}},"published_at":{"type":"string","format":"date-time","nullable":true,"description":"When the publications go live. `null` means immediately."},"unpublished_at":{"type":"string","format":"date-time","nullable":true,"description":"When the publications come down. `null` means never."}}}}}}}},"/api/v3/admin/channels/{id}/remove_products":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"post":{"summary":"Unpublish products from a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Unpublishes the listed products from this channel.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products unpublished","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["product_ids"],"properties":{"product_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/channels/{channel_id}/order_routing_rules":{"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List order routing rules for a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the channel's routing rules in priority order. The rules engine walks them top-down; see the Order Routing guide.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules found","content":{"application/json":{}}}}},"post":{"summary":"Create an order routing rule on a channel","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a rule to the channel's routing list. The `type` is the wire shorthand from `GET /order_routing_rules/types` (e.g. `preferred_location`). Omitting `position` appends the rule at the end of the list. Each rule kind can appear at most once per channel — a duplicate `type` is rejected with a validation error.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"rule created","content":{"application/json":{}}},"422":{"description":"unknown rule type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"active":{"type":"boolean"},"position":{"type":"integer"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/channels/{channel_id}/order_routing_rules/{id}":{"parameters":[{"name":"channel_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Update an order routing rule","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a rule's `active` flag, `position` (the list reorders around it), or `preferences`. The rule kind cannot be changed — delete and re-create instead.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"active":{"type":"boolean"},"position":{"type":"integer"},"preferences":{"type":"object","additionalProperties":true}}}}}}},"delete":{"summary":"Delete an order routing rule","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"rule deleted"}}}},"/api/v3/admin/order_routing_rules/types":{"get":{"summary":"List available order routing rule types","tags":["Channels"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Enumerates the registered rule kinds with their labels, descriptions and preference schemas — drives the \"Add rule\" picker in the admin dashboard. Plugins extend the list by registering `Spree::OrderRoutingRule` subclasses via `Spree.order_routing.rules`.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"types found","content":{"application/json":{}}}}}},"/api/v3/admin/custom_field_definitions":{"get":{"summary":"List custom field definitions","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all defined custom fields. Filter by `?q[resource_type_eq]=Spree::Product` to narrow to one parent type.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"definitions returned","content":{"application/json":{}}}}},"post":{"summary":"Create a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"definition created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["key","field_type","resource_type"],"properties":{"namespace":{"type":"string","description":"Defaults to `custom`"},"key":{"type":"string"},"label":{"type":"string","description":"Human-readable name; defaults to titleized `key`"},"field_type":{"type":"string","description":"Custom field type identifier (one of the registered field-type class names)."},"resource_type":{"type":"string","description":"Owner class, e.g. `Spree::Product`"},"storefront_visible":{"type":"boolean","description":"When false, definition is admin-only (was `display_on: back_end`)"},"searchable":{"type":"boolean","description":"When true, values are included in storefront product text search"},"sortable":{"type":"boolean","description":"When true, storefront product listings can sort by this field"}}}}}}}},"/api/v3/admin/custom_field_definitions/{id}":{"get":{"summary":"Show a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,label,field_type). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"definition found","content":{"application/json":{}}}}},"patch":{"summary":"Update a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"definition updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"storefront_visible":{"type":"boolean"},"searchable":{"type":"boolean"},"sortable":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a custom field definition","tags":["Custom Fields"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes the definition and cascades to all custom field values referencing it.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"definition deleted"}}}},"/api/v3/admin/customer_groups":{"get":{"summary":"List customer groups","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer groups configured for the current store. Groups\nsegment customers for targeted promotions (see the `customer_group`\npromotion rule) and reporting. The list endpoint never embeds the\nmember list — fetch a single group with `?expand=customers` if you\nneed them inline, or query `/admin/customers?customer_group_id_in=…`\nfor paginated membership.\n\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer groups found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a customer group in the current store. `customer_ids` is\noptional; when present, customers are attached at create time.\nPass prefixed IDs (e.g. `cus_…`) — the server decodes them\nautomatically.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"customer group created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"customer_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customer_groups/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Customer group prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single customer group. Pass `?expand=customers` to embed\nthe full member list inline (recommended only for single-record\nreads — embed cost scales with membership size).\n\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `customers`.","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer group with embedded customers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"404":{"description":"customer group not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name, description, or membership. `customer_ids` is a\nfull-set replacement — the server reconciles the membership to\nmatch the array, adding new IDs and removing ones not present.\nSend `customer_ids: []` to clear all members.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customer group updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerGroup"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"customer_ids":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a customer group","tags":["Customer Groups"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"customer group deleted"}}}},"/api/v3/admin/customers/{customer_id}/addresses":{"get":{"summary":"List customer addresses","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer's saved addresses.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., country, state). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., first_name,last_name,address1,city). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"addresses found","content":{"application/json":{}}}}},"post":{"summary":"Create a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new address to the customer's address book. Pass `is_default_billing: true` or `is_default_shipping: true` to set as the default — the previous default loses its flag in the same transaction.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"address created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"address2":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string","description":"ISO-2 country code (e.g. US)"},"state_abbr":{"type":"string","description":"State/province abbreviation (e.g. NY)"},"phone":{"type":"string"},"company":{"type":"string"},"label":{"type":"string"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"}}}}}}}},"/api/v3/admin/customers/{customer_id}/addresses/{id}":{"patch":{"summary":"Update a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a customer address.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"address updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"city":{"type":"string"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"}}}}}}},"delete":{"summary":"Delete a customer address","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes the address. If it was a default, the customer loses that default (no auto-promotion).\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"address deleted"}}}},"/api/v3/admin/customers/{customer_id}/credit_cards":{"get":{"summary":"List customer credit cards","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the customer's saved credit cards. Useful for off-session admin charges via `POST /admin/orders/:id/payments { source_id }`.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"credit cards found","content":{"application/json":{}}}}}},"/api/v3/admin/customers/{customer_id}/credit_cards/{id}":{"get":{"summary":"Show a customer credit card","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a saved credit card by ID.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., brand,last4,month,year). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"credit card found","content":{"application/json":{}}}}},"delete":{"summary":"Delete a customer credit card","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a saved credit card.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"credit card deleted"}}}},"/api/v3/admin/customers/{customer_id}/store_credits":{"get":{"summary":"List customer store credits","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns store credits issued to the customer.\n\n**Required scope:** `read_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., category, store, created_by). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,amount_used,memo,currency). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credits found","content":{"application/json":{}}}}},"post":{"summary":"Issue a store credit to a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"`created_by` is set automatically from the authenticated admin.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"store credit created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["amount","currency","category_id"],"properties":{"amount":{"type":"string"},"currency":{"type":"string"},"category_id":{"type":"string","description":"StoreCreditCategory ID"},"memo":{"type":"string"}}}}}}}},"/api/v3/admin/customers/{customer_id}/store_credits/{id}":{"patch":{"summary":"Update a store credit","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Update memo / category / amount. The amount can only be changed if `amount_used == 0`.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"store credit updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string"},"category_id":{"type":"string"},"memo":{"type":"string"}}}}}}},"delete":{"summary":"Delete a store credit","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an unused store credit (amount_used == 0). Returns 422 otherwise.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"customer_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"store credit deleted"}}}},"/api/v3/admin/customers":{"get":{"summary":"List customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of customers. Supports Ransack search/filters.\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[search]","in":"query","required":false,"description":"Email + name full-text-ish search","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., addresses, store_credits). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customers found","content":{"application/json":{}}}}},"post":{"summary":"Create a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a customer. No welcome email is sent automatically.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"customer created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"phone":{"type":"string"},"accepts_email_marketing":{"type":"boolean"},"internal_note":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}}}}}}},"/api/v3/admin/customers/{id}":{"get":{"summary":"Show a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns full customer details including computed order stats (orders_count, total_spent, last_order_completed_at).\n\n**Required scope:** `read_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Customer ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations: addresses, orders, store_credits, default_billing_address, default_shipping_address","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., email,first_name,last_name). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"customer found","content":{"application/json":{}}}}},"patch":{"summary":"Update a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates customer attributes. `tags` replaces the full set.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customer updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"phone":{"type":"string"},"accepts_email_marketing":{"type":"boolean"},"internal_note":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}}}}}},"delete":{"summary":"Delete a customer","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a customer. Returns 422 if the customer has any orders.\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"customer deleted"}}}},"/api/v3/admin/customers/bulk_add_to_groups":{"post":{"summary":"Bulk-add customers to groups","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each customer in `ids` to every group in `customer_group_ids`.\nIdempotent — customers already in a group are skipped server-side.\nGroups from sibling stores are silently ignored. Returns counts of\ncustomers and groups that were processed (post store-scoping).\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customers added to groups","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"customer_group_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","customer_group_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_from_groups":{"post":{"summary":"Bulk-remove customers from groups","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each customer in `ids` from every group in `customer_group_ids`.\nNo-op for non-members. Groups from sibling stores are silently ignored.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"customers removed from groups","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"customer_group_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","customer_group_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_add_tags":{"post":{"summary":"Bulk-add tags to customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds each tag name in `tags` to every customer in `ids`. Tags are\nupserted by name; re-adding an existing tag is a no-op.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags added","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/customers/bulk_remove_tags":{"post":{"summary":"Bulk-remove tags from customers","tags":["Customers"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes each tag name in `tags` from every customer in `ids`. No-op\nfor customers that don't carry the tag.\n\n\n**Required scope:** `write_customers` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags removed","content":{"application/json":{"schema":{"type":"object","properties":{"customer_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/exports":{"get":{"summary":"List exports","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns CSV exports queued or completed for the current store. Polled by the admin SPA to detect when an export finishes (`done: true`).\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"exports found","content":{"application/json":{}}}}},"post":{"summary":"Create an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Queues a CSV export. The `type` selects the dataset; `search_params` is an\noptional Ransack query (same shape used by the `q[...]` params on list endpoints)\nthat filters which records are exported. Pass `record_selection: \"all\"` to\nclear the filter server-side and export everything in scope.\n\nGeneration is asynchronous. Poll `GET /admin/exports/{id}` until `done` is `true`,\nthen redirect the browser to `download_url` to fetch the file.\n\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"export queued","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["products","orders","customers","product_translations","gift_cards","coupon_codes","newsletter_subscribers"]},"record_selection":{"type":"string","enum":["filtered","all"],"description":"Set to \"all\" to ignore search_params and export everything in scope."},"search_params":{"type":"object","description":"Ransack query hash. Same predicates accepted by the list endpoint.","additionalProperties":true},"results_url":{"type":"string","description":"Absolute URL of your admin exports view; the export-done email uses it as the download button target. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/exports/{id}":{"get":{"summary":"Show an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns export status. While `done` is `false`, the SPA continues polling.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"export found","content":{"application/json":{}}}}},"delete":{"summary":"Delete an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the export and purges its attachment.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"export deleted"}}}},"/api/v3/admin/exports/{id}/download":{"get":{"summary":"Download an export","tags":["Exports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Streams the exported CSV with `Content-Disposition: attachment`. Returns 422 with `code: export_not_ready` while `done` is still `false`. The endpoint is JWT/API-key protected, so SPA clients must fetch it (with `Authorization` header) and trigger the browser download via a Blob URL — a top-level navigation cannot carry the JWT.\n\n**Required scope:** the read scope of the exported resource — `read_products` for product exports, `read_customers` for customer exports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"CSV file","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments":{"get":{"summary":"List fulfillments","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all shipments for an order.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillments found","content":{"application/json":{}}}}},"post":{"summary":"Create a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Manually creates a fulfillment on a completed order, bypassing order routing — for example to mirror a shipment handled by an external carrier or 3PL. Moves the requested line item quantities out of their current fulfillments; when `items` is omitted, every not-yet-shipped unit is moved. Pass `status: 'shipped'` to register an already-shipped fulfillment (fires shipped webhooks and freezes cost/carrier). When `delivery_method_id` is omitted, the fulfillment inherits the delivery method and cost of the source fulfillment(s) it fully drains — keeping the order total unchanged; partially drained splits get no carrier when shipped, and pending fulfillments are otherwise (re)priced by the standard rate engine, which selects the lowest-cost available rate. Pass `cost` to set an explicit shipping cost instead (e.g. the 3PL price) — note this changes the order total and payment state, and is guaranteed to persist only with `status: 'shipped'` (pending fulfillments are re-priced by the rate engine).\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"fulfillment created","content":{"application/json":{}}},"422":{"description":"order not completed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["stock_location_id"],"properties":{"stock_location_id":{"type":"string","description":"Stock location the fulfillment ships from"},"tracking":{"type":"string","description":"Carrier tracking number, or a full https:// tracking link — a full URL is served back as tracking_url unchanged instead of being templated into the delivery method tracking URL"},"delivery_method_id":{"type":"string","description":"Delivery method (carrier) to attach as the selected rate. Defaults to the delivery method of the fully drained source fulfillment(s)"},"cost":{"type":"string","description":"Explicit shipping cost. Defaults to the summed cost of the fully drained source fulfillment(s), which keeps the order total unchanged; an explicit cost changes the order total and payment state. Guaranteed to persist only with status: 'shipped' — pending fulfillments are re-priced by the rate engine"},"status":{"type":"string","enum":["shipped"],"description":"Pass 'shipped' to register the fulfillment as already shipped"},"items":{"type":"array","description":"Line item quantities to fulfill. Omit to fulfill every not-yet-shipped unit.","items":{"type":"object","required":["item_id","quantity"],"properties":{"item_id":{"type":"string","description":"Line item ID"},"quantity":{"type":"integer"}}}},"metadata":{"type":"object","additionalProperties":true}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}":{"get":{"summary":"Show a shipment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific shipment.\n\n**Required scope:** `read_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., inventory_units, stock_location, shipping_rates). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,status,tracking,cost). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"shipment found","content":{"application/json":{}}}}},"patch":{"summary":"Update a shipment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a fulfillment (tracking, delivery rate).\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"shipment updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tracking":{"type":"string","description":"Carrier tracking number, or a full https:// tracking link served back as tracking_url unchanged"},"selected_delivery_rate_id":{"type":"string","description":"Delivery rate ID (dr_...) to select"}}}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/fulfill":{"patch":{"summary":"Fulfill a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Marks a fulfillment as fulfilled.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment fulfilled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":{"patch":{"summary":"Cancel a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Cancels a fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment canceled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":{"patch":{"summary":"Resume a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Resumes a canceled fulfillment.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment resumed","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":{"patch":{"summary":"Split a fulfillment","tags":["Fulfillments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Transfers items from this shipment to a new shipment at a different stock location.\n\n**Required scope:** `write_fulfillments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Fulfillment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"fulfillment split","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id","quantity"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"stock_location_id":{"type":"string","description":"Target stock location ID"}}}}}}}},"/api/v3/admin/gift_card_batches":{"get":{"summary":"List gift card batches","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the gift card batches issued by the current store. Each batch\ngroups the cards generated together for a campaign or bulk-issuance\n— the cards themselves live under `/admin/gift_cards` and reference\nthe batch via `gift_card_batch_id`.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Records per page","schema":{"type":"integer"}},{"name":"q[prefix_cont]","in":"query","required":false,"description":"Filter by prefix (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift card batches found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GiftCardBatch"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a gift card batch","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a batch of gift cards in a single call. The server generates\n`codes_count` cards inline for small batches (configurable via\n`Spree.config.gift_card_batch_web_limit`, default 500) or enqueues\na background job for larger ones. Each card's code is the batch\n`prefix` followed by random hex.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"gift card batch created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCardBatch"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["prefix","amount","codes_count"],"properties":{"prefix":{"type":"string","description":"Lowercased and prepended to every generated code."},"amount":{"type":"string","description":"Decimal amount per card, greater than zero."},"currency":{"type":"string","description":"ISO 4217 currency code. Defaults to the store currency."},"codes_count":{"type":"integer","description":"Number of cards to generate. Capped at `gift_card_batch_limit`."},"expires_at":{"type":"string","nullable":true}}}}}}}},"/api/v3/admin/gift_card_batches/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Gift card batch prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a gift card batch","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single batch.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"gift card batch found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCardBatch"}}}},"404":{"description":"gift card batch not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/gift_cards":{"get":{"summary":"List gift cards","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the gift cards issued by the current store. Filter by\n`q[code_cont]` for code search, `q[user_id_eq]` for cards issued\nto a specific customer, or `q[state_eq]` for status filtering.\n\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[code_cont]","in":"query","required":false,"description":"Filter by gift card code (contains)","schema":{"type":"string"}},{"name":"q[state_eq]","in":"query","required":false,"description":"Filter by status (active, redeemed, partially_redeemed, canceled)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift cards found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/GiftCard"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a gift card scoped to the current store. The code is\nauto-generated when omitted. `currency` defaults to the store's\nconfigured currency. Pass `user_id` (prefixed ID) to attach the\ncard to a specific customer.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"gift card created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["amount"],"properties":{"amount":{"type":"string","description":"Decimal amount, greater than zero."},"currency":{"type":"string","description":"ISO 4217 currency code. Defaults to the store currency."},"code":{"type":"string","description":"Optional caller-supplied code. Auto-generated when omitted."},"expires_at":{"type":"string","description":"ISO 8601 date.","nullable":true},"user_id":{"type":"string","description":"Optional customer prefixed ID.","nullable":true}}}}}}}},"/api/v3/admin/gift_cards/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Gift card prefixed ID","schema":{"type":"string"}}],"get":{"summary":"Get a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single gift card.\n\n**Required scope:** `read_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"gift card found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}},"404":{"description":"gift card not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an active gift card's editable attributes. Redeemed or\npartially-redeemed cards cannot be edited.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"gift card updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GiftCard"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string"},"expires_at":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a gift card","tags":["Gift Cards"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an unused gift card. Cards that have been redeemed or\npartially redeemed cannot be deleted and return 422.\n\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"gift card deleted"},"422":{"description":"redeemed gift card cannot be deleted","content":{"application/json":{}}}}}},"/api/v3/admin/imports":{"get":{"summary":"List imports","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns CSV imports queued or completed for the current store.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"imports found","content":{"application/json":{}}}}},"post":{"summary":"Create an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Queues a CSV import. Upload the file first via `POST /api/v3/admin/direct_uploads`\nand pass the returned `signed_id` as `attachment`. On success the import is in the\n`mapping` state and the response carries the mapping payload: `schema_fields`\n(the canonical columns for the type), `csv_headers`, a `sample_row`, and the\nauto-assigned `mappings`.\n\nAdjust mappings if needed, then call `PATCH /admin/imports/{id}/complete_mapping`\nto start processing. Poll `GET /admin/imports/{id}` while `status` is\n`completed_mapping`/`processing`; terminal statuses are `completed` and `failed`.\n\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"import created in mapping state","content":{"application/json":{}}},"422":{"description":"unknown import type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["type","attachment"],"properties":{"type":{"type":"string","enum":["products","customers","product_translations"]},"attachment":{"type":"string","description":"ActiveStorage signed blob id from POST /api/v3/admin/direct_uploads."},"preferred_delimiter":{"type":"string","enum":[",",";","|","\t"],"description":"CSV column separator. Defaults to a comma."},"results_url":{"type":"string","description":"Absolute URL of your admin imports view; the import-done email links back to it with `?import=<id>` appended. Only honored when it matches one of the store's configured allowed origins."}}}}}}}},"/api/v3/admin/imports/template":{"get":{"summary":"Download an import template","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a CSV header row for the given import type, including the custom field columns available for the model.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"type","in":"query","required":true,"description":"Registered import type, e.g. products.","schema":{"type":"string"}}],"responses":{"200":{"description":"CSV template","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/imports/example":{"get":{"summary":"Download an example import file","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Redirects to a populated example CSV for the given import type — the same sample data `rake spree:load_sample_data` uses, pinned to the installed Spree version. Returns 404 for a type that ships no example file.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"type","in":"query","required":true,"description":"Registered import type, e.g. products.","schema":{"type":"string"}}],"responses":{"302":{"description":"Redirect to the example CSV"}}}},"/api/v3/admin/imports/{id}":{"get":{"summary":"Show an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns import status and row counters. The admin dashboard polls this endpoint while `status` is `completed_mapping` or `processing`; `rows_count`, `completed_rows_count` and `failed_rows_count` drive the progress bar. The mapping payload (`csv_headers`, `sample_row`) is only present while `status` is `mapping`.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"import found","content":{"application/json":{}}}}},"delete":{"summary":"Delete an import","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the import, its rows and the uploaded file. Returns 422 while the import is being processed.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"import deleted"}}}},"/api/v3/admin/imports/{id}/download":{"get":{"summary":"Download the originally uploaded file","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Streams the CSV exactly as it was uploaded — the audit trail for what was imported. JWT/API-key protected; SPA clients fetch it with the Authorization header and trigger the browser download via a Blob URL.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"CSV file","content":{"application/json":{},"text/csv":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v3/admin/imports/{id}/complete_mapping":{"patch":{"summary":"Complete mapping and start processing","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies the submitted column mappings, then starts row processing. Omit `mappings`\nto accept the auto-assigned ones from the create response. Returns 422 when a\nrequired schema field is left unmapped (`details.missing_required_fields`) or a\nfile column is assigned twice.\n\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"mapping completed, processing queued","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"mappings":{"type":"array","description":"Column assignments to apply before starting. `file_column: null` unmaps a field.","items":{"type":"object","required":["schema_field"],"properties":{"schema_field":{"type":"string"},"file_column":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/imports/{id}/retry_failed_rows":{"patch":{"summary":"Retry failed rows","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Re-processes the rows that failed. The import re-enters `processing`; poll `GET /admin/imports/{id}` until it completes again. Returns 422 when the import is not `completed` or has no failed rows.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"retry queued","content":{"application/json":{}}}}}},"/api/v3/admin/imports/{import_id}/rows":{"get":{"summary":"List import rows","tags":["Imports"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Paginated rows of an import — the failure report. Filter with `q[status_eq]=failed` to list only rows that could not be imported; each row carries the raw CSV `data` and its `validation_errors`.\n\n**Required scope:** the write scope of the imported resource — `write_products` for product imports, `write_customers` for customer imports, etc. (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"import_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"description":"Filter rows by status: pending, processing, completed, failed.","schema":{"type":"string"}}],"responses":{"200":{"description":"rows found","content":{"application/json":{}}}}}},"/api/v3/admin/markets":{"get":{"summary":"List markets","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the markets configured for the current store. Markets are\nstore-scoped and ordered by `position` (an `acts_as_list` column —\nupdate the order via `PATCH /markets/{id}` with `position`).\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `countries`.","schema":{"type":"string"}}],"responses":{"200":{"description":"markets found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Market"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new market for the current store.\n\n- `country_isos` accepts 2-letter ISO country codes (e.g. `[\"DE\", \"FR\"]`);\n the market must contain at least one country. Unknown codes are\n silently dropped.\n- `supported_locales` accepts an array of locale codes; the\n `default_locale` is always implicitly included.\n- Setting `default: true` automatically demotes the previous default\n market in the store.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"market created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"currency":{"type":"string","description":"ISO 4217 currency code."},"default_locale":{"type":"string","description":"IETF locale tag used as the market default."},"supported_locales":{"type":"array","items":{"type":"string"},"description":"Locale codes available in this market. The default is always implicitly included."},"tax_inclusive":{"type":"boolean","default":false,"description":"Display prices with tax included."},"default":{"type":"boolean","default":false,"description":"Setting to true demotes the previous default."},"position":{"type":"integer","description":"Sort order within the store; lower = first."},"country_isos":{"type":"array","items":{"type":"string"},"description":"2-letter ISO country codes assigned to this market. At least one is required."}},"required":["name","currency","default_locale","country_isos"]}}}}}},"/api/v3/admin/markets/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"market found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"404":{"description":"market not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing market. Pass `country_isos` to replace the\nmarket's country list (full-set update), `supported_locales` to\nreplace the supported locales, or `position` to reorder the market\nwithin the store.\n\nSetting `default: true` automatically demotes the previous default.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"market updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Market"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"currency":{"type":"string"},"default_locale":{"type":"string"},"supported_locales":{"type":"array","items":{"type":"string"}},"tax_inclusive":{"type":"boolean"},"default":{"type":"boolean"},"position":{"type":"integer"},"country_isos":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a market","tags":["Markets"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the market (sets `deleted_at`). The default market and\nthe last remaining market in a store cannot be deleted — both return\n422 with a `validation_error`.\n\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"market deleted"},"422":{"description":"cannot delete default or last market","content":{"application/json":{}}}}}},"/api/v3/admin/option_types":{"get":{"summary":"List option types","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of option types.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,label,position). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"option types found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/OptionType"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new option type. Supports nested option values.\n\nOption values can be provided inline and will be created or updated by name.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"option type created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"},"filterable":{"type":"boolean"},"option_values":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"}}}}},"required":["name","label"]}}}}}},"/api/v3/admin/option_types/{id}":{"get":{"summary":"Get an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single option type by ID, including its option values.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,label,position). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"option type found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"404":{"description":"option type not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an option type. Supports updating nested option values.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}}],"responses":{"200":{"description":"option type updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptionType"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"},"filterable":{"type":"boolean"},"option_values":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"Existing option value ID to update"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"integer"}}}}}}}}}},"delete":{"summary":"Delete an option type","tags":["Option Types"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes an option type.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Option type ID","schema":{"type":"string"}}],"responses":{"204":{"description":"option type deleted"}}}},"/api/v3/admin/orders/{order_id}/tax_lines":{"get":{"summary":"List tax lines","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Typed tax rows on the order. Read-only — written exclusively by the tax provider.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"200":{"description":"tax lines found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/discounts":{"get":{"summary":"List discounts","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Typed discount rows (promotion-sourced and manual) on the order.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"200":{"description":"discounts found","content":{"application/json":{}}}}},"post":{"summary":"Create manual discount","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a manual discount. With line_item_id a single row is created; without it the amount is distributed across line items (largest remainder). This is the sanctioned post-placement discount path and works on completed orders.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"201":{"description":"discount created","content":{"application/json":{}}},"422":{"description":"invalid discount","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"value":{"type":"number"},"value_type":{"type":"string","enum":["flat","percent"]},"line_item_id":{"type":"string","nullable":true,"description":"Target line item; omit to distribute order-level"}},"required":["label","value"]}}}}}},"/api/v3/admin/orders/{order_id}/fees":{"post":{"summary":"Create fee","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a fee (surcharge, handling, gift wrap, COD, payment fee). Order-level when no target is given. Works on completed orders.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order prefixed ID","schema":{"type":"string"}}],"responses":{"201":{"description":"fee created","content":{"application/json":{}}},"422":{"description":"invalid fee","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string"},"amount":{"type":"number"},"kind":{"type":"string","enum":["surcharge","handling","gift_wrap","cod","payment"],"description":"Defaults to 'surcharge'"},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true}},"required":["label","amount"]}}}}}},"/api/v3/admin/orders/{order_id}/gift_cards":{"post":{"summary":"Apply a gift card to an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies a gift card by code to the order. Returns the gift card.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"gift card applied","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["code"],"properties":{"code":{"type":"string","description":"Gift card code"}}}}}}}},"/api/v3/admin/orders/{order_id}/gift_cards/{id}":{"delete":{"summary":"Remove a gift card from an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the gift card from the order.\n\n**Required scope:** `write_gift_cards` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Gift card ID","schema":{"type":"string"}}],"responses":{"204":{"description":"gift card removed"}}}},"/api/v3/admin/orders/{order_id}/items":{"get":{"summary":"List order items","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all line items for an order.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"items found","content":{"application/json":{}}}}},"post":{"summary":"Add an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new line item to the order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"item added","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id"],"properties":{"variant_id":{"type":"string","description":"Prefixed variant ID"},"quantity":{"type":"integer","default":1}}}}}}}},"/api/v3/admin/orders/{order_id}/items/{id}":{"get":{"summary":"Show an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific line item.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variant, variant.product). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., quantity,price,total). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"item found","content":{"application/json":{}}}}},"patch":{"summary":"Update an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an order item quantity or metadata.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}}],"responses":{"200":{"description":"item updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"quantity":{"type":"integer"}}}}}}},"delete":{"summary":"Remove an item","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes an item from the order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Item ID","schema":{"type":"string"}}],"responses":{"204":{"description":"line item removed"}}}},"/api/v3/admin/orders/{order_id}/store_credits":{"post":{"summary":"Apply customer's store credit to an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Applies the order customer's available store credit. When `amount` is omitted, applies up to the order outstanding balance.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"store credit applied","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string","description":"Optional explicit amount; defaults to order outstanding balance"}}}}}}},"delete":{"summary":"Remove store credit from an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes any applied store credit from the order.\n\n**Required scope:** `write_store_credits` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"204":{"description":"store credit removed"}}}},"/api/v3/admin/orders":{"get":{"summary":"List orders","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of orders for the current store.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"sort","in":"query","required":false,"description":"Sort field (e.g., created_at, -created_at, completed_at)","schema":{"type":"string"}},{"name":"q[state_eq]","in":"query","required":false,"description":"Filter by state (cart, address, delivery, payment, confirm, complete, canceled)","schema":{"type":"string"}},{"name":"q[email_cont]","in":"query","required":false,"description":"Filter by email (contains)","schema":{"type":"string"}},{"name":"q[number_eq]","in":"query","required":false,"description":"Filter by order number","schema":{"type":"string"}},{"name":"q[completed_at_gt]","in":"query","required":false,"description":"Filter by completed after date","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"orders found","content":{"application/json":{}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a draft order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new draft order in one shot. Customer, items, addresses, currency,\nmarket, channel, locale, notes, metadata, and a coupon code can all be\nprovided inline.\n\nSetting `preferred_stock_location_id` pins the order's preferred fulfillment\nlocation — Order Routing's built-in `PreferredLocation` rule consumes it\nwhen picking which stock location ships each shipment.\n\nInvalid coupon codes are non-fatal — the order is created and the failure\nis reported on the service result (not in the API response body for now).\n\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"order created with preferred_stock_location_id","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"customer_id":{"type":"string","description":"Customer ID. Alias: user_id (legacy)."},"use_customer_default_address":{"type":"boolean","description":"When true with customer_id, copies the customer's saved billing/shipping addresses onto the order."},"currency":{"type":"string"},"market_id":{"type":"string","description":"Market ID"},"channel_id":{"type":"string","description":"Channel ID. Defaults to the store primary channel when omitted."},"preferred_stock_location_id":{"type":"string","description":"Stock Location ID to prefer for fulfillment. Order Routing's built-in PreferredLocation rule reads this and ranks the location first; routing falls back to the next rule when the preferred location can't cover the cart."},"locale":{"type":"string"},"customer_note":{"type":"string","description":"Public, customer-visible note"},"internal_note":{"type":"string","description":"Staff-only note"},"metadata":{"type":"object","description":"Arbitrary key/value metadata"},"shipping_address":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"shipping_address_id":{"type":"string","description":"Existing customer address ID"},"billing_address":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"postal_code":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"billing_address_id":{"type":"string","description":"Existing customer address ID"},"items":{"type":"array","items":{"type":"object","required":["variant_id","quantity"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"metadata":{"type":"object"}}}},"coupon_code":{"type":"string","description":"Optional. Applied non-fatally; invalid codes do not block creation."}}}}}}}},"/api/v3/admin/orders/{id}":{"get":{"summary":"Show an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns full order details including admin-only fields.\n\n**Required scope:** `read_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID (e.g., or_xxx)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., items, fulfillments, payments, customer, discounts, billing_address, shipping_address). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., number,total,status,completed_at). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"order found","content":{"application/json":{}}},"404":{"description":"order not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an order. Supports updating email, addresses, special instructions, and line items.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string"},"customer_note":{"type":"string"},"internal_note":{"type":"string"},"channel_id":{"type":"string","description":"Channel ID"},"preferred_stock_location_id":{"type":"string","description":"Stock Location ID to prefer for fulfillment. Re-runs Order Routing's PreferredLocation rule on subsequent shipment rebuilds."},"ship_address":{"type":"object","properties":{"firstname":{"type":"string"},"lastname":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"zipcode":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"bill_address":{"type":"object","properties":{"firstname":{"type":"string"},"lastname":{"type":"string"},"address1":{"type":"string"},"city":{"type":"string"},"zipcode":{"type":"string"},"country_iso":{"type":"string"},"state_abbr":{"type":"string"},"phone":{"type":"string"}}},"items":{"type":"array","items":{"type":"object","required":["variant_id"],"properties":{"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer"},"metadata":{"type":"object"}}}}}}}}}},"delete":{"summary":"Delete a draft order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a draft order. Completed orders cannot be deleted.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"204":{"description":"order deleted"}}}},"/api/v3/admin/orders/{id}/complete":{"patch":{"summary":"Complete an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Completes an order in the `confirm` state, marking it as placed.\n\nSet `notify_customer: true` to send the order confirmation email.\n\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order completed","content":{"application/json":{}}},"422":{"description":"order cannot be completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"notify_customer":{"type":"boolean","description":"Send the order confirmation email after completion."}}}}}}}},"/api/v3/admin/orders/{id}/cancel":{"patch":{"summary":"Cancel an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Cancels a completed order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order canceled","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/approve":{"patch":{"summary":"Approve an order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Approves an order (e.g., for fraud review).\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order approved","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resume":{"patch":{"summary":"Resume a canceled order","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Resumes a previously canceled order.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"order resumed","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{id}/resend_confirmation":{"post":{"summary":"Resend confirmation email","tags":["Orders"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes the order.completed event to trigger confirmation email delivery.\n\n**Required scope:** `write_orders` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"200":{"description":"confirmation resent","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods":{"get":{"summary":"List payment methods","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the store's configured payment methods. Use `source_required: true` to know which methods need a saved source.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,type,active). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment methods found","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods/types":{"get":{"summary":"List available payment provider types","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PaymentMethod subclasses that can be used to create new payment methods. Useful for populating a \"Provider\" dropdown in admin UIs.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"provider types found","content":{"application/json":{}}}}}},"/api/v3/admin/payment_methods/{id}":{"get":{"summary":"Show a payment method","tags":["Payment Methods"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a payment method by ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand. Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,type,active). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment method found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments":{"get":{"summary":"List payments","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all payments for an order.\n\n**Required scope:** `read_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payments found","content":{"application/json":{}}}}},"post":{"summary":"Create a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new payment for the order.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"payment created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["payment_method_id"],"properties":{"payment_method_id":{"type":"string","description":"Payment method ID"},"amount":{"type":"string"},"source_id":{"type":"string","description":"Payment source ID"}}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}":{"get":{"summary":"Show a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns details of a specific payment.\n\n**Required scope:** `read_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment_method, source). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,status,number,response_code). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"payment found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/capture":{"patch":{"summary":"Capture a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Captures a pending payment.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"payment captured","content":{"application/json":{}}},"422":{"description":"capture failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/orders/{order_id}/payments/{id}/void":{"patch":{"summary":"Void a payment","tags":["Payments"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Voids a payment.\n\n**Required scope:** `write_payments` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string"}}],"responses":{"200":{"description":"payment voided","content":{"application/json":{}}}}}},"/api/v3/admin/price_lists":{"get":{"summary":"List price lists","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the price lists configured for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `price_rules`.","schema":{"type":"string"}}],"responses":{"200":{"description":"price lists found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PriceList"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new draft price list.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"price list created (server-to-server — rules + prices, no product_ids)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer"},"product_ids":{"type":"array","items":{"type":"string"},"description":"Prefixed product ids to seed the list with."},"rules":{"type":"array","description":"STI-typed price rules to attach on create. Existing rules on the same payload via PATCH reconcile by id.","items":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"prices":{"type":"array","description":"Server-to-server alternative to `product_ids`: ship the exact per-variant prices the list should contain. Each row upserts on the unique key `(variant_id, currency, price_list_id)`. Mix-and-match with `product_ids` is supported but typically unnecessary — `prices` alone tells the server which variants belong to the list and what the override amount is.","items":{"type":"object","required":["variant_id","currency"],"properties":{"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/price_lists/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}},"404":{"description":"price list not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a price list. The optional `rules:` array reconciles nested\nSTI-typed price rules in a single round-trip — existing rules update\nby `id`, new rules build, missing rules destroy. Mirrors the\npromotion editor's \"save the whole thing on Save\" pattern.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list updated with nested rules","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer"},"product_ids":{"type":"array","items":{"type":"string"},"description":"Prefixed product ids — reconciles list membership (adds + removes)."},"rules":{"type":"array","items":{"type":"object","required":["type"],"properties":{"id":{"type":"string","nullable":true},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"prices":{"type":"array","description":"Individual price overrides (the spreadsheet payload). Each row updates by `id` if shipped, otherwise upserts on the unique key `(variant_id, currency, price_list_id)`.","items":{"type":"object","oneOf":[{"required":["id"]},{"required":["variant_id","currency"]}],"properties":{"id":{"type":"string"},"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}},"delete":{"summary":"Delete a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the price list. Associated prices are removed asynchronously.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"price list deleted"}}}},"/api/v3/admin/price_lists/{id}/activate":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Activate a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Transitions a draft / inactive list to `active`. If `starts_at` is\nin the future the list is marked `scheduled` instead, matching the\nlegacy admin behaviour.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list activated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/price_lists/{id}/deactivate":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Deactivate a price list","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price list deactivated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PriceList"}}}}}}},"/api/v3/admin/prices":{"get":{"summary":"List prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Generic prices endpoint covering both base prices and price-list\noverrides. Filter with Ransack: `q[price_list_id_eq]=…`,\n`q[currency_eq]=USD`, `q[price_list_id_null]=true` (base prices only).\n\nThe admin spreadsheet uses this with server-side pagination so it\nscales past the metadata-PATCH path on `/price_lists/:id`.\n\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"q[price_list_id_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[price_list_id_null]","in":"query","required":false,"schema":{"type":"boolean"}},{"name":"q[currency_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"q[variant_id_eq]","in":"query","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Comma-separated sort keys. Supports e.g. `variant_product_name,variant_id`.","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed. Supported: `variant`.","schema":{"type":"string"}}],"responses":{"200":{"description":"prices found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Price"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a single price. Omit `price_list_id` to create a base price.\nFor more than a handful of rows, prefer `POST /admin/prices/bulk_upsert`.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"price created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["variant_id","currency"],"properties":{"variant_id":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"price_list_id":{"type":"string","nullable":true}}}}}}}},"/api/v3/admin/prices/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"Get a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}},"404":{"description":"price not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"price updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Price"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a price","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the price (acts_as_paranoid).\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"price deleted"}}}},"/api/v3/admin/prices/bulk_upsert":{"post":{"summary":"Bulk-upsert prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Upserts a batch of prices in a single SQL round trip.\n\nEach row either:\n* targets an existing price by `id`, OR\n* matches on the unique key `(variant_id, currency, price_list_id)` —\n updating the existing row if one exists, creating one otherwise.\n\nModel callbacks (e.g. PriceHistory) are bypassed; this is a\nbulk-write fast path for the admin spreadsheet. The response\ncarries `price_count` — the number of rows touched.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"prices upserted","content":{"application/json":{"schema":{"type":"object","properties":{"price_count":{"type":"integer"}}}}}},"422":{"description":"missing prices key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["prices"],"properties":{"prices":{"type":"array","items":{"type":"object","required":["variant_id","currency"],"properties":{"id":{"type":"string","nullable":true},"variant_id":{"type":"string"},"currency":{"type":"string"},"price_list_id":{"type":"string","nullable":true},"amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true}}}}}}}}}}},"/api/v3/admin/prices/bulk_destroy":{"delete":{"summary":"Bulk-delete prices","tags":["Pricing"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes each price in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"prices deleted","content":{"application/json":{"schema":{"type":"object","properties":{"price_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields":{"get":{"summary":"List product custom fields","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the product's custom field values.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"custom fields found","content":{"application/json":{}}}}},"post":{"summary":"Create a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Sets a custom field value on the product. Requires an existing CustomFieldDefinition; pass its prefixed `cfdef_…` id.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"custom field created","content":{"application/json":{}}},"422":{"description":"duplicate definition for the same product","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["custom_field_definition_id","value"],"properties":{"custom_field_definition_id":{"type":"string","description":"Prefixed `cfdef_…` id"},"value":{"description":"Value matching the definition's `field_type`"}}}}}}}},"/api/v3/admin/products/{product_id}/custom_fields/{id}":{"get":{"summary":"Show a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_field_definition). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., key,value,namespace). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"custom field found","content":{"application/json":{}}}}},"patch":{"summary":"Update a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates the custom field's `value`. The linked definition cannot be changed — delete and recreate to switch.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"custom field updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["value"],"properties":{"value":{"description":"New value"}}}}}}},"delete":{"summary":"Delete a product custom field","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"custom field deleted"}}}},"/api/v3/admin/products/{product_id}/translations":{"get":{"summary":"List product translations","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the full translation matrix for the product: the source value and content type per translatable field, plus the translated value for every supported locale.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translations found","content":{"application/json":{}}}}}},"/api/v3/admin/products":{"get":{"summary":"List products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of products for the current store.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"sort","in":"query","required":false,"description":"Sort field (e.g., name, -name, price, -price, best_selling)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.","schema":{"type":"string"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[status_eq]","in":"query","required":false,"description":"Filter by status","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new product. Supports nested variants with prices and option types.\n\nOption types and values are auto-created if they don't exist.\nPrices are upserted by currency. Stock items are upserted by stock location.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"product created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string","enum":["draft","active","archived"]},"tax_category_id":{"type":"string","description":"Tax category ID"},"category_ids":{"type":"array","items":{"type":"string"},"description":"Array of category IDs"},"tags":{"type":"array","items":{"type":"string"}},"prices":{"type":"array","description":"Shorthand for a simple (no-options) product: per-currency prices that forward to the product's sole variant. For products with options, set prices per variant under `variants:` instead.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"variants":{"type":"array","description":"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).","items":{"type":"object","properties":{"sku":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}},"required":["name"]}}}}}},"/api/v3/admin/products/{id}":{"get":{"summary":"Get a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single product by ID.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID (e.g., prod_xxx)","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., variants, media, option_types, categories). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., name,slug,price,status). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"product found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"404":{"description":"product not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a product. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"200":{"description":"product updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"slug":{"type":"string"},"status":{"type":"string","enum":["draft","active","archived"]},"tax_category_id":{"type":"string","description":"Tax category ID"},"category_ids":{"type":"array","items":{"type":"string"},"description":"Array of category IDs"},"tags":{"type":"array","items":{"type":"string"}},"prices":{"type":"array","description":"Shorthand for a simple (no-options) product: per-currency prices that forward to the product's sole variant. For products with options, set prices per variant under `variants:` instead.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"variants":{"type":"array","description":"Array of variant payloads. Variants can declare multiple option pairs via `options:` and per-currency prices via `prices:`. Stock counts go in `stock_items:` (per stock location).","items":{"type":"object","properties":{"sku":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}}}}},"delete":{"summary":"Delete a product","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes a product.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product deleted"}}}},"/api/v3/admin/products/bulk_status_update":{"post":{"summary":"Bulk-update product status","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Sets `status` on each product in `ids`. Reindexes the affected products\nfor search. Cross-store IDs are silently dropped. Returns counts.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"cross-store products silently dropped","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"status":{"type":"string"}}}}}},"422":{"description":"invalid status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","status"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["draft","active","archived"]}}}}}}}},"/api/v3/admin/products/bulk_add_to_categories":{"post":{"summary":"Bulk-add products to categories","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each product in `ids` to every category (taxon) in `category_ids`.\nCategories from sibling stores are silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products added to categories","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"category_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","category_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_categories":{"post":{"summary":"Bulk-remove products from categories","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each product in `ids` from every category in `category_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products removed from categories","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","category_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_to_collections":{"post":{"summary":"Bulk-add products to collections","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Attaches each product in `ids` to every manual collection in `collection_ids`.\nAutomatic (rule-based) and sibling-store collections are silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products added to collections","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"collection_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","collection_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"collection_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_collections":{"post":{"summary":"Bulk-remove products from collections","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Detaches each product in `ids` from every collection in `collection_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products removed from collections","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","collection_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"collection_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_to_channels":{"post":{"summary":"Bulk-add products to channels","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Publishes each product in `ids` on every channel in `channel_ids`. Idempotent —\nre-publishing on an existing channel is a no-op. Channels from sibling stores\nare silently ignored.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products published on channels","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"channel_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","channel_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"channel_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_from_channels":{"post":{"summary":"Bulk-remove products from channels","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Unpublishes each product in `ids` from every channel in `channel_ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products unpublished from channels","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"channel_count":{"type":"integer"},"removed":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","channel_ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"channel_ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_add_tags":{"post":{"summary":"Bulk-add tags to products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds each tag name in `tags` to every product in `ids`. Tags are upserted by name.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags added","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"},"tag_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_remove_tags":{"post":{"summary":"Bulk-remove tags from products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes each tag in `tags` from every product in `ids`.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"tags removed","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids","tags"],"properties":{"ids":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/products/bulk_destroy":{"delete":{"summary":"Bulk-delete products","tags":["Products"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes each product in `ids`. Returns the count actually destroyed.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"products deleted","content":{"application/json":{"schema":{"type":"object","properties":{"product_count":{"type":"integer"}}}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["ids"],"properties":{"ids":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/promotions/{promotion_id}/coupon_codes":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List coupon codes for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the auto-generated coupon codes for a multi-code promotion. Single-code promotions store the code on the promotion itself; this endpoint returns an empty list for them.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"coupon codes found","content":{"application/json":{}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List actions for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"actions found","content":{"application/json":{}}}}},"post":{"summary":"Create an action on a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new action to a promotion. The `type` is the wire shorthand from `GET /promotion_actions/types` (e.g. `free_shipping`, `create_item_adjustments`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"action created","content":{"application/json":{}}},"422":{"description":"unknown action type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_actions/{id}":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"delete":{"summary":"Delete an action from a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"action deleted"}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"summary":"List rules for a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules found","content":{"application/json":{}}}}},"post":{"summary":"Create a rule on a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Adds a new rule to a promotion. The `type` is the wire shorthand from `GET /promotion_rules/types` (e.g. `currency`, `item_total`, `product`). Fully-qualified Ruby class names are also accepted for backward compatibility.\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"rule created with preferences","content":{"application/json":{}}},"422":{"description":"unknown rule type","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}},"required":["type"]}}}}}},"/api/v3/admin/promotions/{promotion_id}/promotion_rules/{id}":{"parameters":[{"name":"promotion_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"summary":"Update a rule's preferences","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"preferences":{"type":"object","additionalProperties":true}}}}}}},"delete":{"summary":"Delete a rule from a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"rule deleted"}}}},"/api/v3/admin/promotions":{"get":{"summary":"List promotions","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the store's promotions, including manual coupon and automatic promotions.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"promotions found","content":{"application/json":{}}}}},"post":{"summary":"Create a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new promotion. `code` is required for single-code coupon promotions;\npass `multi_codes: true` with `number_of_codes` to auto-generate a batch.\n\nRules and actions can be created in the same request by passing arrays of\n`{ type, preferences, ... }` rows. The server reconciles to the desired set:\nnew rows are built, existing rows (by `id`) are updated, omitted rows are removed.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"promotion created with rules and actions","content":{"application/json":{}}},"422":{"description":"invalid params","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"code":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"starts_at":{"type":"string","format":"date-time","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"usage_limit":{"type":"integer","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"kind":{"type":"string","enum":["coupon_code","automatic"]},"multi_codes":{"type":"boolean"},"number_of_codes":{"type":"integer","nullable":true},"code_prefix":{"type":"string","nullable":true},"promotion_category_id":{"type":"string","nullable":true},"rules":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"product_ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}},"customer_ids":{"type":"array","items":{"type":"string"}}},"required":["type"]}},"actions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"calculator":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"required":["type"]}}},"required":["name"]}}}}}},"/api/v3/admin/promotions/{id}":{"get":{"summary":"Show a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"promotion found","content":{"application/json":{}}}}},"patch":{"summary":"Update a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a promotion. The `rules` and `actions` arrays are treated as\na *desired set* — rows with `id` update in place, rows without `id` are\nbuilt fresh, and any existing row not present in the array is destroyed.\nPass `rules: []` or `actions: []` to clear them.\n\n\n**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rules and actions cleared with empty arrays","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"starts_at":{"type":"string","format":"date-time","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"usage_limit":{"type":"integer","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"kind":{"type":"string","enum":["coupon_code","automatic"]},"promotion_category_id":{"type":"string","nullable":true},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","nullable":true,"description":"Pass to update an existing rule; omit to build a new one"},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"product_ids":{"type":"array","items":{"type":"string"}},"category_ids":{"type":"array","items":{"type":"string"}},"customer_ids":{"type":"array","items":{"type":"string"}}},"required":["type"]}},"actions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","nullable":true},"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"calculator":{"type":"object","properties":{"type":{"type":"string"},"preferences":{"type":"object","additionalProperties":true}}}},"required":["type"]}}}}}}}},"delete":{"summary":"Delete a promotion","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"promotion deleted"}}}},"/api/v3/admin/promotion_actions/types":{"get":{"summary":"List available promotion action types","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PromotionAction subclasses with their preference schemas. Used by admin UIs to populate the \"Add action\" picker and render generic preference forms.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"action types found","content":{"application/json":{}}}}}},"/api/v3/admin/promotion_rules/types":{"get":{"summary":"List available promotion rule types","tags":["Promotions"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the registered Spree::PromotionRule subclasses with their preference schemas.\n\n**Required scope:** `read_promotions` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"rule types found","content":{"application/json":{}}}}}},"/api/v3/admin/orders/{order_id}/refunds":{"get":{"summary":"List refunds","tags":["Refunds"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all refunds for an order.\n\n**Required scope:** `read_refunds` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., payment, refund_reason). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., amount,reason,transaction_id). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"refunds found","content":{"application/json":{}}}}},"post":{"summary":"Create a refund","tags":["Refunds"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a refund for a payment on the order. The refund is automatically processed via the payment gateway.\n\n**Required scope:** `write_refunds` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"order_id","in":"path","required":true,"description":"Order ID","schema":{"type":"string"}}],"responses":{"201":{"description":"refund created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["payment_id","amount"],"properties":{"payment_id":{"type":"string","description":"Payment ID"},"amount":{"type":"string"},"refund_reason_id":{"type":"string","description":"Refund reason ID"}}}}}}}},"/api/v3/admin/locales":{"get":{"summary":"List supported locales","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the locales a merchant can translate content into for the current store, with the default and right-to-left flags.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"locales found","content":{"application/json":{}}}}}},"/api/v3/admin/store_credit_categories":{"get":{"summary":"List store credit categories","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the configured store credit categories. Categories classify\nstore credits (e.g., \"Goodwill\", \"Gift Card\", \"Refund\") and surface\nin the admin UI as a dropdown when issuing or editing a store\ncredit. Category names matching `Spree::Config[:non_expiring_credit_types]`\nare flagged via `non_expiring: true`.\n\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credit categories found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StoreCreditCategory"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store_credit_categories/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Store credit category ID","schema":{"type":"string"}}],"get":{"summary":"Get a store credit category","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single store credit category by prefixed ID.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"store credit category found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreCreditCategory"}}}},"404":{"description":"store credit category not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/store":{"get":{"summary":"Get the current store","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the current store configuration. The store is resolved from the request context (host or admin selection); there is no `id` parameter.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"current store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Store"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update the current store","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates the current store configuration.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"store updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Store"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"preferred_admin_locale":{"type":"string"},"preferred_timezone":{"type":"string"},"preferred_weight_unit":{"type":"string"},"preferred_unit_system":{"type":"string"}}}}}}}},"/api/v3/admin/tags":{"get":{"summary":"List tags","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns tag names for a given taggable type. Used for autocomplete in tag inputs on products, orders, and customers.","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"taggable_type","in":"query","required":true,"description":"Taggable type (`Spree::Product`, `Spree::Order`, or `Spree::User`)","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"Optional case-insensitive substring filter","schema":{"type":"string"}}],"responses":{"200":{"description":"tags found","content":{"application/json":{}}},"422":{"description":"invalid taggable type","content":{"application/json":{}}}}}},"/api/v3/admin/translatable_resources":{"get":{"summary":"List translatable resources","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns every translatable resource type and its translatable fields (key + content type), so clients can render translation editors generically.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translatable resources found","content":{"application/json":{}}}}}},"/api/v3/admin/translations/batch":{"post":{"summary":"Batch upsert translations","tags":["Settings"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Atomically upserts translations across many records of (possibly) different translatable resource types in one request — e.g. an option type and all its option values in one save. A flat list of independent registry writes; all entries succeed or none do.\n\n**Required scope:** `write_<resource>` for every resource type in the batch (for API-key authentication) (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"translations upserted","content":{"application/json":{}}},"422":{"description":"unsupported locale rolls back the whole batch","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["translations"],"properties":{"translations":{"type":"array","items":{"type":"object","required":["resource_type","resource_id","values"],"properties":{"resource_type":{"type":"string","description":"Translatable resource type token, e.g. `option_type`"},"resource_id":{"type":"string","description":"Prefixed id of the record"},"values":{"type":"object","description":"Map of locale code to { field: value }","additionalProperties":{"type":"object","additionalProperties":true}}}}}}}}}}}},"/api/v3/admin/admin_users":{"get":{"summary":"List staff","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns admin users with at least one role assignment on the current store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff found","content":{"application/json":{}}}}}},"/api/v3/admin/admin_users/{id}":{"get":{"summary":"Show a staff member","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff member found","content":{"application/json":{}}}}},"patch":{"summary":"Update a staff member","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name fields and reassigns roles for the current store. `role_ids` is a complete replacement — roles not in the array are removed for this store.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"staff member updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"role_ids":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Remove a staff member from this store","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes the user's role assignments on the current store. The account is preserved — the user keeps access to any other stores.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"staff removed from store"}}}},"/api/v3/admin/invitations":{"get":{"summary":"List invitations","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns invitations for the current store, including pending and accepted.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"invitations found","content":{"application/json":{}}}}},"post":{"summary":"Create an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Invites a teammate by email. The invitation is scoped to the current store and carries the chosen role; on accept, a `RoleUser` is created via the invitation's `after_accept` callback.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"invitation created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["email","role_id"],"properties":{"email":{"type":"string"},"role_id":{"type":"string"}}}}}}}},"/api/v3/admin/invitations/{id}":{"delete":{"summary":"Revoke an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"invitation revoked"}}}},"/api/v3/admin/invitations/{id}/resend":{"patch":{"summary":"Resend an invitation","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Issues a fresh token and dispatches the invitation email again.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"invitation resent","content":{"application/json":{}}}}}},"/api/v3/admin/roles":{"get":{"summary":"List roles","tags":["Staff"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the roles available for staff role pickers. Roles are global, not per-store.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"roles found","content":{"application/json":{}}}}}},"/api/v3/admin/stock_locations":{"get":{"summary":"List stock locations","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns the configured stock locations. Stock locations are global\n(shared across stores). Filter with Ransack predicates such as\n`q[active_eq]`, `q[kind_eq]`, `q[pickup_enabled_eq]`, or\n`q[name_cont]`.\n\nPickup-related attributes (`kind`, `pickup_enabled`,\n`pickup_stock_policy`, `pickup_ready_in_minutes`,\n`pickup_instructions`) drive merchant pickup support at checkout —\ncustomers can collect orders from any active location with\n`pickup_enabled: true`.\n\n\n**Required scope:** `read_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[active_eq]","in":"query","required":false,"description":"Filter by active status","schema":{"type":"boolean"}},{"name":"q[kind_eq]","in":"query","required":false,"description":"Filter by kind (built-in: 'warehouse', 'store', 'fulfillment_center')","schema":{"type":"string"}},{"name":"q[pickup_enabled_eq]","in":"query","required":false,"description":"Filter by pickup-enabled flag","schema":{"type":"boolean"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"stock locations found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StockLocation"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new stock location.\n\nSetting `default: true` automatically demotes the previous default\nlocation.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"stock location created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true,"description":"Internal name shown only in the admin"},"active":{"type":"boolean"},"default":{"type":"boolean","description":"Setting to true demotes the previous default."},"kind":{"type":"string","enum":["warehouse","store","fulfillment_center"],"description":"Categorizes the location."},"propagate_all_variants":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true,"description":"ISO-3166 alpha-2 country code (e.g. \"US\")."},"state_abbr":{"type":"string","nullable":true,"description":"State / province abbreviation (e.g. \"NY\"). Resolved against the selected country."},"state_name":{"type":"string","nullable":true,"description":"Free-text state for countries without a states list."},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string","enum":["local","any"],"description":"'local' = items at this location only; 'any' = transfer-eligible (ship-to-store)."},"pickup_ready_in_minutes":{"type":"number","nullable":true,"minimum":0},"pickup_instructions":{"type":"string","nullable":true}},"required":["name"]}}}}}},"/api/v3/admin/stock_locations/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Stock location ID","schema":{"type":"string"}}],"get":{"summary":"Get a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single stock location by prefixed ID.\n\n**Required scope:** `read_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"stock location found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"404":{"description":"stock location not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates an existing stock location. Same address-field conventions as\nthe create endpoint.\n\nSetting `default: true` automatically demotes the previous default.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"stock location updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StockLocation"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true},"active":{"type":"boolean"},"default":{"type":"boolean"},"kind":{"type":"string","enum":["warehouse","store","fulfillment_center"]},"propagate_all_variants":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string","enum":["local","any"]},"pickup_ready_in_minutes":{"type":"number","nullable":true,"minimum":0},"pickup_instructions":{"type":"string","nullable":true}}}}}}},"delete":{"summary":"Delete a stock location","tags":["Stock Locations"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the stock location (sets `deleted_at`). Existing\nfulfillments that referenced it keep the historical record via\n`Spree::StockLocation.with_deleted`.\n\n\n**Required scope:** `write_stock` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"stock location deleted"}}}},"/api/v3/admin/products/{product_id}/variants":{"get":{"summary":"List product variants","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of variants for a product, including the default variant.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"variants found","content":{"application/json":{}}}}},"post":{"summary":"Create a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new variant for a product. Supports nested prices and stock items.\n\nOption types and values are auto-created if they don't exist.\nPrices are upserted by currency. Stock items are upserted by stock location.\n\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"201":{"description":"variant created","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"cost_price":{"type":"string"},"cost_currency":{"type":"string"},"weight":{"type":"number"},"height":{"type":"number"},"width":{"type":"number"},"depth":{"type":"number"},"weight_unit":{"type":"string"},"dimensions_unit":{"type":"string"},"track_inventory":{"type":"boolean"},"tax_category_id":{"type":"string"},"options":{"type":"array","description":"A variant on a product with option types should declare its option pairs (e.g. size + color) — one per option type it participates in. Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"position":{"type":"integer"},"barcode":{"type":"string"},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}}},"/api/v3/admin/products/{product_id}/variants/{id}":{"get":{"summary":"Get a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single variant by ID.\n\n**Required scope:** `read_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., images, prices, stock_items, option_values). Use dot notation for nested expand (max 4 levels).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include (e.g., sku,price,stock). id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"variant found","content":{"application/json":{}}},"404":{"description":"variant not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a variant. Only provided fields are updated.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}}],"responses":{"200":{"description":"variant updated","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"cost_price":{"type":"string"},"cost_currency":{"type":"string"},"weight":{"type":"number"},"height":{"type":"number"},"width":{"type":"number"},"depth":{"type":"number"},"weight_unit":{"type":"string"},"dimensions_unit":{"type":"string"},"track_inventory":{"type":"boolean"},"tax_category_id":{"type":"string"},"options":{"type":"array","description":"One pair per option type the variant participates in (e.g. size + color). Option types and values are auto-created if missing.","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"position":{"type":"integer"},"barcode":{"type":"string"},"prices":{"type":"array","description":"Per-currency prices. Upserted by currency.","items":{"type":"object","required":["currency","amount"],"properties":{"currency":{"type":"string"},"amount":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true}}}},"stock_items":{"type":"array","description":"Per-stock-location inventory. Upserted by stock_location_id.","items":{"type":"object","required":["stock_location_id","count_on_hand"],"properties":{"stock_location_id":{"type":"string","description":"Stock location ID (e.g. sloc_xxx)"},"count_on_hand":{"type":"integer"},"backorderable":{"type":"boolean"}}}}}}}}}},"delete":{"summary":"Delete a variant","tags":["Variants"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes a variant.\n\n**Required scope:** `write_products` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"product_id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Variant ID","schema":{"type":"string"}}],"responses":{"204":{"description":"variant deleted"}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}}],"get":{"summary":"List webhook deliveries","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns delivery attempts for the given endpoint, most recent first.\nEach row carries the original request payload, the response code\n(when the receiver replied), the execution time, and any transport\nerror — everything needed to audit failures and decide whether to\nredeliver.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[event_name_eq]","in":"query","required":false,"description":"Filter by event name (exact)","schema":{"type":"string"}},{"name":"q[success_eq]","in":"query","required":false,"description":"Filter by success flag","schema":{"type":"boolean"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-delivered_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"deliveries found","content":{"application/json":{}}},"404":{"description":"parent webhook endpoint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Webhook delivery ID","schema":{"type":"string"}}],"get":{"summary":"Get a webhook delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single delivery attempt with the full request payload and\nthe response body the receiver returned. Use this for ad-hoc debug\nof failed deliveries.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"delivery found","content":{"application/json":{}}},"404":{"description":"delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v3/admin/webhook_endpoints/{webhook_endpoint_id}/deliveries/{id}/redeliver":{"parameters":[{"name":"webhook_endpoint_id","in":"path","required":true,"description":"Parent webhook endpoint ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Webhook delivery ID to redeliver","schema":{"type":"string"}}],"post":{"summary":"Redeliver a webhook delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new delivery row with the same payload + event_name and\nqueues it. The original row is preserved for audit history.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"redelivery queued","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints":{"get":{"summary":"List webhook endpoints","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns outbound webhook subscriptions for the current store. Each\nendpoint receives a signed POST when any subscribed event fires.\n`secret_key` is `null` on list reads — the plaintext is delivered\nexactly once on create.\n\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"q[name_cont]","in":"query","required":false,"description":"Filter by name (contains)","schema":{"type":"string"}},{"name":"q[url_cont]","in":"query","required":false,"description":"Filter by URL (contains)","schema":{"type":"string"}},{"name":"sort","in":"query","required":false,"description":"Sort by field. Prefix with `-` for descending (e.g., `-created_at`).","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoints found","content":{"application/json":{}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a new outbound webhook subscription. The plaintext\n`secret_key` is returned **once** in this response — persist it\nimmediately to verify incoming webhook signatures. Subsequent reads\nreturn `null` for the secret. Pass an empty `subscriptions` array or\nomit it to receive every event.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"webhook endpoint created — secret_key returned once","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"name":{"type":"string"},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}}}}}}}}},"/api/v3/admin/webhook_endpoints/{id}":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"get":{"summary":"Get a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single webhook endpoint by prefixed ID.\n\n**Required scope:** `read_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"fields","in":"query","required":false,"description":"Comma-separated list of fields to include. id is always included.","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint found","content":{"application/json":{}}},"404":{"description":"webhook endpoint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates name, URL, active flag, or the event subscription list.\nToggling `active` here is equivalent to calling `disable`/`enable`\nwithout an audit reason.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint updated","content":{"application/json":{}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}}}}}}}},"delete":{"summary":"Delete a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Soft-deletes the endpoint and stops future deliveries.\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"204":{"description":"webhook endpoint deleted"}}}},"/api/v3/admin/webhook_endpoints/{id}/send_test":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"post":{"summary":"Send a test delivery","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a `webhook.test` delivery record and queues it. Use this to\nverify the endpoint is reachable and your signature verification\naccepts Spree's payloads.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"test delivery queued","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/enable":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"patch":{"summary":"Re-enable a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Re-enables an endpoint that was manually or automatically disabled.\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint enabled","content":{"application/json":{}}}}}},"/api/v3/admin/webhook_endpoints/{id}/disable":{"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook endpoint ID","schema":{"type":"string"}}],"patch":{"summary":"Disable a webhook endpoint","tags":["Webhooks"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Manually pauses an endpoint. Unlike auto-disable (triggered after\nrepeated delivery failures), no notification email is sent.\n\n\n**Required scope:** `write_webhooks` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"200":{"description":"webhook endpoint disabled","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string"}}}}}}}},"/api/v3/admin/collections":{"get":{"summary":"List collections","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a paginated list of the store's collections.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"page","in":"query","required":false,"description":"Page number","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Number of records per page","schema":{"type":"integer"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_fields, translations).","schema":{"type":"string"}}],"responses":{"200":{"description":"collections found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Collection"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Create a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a manual or automatic (rule-based) collection. For automatic collections, send the full desired rule set under `rules`.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}}],"responses":{"201":{"description":"collection created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}},"422":{"description":"validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string","enum":["all","any"]},"sort_order":{"type":"string"},"permalink":{"type":"string"},"description":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"rules":{"type":"array","description":"Full desired rule set. Entries with an id update, id-less entries create, omitted rules are removed.","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"match_policy":{"type":"string"}}}}},"required":["name"]}}}}}},"/api/v3/admin/collections/{id}":{"get":{"summary":"Get a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns a single collection by ID, including its rules.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to expand (e.g., custom_fields, translations).","schema":{"type":"string"}}],"responses":{"200":{"description":"collection found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}},"404":{"description":"collection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Updates a collection. Send `position` to reorder it within the flat list; send the full `rules` set to sync automatic rules.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"200":{"description":"collection updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Collection"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"permalink":{"type":"string"},"description":{"type":"string"},"meta_title":{"type":"string"},"meta_description":{"type":"string"},"meta_keywords":{"type":"string"},"sort_order":{"type":"string"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string","enum":["all","any"]},"position":{"type":"integer","description":"Reorders the collection within the flat list (acts_as_list)"},"rules":{"type":"array","description":"Full desired rule set (see create).","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"match_policy":{"type":"string"}}}}}}}}}},"delete":{"summary":"Delete a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Deletes a collection.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"204":{"description":"collection deleted"}}}},"/api/v3/admin/collections/{collection_id}/products":{"get":{"summary":"List collection products","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Products curated in the collection, ordered by their membership position.\n\n**Required scope:** `read_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"200":{"description":"products found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]}}}}}},"post":{"summary":"Add a product to a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Curates a product into the collection (appended to the end).\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}}],"responses":{"201":{"description":"product added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"product_id":{"type":"string"}},"required":["product_id"]}}}}}},"/api/v3/admin/collections/{collection_id}/products/{id}":{"delete":{"summary":"Remove a product from a collection","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Removes a product from the collection's manual curation.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product removed"}}}},"/api/v3/admin/collections/{collection_id}/products/{id}/reposition":{"patch":{"summary":"Reposition a collection product","tags":["Collections"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Moves a product to a new index among the collection's products.\n\n**Required scope:** `write_collections` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"description":"Bearer token for admin authentication","schema":{"type":"string"}},{"name":"collection_id","in":"path","required":true,"description":"Collection ID","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"Product ID","schema":{"type":"string"}}],"responses":{"204":{"description":"product repositioned"}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"new_position":{"type":"integer","description":"0-based index among the collection's products"}},"required":["new_position"]}}}}}},"/api/v3/admin/delivery_methods":{"get":{"summary":"List delivery methods","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Returns all delivery methods with calculator and zone configuration.\n\n**Required scope:** `read_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"delivery methods found","content":{"application/json":{}}}}},"post":{"summary":"Create delivery method","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a delivery method. fulfillment_type is one of shipping, digital, pickup, pickup_point.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"delivery method created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"admin_name":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"fulfillment_type":{"type":"string","enum":["shipping","digital","pickup","pickup_point"]},"storefront_visible":{"type":"boolean"},"tracking_url":{"type":"string","nullable":true},"estimated_transit_business_days_min":{"type":"integer","nullable":true},"estimated_transit_business_days_max":{"type":"integer","nullable":true},"tax_category_id":{"type":"string","nullable":true},"calculator_type":{"type":"string"},"calculator_preferences":{"type":"object"},"delivery_zone_ids":{"type":"array","items":{"type":"string"}}},"required":["name"]}}}}}},"/api/v3/admin/delivery_methods/calculators":{"get":{"summary":"List delivery calculators","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Registered delivery calculator classes with preference schemas for building configuration forms.\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"calculators found","content":{"application/json":{}}}}}},"/api/v3/admin/delivery_zones":{"post":{"summary":"Create delivery zone","tags":["Delivery"],"security":[{"api_key":[],"bearer_auth":[]}],"description":"Creates a delivery zone with typed members: country, state, or postal_code (prefix or from/to range).\n\n**Required scope:** `write_settings` (for API-key authentication).","parameters":[{"name":"x-spree-api-key","in":"header","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"}},{"name":"expand","in":"query","required":false,"description":"Comma-separated associations to embed, e.g. `members`","schema":{"type":"string"}}],"responses":{"201":{"description":"delivery zone created","content":{"application/json":{}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string","nullable":true},"members":{"type":"array","items":{"type":"object","properties":{"member_type":{"type":"string","enum":["country","state","postal_code"]},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"postal_code_prefix":{"type":"string","nullable":true},"postal_code_from":{"type":"string","nullable":true},"postal_code_to":{"type":"string","nullable":true}},"required":["member_type"]}}},"required":["name"]}}}}}}},"components":{"schemas":{"PaginationMeta":{"type":"object","properties":{"page":{"type":"integer"},"limit":{"type":"integer"},"count":{"type":"integer","description":"Total number of records"},"pages":{"type":"integer","description":"Total number of pages"},"from":{"type":"integer","description":"Index of first record on this page"},"to":{"type":"integer","description":"Index of last record on this page"},"in":{"type":"integer","description":"Number of records on this page"},"previous":{"type":"integer","nullable":true,"description":"Previous page number"},"next":{"type":"integer","nullable":true,"description":"Next page number"}},"required":["page","limit","count","pages","from","to","in"]},"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","description":"Field-specific validation errors","nullable":true}},"required":["code","message"]}},"required":["error"]},"AuthResponse":{"type":"object","properties":{"token":{"type":"string","description":"JWT access token"},"user":{"$ref":"#/components/schemas/AdminUser"}},"required":["token","user"]},"PermissionRule":{"type":"object","description":"A single permission rule (CanCanCan rule). Rules are applied in order, last-matching-wins.","properties":{"allow":{"type":"boolean","description":"true for `can`, false for `cannot`"},"actions":{"type":"array","items":{"type":"string"},"description":"Action names, e.g. [\"read\", \"update\"] or [\"manage\"]"},"subjects":{"type":"array","items":{"type":"string"},"description":"Subject class names, e.g. [\"Spree::Product\"] or [\"all\"]"},"has_conditions":{"type":"boolean","description":"True if the server-side rule has per-record conditions. The SPA shows the action optimistically and handles 403 from the API."}},"required":["allow","actions","subjects","has_conditions"]},"MeResponse":{"type":"object","description":"Current admin user profile and serialized permissions","properties":{"user":{"$ref":"#/components/schemas/AdminUser"},"permissions":{"type":"array","items":{"$ref":"#/components/schemas/PermissionRule"}}},"required":["user","permissions"]},"ImportSchemaField":{"type":"object","description":"A canonical column of an import type, including per-store custom field columns","properties":{"name":{"type":"string","description":"Canonical field name used in mappings"},"label":{"type":"string","description":"Human-readable label"},"required":{"type":"boolean","description":"Whether the field must be mapped before processing"}},"required":["name","label","required"]},"CheckoutRequirement":{"type":"object","properties":{"step":{"type":"string","description":"Checkout step this requirement belongs to"},"field":{"type":"string","description":"Field that needs to be satisfied"},"message":{"type":"string","description":"Human-readable requirement message"}},"required":["step","field","message"]},"CartWarning":{"type":"object","description":"A warning about a cart issue (e.g., item removed due to stock change)","properties":{"code":{"type":"string","description":"Machine-readable warning code"},"message":{"type":"string","description":"Human-readable warning message"},"line_item_id":{"type":"string","nullable":true,"description":"Prefixed line item ID (when applicable)"},"variant_id":{"type":"string","nullable":true,"description":"Prefixed variant ID (when applicable)"}},"required":["code","message"]},"FulfillmentManifestItem":{"type":"object","description":"An item within a fulfillment — which line item and how many units are in this fulfillment","properties":{"item_id":{"type":"string","description":"Line item ID"},"variant_id":{"type":"string","description":"Variant ID"},"quantity":{"type":"integer","description":"Quantity in this fulfillment"}},"required":["item_id","variant_id","quantity"]},"AdminUserRoleAssignment":{"type":"object","description":"A role assignment for the current store on a staff member","properties":{"id":{"type":"string","description":"Prefixed role ID"},"name":{"type":"string","description":"Role name"}},"required":["id","name"]},"AdminUserStore":{"type":"object","description":"A store the staff member can access through a role assignment","properties":{"id":{"type":"string","description":"Prefixed store ID"},"name":{"type":"string","description":"Store name"},"code":{"type":"string","description":"Store code"}},"required":["id","name","code"]},"PreferenceField":{"type":"object","description":"A single configurable preference on a payment method, promotion rule/action, or calculator. The frontend uses `type` + `default` to render a sensible input.","properties":{"key":{"type":"string"},"type":{"type":"string","description":"string | text | password | integer | decimal | boolean | array | hash"},"default":{"description":"Default value (any JSON type), null when there is no default","nullable":true}},"required":["key","type"]},"PromotionActionCalculator":{"type":"object","description":"The action's nested calculator (when the action carries one — null for actions like `free_shipping`)","properties":{"type":{"type":"string","description":"Wire shorthand for the calculator subclass"},"label":{"type":"string"},"preferences":{"type":"object","additionalProperties":true},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}}},"required":["type","label","preferences","preference_schema"]},"PromotionActionLineItem":{"type":"object","description":"One row in a `create_line_items` action — the variant added to the order and how many","properties":{"variant_id":{"type":"string"},"quantity":{"type":"integer"}},"required":["variant_id","quantity"]},"Address":{"type":"object","properties":{"id":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"full_name":{"type":"string"},"address1":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"postal_code":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"country_name":{"type":"string"},"country_iso":{"type":"string"},"state_text":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"quick_checkout":{"type":"boolean"},"is_default_billing":{"type":"boolean"},"is_default_shipping":{"type":"boolean"},"state_name":{"type":"string","nullable":true},"label":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true}},"required":["id","first_name","last_name","full_name","address1","address2","postal_code","city","phone","company","country_name","country_iso","state_text","state_abbr","quick_checkout","is_default_billing","is_default_shipping","state_name","label","metadata","created_at","updated_at","customer_id"],"x-typelizer":true},"AdminUser":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"full_name":{"type":"string","nullable":true},"selected_locale":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"avatar_url":{"type":"string","nullable":true},"roles":{"type":"array","items":{"$ref":"#/components/schemas/AdminUserRoleAssignment"}},"stores":{"type":"array","items":{"$ref":"#/components/schemas/AdminUserStore"}}},"required":["id","email","first_name","last_name","full_name","selected_locale","created_at","updated_at","avatar_url","roles","stores"],"x-typelizer":true},"AllowedOrigin":{"type":"object","properties":{"id":{"type":"string"},"origin":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","origin","created_at","updated_at"],"x-typelizer":true},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"key_type":{"type":"string"},"token_prefix":{"type":"string","nullable":true},"scopes":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string"},"updated_at":{"type":"string"},"revoked_at":{"type":"string","nullable":true},"last_used_at":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"plaintext_token":{"type":"string","nullable":true},"created_by_email":{"type":"string","nullable":true}},"required":["id","name","key_type","token_prefix","scopes","created_at","updated_at","revoked_at","last_used_at","channel_id","plaintext_token","created_by_email"],"x-typelizer":true},"AppliedPromotion":{"type":"object","properties":{"id":{"type":"string"},"promotion_id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","promotion_id","name","description","code","amount","display_amount","created_at","updated_at"],"x-typelizer":true},"Cart":{"type":"object","properties":{"id":{"type":"string"},"market_id":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"preferred_stock_location_id":{"type":"string","nullable":true},"number":{"type":"string"},"token":{"type":"string"},"email":{"type":"string","nullable":true},"customer_note":{"type":"string","nullable":true},"currency":{"type":"string"},"locale":{"type":"string","nullable":true},"total_quantity":{"type":"number"},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/CartWarning"}},"coupon_code":{"type":"string","nullable":true},"item_total":{"type":"string","nullable":true},"display_item_total":{"type":"string","nullable":true},"adjustment_total":{"type":"string","nullable":true},"display_adjustment_total":{"type":"string","nullable":true},"discount_total":{"type":"string","nullable":true},"display_discount_total":{"type":"string","nullable":true},"tax_total":{"type":"string","nullable":true},"display_tax_total":{"type":"string","nullable":true},"included_tax_total":{"type":"string","nullable":true},"display_included_tax_total":{"type":"string","nullable":true},"additional_tax_total":{"type":"string","nullable":true},"display_additional_tax_total":{"type":"string","nullable":true},"total":{"type":"string","nullable":true},"display_total":{"type":"string","nullable":true},"gift_card_total":{"type":"string","nullable":true},"display_gift_card_total":{"type":"string","nullable":true},"amount_due":{"type":"string","nullable":true},"display_amount_due":{"type":"string","nullable":true},"delivery_total":{"type":"string","nullable":true},"display_delivery_total":{"type":"string","nullable":true},"store_credit_total":{"type":"string","nullable":true},"display_store_credit_total":{"type":"string","nullable":true},"covered_by_store_credit":{"type":"boolean"},"current_step":{"type":"string"},"completed_steps":{"type":"array","items":{"type":"string"}},"requirements":{"type":"array","items":{"$ref":"#/components/schemas/CheckoutRequirement"}},"shipping_eq_billing_address":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"}},"billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"completed_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"applied_promotions":{"type":"array","items":{"$ref":"#/components/schemas/AppliedPromotion"}}},"required":["id","market_id","channel_id","preferred_stock_location_id","number","token","email","customer_note","currency","locale","total_quantity","warnings","coupon_code","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","current_step","completed_steps","requirements","shipping_eq_billing_address","items","billing_address","shipping_address","market","completed_at","created_at","updated_at","applied_promotions"],"x-typelizer":true},"Category":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"permalink":{"type":"string"},"position":{"type":"number"},"depth":{"type":"number"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"children_count":{"type":"number"},"parent_id":{"type":"string","nullable":true},"description":{"type":"string"},"description_html":{"type":"string"},"image_url":{"type":"string","nullable":true},"square_image_url":{"type":"string","nullable":true},"is_root":{"type":"boolean"},"is_child":{"type":"boolean"},"is_leaf":{"type":"boolean"},"parent":{"$ref":"#/components/schemas/Category"},"children":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"ancestors":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"translations":{"type":"object"},"metadata":{"type":"object"},"pretty_name":{"type":"string"},"lft":{"type":"number"},"rgt":{"type":"number"},"products_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","permalink","position","depth","meta_title","meta_description","meta_keywords","children_count","parent_id","description","description_html","image_url","square_image_url","is_root","is_child","is_leaf","metadata","pretty_name","lft","rgt","products_count","created_at","updated_at"],"x-typelizer":true},"Channel":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string"},"active":{"type":"boolean"},"default":{"type":"boolean"},"storefront_access":{"type":"string"},"guest_checkout":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string","nullable":true},"preferred_storefront_access":{"type":"string","nullable":true},"preferred_guest_checkout":{"type":"boolean","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","code","active","default","storefront_access","guest_checkout","preferred_order_routing_strategy","preferred_storefront_access","preferred_guest_checkout","created_at","updated_at"],"x-typelizer":true},"ClaimLineItem":{"type":"object","properties":{"id":{"type":"string"},"quantity":{"type":"number"},"send_replacement":{"type":"boolean"},"description":{"type":"string","nullable":true},"refund_amount":{"type":"string"},"paid_amount":{"type":"string"},"display_refund_amount":{"type":"string"},"variant_id":{"type":"string","nullable":true},"replacement_variant_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"variant":{"$ref":"#/components/schemas/Variant"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"replacement_variant":{"$ref":"#/components/schemas/Variant"}},"required":["id","quantity","send_replacement","description","refund_amount","paid_amount","display_refund_amount","variant_id","replacement_variant_id","line_item_id","created_at","updated_at"],"x-typelizer":true},"ClaimReason":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"active":{"type":"boolean"},"mutable":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"can_be_deleted":{"type":"boolean"}},"required":["id","name","active","mutable","created_at","updated_at","can_be_deleted"],"x-typelizer":true},"Claim":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"claim_type":{"type":"string"},"resolution":{"type":"string","nullable":true},"order_id":{"type":"string","nullable":true},"reason_id":{"type":"string","nullable":true},"refund_total":{"type":"string"},"display_refund_total":{"type":"string"},"approved_at":{"type":"string","nullable":true},"resolved_at":{"type":"string","nullable":true},"denied_at":{"type":"string","nullable":true},"canceled_at":{"type":"string","nullable":true},"claim_line_items":{"type":"array","items":{"$ref":"#/components/schemas/ClaimLineItem"}},"memo":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"created_by_id":{"type":"string","nullable":true},"order":{"$ref":"#/components/schemas/Order"},"refunds":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}},"required":["id","number","status","claim_type","resolution","order_id","reason_id","refund_total","display_refund_total","approved_at","resolved_at","denied_at","canceled_at","memo","metadata","created_at","updated_at","created_by_id"],"x-typelizer":true},"CollectionRule":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"value":{"type":"string","nullable":true},"match_policy":{"type":"string"}},"required":["id","type","value","match_policy"],"x-typelizer":true},"Collection":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"permalink":{"type":"string"},"position":{"type":"number"},"sort_order":{"type":"string"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"products_count":{"type":"number"},"description":{"type":"string"},"description_html":{"type":"string"},"image_url":{"type":"string","nullable":true},"square_image_url":{"type":"string","nullable":true},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"translations":{"type":"object"},"automatic":{"type":"boolean"},"rules_match_policy":{"type":"string"},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"rules":{"type":"array","items":{"$ref":"#/components/schemas/CollectionRule"}}},"required":["id","name","permalink","position","sort_order","meta_title","meta_description","meta_keywords","products_count","description","description_html","image_url","square_image_url","automatic","rules_match_policy","metadata","created_at","updated_at","rules"],"x-typelizer":true},"Country":{"type":"object","properties":{"iso":{"type":"string"},"iso3":{"type":"string"},"name":{"type":"string"},"states_required":{"type":"boolean"},"zipcode_required":{"type":"boolean"},"states":{"type":"array","items":{"$ref":"#/components/schemas/State"}},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["iso","iso3","name","states_required","zipcode_required","created_at","updated_at"],"x-typelizer":true},"CouponCode":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string"},"state":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"promotion_id":{"type":"string"},"order_id":{"type":"string","nullable":true}},"required":["id","code","state","created_at","updated_at","promotion_id","order_id"],"x-typelizer":true},"CreditCard":{"type":"object","properties":{"id":{"type":"string"},"brand":{"type":"string"},"last4":{"type":"string"},"month":{"type":"number"},"year":{"type":"number"},"name":{"type":"string","nullable":true},"default":{"type":"boolean"},"gateway_payment_profile_id":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true},"payment_method_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","brand","last4","month","year","name","default","gateway_payment_profile_id","customer_id","payment_method_id","metadata","created_at","updated_at"],"x-typelizer":true},"CustomFieldDefinition":{"type":"object","properties":{"id":{"type":"string"},"namespace":{"type":"string"},"key":{"type":"string"},"label":{"type":"string"},"field_type":{"type":"string","enum":["short_text","long_text","rich_text","number","boolean","json"]},"resource_type":{"type":"string"},"storefront_visible":{"type":"boolean"},"searchable":{"type":"boolean"},"sortable":{"type":"boolean"},"filter_key":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","namespace","key","label","field_type","resource_type","storefront_visible","searchable","sortable","filter_key","created_at","updated_at"],"x-typelizer":true},"CustomField":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"type":{"type":"string","deprecated":true},"field_type":{"type":"string","enum":["short_text","long_text","rich_text","number","boolean","json"]},"key":{"type":"string"},"value":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"storefront_visible":{"type":"boolean"},"custom_field_definition_id":{"type":"string"}},"required":["id","label","type","field_type","key","value","created_at","updated_at","storefront_visible","custom_field_definition_id"],"x-typelizer":true},"CustomerGroup":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"customers_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}},"required":["id","name","description","customers_count","created_at","updated_at"],"x-typelizer":true},"Customer":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":"string","nullable":true},"last_name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"accepts_email_marketing":{"type":"boolean"},"full_name":{"type":"string"},"available_store_credit_total":{"type":"string"},"display_available_store_credit_total":{"type":"string"},"addresses":{"type":"array","items":{"$ref":"#/components/schemas/Address"}},"default_billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"default_shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"newsletter_subscriber":{"allOf":[{"$ref":"#/components/schemas/NewsletterSubscriber"}],"nullable":true},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"failed_attempts":{"type":"number"},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"internal_note_html":{"type":"string","nullable":true},"default_billing_address_id":{"type":"string","nullable":true},"default_shipping_address_id":{"type":"string","nullable":true},"orders_count":{"type":"number"},"total_spent":{"type":"string"},"display_total_spent":{"type":"string"},"last_order_completed_at":{"type":"string","nullable":true},"orders":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"store_credits":{"type":"array","items":{"$ref":"#/components/schemas/StoreCredit"}},"customer_group_ids":{"type":"array","items":{"type":"string"}}},"required":["id","email","first_name","last_name","phone","accepts_email_marketing","full_name","available_store_credit_total","display_available_store_credit_total","failed_attempts","metadata","created_at","updated_at","tags","internal_note_html","default_billing_address_id","default_shipping_address_id","orders_count","total_spent","display_total_spent","last_order_completed_at","customer_group_ids"],"x-typelizer":true},"DeliveryMethodRule":{"type":"object","properties":{"id":{"type":"string"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"}},"required":["id","active","created_at","updated_at","type","name","description","preferences","preference_schema"],"x-typelizer":true},"DeliveryMethod":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string","nullable":true},"fulfillment_type":{"type":"string"},"estimated_transit_business_days_min":{"type":"number","nullable":true},"estimated_transit_business_days_max":{"type":"number","nullable":true},"admin_name":{"type":"string","nullable":true},"fulfillment_provider":{"type":"string"},"pickup_point_provider":{"type":"string","nullable":true},"storefront_visible":{"type":"boolean"},"tracking_url":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"deleted_at":{"type":"string"},"tax_category_id":{"type":"string","nullable":true},"delivery_zone_ids":{"type":"array","items":{"type":"string"}},"stock_location_ids":{"type":"array","items":{"type":"string"}},"calculator_type":{"type":"string","nullable":true},"calculator_preferences":{"type":"object","nullable":true}},"required":["id","name","code","fulfillment_type","estimated_transit_business_days_min","estimated_transit_business_days_max","admin_name","fulfillment_provider","pickup_point_provider","storefront_visible","tracking_url","created_at","updated_at","deleted_at","tax_category_id","delivery_zone_ids","stock_location_ids","calculator_type","calculator_preferences"],"x-typelizer":true},"DeliveryRate":{"type":"object","properties":{"id":{"type":"string"},"delivery_method_id":{"type":"string"},"name":{"type":"string"},"selected":{"type":"boolean"},"cost":{"type":"string"},"total":{"type":"string"},"additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"tax_total":{"type":"string"},"display_cost":{"type":"string"},"display_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"delivery_method":{"$ref":"#/components/schemas/DeliveryMethod"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","delivery_method_id","name","selected","cost","total","additional_tax_total","included_tax_total","tax_total","display_cost","display_total","display_additional_tax_total","display_included_tax_total","display_tax_total","created_at","updated_at"],"x-typelizer":true},"DeliveryZoneMember":{"type":"object","properties":{"id":{"type":"string"},"member_type":{"type":"string"},"postal_code_prefix":{"type":"string","nullable":true},"postal_code_from":{"type":"string","nullable":true},"postal_code_to":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"state_abbr":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","member_type","postal_code_prefix","postal_code_from","postal_code_to","country_iso","state_abbr","state_name","created_at","updated_at"],"x-typelizer":true},"DeliveryZone":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"members":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryZoneMember"}},"created_at":{"type":"string"},"updated_at":{"type":"string"},"delivery_method_ids":{"type":"array","items":{"type":"string"}}},"required":["id","name","description","created_at","updated_at","delivery_method_ids"],"x-typelizer":true},"DigitalLink":{"type":"object","properties":{"id":{"type":"string"},"access_counter":{"type":"number"},"filename":{"type":"string"},"content_type":{"type":"string"},"download_url":{"type":"string"},"authorizable":{"type":"boolean"},"expired":{"type":"boolean"},"access_limit_exceeded":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","access_counter","filename","content_type","download_url","authorizable","expired","access_limit_exceeded","created_at","updated_at"],"x-typelizer":true},"Discount":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"kind":{"type":"string"},"code":{"type":"string","nullable":true},"value_type":{"type":"string","nullable":true},"value":{"type":"string","nullable":true},"promotion_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","kind","code","value_type","value","promotion_id","line_item_id","fulfillment_id","amount","display_amount","metadata","created_at","updated_at"],"x-typelizer":true},"ExchangeLineItem":{"type":"object","properties":{"id":{"type":"string"},"quantity":{"type":"number"},"received_quantity":{"type":"number"},"resellable":{"type":"boolean"},"original_price":{"type":"string"},"new_variant_price":{"type":"string"},"price_difference":{"type":"string"},"original_variant_id":{"type":"string","nullable":true},"new_variant_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_item_id":{"type":"string","nullable":true},"original_variant":{"$ref":"#/components/schemas/Variant"},"new_variant":{"$ref":"#/components/schemas/Variant"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","quantity","received_quantity","resellable","original_price","new_variant_price","price_difference","original_variant_id","new_variant_id","line_item_id","fulfillment_item_id","created_at","updated_at"],"x-typelizer":true},"Exchange":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"order_id":{"type":"string","nullable":true},"reason_id":{"type":"string","nullable":true},"price_difference":{"type":"string"},"display_price_difference":{"type":"string"},"approved_at":{"type":"string","nullable":true},"received_at":{"type":"string","nullable":true},"fulfilled_at":{"type":"string","nullable":true},"canceled_at":{"type":"string","nullable":true},"exchange_line_items":{"type":"array","items":{"$ref":"#/components/schemas/ExchangeLineItem"}},"memo":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"stock_location_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"order":{"$ref":"#/components/schemas/Order"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"refunds":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}},"required":["id","number","status","order_id","reason_id","price_difference","display_price_difference","approved_at","received_at","fulfilled_at","canceled_at","memo","metadata","created_at","updated_at","stock_location_id","created_by_id"],"x-typelizer":true},"Export":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"format":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true},"done":{"type":"boolean"},"filename":{"type":"string","nullable":true},"byte_size":{"type":"number","nullable":true},"download_url":{"type":"string","nullable":true}},"required":["id","number","format","created_at","updated_at","type","user_id","done","filename","byte_size","download_url"],"x-typelizer":true},"Fee":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"kind":{"type":"string"},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","kind","line_item_id","fulfillment_id","amount","display_amount","metadata","created_at","updated_at"],"x-typelizer":true},"FulfillmentItem":{"type":"object","properties":{"id":{"type":"string"},"quantity":{"type":"number"},"status":{"type":"string"},"variant_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"options_text":{"type":"string","nullable":true}},"required":["id","quantity","status","variant_id","line_item_id","name","options_text"],"x-typelizer":true},"Fulfillment":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"tracking":{"type":"string","nullable":true},"tracking_url":{"type":"string","nullable":true},"pickup_point_data":{"type":"object","nullable":true},"selected_delivery_rate_id":{"type":"string","nullable":true},"cost":{"type":"string"},"display_cost":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"status":{"type":"string"},"fulfillment_type":{"type":"string"},"fulfilled_at":{"type":"string","nullable":true},"items":{"type":"array","items":{"$ref":"#/components/schemas/FulfillmentManifestItem"}},"delivery_method":{"$ref":"#/components/schemas/DeliveryMethod"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"delivery_rates":{"type":"array","items":{"$ref":"#/components/schemas/DeliveryRate"}},"metadata":{"type":"object"},"adjustment_total":{"type":"string"},"pre_tax_amount":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"order_id":{"type":"string","nullable":true},"stock_location_id":{"type":"string","nullable":true},"fulfillment_items":{"type":"array","items":{"$ref":"#/components/schemas/FulfillmentItem"}},"order":{"$ref":"#/components/schemas/Order"}},"required":["id","number","tracking","tracking_url","pickup_point_data","selected_delivery_rate_id","cost","display_cost","total","display_total","discount_total","display_discount_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","tax_total","display_tax_total","status","fulfillment_type","fulfilled_at","items","metadata","adjustment_total","pre_tax_amount","created_at","updated_at","order_id","stock_location_id"],"x-typelizer":true},"GiftCardBatch":{"type":"object","properties":{"id":{"type":"string"},"codes_count":{"type":"number"},"currency":{"type":"string","nullable":true},"prefix":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"amount":{"type":"string","nullable":true},"expires_at":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true}},"required":["id","codes_count","currency","prefix","created_at","updated_at","amount","expires_at","created_by_id"],"x-typelizer":true},"GiftCard":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string"},"status":{"type":"string"},"currency":{"type":"string"},"amount":{"type":"string"},"amount_used":{"type":"string"},"amount_authorized":{"type":"string"},"amount_remaining":{"type":"string"},"display_amount":{"type":"string"},"display_amount_used":{"type":"string"},"display_amount_remaining":{"type":"string"},"expires_at":{"type":"string","nullable":true},"redeemed_at":{"type":"string","nullable":true},"expired":{"type":"boolean"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"customer":{"$ref":"#/components/schemas/Customer"},"created_by":{"$ref":"#/components/schemas/AdminUser"},"gift_card_batch":{"$ref":"#/components/schemas/GiftCardBatch"},"orders":{"type":"array","items":{"$ref":"#/components/schemas/Order"}}},"required":["id","code","status","currency","amount","amount_used","amount_authorized","amount_remaining","display_amount","display_amount_used","display_amount_remaining","expires_at","redeemed_at","expired","active","created_at","updated_at","customer_id","created_by_id"],"x-typelizer":true},"ImportMapping":{"type":"object","properties":{"id":{"type":"string"},"schema_field":{"type":"string"},"file_column":{"type":"string","nullable":true},"required":{"type":"boolean"}},"required":["id","schema_field","file_column","required"],"x-typelizer":true},"ImportRow":{"type":"object","properties":{"id":{"type":"string"},"row_number":{"type":"number"},"status":{"type":"string"},"validation_errors":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"import_id":{"type":"string","nullable":true},"item_type":{"type":"string","nullable":true},"item_id":{"type":"string","nullable":true},"data":{"type":"object"}},"required":["id","row_number","status","validation_errors","created_at","updated_at","import_id","item_type","item_id","data"],"x-typelizer":true},"Import":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"rows_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string","nullable":true},"status":{"type":"string"},"owner_type":{"type":"string","nullable":true},"owner_id":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true},"processing_errors":{"type":"string","nullable":true},"preferred_delimiter":{"type":"string"},"original_filename":{"type":"string","nullable":true},"original_byte_size":{"type":"number","nullable":true},"original_file_url":{"type":"string","nullable":true},"completed_rows_count":{"type":"number"},"failed_rows_count":{"type":"number"},"schema_fields":{"type":"array","items":{"$ref":"#/components/schemas/ImportSchemaField"}},"csv_headers":{"type":"array","items":{"type":"string"}},"sample_row":{"type":"object"},"mappings":{"type":"array","items":{"$ref":"#/components/schemas/ImportMapping"}}},"required":["id","number","rows_count","created_at","updated_at","type","status","owner_type","owner_id","user_id","processing_errors","preferred_delimiter","original_filename","original_byte_size","original_file_url","completed_rows_count","failed_rows_count","schema_fields","csv_headers","sample_row","mappings"],"x-typelizer":true},"Invitation":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"status":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"expires_at":{"type":"string"},"role_id":{"type":"string"},"role_name":{"type":"string"},"inviter_email":{"type":"string"},"acceptance_url":{"type":"string"},"invitee_exists":{"type":"boolean"},"store":{"type":"object"}},"required":["id","email","status","created_at","updated_at","expires_at","role_id","role_name","inviter_email","acceptance_url","invitee_exists","store"],"x-typelizer":true},"LineItem":{"type":"object","properties":{"id":{"type":"string"},"variant_id":{"type":"string"},"preorder":{"type":"boolean"},"preorder_ships_at":{"type":"string","nullable":true},"quantity":{"type":"number"},"currency":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"options_text":{"type":"string"},"price":{"type":"string"},"display_price":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"adjustment_total":{"type":"string"},"display_adjustment_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"pre_tax_amount":{"type":"string"},"display_pre_tax_amount":{"type":"string"},"discounted_amount":{"type":"string"},"display_discounted_amount":{"type":"string"},"display_compare_at_amount":{"type":"string","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"thumbnail_url":{"type":"string","nullable":true},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"digital_links":{"type":"array","items":{"$ref":"#/components/schemas/DigitalLink"}},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"cost_price":{"type":"string","nullable":true},"tax_category_id":{"type":"string","nullable":true},"variant":{"$ref":"#/components/schemas/Variant"},"tax_category":{"$ref":"#/components/schemas/TaxCategory"}},"required":["id","variant_id","preorder","preorder_ships_at","quantity","currency","name","slug","options_text","price","display_price","total","display_total","adjustment_total","display_adjustment_total","additional_tax_total","display_additional_tax_total","included_tax_total","display_included_tax_total","discount_total","display_discount_total","pre_tax_amount","display_pre_tax_amount","discounted_amount","display_discounted_amount","display_compare_at_amount","compare_at_amount","thumbnail_url","option_values","digital_links","metadata","created_at","updated_at","cost_price","tax_category_id"],"x-typelizer":true},"Market":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"currency":{"type":"string"},"default_locale":{"type":"string"},"tax_inclusive":{"type":"boolean"},"default":{"type":"boolean"},"country_isos":{"type":"array","items":{"type":"string"}},"supported_locales":{"type":"array","items":{"type":"string"}},"countries":{"type":"array","items":{"$ref":"#/components/schemas/Country"}},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","currency","default_locale","tax_inclusive","default","country_isos","supported_locales","created_at","updated_at"],"x-typelizer":true},"Media":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string","nullable":true},"variant_ids":{"type":"array","items":{"type":"string"}},"position":{"type":"number"},"alt":{"type":"string","nullable":true},"media_type":{"type":"string"},"focal_point_x":{"type":"number","nullable":true},"focal_point_y":{"type":"number","nullable":true},"external_video_url":{"type":"string","nullable":true},"original_url":{"type":"string","nullable":true},"mini_url":{"type":"string","nullable":true},"small_url":{"type":"string","nullable":true},"medium_url":{"type":"string","nullable":true},"large_url":{"type":"string","nullable":true},"xlarge_url":{"type":"string","nullable":true},"og_image_url":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"viewable_id":{"type":"string"},"download_url":{"type":"string","nullable":true},"metadata":{"type":"object"},"viewable_type":{"type":"string"}},"required":["id","product_id","variant_ids","position","alt","media_type","focal_point_x","focal_point_y","external_video_url","original_url","mini_url","small_url","medium_url","large_url","xlarge_url","og_image_url","created_at","updated_at","viewable_id","download_url","metadata","viewable_type"],"x-typelizer":true},"NewsletterSubscriber":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"verified":{"type":"boolean"},"verified_at":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true}},"required":["id","email","created_at","updated_at","verified","verified_at","customer_id"],"x-typelizer":true},"OptionType":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"number"},"kind":{"type":"string"},"translations":{"type":"object"},"metadata":{"type":"object"},"filterable":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}}},"required":["id","name","label","position","kind","metadata","filterable","created_at","updated_at"],"x-typelizer":true},"OptionValue":{"type":"object","properties":{"id":{"type":"string"},"option_type_id":{"type":"string"},"name":{"type":"string"},"label":{"type":"string"},"position":{"type":"number"},"color_code":{"type":"string","nullable":true},"option_type_name":{"type":"string"},"option_type_label":{"type":"string"},"image_url":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"option_type":{"$ref":"#/components/schemas/OptionType"}},"required":["id","option_type_id","name","label","position","color_code","option_type_name","option_type_label","image_url","metadata","created_at","updated_at"],"x-typelizer":true},"OrderRoutingRule":{"type":"object","properties":{"id":{"type":"string"},"position":{"type":"number"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"channel_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"},"label":{"type":"string"},"description":{"type":"string"}},"required":["id","position","active","created_at","updated_at","type","channel_id","preferences","preference_schema","label","description"],"x-typelizer":true},"Order":{"type":"object","properties":{"id":{"type":"string"},"market_id":{"type":"string","nullable":true},"cart_id":{"type":"string","nullable":true},"channel_id":{"type":"string","nullable":true},"number":{"type":"string"},"email":{"type":"string"},"customer_note":{"type":"string","nullable":true},"currency":{"type":"string"},"locale":{"type":"string","nullable":true},"total_quantity":{"type":"number"},"coupon_code":{"type":"string","nullable":true},"fulfillment_status":{"type":"string","nullable":true},"payment_status":{"type":"string","nullable":true},"completed_at":{"type":"string","nullable":true},"item_total":{"type":"string"},"display_item_total":{"type":"string"},"adjustment_total":{"type":"string"},"display_adjustment_total":{"type":"string"},"discount_total":{"type":"string"},"display_discount_total":{"type":"string"},"tax_total":{"type":"string"},"display_tax_total":{"type":"string"},"included_tax_total":{"type":"string"},"display_included_tax_total":{"type":"string"},"additional_tax_total":{"type":"string"},"display_additional_tax_total":{"type":"string"},"total":{"type":"string"},"display_total":{"type":"string"},"gift_card_total":{"type":"string"},"display_gift_card_total":{"type":"string"},"amount_due":{"type":"string"},"display_amount_due":{"type":"string"},"delivery_total":{"type":"string"},"display_delivery_total":{"type":"string"},"store_credit_total":{"type":"string"},"display_store_credit_total":{"type":"string"},"covered_by_store_credit":{"type":"boolean"},"items":{"type":"array","items":{"$ref":"#/components/schemas/LineItem"}},"fulfillments":{"type":"array","items":{"$ref":"#/components/schemas/Fulfillment"}},"payments":{"type":"array","items":{"$ref":"#/components/schemas/Payment"}},"billing_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"shipping_address":{"allOf":[{"$ref":"#/components/schemas/Address"}],"nullable":true},"gift_card":{"allOf":[{"$ref":"#/components/schemas/GiftCard"}],"nullable":true},"market":{"allOf":[{"$ref":"#/components/schemas/Market"}],"nullable":true},"status":{"type":"string"},"last_ip_address":{"type":"string","nullable":true},"considered_risky":{"type":"boolean"},"confirmation_delivered":{"type":"boolean"},"store_owner_notification_delivered":{"type":"boolean"},"payment_total":{"type":"string"},"display_payment_total":{"type":"string"},"metadata":{"type":"object"},"canceled_at":{"type":"string","nullable":true},"approved_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preferred_stock_location_id":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"internal_note":{"type":"string","nullable":true},"approver_id":{"type":"string","nullable":true},"canceler_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"customer_id":{"type":"string","nullable":true},"applied_promotions":{"type":"array","items":{"$ref":"#/components/schemas/AppliedPromotion"}},"cart":{"$ref":"#/components/schemas/Cart"},"channel":{"$ref":"#/components/schemas/Channel"},"preferred_stock_location":{"$ref":"#/components/schemas/StockLocation"},"payment_methods":{"type":"array","items":{"$ref":"#/components/schemas/PaymentMethod"}},"customer":{"$ref":"#/components/schemas/Customer"},"approver":{"$ref":"#/components/schemas/Customer"},"canceler":{"$ref":"#/components/schemas/Customer"},"created_by":{"$ref":"#/components/schemas/Customer"},"returns":{"type":"array","items":{"$ref":"#/components/schemas/Return"}},"exchanges":{"type":"array","items":{"$ref":"#/components/schemas/Exchange"}},"claims":{"type":"array","items":{"$ref":"#/components/schemas/Claim"}}},"required":["id","market_id","cart_id","channel_id","number","email","customer_note","currency","locale","total_quantity","coupon_code","fulfillment_status","payment_status","completed_at","item_total","display_item_total","adjustment_total","display_adjustment_total","discount_total","display_discount_total","tax_total","display_tax_total","included_tax_total","display_included_tax_total","additional_tax_total","display_additional_tax_total","total","display_total","gift_card_total","display_gift_card_total","amount_due","display_amount_due","delivery_total","display_delivery_total","store_credit_total","display_store_credit_total","covered_by_store_credit","gift_card","market","status","last_ip_address","considered_risky","confirmation_delivered","store_owner_notification_delivered","payment_total","display_payment_total","metadata","canceled_at","approved_at","created_at","updated_at","preferred_stock_location_id","tags","internal_note","approver_id","canceler_id","created_by_id","customer_id"],"x-typelizer":true},"PaymentMethod":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"type":{"type":"string"},"session_required":{"type":"boolean"},"source_required":{"type":"boolean"},"metadata":{"type":"object"},"active":{"type":"boolean"},"auto_capture":{"type":"boolean","nullable":true},"storefront_visible":{"type":"boolean"},"position":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"object"}},"required":["id","name","description","type","session_required","source_required","metadata","active","auto_capture","storefront_visible","position","created_at","updated_at","preferences","preference_schema"],"x-typelizer":true},"Payment":{"type":"object","properties":{"id":{"type":"string"},"payment_method_id":{"type":"string"},"response_code":{"type":"string","nullable":true},"number":{"type":"string"},"amount":{"type":"string"},"display_amount":{"type":"string"},"status":{"type":"string"},"source_type":{"type":"string","nullable":true,"enum":["credit_card","store_credit","payment_source"]},"source_id":{"type":"string","nullable":true},"source":{"anyOf":[{"$ref":"#/components/schemas/CreditCard"},{"$ref":"#/components/schemas/StoreCredit"},{"$ref":"#/components/schemas/PaymentSource"}],"nullable":true},"payment_method":{"$ref":"#/components/schemas/PaymentMethod"},"metadata":{"type":"object"},"avs_response":{"type":"string","nullable":true},"cvv_response_code":{"type":"string","nullable":true},"cvv_response_message":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"captured_amount":{"type":"string"},"order_id":{"type":"string","nullable":true},"order":{"$ref":"#/components/schemas/Order"},"refunds":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}},"required":["id","payment_method_id","response_code","number","amount","display_amount","status","source_type","source_id","source","metadata","avs_response","cvv_response_code","cvv_response_message","created_at","updated_at","captured_amount","order_id"],"x-typelizer":true},"PaymentSource":{"type":"object","properties":{"id":{"type":"string"},"gateway_payment_profile_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","gateway_payment_profile_id","metadata","created_at","updated_at"],"x-typelizer":true},"PriceHistory":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string"},"amount_in_cents":{"type":"number"},"currency":{"type":"string"},"display_amount":{"type":"string"},"recorded_at":{"type":"string"},"variant_id":{"type":"string"},"price_id":{"type":"string"},"compare_at_amount":{"type":"string","nullable":true},"created_at":{"type":"string"}},"required":["id","amount","amount_in_cents","currency","display_amount","recorded_at","variant_id","price_id","compare_at_amount","created_at"],"x-typelizer":true},"PriceList":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"status":{"type":"string"},"position":{"type":"number"},"match_policy":{"type":"string"},"starts_at":{"type":"string","nullable":true},"ends_at":{"type":"string","nullable":true},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"currently_active":{"type":"boolean"},"products_count":{"type":"number"},"prices_count":{"type":"number"},"product_ids":{"type":"array","items":{"type":"string"}},"price_rules":{"type":"array","items":{"$ref":"#/components/schemas/PriceRule"}}},"required":["id","name","description","status","position","match_policy","starts_at","ends_at","deleted_at","created_at","updated_at","currently_active","products_count","prices_count","product_ids"],"x-typelizer":true},"PriceRule":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"price_list_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"description":{"type":"string","nullable":true},"markets":{"type":"array","items":{"$ref":"#/components/schemas/Market"}},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}},"required":["id","created_at","updated_at","type","price_list_id","preferences","preference_schema","label","description"],"x-typelizer":true},"Price":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string","nullable":true},"amount_in_cents":{"type":"number","nullable":true},"compare_at_amount":{"type":"string","nullable":true},"compare_at_amount_in_cents":{"type":"number","nullable":true},"currency":{"type":"string","nullable":true},"display_amount":{"type":"string","nullable":true},"display_compare_at_amount":{"type":"string","nullable":true},"price_list_id":{"type":"string","nullable":true},"variant_id":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"variant":{"$ref":"#/components/schemas/Variant"}},"required":["id","amount","amount_in_cents","compare_at_amount","compare_at_amount_in_cents","currency","display_amount","display_compare_at_amount","price_list_id","variant_id","created_at","updated_at"],"x-typelizer":true},"ProductPublication":{"type":"object","properties":{"id":{"type":"string"},"published_at":{"type":"string","nullable":true},"unpublished_at":{"type":"string","nullable":true},"product_id":{"type":"string"},"channel_id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","published_at","unpublished_at","product_id","channel_id","created_at","updated_at"],"x-typelizer":true},"Product":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"meta_title":{"type":"string","nullable":true},"meta_description":{"type":"string","nullable":true},"meta_keywords":{"type":"string","nullable":true},"variant_count":{"type":"number"},"available_on":{"type":"string","nullable":true},"preorder_ships_at":{"type":"string","nullable":true},"purchasable":{"type":"boolean"},"preorder":{"type":"boolean"},"in_stock":{"type":"boolean"},"backorderable":{"type":"boolean"},"available":{"type":"boolean"},"description":{"type":"string","nullable":true},"description_html":{"type":"string","nullable":true},"default_variant_id":{"type":"string"},"thumbnail_url":{"type":"string","nullable":true},"tags":{"type":"array","items":{"type":"string"}},"price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"original_price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"primary_media":{"$ref":"#/components/schemas/Media"},"media":{"type":"array","items":{"$ref":"#/components/schemas/Media"}},"variants":{"type":"array","items":{"$ref":"#/components/schemas/Variant"}},"default_variant":{"$ref":"#/components/schemas/Variant"},"option_types":{"type":"array","items":{"$ref":"#/components/schemas/OptionType"}},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"categories":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"prior_price":{"allOf":[{"$ref":"#/components/schemas/PriceHistory"}],"nullable":true},"translations":{"type":"object"},"status":{"type":"string"},"metadata":{"type":"object"},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"product_type_id":{"type":"string","nullable":true},"tax_category_id":{"type":"string","nullable":true},"product_publications":{"type":"array","items":{"$ref":"#/components/schemas/ProductPublication"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}}},"required":["id","name","slug","meta_title","meta_description","meta_keywords","variant_count","available_on","preorder_ships_at","purchasable","preorder","in_stock","backorderable","available","description","description_html","default_variant_id","thumbnail_url","tags","price","original_price","status","metadata","deleted_at","created_at","updated_at","product_type_id","tax_category_id"],"x-typelizer":true},"ProductType":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"fulfillment_types":{"type":"array","items":{"type":"string"}},"products_count":{"type":"number"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","fulfillment_types","products_count","created_at","updated_at"],"x-typelizer":true},"PromotionAction":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"promotion_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"calculator":{"allOf":[{"$ref":"#/components/schemas/PromotionActionCalculator"}],"nullable":true},"line_items":{"type":"array","items":{"$ref":"#/components/schemas/PromotionActionLineItem"},"nullable":true}},"required":["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","calculator","line_items"],"x-typelizer":true},"PromotionRule":{"type":"object","properties":{"id":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"type":{"type":"string"},"promotion_id":{"type":"string"},"preferences":{"type":"object"},"preference_schema":{"type":"array","items":{"$ref":"#/components/schemas/PreferenceField"}},"label":{"type":"string"},"product_ids":{"type":"array","items":{"type":"string"},"nullable":true},"category_ids":{"type":"array","items":{"type":"string"},"nullable":true},"customer_ids":{"type":"array","items":{"type":"string"},"nullable":true},"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"categories":{"type":"array","items":{"$ref":"#/components/schemas/Category"}},"customers":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}},"customer_groups":{"type":"array","items":{"$ref":"#/components/schemas/CustomerGroup"}},"countries":{"type":"array","items":{"$ref":"#/components/schemas/Country"}},"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"markets":{"type":"array","items":{"$ref":"#/components/schemas/Market"}}},"required":["id","created_at","updated_at","type","promotion_id","preferences","preference_schema","label","product_ids","category_ids","customer_ids"],"x-typelizer":true},"Promotion":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"starts_at":{"type":"string","nullable":true},"expires_at":{"type":"string","nullable":true},"usage_limit":{"type":"number","nullable":true},"match_policy":{"type":"string","enum":["all","any"]},"path":{"type":"string","nullable":true},"kind":{"type":"string","enum":["coupon_code","automatic"]},"multi_codes":{"type":"boolean"},"number_of_codes":{"type":"number","nullable":true},"code_prefix":{"type":"string","nullable":true},"promotion_category_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"action_ids":{"type":"array","items":{"type":"string"}},"rule_ids":{"type":"array","items":{"type":"string"}}},"required":["id","name","description","code","starts_at","expires_at","usage_limit","match_policy","path","kind","multi_codes","number_of_codes","code_prefix","promotion_category_id","metadata","created_at","updated_at","action_ids","rule_ids"],"x-typelizer":true},"RefundReason":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"active":{"type":"boolean"},"mutable":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"can_be_deleted":{"type":"boolean"}},"required":["id","name","active","mutable","created_at","updated_at","can_be_deleted"],"x-typelizer":true},"Refund":{"type":"object","properties":{"id":{"type":"string"},"transaction_id":{"type":"string","nullable":true},"amount":{"type":"string","nullable":true},"payment_id":{"type":"string","nullable":true},"refund_reason_id":{"type":"string","nullable":true},"originator_id":{"type":"string","nullable":true},"originator_type":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"payment":{"$ref":"#/components/schemas/Payment"}},"required":["id","transaction_id","amount","payment_id","refund_reason_id","originator_id","originator_type","metadata","created_at","updated_at"],"x-typelizer":true},"ReturnLineItem":{"type":"object","properties":{"id":{"type":"string"},"quantity":{"type":"number"},"received_quantity":{"type":"number"},"resellable":{"type":"boolean"},"pre_tax_amount":{"type":"string"},"display_pre_tax_amount":{"type":"string"},"variant_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_item_id":{"type":"string","nullable":true},"variant":{"$ref":"#/components/schemas/Variant"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"line_item":{"$ref":"#/components/schemas/LineItem"}},"required":["id","quantity","received_quantity","resellable","pre_tax_amount","display_pre_tax_amount","variant_id","line_item_id","fulfillment_item_id","created_at","updated_at"],"x-typelizer":true},"ReturnReason":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"active":{"type":"boolean"},"mutable":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"can_be_deleted":{"type":"boolean"}},"required":["id","name","active","mutable","created_at","updated_at","can_be_deleted"],"x-typelizer":true},"Return":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"status":{"type":"string"},"return_label_url":{"type":"string","nullable":true},"order_id":{"type":"string","nullable":true},"reason_id":{"type":"string","nullable":true},"refund_total":{"type":"string"},"display_refund_total":{"type":"string"},"approved_at":{"type":"string","nullable":true},"received_at":{"type":"string","nullable":true},"refunded_at":{"type":"string","nullable":true},"canceled_at":{"type":"string","nullable":true},"return_line_items":{"type":"array","items":{"$ref":"#/components/schemas/ReturnLineItem"}},"memo":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"stock_location_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"refunded_total":{"type":"string"},"refundable_total":{"type":"string"},"order":{"$ref":"#/components/schemas/Order"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"refunds":{"type":"array","items":{"$ref":"#/components/schemas/Refund"}}},"required":["id","number","status","return_label_url","order_id","reason_id","refund_total","display_refund_total","approved_at","received_at","refunded_at","canceled_at","memo","metadata","created_at","updated_at","stock_location_id","created_by_id","refunded_total","refundable_total"],"x-typelizer":true},"Role":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","created_at","updated_at"],"x-typelizer":true},"SetupTask":{"type":"object","properties":{"name":{"type":"string"},"done":{"type":"boolean"}},"required":["name","done"],"x-typelizer":true},"State":{"type":"object","properties":{"abbr":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["abbr","name","created_at","updated_at"],"x-typelizer":true},"StockItem":{"type":"object","properties":{"id":{"type":"string"},"count_on_hand":{"type":"number"},"backorderable":{"type":"boolean"},"stock_location_id":{"type":"string","nullable":true},"variant_id":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"allocated_count":{"type":"number"},"available_count":{"type":"number"},"stock_location":{"$ref":"#/components/schemas/StockLocation"},"variant":{"$ref":"#/components/schemas/Variant"}},"required":["id","count_on_hand","backorderable","stock_location_id","variant_id","metadata","created_at","updated_at","allocated_count","available_count"],"x-typelizer":true},"StockLocation":{"type":"object","properties":{"id":{"type":"string"},"state_abbr":{"type":"string","nullable":true},"name":{"type":"string"},"address1":{"type":"string","nullable":true},"city":{"type":"string","nullable":true},"zipcode":{"type":"string","nullable":true},"country_iso":{"type":"string","nullable":true},"country_name":{"type":"string","nullable":true},"state_text":{"type":"string","nullable":true},"admin_name":{"type":"string","nullable":true},"address2":{"type":"string","nullable":true},"state_name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"company":{"type":"string","nullable":true},"active":{"type":"boolean"},"default":{"type":"boolean"},"backorderable_default":{"type":"boolean"},"propagate_all_variants":{"type":"boolean"},"kind":{"type":"string"},"pickup_enabled":{"type":"boolean"},"pickup_stock_policy":{"type":"string"},"pickup_ready_in_minutes":{"type":"number","nullable":true},"pickup_instructions":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","state_abbr","name","address1","city","zipcode","country_iso","country_name","state_text","admin_name","address2","state_name","phone","company","active","default","backorderable_default","propagate_all_variants","kind","pickup_enabled","pickup_stock_policy","pickup_ready_in_minutes","pickup_instructions","created_at","updated_at"],"x-typelizer":true},"StockReservation":{"type":"object","properties":{"id":{"type":"string"},"stock_item_id":{"type":"string"},"line_item_id":{"type":"string"},"order_id":{"type":"string"},"variant_id":{"type":"string","nullable":true},"stock_location_id":{"type":"string","nullable":true},"quantity":{"type":"number"},"expires_at":{"type":"string"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","stock_item_id","line_item_id","order_id","variant_id","stock_location_id","quantity","expires_at","active","created_at","updated_at"],"x-typelizer":true},"StockTransfer":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"string"},"reference":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"source_location_id":{"type":"string","nullable":true},"destination_location_id":{"type":"string","nullable":true},"source_location":{"$ref":"#/components/schemas/StockLocation"},"destination_location":{"$ref":"#/components/schemas/StockLocation"}},"required":["id","number","reference","metadata","created_at","updated_at","source_location_id","destination_location_id"],"x-typelizer":true},"StoreCreditCategory":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"non_expiring":{"type":"boolean"}},"required":["id","name","created_at","updated_at","non_expiring"],"x-typelizer":true},"StoreCredit":{"type":"object","properties":{"id":{"type":"string"},"amount":{"type":"string"},"amount_used":{"type":"string"},"amount_remaining":{"type":"string"},"display_amount":{"type":"string"},"display_amount_used":{"type":"string"},"display_amount_remaining":{"type":"string"},"currency":{"type":"string"},"memo":{"type":"string","nullable":true},"metadata":{"type":"object"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"customer_id":{"type":"string","nullable":true},"created_by_id":{"type":"string","nullable":true},"category_id":{"type":"string","nullable":true},"category_name":{"type":"string","nullable":true}},"required":["id","amount","amount_used","amount_remaining","display_amount","display_amount_used","display_amount_remaining","currency","memo","metadata","created_at","updated_at","customer_id","created_by_id","category_id","category_name"],"x-typelizer":true},"Store":{"type":"object","properties":{"id":{"type":"string"},"metadata":{"type":"object"},"name":{"type":"string"},"code":{"type":"string"},"preferred_storefront_url":{"type":"string","nullable":true},"default_currency":{"type":"string"},"default_locale":{"type":"string"},"mail_from_address":{"type":"string","nullable":true},"customer_support_email":{"type":"string","nullable":true},"new_order_notifications_email":{"type":"string","nullable":true},"preferred_send_consumer_transactional_emails":{"type":"boolean"},"preferred_admin_locale":{"type":"string","nullable":true},"preferred_timezone":{"type":"string"},"preferred_weight_unit":{"type":"string"},"preferred_unit_system":{"type":"string"},"preferred_storefront_access":{"type":"string"},"preferred_guest_checkout":{"type":"boolean"},"preferred_order_routing_strategy":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"url":{"type":"string"},"api_url":{"type":"string"},"setup_tasks":{"type":"array","items":{"$ref":"#/components/schemas/SetupTask"}},"supported_currencies":{"type":"array","items":{"type":"string"}},"supported_locales":{"type":"array","items":{"type":"string"}},"available_locales":{"type":"array","items":{"type":"string"}},"logo_url":{"type":"string","nullable":true},"mailer_logo_url":{"type":"string","nullable":true}},"required":["id","metadata","name","code","preferred_storefront_url","default_currency","default_locale","mail_from_address","customer_support_email","new_order_notifications_email","preferred_send_consumer_transactional_emails","preferred_admin_locale","preferred_timezone","preferred_weight_unit","preferred_unit_system","preferred_storefront_access","preferred_guest_checkout","preferred_order_routing_strategy","created_at","updated_at","url","api_url","setup_tasks","supported_currencies","supported_locales","available_locales","logo_url","mailer_logo_url"],"x-typelizer":true},"TaxCategory":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"tax_code":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"is_default":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","tax_code","description","is_default","created_at","updated_at"],"x-typelizer":true},"TaxLine":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"included":{"type":"boolean"},"rate":{"type":"string"},"tax_rate_id":{"type":"string","nullable":true},"line_item_id":{"type":"string","nullable":true},"fulfillment_id":{"type":"string","nullable":true},"fee_id":{"type":"string","nullable":true},"amount":{"type":"string"},"display_amount":{"type":"string"},"provider_id":{"type":"string","nullable":true},"metadata":{"type":"object","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","label","included","rate","tax_rate_id","line_item_id","fulfillment_id","fee_id","amount","display_amount","provider_id","metadata","created_at","updated_at"],"x-typelizer":true},"Variant":{"type":"object","properties":{"id":{"type":"string"},"product_id":{"type":"string"},"sku":{"type":"string","nullable":true},"options_text":{"type":"string"},"track_inventory":{"type":"boolean"},"media_count":{"type":"number"},"preorder_ships_at":{"type":"string","nullable":true},"thumbnail_url":{"type":"string","nullable":true},"purchasable":{"type":"boolean"},"in_stock":{"type":"boolean"},"backorderable":{"type":"boolean"},"preorder":{"type":"boolean"},"weight":{"type":"number","nullable":true},"height":{"type":"number","nullable":true},"width":{"type":"number","nullable":true},"depth":{"type":"number","nullable":true},"price":{"$ref":"#/components/schemas/Price"},"original_price":{"allOf":[{"$ref":"#/components/schemas/Price"}],"nullable":true},"primary_media":{"$ref":"#/components/schemas/Media"},"media":{"type":"array","items":{"$ref":"#/components/schemas/Media"}},"option_values":{"type":"array","items":{"$ref":"#/components/schemas/OptionValue"}},"custom_fields":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}},"prior_price":{"allOf":[{"$ref":"#/components/schemas/PriceHistory"}],"nullable":true},"metadata":{"type":"object"},"position":{"type":"number"},"cost_price":{"type":"string","nullable":true},"cost_currency":{"type":"string","nullable":true},"barcode":{"type":"string","nullable":true},"weight_unit":{"type":"string","nullable":true},"dimensions_unit":{"type":"string","nullable":true},"backorder_limit":{"type":"number","nullable":true},"deleted_at":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"preorderable":{"type":"boolean"},"tax_category_id":{"type":"string","nullable":true},"available_stock":{"type":"number","nullable":true},"reserved_quantity":{"type":"number"},"total_on_hand":{"type":"number","nullable":true},"product_name":{"type":"string"},"prices":{"type":"array","items":{"$ref":"#/components/schemas/Price"}},"stock_items":{"type":"array","items":{"$ref":"#/components/schemas/StockItem"}}},"required":["id","product_id","sku","options_text","track_inventory","media_count","preorder_ships_at","thumbnail_url","purchasable","in_stock","backorderable","preorder","weight","height","width","depth","price","original_price","option_values","metadata","position","cost_price","cost_currency","barcode","weight_unit","dimensions_unit","backorder_limit","deleted_at","created_at","updated_at","preorderable","tax_category_id","available_stock","reserved_quantity","total_on_hand","product_name"],"x-typelizer":true},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string"},"event_name":{"type":"string"},"event_id":{"type":"string","nullable":true},"response_code":{"type":"number","nullable":true},"execution_time":{"type":"number","nullable":true},"error_type":{"type":"string","nullable":true},"request_errors":{"type":"string","nullable":true},"response_body":{"type":"string","nullable":true},"success":{"type":"boolean","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"delivered_at":{"type":"string","nullable":true},"payload":{"type":"object"},"webhook_endpoint_id":{"type":"string"},"webhook_endpoint_url":{"type":"string"}},"required":["id","event_name","event_id","response_code","execution_time","error_type","request_errors","response_body","success","created_at","updated_at","delivered_at","payload","webhook_endpoint_id","webhook_endpoint_url"],"x-typelizer":true},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","nullable":true},"url":{"type":"string"},"active":{"type":"boolean"},"subscriptions":{"type":"array","items":{"type":"string"}},"disabled_reason":{"type":"string","nullable":true},"created_at":{"type":"string"},"updated_at":{"type":"string"},"disabled_at":{"type":"string","nullable":true},"secret_key":{"type":"string","nullable":true},"last_delivery_at":{"type":"string","nullable":true},"recent_delivery_count":{"type":"number"},"recent_failure_count":{"type":"number"},"total_delivery_count":{"type":"number"},"successful_delivery_count":{"type":"number"},"failed_delivery_count":{"type":"number"}},"required":["id","name","url","active","subscriptions","disabled_reason","created_at","updated_at","disabled_at","secret_key","last_delivery_at","recent_delivery_count","recent_failure_count","total_delivery_count","successful_delivery_count","failed_delivery_count"],"x-typelizer":true}}}}
\ No newline at end of file
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.ts
index 5d788be51c..298390e3d8 100644
--- a/packages/dashboard-core/src/lib/permissions.ts
+++ b/packages/dashboard-core/src/lib/permissions.ts
@@ -25,6 +25,9 @@ export const Subject = {
OptionType: 'Spree::OptionType',
OptionValue: 'Spree::OptionValue',
TaxCategory: 'Spree::TaxCategory',
+ ReturnReason: 'Spree::ReturnReason',
+ ClaimReason: 'Spree::ClaimReason',
+ RefundReason: 'Spree::RefundReason',
CustomFieldDefinition: 'Spree::MetafieldDefinition',
PaymentMethod: 'Spree::PaymentMethod',
DeliveryMethod: 'Spree::DeliveryMethod',
diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.ts
index 4afcb968cb..e748b6a516 100644
--- a/packages/dashboard-starter/src/routeTree.gen.ts
+++ b/packages/dashboard-starter/src/routeTree.gen.ts
@@ -33,6 +33,7 @@ import { Route as SettingsTaxCategoriesRouteImport } from './../../dashboard/src
import { Route as SettingsStoreRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/store'
import { Route as SettingsStockLocationsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/stock-locations'
import { Route as SettingsStaffRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/staff'
+import { Route as SettingsReasonsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/reasons'
import { Route as SettingsProfileRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/profile'
import { Route as SettingsProductTypesRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/product-types'
import { Route as SettingsPaymentMethodsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/payment-methods'
@@ -187,6 +188,11 @@ const SettingsStaffRoute = SettingsStaffRouteImport.update({
path: '/staff',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsReasonsRoute = SettingsReasonsRouteImport.update({
+ id: '/reasons',
+ path: '/reasons',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsProfileRoute = SettingsProfileRouteImport.update({
id: '/profile',
path: '/profile',
@@ -395,6 +401,7 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$storeId/settings/store': typeof SettingsStoreRoute
@@ -451,6 +458,7 @@ export interface FileRoutesByTo {
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$storeId/settings/store': typeof SettingsStoreRoute
@@ -511,6 +519,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/_authenticated/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/_authenticated/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/_authenticated/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/_authenticated/$storeId/settings/staff': typeof SettingsStaffRoute
'/_authenticated/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/_authenticated/$storeId/settings/store': typeof SettingsStoreRoute
@@ -571,6 +580,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/payment-methods'
| '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
+ | '/$storeId/settings/reasons'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
| '/$storeId/settings/store'
@@ -627,6 +637,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/payment-methods'
| '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
+ | '/$storeId/settings/reasons'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
| '/$storeId/settings/store'
@@ -686,6 +697,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/payment-methods'
| '/_authenticated/$storeId/settings/product-types'
| '/_authenticated/$storeId/settings/profile'
+ | '/_authenticated/$storeId/settings/reasons'
| '/_authenticated/$storeId/settings/staff'
| '/_authenticated/$storeId/settings/stock-locations'
| '/_authenticated/$storeId/settings/store'
@@ -885,6 +897,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsStaffRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/reasons': {
+ id: '/_authenticated/$storeId/settings/reasons'
+ path: '/reasons'
+ fullPath: '/$storeId/settings/reasons'
+ preLoaderRoute: typeof SettingsReasonsRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/profile': {
id: '/_authenticated/$storeId/settings/profile'
path: '/profile'
@@ -1131,6 +1150,7 @@ interface SettingsRouteChildren {
SettingsPaymentMethodsRoute: typeof SettingsPaymentMethodsRoute
SettingsProductTypesRoute: typeof SettingsProductTypesRoute
SettingsProfileRoute: typeof SettingsProfileRoute
+ SettingsReasonsRoute: typeof SettingsReasonsRoute
SettingsStaffRoute: typeof SettingsStaffRoute
SettingsStockLocationsRoute: typeof SettingsStockLocationsRoute
SettingsStoreRoute: typeof SettingsStoreRoute
@@ -1153,6 +1173,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsPaymentMethodsRoute: SettingsPaymentMethodsRoute,
SettingsProductTypesRoute: SettingsProductTypesRoute,
SettingsProfileRoute: SettingsProfileRoute,
+ SettingsReasonsRoute: SettingsReasonsRoute,
SettingsStaffRoute: SettingsStaffRoute,
SettingsStockLocationsRoute: SettingsStockLocationsRoute,
SettingsStoreRoute: SettingsStoreRoute,
diff --git a/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx b/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
index 88dca3061d..4f953fc027 100644
--- a/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
+++ b/packages/dashboard/src/components/spree/post-sale-create-dialogs.tsx
@@ -20,6 +20,7 @@ import {
} from '@spree/dashboard-ui'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { type ReasonKind, useReasons } from '../../hooks/use-reasons'
/** A fulfilled unit the customer could send back. */
export type FulfilledUnit = {
@@ -84,6 +85,54 @@ function QuantityPicker({
)
}
+/**
+ * Reason dropdown. Optional by design — the API accepts a record without one,
+ * and a merchant mid-return should not be blocked because nobody has curated
+ * the list yet. Inactive reasons are excluded so retired vocabulary stops
+ * appearing on new records.
+ */
+function ReasonField({
+ kind,
+ value,
+ onChange,
+}: {
+ kind: ReasonKind
+ value: string
+ onChange: (value: string) => void
+}) {
+ const { t } = useTranslation()
+ const { data } = useReasons(kind)
+
+ // Filtered in memory rather than through the query so this shares the
+ // settings page's cache entry — the lists are a handful of rows.
+ const reasons = (data?.data ?? []).filter((reason) => reason.active)
+ if (reasons.length === 0) return null
+
+ // Base UI's <Select> needs `items` to resolve the trigger label; without it
+ // the closed trigger renders the raw id (see CLAUDE.md).
+ const options = reasons.map((reason) => ({ value: reason.id, label: reason.name }))
+
+ return (
+ <Field>
+ <FieldLabel htmlFor={`reason-${kind}`}>
+ {t('admin.pages.orders.detail.returns.reason')}
+ </FieldLabel>
+ <Select items={options} value={value} onValueChange={onChange}>
+ <SelectTrigger id={`reason-${kind}`}>
+ <SelectValue placeholder={t('admin.common.select_placeholder')} />
+ </SelectTrigger>
+ <SelectContent>
+ {options.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Field>
+ )
+}
+
function selectedItems(selection: Selection): Array<[string, number]> {
return Object.entries(selection).filter(([, quantity]) => quantity > 0)
}
@@ -98,12 +147,14 @@ export function CreateReturnDialog({
onSubmit: (params: {
items: Array<{ fulfillment_item_id: string; quantity: number }>
memo?: string
+ reasonId?: string
}) => void
}) {
const { t } = useTranslation()
const units = fulfilledUnits(order)
const [selection, setSelection] = useState<Selection>({})
const [memo, setMemo] = useState('')
+ const [reasonId, setReasonId] = useState('')
const chosen = selectedItems(selection)
@@ -115,6 +166,7 @@ export function CreateReturnDialog({
</DialogHeader>
<DialogBody className="flex flex-col gap-4">
<QuantityPicker units={units} selection={selection} onChange={setSelection} />
+ <ReasonField kind="return-reasons" value={reasonId} onChange={setReasonId} />
<Field>
<FieldLabel htmlFor="return-memo">
{t('admin.pages.orders.detail.returns.memo')}
@@ -139,6 +191,7 @@ export function CreateReturnDialog({
quantity,
})),
memo: memo || undefined,
+ reasonId: reasonId || undefined,
})
}
>
@@ -165,6 +218,7 @@ export function CreateExchangeDialog({
onSubmit: (params: {
items: Array<{ fulfillment_item_id: string; new_variant_id: string; quantity: number }>
memo?: string
+ reasonId?: string
}) => void
}) {
const { t } = useTranslation()
@@ -172,6 +226,7 @@ export function CreateExchangeDialog({
const [selection, setSelection] = useState<Selection>({})
const [replacements, setReplacements] = useState<Record<string, string>>({})
const [memo, setMemo] = useState('')
+ const [reasonId, setReasonId] = useState('')
const chosen = selectedItems(selection)
const ready = chosen.length > 0 && chosen.every(([id]) => replacements[id]?.trim())
@@ -218,6 +273,7 @@ export function CreateExchangeDialog({
)}
</div>
))}
+ <ReasonField kind="return-reasons" value={reasonId} onChange={setReasonId} />
<Field>
<FieldLabel htmlFor="exchange-memo">
{t('admin.pages.orders.detail.returns.memo')}
@@ -243,6 +299,7 @@ export function CreateExchangeDialog({
quantity,
})),
memo: memo || undefined,
+ reasonId: reasonId || undefined,
})
}
>
@@ -273,6 +330,7 @@ export function CreateClaimDialog({
}>
claim_type: string
memo?: string
+ reasonId?: string
}) => void
}) {
const { t } = useTranslation()
@@ -281,6 +339,7 @@ export function CreateClaimDialog({
const [amounts, setAmounts] = useState<Record<string, string>>({})
const [claimType, setClaimType] = useState<string>('damaged')
const [memo, setMemo] = useState('')
+ const [reasonId, setReasonId] = useState('')
const chosen = selectedItems(selection)
const typeOptions = CLAIM_TYPES.map((value) => ({
@@ -367,6 +426,7 @@ export function CreateClaimDialog({
})}
</div>
+ <ReasonField kind="claim-reasons" value={reasonId} onChange={setReasonId} />
<Field>
<FieldLabel htmlFor="claim-memo">
{t('admin.pages.orders.detail.returns.memo')}
@@ -393,6 +453,7 @@ export function CreateClaimDialog({
})),
claim_type: claimType,
memo: memo || undefined,
+ reasonId: reasonId || undefined,
})
}
>
diff --git a/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx b/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx
index d676c1ddde..da4f7f5303 100644
--- a/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx
+++ b/packages/dashboard/src/components/spree/price-list-editors/price-list-form.tsx
@@ -65,6 +65,7 @@ import {
type PriceRuleFormDraft,
priceListFormSchema,
priceListValuesToParams,
+ type RuleEmbedRecord,
ruleDraftFromRule,
ruleDraftFromType,
} from '../../../schemas/price-list'
@@ -337,12 +338,21 @@ function ActivationButtons({ priceList }: { priceList: PriceList }) {
async function handleDeactivate() {
const isScheduled = priceList.status === 'scheduled'
- const namespace = isScheduled
- ? 'admin.pages.products.price_lists.unschedule_confirm'
- : 'admin.pages.products.price_lists.deactivate_confirm'
+ // Whole keys, not `${namespace}.title` — a template literal built from a
+ // union of prefixes makes TypeScript cross-product that union against
+ // i18next's full key union, which exhausts the checker's relation cache
+ // (`RangeError: Map maximum size exceeded`) on TS 6.
const ok = await confirm({
- title: t(`${namespace}.title`),
- message: t(`${namespace}.message`, { name: priceList.name }),
+ title: isScheduled
+ ? t('admin.pages.products.price_lists.unschedule_confirm.title')
+ : t('admin.pages.products.price_lists.deactivate_confirm.title'),
+ message: isScheduled
+ ? t('admin.pages.products.price_lists.unschedule_confirm.message', {
+ name: priceList.name,
+ })
+ : t('admin.pages.products.price_lists.deactivate_confirm.message', {
+ name: priceList.name,
+ }),
// Not destructive — flips status; primary confirm button keeps default styling.
confirmLabel: t(
isScheduled
@@ -605,29 +615,40 @@ function RuleRow({
// Display embeds the API ships alongside each rule. The preference key
// is skipped in the generic prefs dump below so the row preview reads
// "VIPs, Wholesale" instead of "Customer group ids: cg_…".
-const RULE_EMBEDS = [
+//
+// RULE_EMBEDS carries an explicit homogeneous type: letting inference
+// build a union of four function-bearing literals makes the checker's
+// subtype reduction compare every embed array against every other (12
+// ordered pairs), which is its own relation-cache blowup on TS 6 —
+// separate from the Path-expansion one documented on RuleEmbedRecord.
+interface RuleEmbed {
+ prefKey: string
+ pick: (draft: PriceRuleFormDraft) => RuleEmbedRecord[] | undefined
+ label: (record: RuleEmbedRecord) => string
+}
+
+const RULE_EMBEDS: readonly RuleEmbed[] = [
{
prefKey: 'customer_group_ids',
- pick: (d: PriceRuleFormDraft) => d.customer_groups,
- label: (g: { name?: string | null; id: string }) => g.name ?? g.id,
+ pick: (d) => d.customer_groups,
+ label: (g) => g.name ?? g.id,
},
{
prefKey: 'user_ids',
- pick: (d: PriceRuleFormDraft) => d.customers,
- label: (c: { email?: string | null; id: string }) => c.email ?? c.id,
+ pick: (d) => d.customers,
+ label: (c) => c.email ?? c.id,
},
{
prefKey: 'market_ids',
- pick: (d: PriceRuleFormDraft) => d.markets,
- label: (m: { name?: string | null; id: string }) => m.name ?? m.id,
+ pick: (d) => d.markets,
+ label: (m) => m.name ?? m.id,
},
{
prefKey: 'channel_ids',
- pick: (d: PriceRuleFormDraft) => d.channels,
- label: (c: { name?: string | null; code?: string | null; id: string }) =>
- c.name ?? c.code ?? c.id,
+ pick: (d) => d.channels,
+ label: (c) => c.name ?? c.code ?? c.id,
},
-] as const
+]
const PREFS_SHOWN_VIA_EMBED: ReadonlySet<string> = new Set(RULE_EMBEDS.map((e) => e.prefKey))
@@ -636,8 +657,7 @@ function RuleSummary({ draft }: { draft: PriceRuleFormDraft }) {
const parts: string[] = []
for (const embed of RULE_EMBEDS) {
- const items = embed.pick(draft) as Array<{ id: string }> | undefined
- const rendered = nameList(items, embed.label as (item: { id: string }) => string, t)
+ const rendered = nameList(embed.pick(draft), embed.label, t)
if (rendered) parts.push(rendered)
}
diff --git a/packages/dashboard/src/components/spree/price-list-editors/rule-channel.tsx b/packages/dashboard/src/components/spree/price-list-editors/rule-channel.tsx
index 3827b0741d..5c894b8806 100644
--- a/packages/dashboard/src/components/spree/price-list-editors/rule-channel.tsx
+++ b/packages/dashboard/src/components/spree/price-list-editors/rule-channel.tsx
@@ -1,9 +1,9 @@
-import type { Channel } from '@spree/admin-sdk'
import { ResourceMultiAutocomplete } from '@spree/dashboard-core'
import { Field, FieldGroup, FieldLabel } from '@spree/dashboard-ui'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { channelAutocompleteProps, useChannels } from '../../../hooks/use-channels'
+import type { RuleEmbedRecord } from '../../../schemas/price-list'
import { EditorShell } from '../promotion-editors/editor-shell'
import type { PriceRuleEditorContext } from './types'
@@ -25,7 +25,7 @@ export function ChannelRuleEditor({ draft, onSave, onClose }: PriceRuleEditorCon
const [channelIds, setChannelIds] = useState<string[]>(() =>
(draft.channels ?? []).map((c) => c.id),
)
- const [channels, setChannels] = useState<Channel[]>(draft.channels ?? [])
+ const [channels, setChannels] = useState<RuleEmbedRecord[]>(draft.channels ?? [])
function handleSave() {
onSave({
diff --git a/packages/dashboard/src/components/spree/price-list-editors/rule-customer-group.tsx b/packages/dashboard/src/components/spree/price-list-editors/rule-customer-group.tsx
index 8dc76c42bc..c9d5a0888a 100644
--- a/packages/dashboard/src/components/spree/price-list-editors/rule-customer-group.tsx
+++ b/packages/dashboard/src/components/spree/price-list-editors/rule-customer-group.tsx
@@ -1,4 +1,3 @@
-import type { CustomerGroup } from '@spree/admin-sdk'
import { ResourceMultiAutocomplete } from '@spree/dashboard-core'
import { Field, FieldGroup, FieldLabel } from '@spree/dashboard-ui'
import { useState } from 'react'
@@ -7,6 +6,7 @@ import {
customerGroupAutocompleteProps,
useCustomerGroups,
} from '../../../hooks/use-customer-groups'
+import type { RuleEmbedRecord } from '../../../schemas/price-list'
import { EditorShell } from '../promotion-editors/editor-shell'
import type { PriceRuleEditorContext } from './types'
@@ -21,7 +21,9 @@ export function CustomerGroupRuleEditor({ draft, onSave, onClose }: PriceRuleEdi
const [groupIds, setGroupIds] = useState<string[]>(() =>
(draft.customer_groups ?? []).map((g) => g.id),
)
- const [customerGroups, setCustomerGroups] = useState<CustomerGroup[]>(draft.customer_groups ?? [])
+ const [customerGroups, setCustomerGroups] = useState<RuleEmbedRecord[]>(
+ draft.customer_groups ?? [],
+ )
function handleSave() {
onSave({
diff --git a/packages/dashboard/src/components/spree/price-list-editors/rule-customer.tsx b/packages/dashboard/src/components/spree/price-list-editors/rule-customer.tsx
index 0a686852a3..93bef6f0de 100644
--- a/packages/dashboard/src/components/spree/price-list-editors/rule-customer.tsx
+++ b/packages/dashboard/src/components/spree/price-list-editors/rule-customer.tsx
@@ -1,9 +1,9 @@
-import type { Customer } from '@spree/admin-sdk'
import { ResourceMultiAutocomplete } from '@spree/dashboard-core'
import { Field, FieldGroup, FieldLabel } from '@spree/dashboard-ui'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { customerAutocompleteProps } from '../../../hooks/use-customers'
+import type { RuleEmbedRecord } from '../../../schemas/price-list'
import { EditorShell } from '../promotion-editors/editor-shell'
import type { PriceRuleEditorContext } from './types'
@@ -20,7 +20,10 @@ export function CustomerRuleEditor({ draft, onSave, onClose }: PriceRuleEditorCo
const [customerIds, setCustomerIds] = useState<string[]>(() =>
(draft.customers ?? []).map((c) => c.id),
)
- const [customers, setCustomers] = useState<Customer[]>(draft.customers ?? [])
+ // RuleEmbedRecord, not Customer — the draft's embed fields are opaque to
+ // keep the SDK object graph out of the form type (see RuleEmbedRecord).
+ // The autocomplete still resolves full Customer records into this state.
+ const [customers, setCustomers] = useState<RuleEmbedRecord[]>(draft.customers ?? [])
function handleSave() {
onSave({
diff --git a/packages/dashboard/src/hooks/use-post-sale.ts b/packages/dashboard/src/hooks/use-post-sale.ts
index 23eb837833..edc1f65086 100644
--- a/packages/dashboard/src/hooks/use-post-sale.ts
+++ b/packages/dashboard/src/hooks/use-post-sale.ts
@@ -68,10 +68,14 @@ export function useExchangeActions(orderId: string) {
orderId,
'order-exchanges',
'exchanges',
- (params: {
+ ({
+ reasonId,
+ ...params
+ }: {
items: Array<{ fulfillment_item_id: string; new_variant_id: string; quantity: number }>
memo?: string
- }) => adminClient.orders.exchanges.create(orderId, params),
+ reasonId?: string
+ }) => adminClient.orders.exchanges.create(orderId, { ...params, reason_id: reasonId }),
)
const approve = usePostSaleMutation(
@@ -133,7 +137,11 @@ export function useClaimActions(orderId: string) {
}>
claim_type: string
memo?: string
- }) => adminClient.orders.claims.create(orderId, params),
+ reasonId?: string
+ }) => {
+ const { reasonId, ...rest } = params
+ return adminClient.orders.claims.create(orderId, { ...rest, reason_id: reasonId })
+ },
)
const approve = usePostSaleMutation(orderId, 'order-claims', 'claims', (claimId: string) =>
diff --git a/packages/dashboard/src/hooks/use-reasons.ts b/packages/dashboard/src/hooks/use-reasons.ts
new file mode 100644
index 0000000000..0e8308c5d6
--- /dev/null
+++ b/packages/dashboard/src/hooks/use-reasons.ts
@@ -0,0 +1,64 @@
+import type {
+ ClaimReason,
+ ReasonCreateParams,
+ ReasonUpdateParams,
+ RefundReason,
+ ReturnReason,
+} from '@spree/admin-sdk'
+import { adminClient, useResourceKey, useResourceMutation } from '@spree/dashboard-core'
+import { useQuery } from '@tanstack/react-query'
+import i18n from 'i18next'
+
+/** Any of the three reason lists — they share one shape. */
+export type Reason = ReturnReason | ClaimReason | RefundReason
+
+/** Which list a screen is working with. Doubles as the query key. */
+export type ReasonKind = 'return-reasons' | 'claim-reasons' | 'refund-reasons'
+
+const CLIENTS = {
+ 'return-reasons': () => adminClient.returnReasons,
+ 'claim-reasons': () => adminClient.claimReasons,
+ 'refund-reasons': () => adminClient.refundReasons,
+} as const
+
+/**
+ * Every reason list is short — a handful of rows a merchant reads in one go —
+ * so they are fetched unpaginated and cached for the session. Deliberately
+ * unfiltered: one cache entry per kind means the pickers in the create
+ * dialogs reuse whatever the settings page already loaded, and they narrow to
+ * the active rows in memory rather than paying for a second entry.
+ */
+export function useReasons(kind: ReasonKind) {
+ return useQuery({
+ queryKey: useResourceKey(kind),
+ queryFn: () => CLIENTS[kind]().list({ limit: 100 }),
+ staleTime: 1000 * 60 * 5,
+ })
+}
+
+export function useCreateReason(kind: ReasonKind) {
+ return useResourceMutation<Reason, Error, ReasonCreateParams>({
+ mutationFn: (params) => CLIENTS[kind]().create(params),
+ invalidate: [[kind]],
+ successMessage: i18n.t('admin.reasons.messages.created'),
+ errorMessage: i18n.t('admin.errors.failed_to_create'),
+ })
+}
+
+export function useUpdateReason(kind: ReasonKind, id: string) {
+ return useResourceMutation<Reason, Error, ReasonUpdateParams>({
+ mutationFn: (params) => CLIENTS[kind]().update(id, params),
+ invalidate: [[kind]],
+ successMessage: i18n.t('admin.reasons.messages.updated'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useDeleteReason(kind: ReasonKind) {
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (id) => CLIENTS[kind]().delete(id),
+ invalidate: [[kind]],
+ successMessage: i18n.t('admin.reasons.messages.deleted'),
+ errorMessage: i18n.t('admin.errors.failed_to_delete'),
+ })
+}
diff --git a/packages/dashboard/src/hooks/use-returns.ts b/packages/dashboard/src/hooks/use-returns.ts
index 976a73a3b5..65f569ed35 100644
--- a/packages/dashboard/src/hooks/use-returns.ts
+++ b/packages/dashboard/src/hooks/use-returns.ts
@@ -55,8 +55,14 @@ export function useReturnActions(orderId: string) {
// so staff-created and self-service returns share one path.
const create = useReturnMutation(
orderId,
- (params: { items: Array<{ fulfillment_item_id: string; quantity: number }>; memo?: string }) =>
- adminClient.orders.returns.create(orderId, params),
+ ({
+ reasonId,
+ ...params
+ }: {
+ items: Array<{ fulfillment_item_id: string; quantity: number }>
+ memo?: string
+ reasonId?: string
+ }) => adminClient.orders.returns.create(orderId, { ...params, reason_id: reasonId }),
)
const approve = useReturnMutation(orderId, (returnId: string) =>
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 8b683ce497..2f4e994871 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -2813,6 +2813,41 @@
"prefix_required": "البادئة مطلوبة لدفعات الرموز المتعددة"
}
},
+ "reasons": {
+ "title": "المرتجعات",
+ "description": "القوائم التي يختار منها فريقك عند معالجة المرتجعات والمطالبات والمبالغ المستردة.",
+ "add_cta": "إضافة سبب",
+ "add_sheet_title": "إضافة سبب",
+ "edit_sheet_title": "تعديل السبب",
+ "create_description": "تظهر الأسباب في قائمة منسدلة عند إنشاء مرتجع أو مطالبة أو مبلغ مسترد.",
+ "name_placeholder": "مثال: مقاس غير مناسب",
+ "active_label": "متاح للسجلات الجديدة",
+ "empty": "لا توجد أسباب بعد",
+ "inactive": "غير نشط",
+ "locked": "مدمج",
+ "locked_help": "يبحث Spree عن هذا السبب بالاسم، لذا لا يمكن إعادة تسميته أو حذفه.",
+ "delete_confirm": {
+ "title": "حذف السبب؟",
+ "message": "لن يعود {{name}} متاحًا. تحتفظ به السجلات التي تستخدمه بالفعل."
+ },
+ "messages": {
+ "created": "تم إنشاء السبب",
+ "updated": "تم تحديث السبب",
+ "deleted": "تم حذف السبب"
+ },
+ "return": {
+ "title": "أسباب الإرجاع",
+ "help": "سبب إعادة العميل للمنتج. مشترك بين المرتجعات والاستبدال."
+ },
+ "claim": {
+ "title": "أسباب المطالبة",
+ "help": "ما حدث من خطأ في التسليم — تالف أو مفقود أو منتج خاطئ."
+ },
+ "refund": {
+ "title": "أسباب رد المبلغ",
+ "help": "سبب إعادة الأموال. يُستخدم في تقارير جميع المبالغ المستردة."
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2846,6 +2881,7 @@
"payment_methods": "طرق الدفع",
"product_types": "أنواع المنتجات",
"profile": "الملف الشخصي",
+ "reasons": "المرتجعات",
"staff": "الموظفون",
"stock_locations": "مواقع المخزون",
"store": "المتجر",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index ab354e2046..97f227833c 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -2813,6 +2813,41 @@
"prefix_required": "Präfix ist für Stapel mit mehreren Codes erforderlich"
}
},
+ "reasons": {
+ "title": "Rücksendungen",
+ "description": "Die Auswahllisten, aus denen Ihr Team bei Rücksendungen, Reklamationen und Rückerstattungen wählt.",
+ "add_cta": "Grund hinzufügen",
+ "add_sheet_title": "Grund hinzufügen",
+ "edit_sheet_title": "Grund bearbeiten",
+ "create_description": "Gründe erscheinen als Auswahl, wenn Mitarbeitende eine Rücksendung, Reklamation oder Rückerstattung anlegen.",
+ "name_placeholder": "z. B. Falsche Größe",
+ "active_label": "Für neue Vorgänge verfügbar",
+ "empty": "Noch keine Gründe",
+ "inactive": "Inaktiv",
+ "locked": "Vorgegeben",
+ "locked_help": "Spree sucht diesen Grund über den Namen. Er kann weder umbenannt noch gelöscht werden.",
+ "delete_confirm": {
+ "title": "Grund löschen?",
+ "message": "{{name}} wird nicht mehr angeboten. Bestehende Vorgänge behalten ihn."
+ },
+ "messages": {
+ "created": "Grund erstellt",
+ "updated": "Grund aktualisiert",
+ "deleted": "Grund gelöscht"
+ },
+ "return": {
+ "title": "Rücksendegründe",
+ "help": "Warum ein Kunde etwas zurückschickt. Gilt für Rücksendungen und Umtausch."
+ },
+ "claim": {
+ "title": "Reklamationsgründe",
+ "help": "Was bei der Lieferung schiefging – beschädigt, fehlend oder falscher Artikel."
+ },
+ "refund": {
+ "title": "Rückerstattungsgründe",
+ "help": "Warum Geld zurückging. Für Auswertungen über alle Rückerstattungen."
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2846,6 +2881,7 @@
"payment_methods": "Zahlungsmethoden",
"product_types": "Produkttypen",
"profile": "Profil",
+ "reasons": "Rücksendungen",
"staff": "Mitarbeiter",
"stock_locations": "Lagerstandorte",
"store": "Shop",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 272985d27a..49acdd650f 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -2813,6 +2813,41 @@
"prefix_required": "Prefix is required for multi-code batches"
}
},
+ "reasons": {
+ "title": "Returns",
+ "description": "The vocabularies your team picks from when handling returns, claims and refunds.",
+ "add_cta": "Add reason",
+ "add_sheet_title": "Add reason",
+ "edit_sheet_title": "Edit reason",
+ "create_description": "Reasons appear in a dropdown when staff open a return, claim or refund.",
+ "name_placeholder": "e.g. Wrong size",
+ "active_label": "Available on new records",
+ "empty": "No reasons yet",
+ "inactive": "Inactive",
+ "locked": "Built in",
+ "locked_help": "Spree looks this reason up by name, so it cannot be renamed or removed.",
+ "delete_confirm": {
+ "title": "Delete reason?",
+ "message": "{{name}} will no longer be offered. Records already using it keep it."
+ },
+ "messages": {
+ "created": "Reason created",
+ "updated": "Reason updated",
+ "deleted": "Reason deleted"
+ },
+ "return": {
+ "title": "Return reasons",
+ "help": "Why a customer is sending something back. Shared by returns and exchanges."
+ },
+ "claim": {
+ "title": "Claim reasons",
+ "help": "What went wrong with a delivery — damaged, missing or wrong item."
+ },
+ "refund": {
+ "title": "Refund reasons",
+ "help": "Why money went back. Used for reporting across every refund."
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2846,6 +2881,7 @@
"payment_methods": "Payment methods",
"product_types": "Product types",
"profile": "Profile",
+ "reasons": "Returns",
"staff": "Staff",
"stock_locations": "Stock locations",
"store": "Store",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 5f26c6448a..4dc2bb966d 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -2813,6 +2813,41 @@
"prefix_required": "Le préfixe est requis pour les lots de plusieurs codes"
}
},
+ "reasons": {
+ "title": "Retours",
+ "description": "Les listes dans lesquelles votre équipe choisit lors des retours, réclamations et remboursements.",
+ "add_cta": "Ajouter un motif",
+ "add_sheet_title": "Ajouter un motif",
+ "edit_sheet_title": "Modifier le motif",
+ "create_description": "Les motifs apparaissent dans une liste déroulante lors de la création d'un retour, d'une réclamation ou d'un remboursement.",
+ "name_placeholder": "ex. Mauvaise taille",
+ "active_label": "Proposé sur les nouveaux enregistrements",
+ "empty": "Aucun motif pour l'instant",
+ "inactive": "Inactif",
+ "locked": "Intégré",
+ "locked_help": "Spree recherche ce motif par son nom : il ne peut être ni renommé ni supprimé.",
+ "delete_confirm": {
+ "title": "Supprimer le motif ?",
+ "message": "{{name}} ne sera plus proposé. Les enregistrements existants le conservent."
+ },
+ "messages": {
+ "created": "Motif créé",
+ "updated": "Motif mis à jour",
+ "deleted": "Motif supprimé"
+ },
+ "return": {
+ "title": "Motifs de retour",
+ "help": "Pourquoi un client renvoie un article. Partagé par les retours et les échanges."
+ },
+ "claim": {
+ "title": "Motifs de réclamation",
+ "help": "Ce qui s'est mal passé à la livraison — endommagé, manquant ou article incorrect."
+ },
+ "refund": {
+ "title": "Motifs de remboursement",
+ "help": "Pourquoi l'argent a été rendu. Utilisé pour le suivi de tous les remboursements."
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2846,6 +2881,7 @@
"payment_methods": "Modes de paiement",
"product_types": "Types de produit",
"profile": "Profil",
+ "reasons": "Retours",
"staff": "Personnel",
"stock_locations": "Emplacements de stock",
"store": "Boutique",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 14cb99e885..587e42c425 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -2845,6 +2845,41 @@
"prefix_required": "Prefiks jest wymagany dla partii wielu kodów"
}
},
+ "reasons": {
+ "title": "Zwroty",
+ "description": "Listy, z których zespół wybiera przy zwrotach, reklamacjach i zwrotach pieniędzy.",
+ "add_cta": "Dodaj powód",
+ "add_sheet_title": "Dodaj powód",
+ "edit_sheet_title": "Edytuj powód",
+ "create_description": "Powody pojawiają się na liście przy tworzeniu zwrotu, reklamacji lub zwrotu pieniędzy.",
+ "name_placeholder": "np. Zły rozmiar",
+ "active_label": "Dostępny dla nowych zgłoszeń",
+ "empty": "Brak powodów",
+ "inactive": "Nieaktywny",
+ "locked": "Wbudowany",
+ "locked_help": "Spree wyszukuje ten powód po nazwie, więc nie można go zmienić ani usunąć.",
+ "delete_confirm": {
+ "title": "Usunąć powód?",
+ "message": "{{name}} nie będzie już proponowany. Istniejące zgłoszenia go zachowują."
+ },
+ "messages": {
+ "created": "Powód utworzony",
+ "updated": "Powód zaktualizowany",
+ "deleted": "Powód usunięty"
+ },
+ "return": {
+ "title": "Powody zwrotu",
+ "help": "Dlaczego klient odsyła towar. Wspólne dla zwrotów i wymian."
+ },
+ "claim": {
+ "title": "Powody reklamacji",
+ "help": "Co poszło nie tak z dostawą — uszkodzony, brakujący lub zły towar."
+ },
+ "refund": {
+ "title": "Powody zwrotu pieniędzy",
+ "help": "Dlaczego pieniądze wróciły. Używane w raportach o wszystkich zwrotach."
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2878,6 +2913,7 @@
"payment_methods": "Metody płatności",
"product_types": "Typy produktów",
"profile": "Profil",
+ "reasons": "Zwroty",
"staff": "Zespół",
"stock_locations": "Lokalizacje magazynowe",
"store": "Sklep",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index 846ed201ca..80b3fe4bf4 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -2813,6 +2813,41 @@
"prefix_required": "多代码批次需要前缀"
}
},
+ "reasons": {
+ "title": "退货",
+ "description": "团队处理退货、理赔和退款时可选择的原因列表。",
+ "add_cta": "添加原因",
+ "add_sheet_title": "添加原因",
+ "edit_sheet_title": "编辑原因",
+ "create_description": "员工创建退货、理赔或退款时,可从下拉列表中选择原因。",
+ "name_placeholder": "例如:尺码不合适",
+ "active_label": "可用于新记录",
+ "empty": "暂无原因",
+ "inactive": "已停用",
+ "locked": "内置",
+ "locked_help": "Spree 按名称查找此原因,因此无法重命名或删除。",
+ "delete_confirm": {
+ "title": "删除原因?",
+ "message": "将不再提供 {{name}}。已使用它的记录保持不变。"
+ },
+ "messages": {
+ "created": "原因已创建",
+ "updated": "原因已更新",
+ "deleted": "原因已删除"
+ },
+ "return": {
+ "title": "退货原因",
+ "help": "客户退回商品的原因。退货和换货共用。"
+ },
+ "claim": {
+ "title": "理赔原因",
+ "help": "配送出现的问题——商品损坏、缺失或发错。"
+ },
+ "refund": {
+ "title": "退款原因",
+ "help": "退款的原因。用于所有退款的统计分析。"
+ }
+ },
"settings": {
"webhooks": {
"errors": {
@@ -2846,6 +2881,7 @@
"payment_methods": "支付方式",
"product_types": "商品类型",
"profile": "个人资料",
+ "reasons": "退货",
"staff": "员工",
"stock_locations": "库存地点",
"store": "店铺",
diff --git a/packages/dashboard/src/nav/settings.ts b/packages/dashboard/src/nav/settings.ts
index f9e10c3973..c78312d8f1 100644
--- a/packages/dashboard/src/nav/settings.ts
+++ b/packages/dashboard/src/nav/settings.ts
@@ -8,6 +8,7 @@ import {
MapIcon,
PercentIcon,
RadioTowerIcon,
+ RotateCcwIcon,
ShapesIcon,
StoreIcon,
TagIcon,
@@ -136,6 +137,16 @@ settingsNav.add({
subject: Subject.StockLocation,
})
+settingsNav.add({
+ key: 'settings.reasons',
+ labelKey: 'admin.settings_nav.items.reasons',
+ path: '/reasons',
+ icon: RotateCcwIcon,
+ group: 'fulfillment',
+ position: 200,
+ subject: Subject.ReturnReason,
+})
+
settingsNav.add({
key: 'settings.custom-field-definitions',
labelKey: 'admin.settings_nav.items.custom_field_definitions',
diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.ts
index bac800ca32..155c7fa1bd 100644
--- a/packages/dashboard/src/routeTree.gen.ts
+++ b/packages/dashboard/src/routeTree.gen.ts
@@ -32,6 +32,7 @@ import { Route as SettingsTaxCategoriesRouteImport } from './routes/_authenticat
import { Route as SettingsStoreRouteImport } from './routes/_authenticated/$storeId/settings/store'
import { Route as SettingsStockLocationsRouteImport } from './routes/_authenticated/$storeId/settings/stock-locations'
import { Route as SettingsStaffRouteImport } from './routes/_authenticated/$storeId/settings/staff'
+import { Route as SettingsReasonsRouteImport } from './routes/_authenticated/$storeId/settings/reasons'
import { Route as SettingsProfileRouteImport } from './routes/_authenticated/$storeId/settings/profile'
import { Route as SettingsProductTypesRouteImport } from './routes/_authenticated/$storeId/settings/product-types'
import { Route as SettingsPaymentMethodsRouteImport } from './routes/_authenticated/$storeId/settings/payment-methods'
@@ -180,6 +181,11 @@ const SettingsStaffRoute = SettingsStaffRouteImport.update({
path: '/staff',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsReasonsRoute = SettingsReasonsRouteImport.update({
+ id: '/reasons',
+ path: '/reasons',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsProfileRoute = SettingsProfileRouteImport.update({
id: '/profile',
path: '/profile',
@@ -382,6 +388,7 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$storeId/settings/store': typeof SettingsStoreRoute
@@ -436,6 +443,7 @@ export interface FileRoutesByTo {
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/$storeId/settings/store': typeof SettingsStoreRoute
@@ -494,6 +502,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
'/_authenticated/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/_authenticated/$storeId/settings/profile': typeof SettingsProfileRoute
+ '/_authenticated/$storeId/settings/reasons': typeof SettingsReasonsRoute
'/_authenticated/$storeId/settings/staff': typeof SettingsStaffRoute
'/_authenticated/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
'/_authenticated/$storeId/settings/store': typeof SettingsStoreRoute
@@ -552,6 +561,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/payment-methods'
| '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
+ | '/$storeId/settings/reasons'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
| '/$storeId/settings/store'
@@ -606,6 +616,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/payment-methods'
| '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
+ | '/$storeId/settings/reasons'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
| '/$storeId/settings/store'
@@ -663,6 +674,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/payment-methods'
| '/_authenticated/$storeId/settings/product-types'
| '/_authenticated/$storeId/settings/profile'
+ | '/_authenticated/$storeId/settings/reasons'
| '/_authenticated/$storeId/settings/staff'
| '/_authenticated/$storeId/settings/stock-locations'
| '/_authenticated/$storeId/settings/store'
@@ -854,6 +866,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsStaffRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/reasons': {
+ id: '/_authenticated/$storeId/settings/reasons'
+ path: '/reasons'
+ fullPath: '/$storeId/settings/reasons'
+ preLoaderRoute: typeof SettingsReasonsRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/profile': {
id: '/_authenticated/$storeId/settings/profile'
path: '/profile'
@@ -1093,6 +1112,7 @@ interface SettingsRouteChildren {
SettingsPaymentMethodsRoute: typeof SettingsPaymentMethodsRoute
SettingsProductTypesRoute: typeof SettingsProductTypesRoute
SettingsProfileRoute: typeof SettingsProfileRoute
+ SettingsReasonsRoute: typeof SettingsReasonsRoute
SettingsStaffRoute: typeof SettingsStaffRoute
SettingsStockLocationsRoute: typeof SettingsStockLocationsRoute
SettingsStoreRoute: typeof SettingsStoreRoute
@@ -1115,6 +1135,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsPaymentMethodsRoute: SettingsPaymentMethodsRoute,
SettingsProductTypesRoute: SettingsProductTypesRoute,
SettingsProfileRoute: SettingsProfileRoute,
+ SettingsReasonsRoute: SettingsReasonsRoute,
SettingsStaffRoute: SettingsStaffRoute,
SettingsStockLocationsRoute: SettingsStockLocationsRoute,
SettingsStoreRoute: SettingsStoreRoute,
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/reasons.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/reasons.tsx
new file mode 100644
index 0000000000..b91f467ef1
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/reasons.tsx
@@ -0,0 +1,383 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import {
+ Can,
+ mapSpreeErrorsToForm,
+ PageHeader,
+ Subject,
+ usePermissions,
+} from '@spree/dashboard-core'
+import {
+ ActiveBadge,
+ Badge,
+ Button,
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ Empty,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ RowActions,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+ Skeleton,
+ Switch,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+ useConfirm,
+} from '@spree/dashboard-ui'
+import { createFileRoute } from '@tanstack/react-router'
+import { PlusIcon, RotateCcwIcon } from 'lucide-react'
+import { useState } from 'react'
+import { Controller, type UseFormReturn, useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import {
+ type Reason,
+ type ReasonKind,
+ useCreateReason,
+ useDeleteReason,
+ useReasons,
+ useUpdateReason,
+} from '../../../../hooks/use-reasons'
+import {
+ REASON_DEFAULTS,
+ type ReasonFormValues,
+ reasonFormSchema,
+} from '../../../../schemas/reason'
+
+export const Route = createFileRoute('/_authenticated/$storeId/settings/reasons')({
+ component: ReasonsPage,
+})
+
+/**
+ * The three reason lists live on one page rather than three: each is a handful
+ * of short rows, and a merchant setting up returns wants to see the whole
+ * vocabulary at once. They stay separate lists because they answer different
+ * questions — why a customer sent something back, what the merchant got wrong,
+ * and why money moved.
+ */
+const SECTIONS: Array<{ kind: ReasonKind; subject: string; titleKey: string; helpKey: string }> = [
+ {
+ kind: 'return-reasons',
+ subject: Subject.ReturnReason,
+ titleKey: 'admin.reasons.return.title',
+ helpKey: 'admin.reasons.return.help',
+ },
+ {
+ kind: 'claim-reasons',
+ subject: Subject.ClaimReason,
+ titleKey: 'admin.reasons.claim.title',
+ helpKey: 'admin.reasons.claim.help',
+ },
+ {
+ kind: 'refund-reasons',
+ subject: Subject.RefundReason,
+ titleKey: 'admin.reasons.refund.title',
+ helpKey: 'admin.reasons.refund.help',
+ },
+]
+
+function ReasonsPage() {
+ const { t } = useTranslation()
+
+ return (
+ <div className="flex flex-col gap-6">
+ <PageHeader title={t('admin.reasons.title')} subtitle={t('admin.reasons.description')} />
+
+ {SECTIONS.map((section) => (
+ <ReasonSection key={section.kind} {...section} />
+ ))}
+ </div>
+ )
+}
+
+function ReasonSection({
+ kind,
+ subject,
+ titleKey,
+ helpKey,
+}: {
+ kind: ReasonKind
+ subject: string
+ titleKey: string
+ helpKey: string
+}) {
+ const { t } = useTranslation()
+ const { data, isLoading } = useReasons(kind)
+
+ const [creating, setCreating] = useState(false)
+ const [editing, setEditing] = useState<Reason | null>(null)
+
+ const reasons = data?.data ?? []
+
+ return (
+ <>
+ <Card>
+ <CardHeader className="flex flex-row items-start justify-between gap-3 space-y-0">
+ <div>
+ <CardTitle>{t(titleKey)}</CardTitle>
+ <p className="mt-1 text-sm text-muted-foreground">{t(helpKey)}</p>
+ </div>
+ <Can I="create" a={subject}>
+ <Button size="sm" onClick={() => setCreating(true)}>
+ <PlusIcon className="size-4" />
+ {t('admin.reasons.add_cta')}
+ </Button>
+ </Can>
+ </CardHeader>
+ <CardContent className="p-0">
+ {isLoading ? (
+ <div className="p-4">
+ <Skeleton className="h-10 w-full" />
+ </div>
+ ) : reasons.length === 0 ? (
+ <Empty>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <RotateCcwIcon />
+ </EmptyMedia>
+ <EmptyTitle>{t('admin.reasons.empty')}</EmptyTitle>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <Table>
+ <TableHeader className="border-b">
+ <TableRow>
+ <TableHead>{t('admin.fields.name.label')}</TableHead>
+ <TableHead>{t('admin.fields.status.label')}</TableHead>
+ <TableHead className="w-12" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {reasons.map((reason) => (
+ <ReasonRow
+ key={reason.id}
+ kind={kind}
+ subject={subject}
+ reason={reason}
+ onEdit={setEditing}
+ />
+ ))}
+ </TableBody>
+ </Table>
+ )}
+ </CardContent>
+ </Card>
+
+ {creating && <CreateReasonSheet kind={kind} onClose={() => setCreating(false)} />}
+ {editing && <EditReasonSheet kind={kind} reason={editing} onClose={() => setEditing(null)} />}
+ </>
+ )
+}
+
+function ReasonRow({
+ kind,
+ subject,
+ reason,
+ onEdit,
+}: {
+ kind: ReasonKind
+ subject: string
+ reason: Reason
+ onEdit: (reason: Reason) => void
+}) {
+ const { t } = useTranslation()
+ const confirm = useConfirm()
+ const { permissions } = usePermissions()
+ const deleteMutation = useDeleteReason(kind)
+
+ async function handleDelete() {
+ const ok = await confirm({
+ title: t('admin.reasons.delete_confirm.title'),
+ message: t('admin.reasons.delete_confirm.message', { name: reason.name }),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.delete'),
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(reason.id).catch(() => undefined)
+ }
+
+ return (
+ <TableRow>
+ <TableCell>
+ <span className="flex items-center gap-2 font-medium">
+ {reason.name}
+ {!reason.can_be_deleted && (
+ <Badge variant="outline" title={t('admin.reasons.locked_help')}>
+ {t('admin.reasons.locked')}
+ </Badge>
+ )}
+ </span>
+ </TableCell>
+ <TableCell>
+ <ActiveBadge
+ active={reason.active}
+ activeLabel={t('admin.fields.active.label')}
+ inactiveLabel={t('admin.reasons.inactive')}
+ />
+ </TableCell>
+ <TableCell>
+ <RowActions
+ actions={[
+ {
+ key: 'edit',
+ // A locked reason is one core looks up by name; the API refuses
+ // the rename, so don't offer it.
+ visible: permissions.can('update', subject) && reason.can_be_deleted,
+ onSelect: () => onEdit(reason),
+ },
+ {
+ key: 'delete',
+ destructive: true,
+ visible: permissions.can('destroy', subject) && reason.can_be_deleted,
+ disabled: deleteMutation.isPending,
+ onSelect: handleDelete,
+ },
+ ]}
+ />
+ </TableCell>
+ </TableRow>
+ )
+}
+
+function CreateReasonSheet({ kind, onClose }: { kind: ReasonKind; onClose: () => void }) {
+ const { t } = useTranslation()
+ const createMutation = useCreateReason(kind)
+ const form = useForm<ReasonFormValues>({
+ resolver: zodResolver(reasonFormSchema),
+ defaultValues: REASON_DEFAULTS,
+ })
+
+ async function onSubmit(values: ReasonFormValues) {
+ try {
+ await createMutation.mutateAsync(values)
+ onClose()
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ return (
+ <Sheet open onOpenChange={(next) => !next && onClose()}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('admin.reasons.add_sheet_title')}</SheetTitle>
+ <SheetDescription>{t('admin.reasons.create_description')}</SheetDescription>
+ </SheetHeader>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <ReasonFormFields form={form} />
+ </div>
+ <SheetFooter>
+ <Button type="button" variant="outline" onClick={onClose}>
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" disabled={createMutation.isPending}>
+ {t('admin.actions.create')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function EditReasonSheet({
+ kind,
+ reason,
+ onClose,
+}: {
+ kind: ReasonKind
+ reason: Reason
+ onClose: () => void
+}) {
+ const { t } = useTranslation()
+ const updateMutation = useUpdateReason(kind, reason.id)
+ const form = useForm<ReasonFormValues>({
+ resolver: zodResolver(reasonFormSchema),
+ defaultValues: { name: reason.name, active: reason.active },
+ })
+
+ async function onSubmit(values: ReasonFormValues) {
+ try {
+ await updateMutation.mutateAsync(values)
+ onClose()
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ return (
+ <Sheet open onOpenChange={(next) => !next && onClose()}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('admin.reasons.edit_sheet_title')}</SheetTitle>
+ </SheetHeader>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <ReasonFormFields form={form} />
+ </div>
+ <SheetFooter>
+ <Button type="button" variant="outline" onClick={onClose}>
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" disabled={updateMutation.isPending}>
+ {t('admin.actions.save')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function ReasonFormFields({ form }: { form: UseFormReturn<ReasonFormValues> }) {
+ const { t } = useTranslation()
+ const { errors } = form.formState
+
+ return (
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-sm text-destructive" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+
+ <Field>
+ <FieldLabel htmlFor="reason-name">{t('admin.fields.name.label')}</FieldLabel>
+ <Input
+ id="reason-name"
+ aria-invalid={!!errors.name}
+ placeholder={t('admin.reasons.name_placeholder')}
+ {...form.register('name')}
+ />
+ {errors.name && <FieldError>{errors.name.message}</FieldError>}
+ </Field>
+
+ <Field orientation="horizontal">
+ <FieldLabel htmlFor="reason-active">{t('admin.reasons.active_label')}</FieldLabel>
+ <Controller
+ control={form.control}
+ name="active"
+ render={({ field }) => (
+ <Switch id="reason-active" checked={field.value} onCheckedChange={field.onChange} />
+ )}
+ />
+ </Field>
+ </FieldGroup>
+ )
+}
diff --git a/packages/dashboard/src/schemas/price-list.ts b/packages/dashboard/src/schemas/price-list.ts
index 1b27bd2787..78b9073534 100644
--- a/packages/dashboard/src/schemas/price-list.ts
+++ b/packages/dashboard/src/schemas/price-list.ts
@@ -1,8 +1,4 @@
import type {
- Channel,
- Customer,
- CustomerGroup,
- Market,
PreferenceField,
PriceListCreateParams,
PriceListUpdateParams,
@@ -39,10 +35,29 @@ export interface PriceRuleFormDraft {
* reads "Customer groups: VIPs, Wholesale" instead of "cg_…". Never
* sent to the API — `priceListValuesToParams` strips them.
*/
- customers?: Customer[]
- customer_groups?: CustomerGroup[]
- markets?: Market[]
- channels?: Channel[]
+ customers?: RuleEmbedRecord[]
+ customer_groups?: RuleEmbedRecord[]
+ markets?: RuleEmbedRecord[]
+ channels?: RuleEmbedRecord[]
+}
+
+/**
+ * Display-only slice of an embed record — enough to render a label,
+ * nothing more. Deliberately NOT the SDK types (`Customer`, `Channel`, …):
+ * this interface is part of the form values, and react-hook-form's
+ * `Path<T>` enumerates every nested key of the form type. The SDK types
+ * embed the whole object graph (`Customer` → `orders[]` → `payments[]` →
+ * `source` → …), which turns the path union into millions of keys and
+ * overflows TypeScript's relation cache ("RangeError: Map maximum size
+ * exceeded" on TS 6). Assigning a full SDK record INTO one of these
+ * fields is fine — the editors do exactly that — but the form type must
+ * stay shallow.
+ */
+export interface RuleEmbedRecord {
+ id: string
+ name?: string | null
+ email?: string | null
+ code?: string | null
}
const priceRuleDraftSchema: z.ZodType<PriceRuleFormDraft> = z.object({
diff --git a/packages/dashboard/src/schemas/reason.ts b/packages/dashboard/src/schemas/reason.ts
new file mode 100644
index 0000000000..c9f8b77813
--- /dev/null
+++ b/packages/dashboard/src/schemas/reason.ts
@@ -0,0 +1,15 @@
+import { requiredMessage } from '@spree/dashboard-ui'
+import { z } from 'zod/v4'
+
+/** Shared by return, claim and refund reasons — all three carry the same two fields. */
+export const reasonFormSchema = z.object({
+ name: z.string().min(1, { error: requiredMessage('name') }),
+ active: z.boolean(),
+})
+
+export type ReasonFormValues = z.infer<typeof reasonFormSchema>
+
+export const REASON_DEFAULTS: ReasonFormValues = {
+ name: '',
+ active: true,
+}
diff --git a/packages/dashboard/src/schemas/webhook-endpoint.ts b/packages/dashboard/src/schemas/webhook-endpoint.ts
index fcb639cbdb..7973d949ed 100644
--- a/packages/dashboard/src/schemas/webhook-endpoint.ts
+++ b/packages/dashboard/src/schemas/webhook-endpoint.ts
@@ -187,17 +187,30 @@ export const WEBHOOK_EVENT_GROUPS: readonly WebhookEventGroup[] = [
{
labelKey: 'admin.pages.settings.webhooks.event_groups.return',
events: [
- 'customer_return.created',
- 'customer_return.deleted',
- 'customer_return.updated',
- 'reimbursement.reimbursed',
- 'return_authorization.canceled',
- 'return_authorization.created',
- 'return_authorization.deleted',
- 'return_authorization.updated',
- 'return_item.canceled',
- 'return_item.given',
- 'return_item.received',
+ 'return.approved',
+ 'return.canceled',
+ 'return.created',
+ 'return.deleted',
+ 'return.received',
+ 'return.refunded',
+ 'return.requested',
+ 'return.updated',
+ 'exchange.approved',
+ 'exchange.canceled',
+ 'exchange.created',
+ 'exchange.deleted',
+ 'exchange.fulfilled',
+ 'exchange.received',
+ 'exchange.requested',
+ 'exchange.updated',
+ 'claim.approved',
+ 'claim.canceled',
+ 'claim.created',
+ 'claim.deleted',
+ 'claim.denied',
+ 'claim.opened',
+ 'claim.resolved',
+ 'claim.updated',
],
},
{
diff --git a/packages/sdk/src/types/generated/Exchange.ts b/packages/sdk/src/types/generated/Exchange.ts
deleted file mode 100644
index 99b04cf5bc..0000000000
--- a/packages/sdk/src/types/generated/Exchange.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-// Typelizer digest 3798e992f1786dd096ec8b93dc9ca3cc
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {ExchangeLineItem} from '@/types'
-
-interface Exchange {
- id: string;
- number: string;
- status: string;
- order_id: string | null;
- reason_id: string | null;
- price_difference: string;
- display_price_difference: string;
- approved_at: string | null;
- received_at: string | null;
- fulfilled_at: string | null;
- canceled_at: string | null;
- exchange_line_items?: Array<ExchangeLineItem>;
-}
-
-export default Exchange;
diff --git a/packages/sdk/src/types/generated/ExchangeLineItem.ts b/packages/sdk/src/types/generated/ExchangeLineItem.ts
deleted file mode 100644
index 32d1dceaeb..0000000000
--- a/packages/sdk/src/types/generated/ExchangeLineItem.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// Typelizer digest 6230936c0a851435292a2454ad40dd94
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Variant} from '@/types'
-
-interface ExchangeLineItem {
- id: string;
- quantity: number;
- received_quantity: number;
- resellable: boolean;
- original_price: string;
- new_variant_price: string;
- price_difference: string;
- original_variant_id: string | null;
- new_variant_id: string | null;
- line_item_id: string | null;
- fulfillment_item_id: string | null;
- original_variant?: Variant;
- new_variant?: Variant;
-}
-
-export default ExchangeLineItem;
diff --git a/packages/sdk/src/types/generated/Refund.ts b/packages/sdk/src/types/generated/Refund.ts
index 4156d5c767..7d484ff943 100644
--- a/packages/sdk/src/types/generated/Refund.ts
+++ b/packages/sdk/src/types/generated/Refund.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 40931f60bfccedfe93b2b8a88e91ef0d
+// Typelizer digest ecfd3951bcab7a3af1649f7e4964be25
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -8,7 +8,8 @@ interface Refund {
amount: string | null;
payment_id: string | null;
refund_reason_id: string | null;
- reimbursement_id: string | null;
+ originator_id: string | null;
+ originator_type: string | null;
}
export default Refund;
diff --git a/packages/sdk/src/types/generated/ReturnAuthorization.ts b/packages/sdk/src/types/generated/ReturnAuthorization.ts
deleted file mode 100644
index e588b1ba86..0000000000
--- a/packages/sdk/src/types/generated/ReturnAuthorization.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-// Typelizer digest b74e9f7a9e52c3f023c46d097db79d93
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-
-interface ReturnAuthorization {
- id: string;
- number: string;
- status: string;
- order_id: string | null;
- stock_location_id: string | null;
- return_authorization_reason_id: string | null;
-}
-
-export default ReturnAuthorization;
diff --git a/packages/sdk/src/types/generated/ReturnItem.ts b/packages/sdk/src/types/generated/ReturnItem.ts
deleted file mode 100644
index de3856992e..0000000000
--- a/packages/sdk/src/types/generated/ReturnItem.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-// Typelizer digest 4ee896d860131322b1aa9efed6818dfd
-//
-// DO NOT MODIFY: This file was automatically generated by Typelizer.
-
-interface ReturnItem {
- id: string;
- reception_status: string | null;
- acceptance_status: string | null;
- created_at: string;
- updated_at: string;
- pre_tax_amount: string | null;
- included_tax_total: string | null;
- additional_tax_total: string | null;
- inventory_unit_id: string | null;
- return_authorization_id: string | null;
- customer_return_id: string | null;
- reimbursement_id: string | null;
- exchange_variant_id: string | null;
-}
-
-export default ReturnItem;
diff --git a/packages/sdk/src/types/generated/index.ts b/packages/sdk/src/types/generated/index.ts
index b82b6fa089..8e19be0f21 100644
--- a/packages/sdk/src/types/generated/index.ts
+++ b/packages/sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 3a9d9f32d1a94d563b5c4c2b272da5d7
+// Typelizer digest 89f41f905b6cda40eac05dcc72c5b5d1
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -23,8 +23,6 @@ export type { default as DeliveryZone } from './DeliveryZone'
export type { default as DigitalLink } from './DigitalLink'
export type { default as Digital } from './Digital'
export type { default as Discount } from './Discount'
-export type { default as ExchangeLineItem } from './ExchangeLineItem'
-export type { default as Exchange } from './Exchange'
export type { default as Fee } from './Fee'
export type { default as Fulfillment } from './Fulfillment'
export type { default as GiftCardBatch } from './GiftCardBatch'
@@ -60,8 +58,6 @@ export type { default as Product } from './Product'
export type { default as ProductType } from './ProductType'
export type { default as Promotion } from './Promotion'
export type { default as Refund } from './Refund'
-export type { default as ReturnAuthorization } from './ReturnAuthorization'
-export type { default as ReturnItem } from './ReturnItem'
export type { default as ReturnLineItem } from './ReturnLineItem'
export type { default as Return } from './Return'
export type { default as State } from './State'
diff --git a/packages/sdk/src/types/index.ts b/packages/sdk/src/types/index.ts
index 5cebaab64c..9d6aedcd12 100644
--- a/packages/sdk/src/types/index.ts
+++ b/packages/sdk/src/types/index.ts
@@ -44,8 +44,6 @@ export type {
Promotion,
Refund,
Return,
- ReturnAuthorization,
- ReturnItem,
ReturnLineItem,
State,
StockLocation,
diff --git a/packages/sdk/src/zod/generated/Exchange.ts b/packages/sdk/src/zod/generated/Exchange.ts
deleted file mode 100644
index 635fa149f8..0000000000
--- a/packages/sdk/src/zod/generated/Exchange.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file is auto-generated. Do not edit directly.
-import { z } from 'zod';
-import { ExchangeLineItemSchema } from './ExchangeLineItem';
-
-export const ExchangeSchema = z.object({
- id: z.string(),
- number: z.string(),
- status: z.string(),
- order_id: z.string().nullable(),
- reason_id: z.string().nullable(),
- price_difference: z.string(),
- display_price_difference: z.string(),
- approved_at: z.string().nullable(),
- received_at: z.string().nullable(),
- fulfilled_at: z.string().nullable(),
- canceled_at: z.string().nullable(),
- exchange_line_items: z.array(ExchangeLineItemSchema).optional(),
-});
-
-export type Exchange = z.infer<typeof ExchangeSchema>;
diff --git a/packages/sdk/src/zod/generated/ExchangeLineItem.ts b/packages/sdk/src/zod/generated/ExchangeLineItem.ts
deleted file mode 100644
index 1303852f8d..0000000000
--- a/packages/sdk/src/zod/generated/ExchangeLineItem.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-// This file is auto-generated. Do not edit directly.
-import { z } from 'zod';
-import { VariantSchema } from './Variant';
-
-export const ExchangeLineItemSchema = z.object({
- id: z.string(),
- quantity: z.number(),
- received_quantity: z.number(),
- resellable: z.boolean(),
- original_price: z.string(),
- new_variant_price: z.string(),
- price_difference: z.string(),
- original_variant_id: z.string().nullable(),
- new_variant_id: z.string().nullable(),
- line_item_id: z.string().nullable(),
- fulfillment_item_id: z.string().nullable(),
- original_variant: VariantSchema.optional(),
- new_variant: VariantSchema.optional(),
-});
-
-export type ExchangeLineItem = z.infer<typeof ExchangeLineItemSchema>;
diff --git a/packages/sdk/src/zod/generated/Refund.ts b/packages/sdk/src/zod/generated/Refund.ts
index b45749644b..155ca929ca 100644
--- a/packages/sdk/src/zod/generated/Refund.ts
+++ b/packages/sdk/src/zod/generated/Refund.ts
@@ -7,7 +7,8 @@ export const RefundSchema = z.object({
amount: z.string().nullable(),
payment_id: z.string().nullable(),
refund_reason_id: z.string().nullable(),
- reimbursement_id: z.string().nullable(),
+ originator_id: z.string().nullable(),
+ originator_type: z.string().nullable(),
});
export type Refund = z.infer<typeof RefundSchema>;
diff --git a/packages/sdk/src/zod/generated/ReturnAuthorization.ts b/packages/sdk/src/zod/generated/ReturnAuthorization.ts
deleted file mode 100644
index ebd43d3c9a..0000000000
--- a/packages/sdk/src/zod/generated/ReturnAuthorization.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-// This file is auto-generated. Do not edit directly.
-import { z } from 'zod';
-
-export const ReturnAuthorizationSchema = z.object({
- id: z.string(),
- number: z.string(),
- status: z.string(),
- order_id: z.string().nullable(),
- stock_location_id: z.string().nullable(),
- return_authorization_reason_id: z.string().nullable(),
-});
-
-export type ReturnAuthorization = z.infer<typeof ReturnAuthorizationSchema>;
diff --git a/packages/sdk/src/zod/generated/ReturnItem.ts b/packages/sdk/src/zod/generated/ReturnItem.ts
deleted file mode 100644
index 94cac41433..0000000000
--- a/packages/sdk/src/zod/generated/ReturnItem.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file is auto-generated. Do not edit directly.
-import { z } from 'zod';
-
-export const ReturnItemSchema = z.object({
- id: z.string(),
- reception_status: z.string().nullable(),
- acceptance_status: z.string().nullable(),
- created_at: z.string(),
- updated_at: z.string(),
- pre_tax_amount: z.string().nullable(),
- included_tax_total: z.string().nullable(),
- additional_tax_total: z.string().nullable(),
- inventory_unit_id: z.string().nullable(),
- return_authorization_id: z.string().nullable(),
- customer_return_id: z.string().nullable(),
- reimbursement_id: z.string().nullable(),
- exchange_variant_id: z.string().nullable(),
-});
-
-export type ReturnItem = z.infer<typeof ReturnItemSchema>;
diff --git a/packages/sdk/src/zod/generated/index.ts b/packages/sdk/src/zod/generated/index.ts
index df5dada59a..feb057e579 100644
--- a/packages/sdk/src/zod/generated/index.ts
+++ b/packages/sdk/src/zod/generated/index.ts
@@ -21,8 +21,6 @@ export { DeliveryZoneMemberSchema, type DeliveryZoneMember } from './DeliveryZon
export { DigitalSchema, type Digital } from './Digital';
export { DigitalLinkSchema, type DigitalLink } from './DigitalLink';
export { DiscountSchema, type Discount } from './Discount';
-export { ExchangeSchema, type Exchange } from './Exchange';
-export { ExchangeLineItemSchema, type ExchangeLineItem } from './ExchangeLineItem';
export { FeeSchema, type Fee } from './Fee';
export { FulfillmentSchema, type Fulfillment } from './Fulfillment';
export { GiftCardSchema, type GiftCard } from './GiftCard';
@@ -59,8 +57,6 @@ export { ProductTypeSchema, type ProductType } from './ProductType';
export { PromotionSchema, type Promotion } from './Promotion';
export { RefundSchema, type Refund } from './Refund';
export { ReturnSchema, type Return } from './Return';
-export { ReturnAuthorizationSchema, type ReturnAuthorization } from './ReturnAuthorization';
-export { ReturnItemSchema, type ReturnItem } from './ReturnItem';
export { ReturnLineItemSchema, type ReturnLineItem } from './ReturnLineItem';
export { StateSchema, type State } from './State';
export { StockLocationSchema, type StockLocation } from './StockLocation';
diff --git a/spree/api/app/controllers/spree/api/v3/admin/claim_reasons_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/claim_reasons_controller.rb
new file mode 100644
index 0000000000..ce04c13000
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/claim_reasons_controller.rb
@@ -0,0 +1,25 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class ClaimReasonsController < ResourceController
+ scoped_resource :settings
+
+ protected
+
+ def model_class
+ Spree::ClaimReason
+ end
+
+ def serializer_class
+ Spree.api.admin_claim_reason_serializer
+ end
+
+ def permitted_params
+ params.permit(:name, :active)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/orders/claims_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders/claims_controller.rb
index 6adf4cd033..130e0f55d4 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/orders/claims_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/orders/claims_controller.rb
@@ -141,7 +141,7 @@ module Spree
def reason_for_create
return nil if create_params[:reason_id].blank?
- Spree::ReturnAuthorizationReason.find_by_prefix_id!(create_params[:reason_id])
+ Spree::ClaimReason.find_by_prefix_id!(create_params[:reason_id])
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/orders/exchanges_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders/exchanges_controller.rb
index 54ef250b96..f8927ac495 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/orders/exchanges_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/orders/exchanges_controller.rb
@@ -134,7 +134,7 @@ module Spree
def reason_for_create
return nil if create_params[:reason_id].blank?
- Spree::ReturnAuthorizationReason.find_by_prefix_id!(create_params[:reason_id])
+ Spree::ReturnReason.find_by_prefix_id!(create_params[:reason_id])
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/orders/returns_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders/returns_controller.rb
index 1ae3269bb4..b68edd496c 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/orders/returns_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/orders/returns_controller.rb
@@ -144,7 +144,7 @@ module Spree
def reason_for_create
return nil if create_params[:reason_id].blank?
- Spree::ReturnAuthorizationReason.find_by_prefix_id!(create_params[:reason_id])
+ Spree::ReturnReason.find_by_prefix_id!(create_params[:reason_id])
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/refund_reasons_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/refund_reasons_controller.rb
new file mode 100644
index 0000000000..07b67ac25c
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/refund_reasons_controller.rb
@@ -0,0 +1,25 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class RefundReasonsController < ResourceController
+ scoped_resource :settings
+
+ protected
+
+ def model_class
+ Spree::RefundReason
+ end
+
+ def serializer_class
+ Spree.api.admin_refund_reason_serializer
+ end
+
+ def permitted_params
+ params.permit(:name, :active)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/return_reasons_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/return_reasons_controller.rb
new file mode 100644
index 0000000000..0d6889ab39
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/return_reasons_controller.rb
@@ -0,0 +1,25 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class ReturnReasonsController < ResourceController
+ scoped_resource :settings
+
+ protected
+
+ def model_class
+ Spree::ReturnReason
+ end
+
+ def serializer_class
+ Spree.api.admin_return_reason_serializer
+ end
+
+ def permitted_params
+ params.permit(:name, :active)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/store/orders/returns_controller.rb b/spree/api/app/controllers/spree/api/v3/store/orders/returns_controller.rb
index a0b01cb9df..1cef96fb17 100644
--- a/spree/api/app/controllers/spree/api/v3/store/orders/returns_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/store/orders/returns_controller.rb
@@ -96,7 +96,7 @@ module Spree
def reason_for_create
return nil if create_params[:reason_id].blank?
- Spree::ReturnAuthorizationReason.find_by_prefix_id!(create_params[:reason_id])
+ Spree::ReturnReason.find_by_prefix_id!(create_params[:reason_id])
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/claim_reason_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/claim_reason_serializer.rb
new file mode 100644
index 0000000000..e857173b1c
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/claim_reason_serializer.rb
@@ -0,0 +1,28 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Admin-only: reasons are back-office vocabulary and have no Store API
+ # controller, so there is no store serializer to extend.
+ #
+ # The three reason serializers are deliberately parallel rather than
+ # sharing a base class: Typelizer emits one TS type per serializer, so
+ # a shared parent would publish an abstract `Reason` type into the
+ # admin SDK that no endpoint returns.
+ class ClaimReasonSerializer < V3::BaseSerializer
+ typelize name: :string, active: :boolean, mutable: :boolean,
+ can_be_deleted: :boolean
+
+ attributes :name, :active, :mutable,
+ created_at: :iso8601, updated_at: :iso8601
+
+ # Lets the dashboard hide destructive controls instead of offering a
+ # delete that the model will refuse.
+ attribute :can_be_deleted do |reason|
+ reason.can_be_deleted?
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb
index 663e7d2a0d..0435ff6548 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb
@@ -108,13 +108,17 @@ module Spree
if: proc { expand?('created_by') }
- many :return_authorizations,
- resource: proc { Spree.api.admin_return_authorization_serializer },
- if: proc { expand?('return_authorizations') }
+ many :returns,
+ resource: proc { Spree.api.admin_return_serializer },
+ if: proc { expand?('returns') }
- many :reimbursements,
- resource: proc { Spree.api.admin_reimbursement_serializer },
- if: proc { expand?('reimbursements') }
+ many :exchanges,
+ resource: proc { Spree.api.admin_exchange_serializer },
+ if: proc { expand?('exchanges') }
+
+ many :claims,
+ resource: proc { Spree.api.admin_claim_serializer },
+ if: proc { expand?('claims') }
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/refund_reason_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/refund_reason_serializer.rb
new file mode 100644
index 0000000000..858378c44e
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/refund_reason_serializer.rb
@@ -0,0 +1,28 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Admin-only: reasons are back-office vocabulary and have no Store API
+ # controller, so there is no store serializer to extend.
+ #
+ # The three reason serializers are deliberately parallel rather than
+ # sharing a base class: Typelizer emits one TS type per serializer, so
+ # a shared parent would publish an abstract `Reason` type into the
+ # admin SDK that no endpoint returns.
+ class RefundReasonSerializer < V3::BaseSerializer
+ typelize name: :string, active: :boolean, mutable: :boolean,
+ can_be_deleted: :boolean
+
+ attributes :name, :active, :mutable,
+ created_at: :iso8601, updated_at: :iso8601
+
+ # Lets the dashboard hide destructive controls instead of offering a
+ # delete that the model will refuse.
+ attribute :can_be_deleted do |reason|
+ reason.can_be_deleted?
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb
index 0920aba83e..a259f5edc8 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb
@@ -5,7 +5,6 @@ module Spree
class RefundSerializer < V3::RefundSerializer
typelize payment_id: [:string, nullable: true],
refund_reason_id: [:string, nullable: true],
- reimbursement_id: [:string, nullable: true],
metadata: 'Record<string, unknown>'
attributes :metadata,
@@ -14,10 +13,6 @@ module Spree
one :payment,
resource: proc { Spree.api.admin_payment_serializer },
if: proc { expand?('payment') }
-
- one :reimbursement,
- resource: proc { Spree.api.admin_reimbursement_serializer },
- if: proc { expand?('reimbursement') }
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/reimbursement_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/reimbursement_serializer.rb
deleted file mode 100644
index 0db322141a..0000000000
--- a/spree/api/app/serializers/spree/api/v3/admin/reimbursement_serializer.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Spree
- module Api
- module V3
- module Admin
- class ReimbursementSerializer < V3::ReimbursementSerializer
- attributes created_at: :iso8601, updated_at: :iso8601
-
- one :order,
- resource: proc { Spree.api.admin_order_serializer },
- if: proc { expand?('order') }
- end
- end
- end
- end
-end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/return_authorization_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/return_authorization_serializer.rb
deleted file mode 100644
index f9ca39d1b9..0000000000
--- a/spree/api/app/serializers/spree/api/v3/admin/return_authorization_serializer.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Spree
- module Api
- module V3
- module Admin
- class ReturnAuthorizationSerializer < V3::ReturnAuthorizationSerializer
- attributes created_at: :iso8601, updated_at: :iso8601
-
- one :order,
- resource: proc { Spree.api.admin_order_serializer },
- if: proc { expand?('order') }
-
- one :stock_location,
- resource: proc { Spree.api.admin_stock_location_serializer },
- if: proc { expand?('stock_location') }
- end
- end
- end
- end
-end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/return_reason_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/return_reason_serializer.rb
new file mode 100644
index 0000000000..615ae55899
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/return_reason_serializer.rb
@@ -0,0 +1,28 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ # Admin-only: reasons are back-office vocabulary and have no Store API
+ # controller, so there is no store serializer to extend.
+ #
+ # The three reason serializers are deliberately parallel rather than
+ # sharing a base class: Typelizer emits one TS type per serializer, so
+ # a shared parent would publish an abstract `Reason` type into the
+ # admin SDK that no endpoint returns.
+ class ReturnReasonSerializer < V3::BaseSerializer
+ typelize name: :string, active: :boolean, mutable: :boolean,
+ can_be_deleted: :boolean
+
+ attributes :name, :active, :mutable,
+ created_at: :iso8601, updated_at: :iso8601
+
+ # Lets the dashboard hide destructive controls instead of offering a
+ # delete that the model will refuse.
+ attribute :can_be_deleted do |reason|
+ reason.can_be_deleted?
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/customer_return_serializer.rb b/spree/api/app/serializers/spree/api/v3/customer_return_serializer.rb
deleted file mode 100644
index a438bbfa0a..0000000000
--- a/spree/api/app/serializers/spree/api/v3/customer_return_serializer.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-module Spree
- module Api
- module V3
- class CustomerReturnSerializer < BaseSerializer
- typelize number: :string, stock_location_id: [:string, nullable: true]
-
- attributes :number, created_at: :iso8601, updated_at: :iso8601
-
- attribute :stock_location_id do |customer_return|
- customer_return.stock_location&.prefixed_id
- end
- end
- end
- end
-end
diff --git a/spree/api/app/serializers/spree/api/v3/refund_serializer.rb b/spree/api/app/serializers/spree/api/v3/refund_serializer.rb
index a1333c1583..0d7ad95321 100644
--- a/spree/api/app/serializers/spree/api/v3/refund_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/refund_serializer.rb
@@ -6,7 +6,7 @@ module Spree
class RefundSerializer < BaseSerializer
typelize amount: [:string, nullable: true], transaction_id: [:string, nullable: true],
payment_id: [:string, nullable: true], refund_reason_id: [:string, nullable: true],
- reimbursement_id: [:string, nullable: true]
+ originator_id: [:string, nullable: true], originator_type: [:string, nullable: true]
attributes :transaction_id
@@ -22,8 +22,14 @@ module Spree
refund.reason&.prefixed_id
end
- attribute :reimbursement_id do |refund|
- refund.reimbursement&.prefixed_id
+ # What triggered this refund — a Return, Exchange or Claim; nil for a
+ # manual refund.
+ attribute :originator_id do |refund|
+ refund.originator&.prefixed_id
+ end
+
+ attribute :originator_type do |refund|
+ refund.originator_type
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/reimbursement_serializer.rb b/spree/api/app/serializers/spree/api/v3/reimbursement_serializer.rb
deleted file mode 100644
index c3022f3287..0000000000
--- a/spree/api/app/serializers/spree/api/v3/reimbursement_serializer.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-module Spree
- module Api
- module V3
- class ReimbursementSerializer < BaseSerializer
- typelize number: :string, reimbursement_status: [:string, nullable: true],
- total: [:string, nullable: true],
- order_id: [:string, nullable: true], customer_return_id: [:string, nullable: true]
-
- attributes :number, :reimbursement_status
-
- attribute :total do |reimbursement|
- reimbursement.total&.to_s
- end
-
- attribute :order_id do |reimbursement|
- reimbursement.order&.prefixed_id
- end
-
- attribute :customer_return_id do |reimbursement|
- reimbursement.customer_return&.prefixed_id
- end
- end
- end
- end
-end
diff --git a/spree/api/app/serializers/spree/api/v3/return_authorization_serializer.rb b/spree/api/app/serializers/spree/api/v3/return_authorization_serializer.rb
deleted file mode 100644
index 89eb472c75..0000000000
--- a/spree/api/app/serializers/spree/api/v3/return_authorization_serializer.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-module Spree
- module Api
- module V3
- class ReturnAuthorizationSerializer < BaseSerializer
- typelize number: :string, status: :string,
- order_id: [:string, nullable: true], stock_location_id: [:string, nullable: true],
- return_authorization_reason_id: [:string, nullable: true]
-
- attributes :number
-
- attribute :status do |return_authorization|
- return_authorization.state.to_s
- end
-
- attribute :order_id do |return_authorization|
- return_authorization.order&.prefixed_id
- end
-
- attribute :stock_location_id do |return_authorization|
- return_authorization.stock_location&.prefixed_id
- end
-
- attribute :return_authorization_reason_id do |return_authorization|
- return_authorization.reason&.prefixed_id
- end
- end
- end
- end
-end
diff --git a/spree/api/app/serializers/spree/api/v3/return_item_serializer.rb b/spree/api/app/serializers/spree/api/v3/return_item_serializer.rb
deleted file mode 100644
index 1902653f24..0000000000
--- a/spree/api/app/serializers/spree/api/v3/return_item_serializer.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-module Spree
- module Api
- module V3
- class ReturnItemSerializer < BaseSerializer
- typelize reception_status: [:string, nullable: true], acceptance_status: [:string, nullable: true],
- pre_tax_amount: [:string, nullable: true],
- included_tax_total: [:string, nullable: true], additional_tax_total: [:string, nullable: true],
- inventory_unit_id: [:string, nullable: true],
- return_authorization_id: [:string, nullable: true],
- customer_return_id: [:string, nullable: true],
- reimbursement_id: [:string, nullable: true],
- exchange_variant_id: [:string, nullable: true]
-
- attributes :reception_status, :acceptance_status,
- created_at: :iso8601, updated_at: :iso8601
-
- attribute :pre_tax_amount do |item|
- item.pre_tax_amount&.to_s
- end
-
- attribute :included_tax_total do |item|
- item.included_tax_total&.to_s
- end
-
- attribute :additional_tax_total do |item|
- item.additional_tax_total&.to_s
- end
-
- attribute :inventory_unit_id do |item|
- item.inventory_unit&.prefixed_id
- end
-
- attribute :return_authorization_id do |item|
- item.return_authorization&.prefixed_id
- end
-
- attribute :customer_return_id do |item|
- item.customer_return&.prefixed_id
- end
-
- attribute :reimbursement_id do |item|
- item.reimbursement&.prefixed_id
- end
-
- attribute :exchange_variant_id do |item|
- item.exchange_variant&.prefixed_id
- end
- end
- end
- end
-end
diff --git a/spree/api/config/initializers/typelizer.rb b/spree/api/config/initializers/typelizer.rb
index be279f8550..1c66bff04f 100644
--- a/spree/api/config/initializers/typelizer.rb
+++ b/spree/api/config/initializers/typelizer.rb
@@ -24,8 +24,8 @@ Rails.application.config.after_initialize do
store_excluded = %w[
Asset CartPromotion OrderPromotion
StockItem StockMovement StockTransfer ShippingCategory
- Reimbursement Report Export Import ImportRow
- TaxCategory CustomerReturn
+ Report Export Import ImportRow
+ TaxCategory Exchange ExchangeLineItem
].to_set
# Store SDK — no prefix, package provides namespace
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 9e7ea9fd02..8ab1b98313 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -293,6 +293,11 @@ Spree::Core::Engine.add_routes do
# Tax Categories
resources :tax_categories
+ # Return / claim / refund reasons (dropdowns + settings management)
+ resources :return_reasons
+ resources :claim_reasons
+ resources :refund_reasons
+
# Markets
resources :markets
diff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rb
index d38ada6142..8e129ae3dd 100644
--- a/spree/api/lib/spree/api/dependencies.rb
+++ b/spree/api/lib/spree/api/dependencies.rb
@@ -69,7 +69,6 @@ module Spree
# v3 event serializers (for models without Store API endpoints yet)
asset_serializer: 'Spree::Api::V3::AssetSerializer',
- customer_return_serializer: 'Spree::Api::V3::CustomerReturnSerializer',
return_serializer: 'Spree::Api::V3::ReturnSerializer',
return_line_item_serializer: 'Spree::Api::V3::ReturnLineItemSerializer',
exchange_serializer: 'Spree::Api::V3::ExchangeSerializer',
@@ -85,10 +84,7 @@ module Spree
newsletter_subscriber_serializer: 'Spree::Api::V3::NewsletterSubscriberSerializer',
promotion_serializer: 'Spree::Api::V3::PromotionSerializer',
refund_serializer: 'Spree::Api::V3::RefundSerializer',
- reimbursement_serializer: 'Spree::Api::V3::ReimbursementSerializer',
report_serializer: 'Spree::Api::V3::ReportSerializer',
- return_authorization_serializer: 'Spree::Api::V3::ReturnAuthorizationSerializer',
- return_item_serializer: 'Spree::Api::V3::ReturnItemSerializer',
stock_item_serializer: 'Spree::Api::V3::StockItemSerializer',
stock_movement_serializer: 'Spree::Api::V3::StockMovementSerializer',
stock_reservation_serializer: 'Spree::Api::V3::StockReservationSerializer',
@@ -131,6 +127,9 @@ module Spree
admin_gift_card_batch_serializer: 'Spree::Api::V3::Admin::GiftCardBatchSerializer',
admin_payment_serializer: 'Spree::Api::V3::Admin::PaymentSerializer',
admin_refund_serializer: 'Spree::Api::V3::Admin::RefundSerializer',
+ admin_return_reason_serializer: 'Spree::Api::V3::Admin::ReturnReasonSerializer',
+ admin_claim_reason_serializer: 'Spree::Api::V3::Admin::ClaimReasonSerializer',
+ admin_refund_reason_serializer: 'Spree::Api::V3::Admin::RefundReasonSerializer',
admin_return_serializer: 'Spree::Api::V3::Admin::ReturnSerializer',
admin_return_line_item_serializer: 'Spree::Api::V3::Admin::ReturnLineItemSerializer',
admin_exchange_serializer: 'Spree::Api::V3::Admin::ExchangeSerializer',
@@ -139,8 +138,6 @@ module Spree
admin_claim_line_item_serializer: 'Spree::Api::V3::Admin::ClaimLineItemSerializer',
admin_shipping_category_serializer: 'Spree::Api::V3::Admin::ShippingCategorySerializer',
admin_tax_category_serializer: 'Spree::Api::V3::Admin::TaxCategorySerializer',
- admin_return_authorization_serializer: 'Spree::Api::V3::Admin::ReturnAuthorizationSerializer',
- admin_reimbursement_serializer: 'Spree::Api::V3::Admin::ReimbursementSerializer',
admin_admin_user_serializer: 'Spree::Api::V3::Admin::AdminUserSerializer',
admin_address_serializer: 'Spree::Api::V3::Admin::AddressSerializer',
admin_channel_serializer: 'Spree::Api::V3::Admin::ChannelSerializer',
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/claim_reasons_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/claim_reasons_controller_spec.rb
new file mode 100644
index 0000000000..f9256746da
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/claim_reasons_controller_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::ClaimReasonsController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:reason) { create(:claim_reason, name: 'Arrived damaged') }
+
+ before { request.headers.merge!(headers) }
+
+ it 'lists claim reasons' do
+ get :index, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data'].map { |r| r['id'] }).to include(reason.prefixed_id)
+ end
+
+ it 'creates a claim reason' do
+ expect { post :create, params: { name: 'Never arrived' }, as: :json }.
+ to change(Spree::ClaimReason, :count).by(1)
+
+ expect(response).to have_http_status(:created)
+ end
+
+ it 'updates a claim reason' do
+ patch :update, params: { id: reason.prefixed_id, active: false }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(reason.reload.active).to be(false)
+ end
+
+ it 'refuses to delete a reason in use' do
+ create(:claim, reason: reason)
+
+ expect { delete :destroy, params: { id: reason.prefixed_id }, as: :json }.
+ not_to change(Spree::ClaimReason, :count)
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/refund_reasons_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/refund_reasons_controller_spec.rb
new file mode 100644
index 0000000000..b127328cf8
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/refund_reasons_controller_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::RefundReasonsController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:reason) { create(:refund_reason, name: 'Goodwill gesture') }
+
+ before { request.headers.merge!(headers) }
+
+ it 'lists refund reasons' do
+ get :index, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data'].map { |r| r['id'] }).to include(reason.prefixed_id)
+ end
+
+ it 'creates a refund reason' do
+ expect { post :create, params: { name: 'Price match' }, as: :json }.
+ to change(Spree::RefundReason, :count).by(1)
+ end
+
+ # Core looks this one up by name to attach to every return refund.
+ context 'with the seeded return-processing reason' do
+ let!(:locked) { Spree::RefundReason.return_processing_reason }
+
+ it 'reports that it cannot be deleted' do
+ get :show, params: { id: locked.prefixed_id }, as: :json
+
+ expect(json_response['can_be_deleted']).to be(false)
+ end
+
+ # The ability layer denies :update on an immutable reason outright, and
+ # the v3 error handler renders that as 404 rather than leaking existence.
+ # The model guard below it is what protects the secret-key path, which
+ # authorizes by scope and never consults CanCanCan.
+ it 'refuses to rename it' do
+ patch :update, params: { id: locked.prefixed_id, name: 'Something else' }, as: :json
+
+ expect(response).to have_http_status(:not_found)
+ expect(locked.reload.name).to eq(Spree::RefundReason::RETURN_PROCESSING_REASON)
+ end
+
+ it 'refuses to delete it' do
+ expect { delete :destroy, params: { id: locked.prefixed_id }, as: :json }.
+ not_to change(Spree::RefundReason, :count)
+ end
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/return_reasons_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/return_reasons_controller_spec.rb
new file mode 100644
index 0000000000..339e069b7a
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/return_reasons_controller_spec.rb
@@ -0,0 +1,102 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::ReturnReasonsController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:reason) { create(:return_reason, name: 'Wrong size') }
+
+ before { request.headers.merge!(headers) }
+
+ describe 'GET #index' do
+ it 'returns return reasons' do
+ get :index, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data'].map { |r| r['id'] }).to include(reason.prefixed_id)
+ end
+
+ it 'filters by active' do
+ inactive = create(:return_reason, name: 'Retired reason', active: false)
+
+ get :index, params: { q: { active_eq: false } }, as: :json
+
+ ids = json_response['data'].map { |r| r['id'] }
+ expect(ids).to include(inactive.prefixed_id)
+ expect(ids).not_to include(reason.prefixed_id)
+ end
+ end
+
+ describe 'GET #show' do
+ it 'returns the reason' do
+ get :show, params: { id: reason.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['name']).to eq('Wrong size')
+ expect(json_response['can_be_deleted']).to be(true)
+ end
+ end
+
+ describe 'POST #create' do
+ it 'creates a reason' do
+ expect { post :create, params: { name: 'Changed my mind', active: true }, as: :json }.
+ to change(Spree::ReturnReason, :count).by(1)
+
+ expect(response).to have_http_status(:created)
+ expect(json_response['name']).to eq('Changed my mind')
+ end
+
+ it 'rejects a blank name' do
+ post :create, params: { name: '' }, as: :json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+
+ it 'rejects a duplicate name' do
+ post :create, params: { name: reason.name }, as: :json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+ end
+
+ describe 'PATCH #update' do
+ it 'updates the reason' do
+ patch :update, params: { id: reason.prefixed_id, name: 'Too small' }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(reason.reload.name).to eq('Too small')
+ end
+
+ it 'does not allow unlocking a protected reason' do
+ locked = create(:return_reason, name: 'Locked', mutable: false)
+
+ patch :update, params: { id: locked.prefixed_id, mutable: true }, as: :json
+
+ expect(locked.reload.mutable).to be(false)
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'deletes the reason' do
+ expect { delete :destroy, params: { id: reason.prefixed_id }, as: :json }.
+ to change(Spree::ReturnReason, :count).by(-1)
+ end
+
+ it 'refuses to delete a reason in use' do
+ return_record = create(:return, reason: reason)
+
+ expect { delete :destroy, params: { id: reason.prefixed_id }, as: :json }.
+ not_to change(Spree::ReturnReason, :count)
+
+ expect(return_record.reload.reason).to eq(reason)
+ end
+
+ it 'refuses to delete a protected reason' do
+ locked = create(:return_reason, name: 'Locked', mutable: false)
+
+ expect { delete :destroy, params: { id: locked.prefixed_id }, as: :json }.
+ not_to change(Spree::ReturnReason, :count)
+ end
+ end
+end
diff --git a/spree/api/spec/serializers/spree/api/v3/customer_return_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/customer_return_serializer_spec.rb
deleted file mode 100644
index 7bf35f6ed7..0000000000
--- a/spree/api/spec/serializers/spree/api/v3/customer_return_serializer_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Spree::Api::V3::CustomerReturnSerializer do
- let(:store) { @default_store }
- let(:customer_return) { create(:customer_return) }
- let(:base_params) { { store: store, currency: 'USD' } }
-
- subject { described_class.new(customer_return, params: base_params).to_h }
-
- it 'includes all expected attributes' do
- expect(subject.keys).to match_array(%w[
- id number stock_location_id created_at updated_at
- ])
- end
-
- it 'returns the prefixed id' do
- expect(subject['id']).to eq(customer_return.prefixed_id)
- end
-
- it 'returns prefixed stock_location_id' do
- expect(subject['stock_location_id']).to eq(customer_return.stock_location.prefixed_id)
- end
-end
diff --git a/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb
index 9cce47f765..4944a61d41 100644
--- a/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb
+++ b/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb
@@ -12,10 +12,20 @@ RSpec.describe Spree::Api::V3::RefundSerializer do
it 'includes all expected attributes' do
expect(subject.keys).to match_array(%w[
- id amount transaction_id payment_id refund_reason_id reimbursement_id
+ id amount transaction_id payment_id refund_reason_id originator_id originator_type
])
end
+ context 'when the refund was issued for a return' do
+ let(:return_record) { create(:received_return) }
+ let(:refund) { create(:refund, payment: payment, amount: 10, originator: return_record) }
+
+ it 'names what triggered it' do
+ expect(subject['originator_id']).to eq(return_record.prefixed_id)
+ expect(subject['originator_type']).to eq('Spree::Return')
+ end
+ end
+
it 'returns the prefixed id' do
expect(subject['id']).to eq(refund.prefixed_id)
end
diff --git a/spree/api/spec/serializers/spree/api/v3/reimbursement_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/reimbursement_serializer_spec.rb
deleted file mode 100644
index b21f257f93..0000000000
--- a/spree/api/spec/serializers/spree/api/v3/reimbursement_serializer_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Spree::Api::V3::ReimbursementSerializer do
- let(:store) { @default_store }
- let(:reimbursement) { create(:reimbursement) }
- let(:base_params) { { store: store, currency: 'USD' } }
-
- subject { described_class.new(reimbursement, params: base_params).to_h }
-
- it 'includes all expected attributes' do
- expect(subject.keys).to match_array(%w[
- id number reimbursement_status total order_id customer_return_id
- ])
- end
-
- it 'returns the prefixed id' do
- expect(subject['id']).to eq(reimbursement.prefixed_id)
- end
-
- it 'returns prefixed order_id' do
- expect(subject['order_id']).to eq(reimbursement.order.prefixed_id)
- end
-end
diff --git a/spree/api/spec/serializers/spree/api/v3/return_authorization_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/return_authorization_serializer_spec.rb
deleted file mode 100644
index 2222ee0479..0000000000
--- a/spree/api/spec/serializers/spree/api/v3/return_authorization_serializer_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Spree::Api::V3::ReturnAuthorizationSerializer do
- let(:store) { @default_store }
- let(:return_authorization) { create(:return_authorization) }
- let(:base_params) { { store: store, currency: 'USD' } }
-
- subject { described_class.new(return_authorization, params: base_params).to_h }
-
- it 'includes all expected attributes' do
- expect(subject.keys).to match_array(%w[
- id number status order_id stock_location_id return_authorization_reason_id
- ])
- end
-
- it 'returns the prefixed id' do
- expect(subject['id']).to eq(return_authorization.prefixed_id)
- end
-
- it 'returns prefixed order_id' do
- expect(subject['order_id']).to eq(return_authorization.order.prefixed_id)
- end
-
- it 'returns status as string' do
- expect(subject['status']).to be_a(String)
- end
-end
diff --git a/spree/api/spec/serializers/spree/api/v3/return_item_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/return_item_serializer_spec.rb
deleted file mode 100644
index 72afbebb5d..0000000000
--- a/spree/api/spec/serializers/spree/api/v3/return_item_serializer_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Spree::Api::V3::ReturnItemSerializer do
- let(:store) { @default_store }
- let(:return_item) { create(:return_item) }
- let(:base_params) { { store: store, currency: 'USD' } }
-
- subject { described_class.new(return_item, params: base_params).to_h }
-
- it 'includes all expected attributes' do
- expect(subject.keys).to match_array(%w[
- id reception_status acceptance_status pre_tax_amount
- included_tax_total additional_tax_total inventory_unit_id
- return_authorization_id customer_return_id reimbursement_id
- exchange_variant_id created_at updated_at
- ])
- end
-
- it 'returns the prefixed id' do
- expect(subject['id']).to eq(return_item.prefixed_id)
- end
-
- it 'returns prefixed inventory_unit_id' do
- expect(subject['inventory_unit_id']).to eq(return_item.inventory_unit.prefixed_id)
- end
-end
diff --git a/spree/core/app/models/concerns/spree/admin_user_methods.rb b/spree/core/app/models/concerns/spree/admin_user_methods.rb
index d64adea7b1..0ab37dbe4d 100644
--- a/spree/core/app/models/concerns/spree/admin_user_methods.rb
+++ b/spree/core/app/models/concerns/spree/admin_user_methods.rb
@@ -39,7 +39,9 @@ module Spree
has_many :created_gift_cards, class_name: 'Spree::GiftCard', foreign_key: :created_by_id
has_many :created_gift_card_batches, class_name: 'Spree::GiftCardBatch', foreign_key: :created_by_id
has_many :refunded_refunds, class_name: 'Spree::Refund', foreign_key: :refunder_id
- has_many :performed_reimbursements, class_name: 'Spree::Reimbursement', foreign_key: :performed_by_id
+ has_many :created_returns, class_name: 'Spree::Return', foreign_key: :created_by_id
+ has_many :created_exchanges, class_name: 'Spree::Exchange', foreign_key: :created_by_id
+ has_many :created_claims, class_name: 'Spree::Claim', foreign_key: :created_by_id
has_many :created_store_credits, class_name: 'Spree::StoreCredit', foreign_key: :created_by_id
has_many :reports, class_name: 'Spree::Report', foreign_key: :user_id
has_many :exports, class_name: 'Spree::Export', foreign_key: :user_id
@@ -91,7 +93,9 @@ module Spree
created_gift_cards.update_all(created_by_id: nil, updated_at: Time.current)
created_gift_card_batches.update_all(created_by_id: nil, updated_at: Time.current)
refunded_refunds.update_all(refunder_id: nil, updated_at: Time.current)
- performed_reimbursements.update_all(performed_by_id: nil, updated_at: Time.current)
+ created_returns.update_all(created_by_id: nil, updated_at: Time.current)
+ created_exchanges.update_all(created_by_id: nil, updated_at: Time.current)
+ created_claims.update_all(created_by_id: nil, updated_at: Time.current)
created_store_credits.update_all(created_by_id: nil, updated_at: Time.current)
# resources to destroy
diff --git a/spree/core/app/models/concerns/spree/named_type.rb b/spree/core/app/models/concerns/spree/named_type.rb
index da9fef9549..ab5e0e2d3a 100644
--- a/spree/core/app/models/concerns/spree/named_type.rb
+++ b/spree/core/app/models/concerns/spree/named_type.rb
@@ -7,6 +7,41 @@ module Spree
default_scope { order(name: :asc) }
include Spree::UniqueName
+
+ # Core seeds a handful of reasons it looks up by name (RefundReason's
+ # "Return processing", for instance) and marks them immutable. Renaming
+ # or deleting one silently breaks the flow that finds it, so the guard
+ # lives on the model rather than only in the ability layer — API keys
+ # authorize by scope and never consult CanCanCan.
+ validate :name_is_not_locked, on: :update
+ before_destroy :abort_if_locked
+ end
+
+ # @return [Boolean] false when core depends on this record staying as it is
+ def can_be_deleted?
+ !locked?
+ end
+
+ private
+
+ # Not every NamedType carries the column, so ask the record itself rather
+ # than the class — checking column_names at include time would hit the
+ # database during boot.
+ def locked?
+ has_attribute?(:mutable) && !mutable?
+ end
+
+ def name_is_not_locked
+ return unless locked? && name_changed?
+
+ errors.add(:name, :immutable_named_type)
+ end
+
+ def abort_if_locked
+ return unless locked?
+
+ errors.add(:base, :immutable_named_type)
+ throw(:abort)
end
end
end
diff --git a/spree/core/app/models/spree/calculator/returns/default_refund_amount.rb b/spree/core/app/models/spree/calculator/returns/default_refund_amount.rb
deleted file mode 100644
index 09a05a5a2a..0000000000
--- a/spree/core/app/models/spree/calculator/returns/default_refund_amount.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_dependency 'spree/returns_calculator'
-
-module Spree
- module Calculator::Returns
- class DefaultRefundAmount < ReturnsCalculator
- attr_reader :fulfillment_item
-
- def self.description
- Spree.t(:default_refund_amount)
- end
-
- # The line item's pre_tax_amount already reflects every discount that
- # touches the line — including the line's share of whole-order
- # promotions, which are distributed to line-item Discount rows at
- # application time — so no separate order-level weighting is needed.
- def compute(return_item)
- return 0.0.to_d if return_item.exchange_requested?
-
- @fulfillment_item = return_item.fulfillment_item
- weighted_line_item_pre_tax_amount(return_item)
- end
-
- private
-
- def weighted_line_item_pre_tax_amount(return_item)
- fulfillment_item.line_item.pre_tax_amount * percentage_of_line_item(return_item)
- end
-
- def percentage_of_line_item(return_item)
- return_item.return_quantity / BigDecimal(fulfillment_item.line_item.quantity)
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/claim.rb b/spree/core/app/models/spree/claim.rb
index 89c4f20f9b..ee92c5e30f 100644
--- a/spree/core/app/models/spree/claim.rb
+++ b/spree/core/app/models/spree/claim.rb
@@ -2,9 +2,8 @@ module Spree
# A customer reports a problem — damaged, missing or wrong item — and the
# merchant makes it right without necessarily asking for the goods back.
#
- # This has no equivalent in the legacy chain: merchants either created a
- # manual order or faked it through a return authorization received
- # immediately. Transitions are workflows
+ # New in 6.0 — there was previously no way to model "send a replacement
+ # without asking for the original back". Transitions are workflows
# (docs/plans/6.0-returns-exchanges-claims.md).
class Claim < Spree.base_class
has_prefix_id :claim
@@ -13,6 +12,7 @@ module Spree
include Spree::NumberIdentifier
include Spree::SingleStoreResource
include Spree::HasStatus
+ include Spree::Metafields
include Spree::Metadata
publishes_lifecycle_events
@@ -31,7 +31,7 @@ module Spree
belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :claims
- belongs_to :reason, class_name: 'Spree::ReturnAuthorizationReason', optional: true
+ belongs_to :reason, class_name: 'Spree::ClaimReason', optional: true, inverse_of: :claims
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
has_many :claim_line_items, class_name: 'Spree::ClaimLineItem',
diff --git a/spree/core/app/models/spree/claim_reason.rb b/spree/core/app/models/spree/claim_reason.rb
new file mode 100644
index 0000000000..3b7147bb00
--- /dev/null
+++ b/spree/core/app/models/spree/claim_reason.rb
@@ -0,0 +1,15 @@
+module Spree
+ # Why a customer raised a claim — "arrived damaged", "never arrived",
+ # "wrong item sent". A different vocabulary from {Spree::ReturnReason}:
+ # a claim is about something the merchant got wrong, not about a customer
+ # changing their mind.
+ class ClaimReason < Spree.base_class
+ has_prefix_id :clr
+
+ include Spree::NamedType
+
+ self.whitelisted_ransackable_attributes = %w[name active mutable]
+
+ has_many :claims, class_name: 'Spree::Claim', inverse_of: :reason, dependent: :restrict_with_error
+ end
+end
diff --git a/spree/core/app/models/spree/customer_return.rb b/spree/core/app/models/spree/customer_return.rb
deleted file mode 100644
index 46d6a00f43..0000000000
--- a/spree/core/app/models/spree/customer_return.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-module Spree
- class CustomerReturn < Spree.base_class
- has_prefix_id :cr
-
- include Spree::SingleStoreResource
- include Spree::Core::NumberGenerator.new(prefix: 'CR', length: 9)
- include Spree::NumberIdentifier
- include Spree::Metafields
- include Spree::Metadata
-
- publishes_lifecycle_events
-
- belongs_to :stock_location
- belongs_to :store, class_name: 'Spree::Store', inverse_of: :customer_returns
-
- has_many :reimbursements, inverse_of: :customer_return
- has_many :return_items, inverse_of: :customer_return
- has_many :return_authorizations, through: :return_items
-
- after_create :process_return!
-
- validates :return_items, :stock_location, presence: true
- validate :must_have_return_authorization, on: :create
- validate :return_items_belong_to_same_order
-
- accepts_nested_attributes_for :return_items
-
- extend DisplayMoney
- money_methods :pre_tax_total
-
- self.whitelisted_ransackable_attributes = ['number']
-
- delegate :id, to: :order, prefix: true, allow_nil: true
-
- def completely_decided?
- !return_items.undecided.exists?
- end
-
- def fully_reimbursed?
- completely_decided? && return_items.accepted.includes(:reimbursement).all? { |return_item| return_item.reimbursement.try(:reimbursed?) }
- end
-
- def currency
- order&.currency
- end
-
- # Temporarily tie a customer_return to one order
- def order
- return nil if return_items.blank?
- return nil if return_items.first.inventory_unit.blank?
-
- return_items.first.inventory_unit.order
- end
-
- def pre_tax_total
- return_items.sum(:pre_tax_amount)
- end
-
- def can_create_reimbursement?
- !fully_reimbursed? && completely_decided? && no_pending_reimbursements?
- end
-
- def no_pending_reimbursements?
- if association(:reimbursements).loaded?
- reimbursements.select(&:pending?).empty?
- else
- reimbursements.where(reimbursement_status: :pending).none?
- end
- end
-
- private
-
- def inventory_units
- return_items.flat_map(&:inventory_unit)
- end
-
- def must_have_return_authorization
- if (item = return_items.find { |ri| ri.return_authorization.blank? })
- errors.add(:base, Spree.t(:missing_return_authorization, item_name: item.inventory_unit.variant.name))
- end
- end
-
- def process_return!
- return_items.each(&:receive!)
- # The order-level 'returned' machine state is gone — return lifecycle
- # belongs to the first-class Return models (6.0-returns plan).
- end
-
- def return_items_belong_to_same_order
- if return_items.any? { |return_item| return_item.inventory_unit.order_id != order_id }
- errors.add(:base, Spree.t(:return_items_cannot_be_associated_with_multiple_orders))
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/exchange.rb b/spree/core/app/models/spree/exchange.rb
index 480b56eea8..93e9744f5e 100644
--- a/spree/core/app/models/spree/exchange.rb
+++ b/spree/core/app/models/spree/exchange.rb
@@ -2,10 +2,9 @@ module Spree
# A customer sends items back and gets different ones — a different size,
# colour or product.
#
- # First-class rather than the legacy "a ReturnItem that happens to carry an
- # exchange_variant_id, processed through ReimbursementType::Exchange": you
- # can now ask for all exchanges this month, or every exchange awaiting
- # fulfillment, without digging through return items.
+ # A first-class record rather than a return item that happens to name a
+ # replacement variant, so "all exchanges this month" and "every exchange
+ # awaiting fulfillment" are ordinary queries.
#
# Transitions are workflows (docs/plans/6.0-returns-exchanges-claims.md).
class Exchange < Spree.base_class
@@ -15,6 +14,7 @@ module Spree
include Spree::NumberIdentifier
include Spree::SingleStoreResource
include Spree::HasStatus
+ include Spree::Metafields
include Spree::Metadata
publishes_lifecycle_events
@@ -25,7 +25,7 @@ module Spree
belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :exchanges
belongs_to :stock_location, class_name: 'Spree::StockLocation'
- belongs_to :reason, class_name: 'Spree::ReturnAuthorizationReason', optional: true
+ belongs_to :reason, class_name: 'Spree::ReturnReason', optional: true, inverse_of: :exchanges
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
has_many :exchange_line_items, class_name: 'Spree::ExchangeLineItem',
diff --git a/spree/core/app/models/spree/fulfillment_item.rb b/spree/core/app/models/spree/fulfillment_item.rb
index 049189b4f5..84a753cb77 100644
--- a/spree/core/app/models/spree/fulfillment_item.rb
+++ b/spree/core/app/models/spree/fulfillment_item.rb
@@ -8,13 +8,11 @@ module Spree
belongs_to :variant, -> { with_deleted }, class_name: 'Spree::Variant'
belongs_to :order, class_name: 'Spree::Order'
belongs_to :fulfillment, class_name: 'Spree::Fulfillment', touch: true, optional: true
- has_many :return_items, class_name: 'Spree::ReturnItem', inverse_of: :fulfillment_item
- has_many :return_authorizations, class_name: 'Spree::ReturnAuthorization', through: :return_items
+ has_many :return_line_items, class_name: 'Spree::ReturnLineItem', inverse_of: :fulfillment_item
+ has_many :returns, class_name: 'Spree::Return', through: :return_line_items
belongs_to :line_item, class_name: 'Spree::LineItem'
end
- belongs_to :original_return_item, class_name: 'Spree::ReturnItem'
-
scope :backordered, -> { where status: 'backordered' }
scope :on_hand, -> { where status: 'on_hand' }
scope :on_hand_or_backordered, -> { where status: ['backordered', 'on_hand'] }
@@ -95,10 +93,6 @@ module Spree
split_inventory!(1)
end
- def current_or_new_return_item
- Spree::ReturnItem.from_inventory_unit(self)
- end
-
def additional_tax_total
line_item.additional_tax_total * percentage_of_line_item
end
@@ -108,17 +102,7 @@ module Spree
end
def required_quantity
- return @required_quantity unless @required_quantity.nil?
-
- @required_quantity = if exchanged_unit?
- original_return_item.return_quantity
- else
- line_item.quantity
- end
- end
-
- def exchanged_unit?
- original_return_item_id?
+ @required_quantity ||= line_item.quantity
end
def charged_amount
@@ -139,9 +123,5 @@ module Spree
reload
order.fulfill!
end
-
- def current_return_item
- return_items.not_cancelled.first
- end
end
end
diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rb
index 784f9cf7e1..ea7ae7672a 100644
--- a/spree/core/app/models/spree/order.rb
+++ b/spree/core/app/models/spree/order.rb
@@ -159,19 +159,16 @@ module Spree
has_many :line_items, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::LineItem'
has_many :payments, class_name: 'Spree::Payment'
has_many :payment_sessions, inverse_of: :order, class_name: 'Spree::PaymentSession'
- has_many :return_authorizations, inverse_of: :order, class_name: 'Spree::ReturnAuthorization'
has_many :returns, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::Return'
has_many :exchanges, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::Exchange'
has_many :claims, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::Claim'
has_many :cancellations, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::OrderCancellation'
has_many :approvals, -> { order(:created_at) }, inverse_of: :order, class_name: 'Spree::OrderApproval'
end
- has_many :reimbursements, inverse_of: :order, class_name: 'Spree::Reimbursement'
- has_many :customer_returns, class_name: 'Spree::CustomerReturn', through: :return_authorizations
has_many :fulfillment_items, inverse_of: :order, class_name: 'Spree::FulfillmentItem'
has_many :inventory_units, class_name: 'Spree::FulfillmentItem', inverse_of: :order, deprecated: true
has_many :stock_reservations, class_name: 'Spree::StockReservation', inverse_of: :order, dependent: :destroy
- has_many :return_items, through: :fulfillment_items, class_name: 'Spree::ReturnItem'
+ has_many :return_line_items, through: :returns, class_name: 'Spree::ReturnLineItem', source: :return_line_items
has_many :variants, through: :line_items
has_many :products, through: :variants
has_many :refunds, through: :payments
@@ -535,18 +532,18 @@ module Spree
end
end
+ # Refunds are already netted out of payment_total by
+ # Spree::Carts::RecalculateTotals, so returns and claims need no separate
+ # term here — the legacy reimbursement payout was the only one that sat
+ # outside that sum.
def outstanding_balance
if canceled?
-1 * payment_total
else
- total - (payment_total + reimbursement_paid_total)
+ total - payment_total
end
end
- def reimbursement_paid_total
- reimbursements.sum(&:paid_amount)
- end
-
def name
if (address = bill_address || ship_address)
@@ -910,12 +907,6 @@ module Spree
Spree.order_approve_service.call(order: self)
end
-
- def has_non_reimbursement_related_refunds?
- refunds.non_reimbursement.exists? ||
- payments.offset_payment.exists? # how old versions of spree stored refunds
- end
-
def collect_backend_payment_methods
store.payment_methods.active.available_on_back_end.select { |pm| pm.available_for_order?(self) }
end
diff --git a/spree/core/app/models/spree/permission_sets/configuration_management.rb b/spree/core/app/models/spree/permission_sets/configuration_management.rb
index 2d80c1cb23..171d1e3b0b 100644
--- a/spree/core/app/models/spree/permission_sets/configuration_management.rb
+++ b/spree/core/app/models/spree/permission_sets/configuration_management.rb
@@ -48,8 +48,8 @@ module Spree
# General configuration
can :manage, Spree::RefundReason
- can :manage, Spree::ReimbursementType
can :manage, Spree::ReturnReason
+ can :manage, Spree::ClaimReason
# Channels + per-channel order routing rules
can :manage, Spree::Channel
@@ -57,7 +57,8 @@ module Spree
# Restrictions on immutable types
cannot [:edit, :update], Spree::RefundReason, mutable: false
- cannot [:edit, :update], Spree::ReimbursementType, mutable: false
+ cannot [:edit, :update], Spree::ReturnReason, mutable: false
+ cannot [:edit, :update], Spree::ClaimReason, mutable: false
# Metafield configuration
can :manage, Spree::MetafieldDefinition
diff --git a/spree/core/app/models/spree/permission_sets/order_display.rb b/spree/core/app/models/spree/permission_sets/order_display.rb
index 2ba4c5211b..13d0bef4ee 100644
--- a/spree/core/app/models/spree/permission_sets/order_display.rb
+++ b/spree/core/app/models/spree/permission_sets/order_display.rb
@@ -17,9 +17,6 @@ module Spree
can [:read, :admin], Spree::Discount
can [:read, :admin], Spree::Fee
can [:read, :admin], Spree::LineItem
- can [:read, :admin], Spree::ReturnAuthorization
- can [:read, :admin], Spree::CustomerReturn
- can [:read, :admin], Spree::Reimbursement
can [:read, :admin], Spree::Return
can [:read, :admin], Spree::Exchange
can [:read, :admin], Spree::Claim
diff --git a/spree/core/app/models/spree/permission_sets/order_management.rb b/spree/core/app/models/spree/permission_sets/order_management.rb
index 4d2473dc1f..c969c252c6 100644
--- a/spree/core/app/models/spree/permission_sets/order_management.rb
+++ b/spree/core/app/models/spree/permission_sets/order_management.rb
@@ -17,9 +17,6 @@ module Spree
can :manage, Spree::Discount
can :manage, Spree::Fee
can :manage, Spree::LineItem
- can :manage, Spree::ReturnAuthorization
- can :manage, Spree::CustomerReturn
- can :manage, Spree::Reimbursement
can :manage, Spree::Return
can :manage, Spree::Exchange
can :manage, Spree::Claim
diff --git a/spree/core/app/models/spree/permission_sets/super_user.rb b/spree/core/app/models/spree/permission_sets/super_user.rb
index 842b9a3e1e..3658b077e5 100644
--- a/spree/core/app/models/spree/permission_sets/super_user.rb
+++ b/spree/core/app/models/spree/permission_sets/super_user.rb
@@ -18,7 +18,6 @@ module Spree
cannot :destroy, Spree::Order
can :destroy, Spree::Order, &:can_be_deleted?
cannot [:edit, :update], Spree::RefundReason, mutable: false
- cannot [:edit, :update], Spree::ReimbursementType, mutable: false
# Protect the admin role from modification
cannot [:update, :destroy], Spree::Role, name: ['admin']
diff --git a/spree/core/app/models/spree/refund.rb b/spree/core/app/models/spree/refund.rb
index 906f07b65e..c462406a95 100644
--- a/spree/core/app/models/spree/refund.rb
+++ b/spree/core/app/models/spree/refund.rb
@@ -10,10 +10,7 @@ module Spree
publishes_lifecycle_events
- with_options inverse_of: :refunds do
- belongs_to :payment
- belongs_to :reimbursement, optional: true
- end
+ belongs_to :payment, inverse_of: :refunds
belongs_to :reason, class_name: 'Spree::RefundReason', foreign_key: :refund_reason_id
belongs_to :refunder, class_name: Spree.admin_user_class.to_s, optional: true
# What triggered this refund — a Spree::Return today, later an Exchange
@@ -34,8 +31,6 @@ module Spree
after_create :perform!
after_create :create_log_entry
- scope :non_reimbursement, -> { where(reimbursement_id: nil) }
-
attr_reader :response
delegate :order, :currency, to: :payment
@@ -49,23 +44,17 @@ module Spree
end
alias display_amount money
- class << self
- def total_amount_reimbursed_for(reimbursement)
- reimbursement.refunds.to_a.sum(&:amount)
- end
- end
-
def description
payment.payment_method.name
end
- # return items for the refund
+ # The lines this refund paid for, when it came from a return.
#
- # @return [Array<Spree::ReturnItem>]
- def return_items
- return [] unless reimbursement.present?
+ # @return [Array<Spree::ReturnLineItem>]
+ def return_line_items
+ return [] unless originator.is_a?(Spree::Return)
- reimbursement.customer_return&.return_items || reimbursement.return_items
+ originator.return_line_items.to_a
end
# Returns true if the refund is editable.
diff --git a/spree/core/app/models/spree/refund_reason.rb b/spree/core/app/models/spree/refund_reason.rb
index 3f1d4f281f..658ef0f563 100644
--- a/spree/core/app/models/spree/refund_reason.rb
+++ b/spree/core/app/models/spree/refund_reason.rb
@@ -4,6 +4,8 @@ module Spree
include Spree::NamedType
+ self.whitelisted_ransackable_attributes = %w[name active mutable]
+
RETURN_PROCESSING_REASON = 'Return processing'
ORDER_CANCELED_REASON = 'Order Canceled'
SHIPMENT_CANCELED_REASON = 'Shipment Canceled'
diff --git a/spree/core/app/models/spree/reimbursement.rb b/spree/core/app/models/spree/reimbursement.rb
deleted file mode 100644
index 3248561d7c..0000000000
--- a/spree/core/app/models/spree/reimbursement.rb
+++ /dev/null
@@ -1,167 +0,0 @@
-module Spree
- class Reimbursement < Spree.base_class
- has_prefix_id :reimb
-
- include Spree::Core::NumberGenerator.new(prefix: 'RI', length: 9)
- include Spree::NumberIdentifier
-
- class IncompleteReimbursementError < StandardError; end
-
- with_options inverse_of: :reimbursements do
- belongs_to :order
- belongs_to :customer_return, touch: true, optional: true
- end
-
- with_options inverse_of: :reimbursement do
- has_many :refunds
- has_many :credits, class_name: 'Spree::Reimbursement::Credit'
- has_many :return_items
- end
-
- belongs_to :performed_by, class_name: Spree.admin_user_class.to_s, optional: true
-
- validates :order, presence: true
- validate :validate_return_items_belong_to_same_order
-
- accepts_nested_attributes_for :return_items, allow_destroy: true
-
- scope :reimbursed, -> { where(reimbursement_status: 'reimbursed') }
-
- # The reimbursement_tax_calculator property should be set to an object that responds to "call"
- # and accepts a reimbursement object. Invoking "call" should update the tax fields on the
- # associated ReturnItems.
- # This allows a store to easily integrate with third party tax services.
- class_attribute :reimbursement_tax_calculator
- self.reimbursement_tax_calculator = ReimbursementTaxCalculator
- # A separate attribute here allows you to use a more performant calculator for estimates
- # and a different one (e.g. one that hits a 3rd party API) for the final calculations.
- class_attribute :reimbursement_simulator_tax_calculator
- self.reimbursement_simulator_tax_calculator = ReimbursementTaxCalculator
-
- # The reimbursement_models property should contain an array of all models that provide
- # reimbursements.
- # This allows a store to incorporate custom reimbursement methods that Spree doesn't know about.
- # Each model must implement a "total_amount_reimbursed_for" method.
- # Example:
- # Refund.total_amount_reimbursed_for(reimbursement)
- # See the `reimbursement_generator` property regarding the generation of custom reimbursements.
- class_attribute :reimbursement_models
- self.reimbursement_models = [Refund, Credit]
-
- # The reimbursement_performer property should be set to an object that responds to the following methods:
- # - #perform
- # - #simulate
- # see ReimbursementPerformer for details.
- # This allows a store to customize their reimbursement methods and logic.
- class_attribute :reimbursement_performer
- self.reimbursement_performer = ReimbursementPerformer
-
- # These are called if the call to "reimburse!" succeeds.
- class_attribute :reimbursement_success_hooks
- self.reimbursement_success_hooks = []
-
- # These are called if the call to "reimburse!" fails.
- class_attribute :reimbursement_failure_hooks
- self.reimbursement_failure_hooks = []
-
- delegate :store, :currency, to: :order
-
- state_machine :reimbursement_status, initial: :pending do
- event :errored do
- transition to: :errored, from: :pending
- end
-
- event :reimbursed do
- transition to: :reimbursed, from: [:pending, :errored]
- end
- after_transition to: :reimbursed, do: :publish_reimbursement_reimbursed_event
- end
-
- class << self
- def build_from_customer_return(customer_return)
- order = customer_return.order
- order.reimbursements.build(customer_return: customer_return,
- return_items: customer_return.return_items.accepted.not_reimbursed)
- end
- end
-
- def display_total
- Spree::Money.new(total, currency: order.currency)
- end
-
- def calculated_total
- # rounding every return item individually to handle edge cases for consecutive partial
- # returns where rounding might cause us to try to reimburse more than was originally billed
- return_items.map { |ri| ri.total.to_d.round(2) }.sum
- end
-
- def paid_amount
- reimbursement_models.sum do |model|
- model.total_amount_reimbursed_for(self)
- end
- end
-
- def unpaid_amount
- total - paid_amount
- end
-
- def perform!(performer = nil)
- reimbursement_tax_calculator.call(self)
- reload
- update!(total: calculated_total, performed_by: performer)
-
- reimbursement_performer.perform(self)
-
- if unpaid_amount_within_tolerance?
- reimbursed!
- reimbursement_success_hooks.each { |h| h.call self }
- else
- errored!
- reimbursement_failure_hooks.each { |h| h.call self }
- raise IncompleteReimbursementError, Spree.t('validation.unpaid_amount_not_zero', amount: unpaid_amount)
- end
- end
-
- def simulate
- reimbursement_simulator_tax_calculator.call(self)
- reload
- update!(total: calculated_total)
-
- reimbursement_performer.simulate(self)
- end
-
- def return_items_requiring_exchange
- return_items.select(&:exchange_required?)
- end
-
- private
-
- def publish_reimbursement_reimbursed_event
- publish_event('reimbursement.reimbursed')
- end
-
- def validate_return_items_belong_to_same_order
- if return_items.any? { |ri| ri.inventory_unit.order_id != order_id }
- errors.add(:base, :return_items_order_id_does_not_match)
- end
- end
-
- # If there are multiple different reimbursement types for a single
- # reimbursement we open ourselves to a one-cent rounding error for every
- # type over the first one. This is due to how we round #unpaid_amount and
- # how each reimbursement type will round as well. Since at this point the
- # payments and credits have already been processed, we should allow the
- # reimbursement to show as 'reimbursed' and not 'errored'.
- def unpaid_amount_within_tolerance?
- reimbursement_count = reimbursement_models.size do |model|
- model.total_amount_reimbursed_for(self) > 0
- end
- leniency = if reimbursement_count > 0
- (reimbursement_count - 1) * 0.01.to_d
- else
- 0
- end
- unpaid_amount.abs.between?(0, leniency)
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement/credit.rb b/spree/core/app/models/spree/reimbursement/credit.rb
deleted file mode 100644
index bf9cc5ab5f..0000000000
--- a/spree/core/app/models/spree/reimbursement/credit.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-module Spree
- class Reimbursement::Credit < Spree.base_class
- has_prefix_id :rcred
-
- class_attribute :default_creditable_class
- self.default_creditable_class = nil
-
- belongs_to :reimbursement, inverse_of: :credits
- belongs_to :creditable, polymorphic: true
-
- validates :creditable, presence: true
-
- class << self
- def total_amount_reimbursed_for(reimbursement)
- reimbursement.credits.to_a.sum(&:amount)
- end
- end
-
- def description
- creditable.class.name.demodulize
- end
-
- def display_amount
- Spree::Money.new(amount, currency: creditable.try(:currency) || 'USD')
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement/reimbursement_type_engine.rb b/spree/core/app/models/spree/reimbursement/reimbursement_type_engine.rb
deleted file mode 100644
index d67f4019f3..0000000000
--- a/spree/core/app/models/spree/reimbursement/reimbursement_type_engine.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-module Spree
- class Reimbursement::ReimbursementTypeEngine
- include Spree::Reimbursement::ReimbursementTypeValidator
-
- class_attribute :refund_time_constraint
- self.refund_time_constraint = 90.days
-
- class_attribute :default_reimbursement_type
- self.default_reimbursement_type = Spree::ReimbursementType::OriginalPayment
-
- class_attribute :expired_reimbursement_type
- self.expired_reimbursement_type = Spree::ReimbursementType::OriginalPayment
-
- class_attribute :exchange_reimbursement_type
- self.exchange_reimbursement_type = Spree::ReimbursementType::Exchange
-
- def initialize(return_items)
- @return_items = return_items
- @reimbursement_type_hash = Hash.new { |h, k| h[k] = [] }
- end
-
- def calculate_reimbursement_types
- @return_items.each do |return_item|
- reimbursement_type = calculate_reimbursement_type(return_item)
- @reimbursement_type_hash[reimbursement_type] << return_item if reimbursement_type
- end
-
- @reimbursement_type_hash
- end
-
- private
-
- def calculate_reimbursement_type(return_item)
- return exchange_reimbursement_type if return_item.exchange_required?
- return return_item.override_reimbursement_type.class if return_item.override_reimbursement_type.present?
- if return_item.preferred_reimbursement_type.present?
- return valid_preferred_reimbursement_type?(return_item) ? return_item.preferred_reimbursement_type.class : nil
- end
- return expired_reimbursement_type if past_reimbursable_time_period?(return_item)
-
- default_reimbursement_type
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement/reimbursement_type_validator.rb b/spree/core/app/models/spree/reimbursement/reimbursement_type_validator.rb
deleted file mode 100644
index f6bc117892..0000000000
--- a/spree/core/app/models/spree/reimbursement/reimbursement_type_validator.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Spree
- module Reimbursement::ReimbursementTypeValidator
- def valid_preferred_reimbursement_type?(return_item)
- preferred_type = return_item.preferred_reimbursement_type.class
-
- !past_reimbursable_time_period?(return_item) ||
- preferred_type == expired_reimbursement_type
- end
-
- def past_reimbursable_time_period?(return_item)
- shipped_at = return_item.inventory_unit.shipment.shipped_at
- shipped_at && shipped_at < refund_time_constraint.ago
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_performer.rb b/spree/core/app/models/spree/reimbursement_performer.rb
deleted file mode 100644
index 405618ebb7..0000000000
--- a/spree/core/app/models/spree/reimbursement_performer.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Spree
- class ReimbursementPerformer
- class << self
- class_attribute :reimbursement_type_engine
- self.reimbursement_type_engine = Spree::Reimbursement::ReimbursementTypeEngine
-
- # Simulate performing the reimbursement without actually saving anything or refunding money, etc.
- # This must return an array of objects that respond to the following methods:
- # - #description
- # - #display_amount
- # so they can be displayed in the Admin UI appropriately.
- def simulate(reimbursement)
- execute(reimbursement, true)
- end
-
- # Actually perform the reimbursement
- def perform(reimbursement)
- execute(reimbursement, false)
- end
-
- private
-
- def execute(reimbursement, simulate)
- # Engine reimbursement_type_engine returns hash of preferred reimbursement types pointing at return items
- # {Spree::ReimbursementType::OriginalPayment => [ReturnItem, ...], Spree::ReimbursementType::Exchange => [ReturnItem, ...]}
- reimbursement_type_hash = reimbursement_type_engine.new(reimbursement.return_items).calculate_reimbursement_types
-
- reimbursement_type_hash.flat_map do |reimbursement_type, return_items|
- reimbursement_type.reimburse(reimbursement, return_items, simulate)
- end
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_tax_calculator.rb b/spree/core/app/models/spree/reimbursement_tax_calculator.rb
deleted file mode 100644
index a0aeb41c58..0000000000
--- a/spree/core/app/models/spree/reimbursement_tax_calculator.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-module Spree
- # Tax calculation is broken out at this level to allow easy integration with 3rd party
- # taxation systems. Those systems are usually geared toward calculating all items at once
- # rather than one at a time.
- #
- # To use an alternative tax calculator do this:
- # Spree::ReturnAuthorization.reimbursement_tax_calculator = calculator_object
- # where `calculator_object` is an object that responds to "call" and accepts a reimbursement object
-
- class ReimbursementTaxCalculator
- class << self
- def call(reimbursement)
- reimbursement.return_items.includes(:fulfillment_item).each do |return_item|
- set_tax!(return_item)
- end
- end
-
- private
-
- def set_tax!(return_item)
- calculated_refund = Spree::ReturnItem.refund_amount_calculator.new.compute(return_item)
-
- percent_of_tax = if return_item.pre_tax_amount <= 0 || calculated_refund <= 0
- 0
- else
- return_item.pre_tax_amount / calculated_refund
- end
-
- additional_tax_total = percent_of_tax * return_item.inventory_unit.additional_tax_total
- included_tax_total = percent_of_tax * return_item.inventory_unit.included_tax_total
-
- return_item.update!(additional_tax_total: additional_tax_total,
- included_tax_total: included_tax_total)
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type.rb b/spree/core/app/models/spree/reimbursement_type.rb
deleted file mode 100644
index 10b63a924e..0000000000
--- a/spree/core/app/models/spree/reimbursement_type.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Spree
- class ReimbursementType < Spree.base_class
- has_prefix_id :rtype
-
- include Spree::NamedType
-
- KINDS = %w(Spree::ReimbursementType::Credit
- Spree::ReimbursementType::Exchange
- Spree::ReimbursementType::OriginalPayment
- Spree::ReimbursementType::StoreCredit).freeze
- ORIGINAL = 'original'.freeze
-
- has_many :return_items
-
- # This method will reimburse the return items based on however its child implements it
- # By default it takes a reimbursement, the return items it needs to reimburse, and if
- # it is a simulation or a real reimbursement. This should return an array
- def self.reimburse(_reimbursement, _return_items, _simulate)
- raise 'Implement me'
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/credit.rb b/spree/core/app/models/spree/reimbursement_type/credit.rb
deleted file mode 100644
index 9f0f4fda2b..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/credit.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Spree
- class ReimbursementType::Credit < Spree::ReimbursementType
- extend Spree::ReimbursementType::ReimbursementHelpers
-
- class << self
- def reimburse(reimbursement, return_items, simulate)
- unpaid_amount = return_items.map { |ri| ri.total.to_d.round(2) }.sum
- reimbursement_list, unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate)
- reimbursement_list
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/exchange.rb b/spree/core/app/models/spree/reimbursement_type/exchange.rb
deleted file mode 100644
index ecaae98d27..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/exchange.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Spree::ReimbursementType::Exchange < Spree::ReimbursementType
- def self.reimburse(reimbursement, return_items, simulate)
- return [] unless return_items.present?
-
- exchange = Spree::ReimbursementType::ExchangeProcessor.new(reimbursement.order, return_items)
- exchange.perform! unless simulate
- [exchange]
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb b/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb
deleted file mode 100644
index 7fcb1e08b6..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-module Spree
- class ReimbursementType
- # Legacy exchange execution for the ReturnAuthorization/Reimbursement
- # chain. Renamed out of Spree::Exchange, which is now the first-class
- # exchange model (docs/plans/6.0-returns-exchanges-claims.md); this stays
- # until that chain is dropped.
- class ExchangeProcessor
- class UnableToCreateShipments < StandardError; end
-
- def initialize(order, reimbursement_objects)
- @order = order
- @reimbursement_objects = reimbursement_objects
- end
-
- def description
- @reimbursement_objects.map do |reimbursement_object|
- "#{reimbursement_object.variant.options_text} => #{reimbursement_object.exchange_variant.options_text}"
- end.join(' | ')
- end
-
- def display_amount
- Spree::Money.new @reimbursement_objects.sum(&:total)
- end
-
- def perform!
- new_exchange_inventory_units = @reimbursement_objects.map(&:build_default_exchange_inventory_unit)
- shipments = Spree::Stock::Coordinator.new(@order, new_exchange_inventory_units).shipments
- shipments_units = shipments.flat_map(&:fulfillment_items)
-
- if shipments_units.sum(&:quantity) != new_exchange_inventory_units.sum(&:quantity)
- raise UnableToCreateShipments, 'Could not generate shipments for all items. Out of stock?'
- end
-
- @order.fulfillments += shipments
- @order.save!
-
- shipments.each do |shipment|
- shipment.update!(@order)
- shipment.finalize!
- end
- end
-
- def to_key
- nil
- end
-
- def self.param_key
- 'spree_exchange'
- end
-
- def self.model_name
- Spree::ReimbursementType::ExchangeProcessor
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/original_payment.rb b/spree/core/app/models/spree/reimbursement_type/original_payment.rb
deleted file mode 100644
index a4ff6ef465..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/original_payment.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class Spree::ReimbursementType::OriginalPayment < Spree::ReimbursementType
- extend Spree::ReimbursementType::ReimbursementHelpers
-
- class << self
- def reimburse(reimbursement, return_items, simulate)
- unpaid_amount = return_items.map { |ri| ri.total.to_d.round(2) }.sum
- payments = reimbursement.order.payments.completed
-
- reimbursement_list, unpaid_amount = create_refunds(reimbursement, payments, unpaid_amount, simulate)
- reimbursement_list
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb b/spree/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb
deleted file mode 100644
index b8df070863..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/reimbursement_helpers.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-module Spree
- module ReimbursementType::ReimbursementHelpers
- def create_refunds(reimbursement, payments, unpaid_amount, simulate, reimbursement_list = [])
- payments.each do |payment|
- break if unpaid_amount <= 0
- next unless payment.can_credit?
-
- amount = [unpaid_amount, payment.credit_allowed].min
- reimbursement_list << create_refund(reimbursement, payment, amount, simulate)
- unpaid_amount -= amount
- end
-
- [reimbursement_list, unpaid_amount]
- end
-
- def create_credits(reimbursement, unpaid_amount, simulate, reimbursement_list = [])
- credits = [create_credit(reimbursement, unpaid_amount, simulate)]
- unpaid_amount -= credits.sum(&:amount)
- reimbursement_list += credits
-
- [reimbursement_list, unpaid_amount]
- end
-
- private
-
- def create_refund(reimbursement, payment, amount, simulate)
- refund = reimbursement.refunds.build(
- payment: payment,
- amount: amount,
- reason: Spree::RefundReason.return_processing_reason
- )
-
- simulate ? refund.readonly! : refund.save!
- refund
- end
-
- # If you have multiple methods of crediting a customer, overwrite this method
- # Must return an array of objects the respond to #description, #display_amount
- def create_credit(reimbursement, unpaid_amount, simulate)
- category = Spree::StoreCreditCategory.default_reimbursement_category(category_options(reimbursement))
- creditable = Spree::StoreCredit.new(store_credit_params(category, reimbursement, unpaid_amount))
- credit = reimbursement.credits.build(creditable: creditable, amount: unpaid_amount)
- simulate ? credit.readonly! : credit.save!
- credit
- end
-
- def store_credit_params(category, reimbursement, unpaid_amount)
- {
- customer: reimbursement.order.customer,
- amount: unpaid_amount,
- category: category,
- created_by: reimbursement.order.store.users.first,
- memo: "Refund for uncreditable payments on order #{reimbursement.order.number}",
- currency: reimbursement.order.currency,
- store: reimbursement.order.store
- }
- end
-
- # overwrite if you need options for the default reimbursement category
- def category_options(_reimbursement)
- {}
- end
- end
-end
diff --git a/spree/core/app/models/spree/reimbursement_type/store_credit.rb b/spree/core/app/models/spree/reimbursement_type/store_credit.rb
deleted file mode 100644
index c908fa8cce..0000000000
--- a/spree/core/app/models/spree/reimbursement_type/store_credit.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class Spree::ReimbursementType::StoreCredit < Spree::ReimbursementType
- extend Spree::ReimbursementType::ReimbursementHelpers
-
- class << self
- def reimburse(reimbursement, return_items, simulate)
- unpaid_amount = return_items.sum(&:total).to_d.round(2, :down)
- payments = reimbursement.order.payments.completed.store_credits
-
- # Credit each store credit that was used on the order
- reimbursement_list, unpaid_amount = create_refunds(reimbursement, payments, unpaid_amount, simulate)
-
- # If there is any amount left to pay out to the customer, then create credit with that amount
- if unpaid_amount > 0.0
- reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, reimbursement_list)
- end
-
- reimbursement_list
- end
- end
-end
diff --git a/spree/core/app/models/spree/return.rb b/spree/core/app/models/spree/return.rb
index 69d27be127..ec12376069 100644
--- a/spree/core/app/models/spree/return.rb
+++ b/spree/core/app/models/spree/return.rb
@@ -1,10 +1,9 @@
module Spree
# A customer sends items back and gets their money back.
#
- # Replaces the ReturnAuthorization → CustomerReturn → Reimbursement chain
- # with one record that owns the whole operation
- # (docs/plans/6.0-returns-exchanges-claims.md). The legacy chain still
- # exists and is untouched; this is the surface new code should use.
+ # One record owns the whole operation — permission, physical receipt and
+ # money back (docs/plans/6.0-returns-exchanges-claims.md), replacing the
+ # ReturnAuthorization → CustomerReturn → Reimbursement chain removed in 6.0.
#
# The model holds associations, validations and pure reads only. Every
# transition is a workflow — `Spree::Returns::Receive.call(...)`, never
@@ -18,6 +17,7 @@ module Spree
include Spree::NumberIdentifier
include Spree::SingleStoreResource
include Spree::HasStatus
+ include Spree::Metafields
include Spree::Metadata
publishes_lifecycle_events
@@ -28,7 +28,7 @@ module Spree
belongs_to :store, class_name: 'Spree::Store'
belongs_to :order, class_name: 'Spree::Order', inverse_of: :returns
belongs_to :stock_location, class_name: 'Spree::StockLocation'
- belongs_to :reason, class_name: 'Spree::ReturnAuthorizationReason', optional: true
+ belongs_to :reason, class_name: 'Spree::ReturnReason', optional: true, inverse_of: :returns
# Staff only. Customer-initiated returns leave this nil — the requester
# is always order.customer, so no second association is needed.
belongs_to :created_by, class_name: Spree.admin_user_class.to_s, optional: true
@@ -36,6 +36,7 @@ module Spree
has_many :return_line_items, class_name: 'Spree::ReturnLineItem',
dependent: :destroy, inverse_of: :return
has_many :refunds, class_name: 'Spree::Refund', as: :originator, dependent: :nullify
+ has_many :store_credits, class_name: 'Spree::StoreCredit', as: :originator, dependent: :nullify
validates :order, :stock_location, presence: true
validates :return_line_items, presence: true, on: :create
@@ -53,9 +54,10 @@ module Spree
end
# What has actually been refunded so far — a return can be refunded in
- # more than one step (part to store credit, part to the card).
+ # more than one step (part to store credit, part to the card), and store
+ # credit is its own ledger rather than a Spree::Refund row.
def refunded_total
- refunds.sum(:amount)
+ refunds.sum(:amount) + store_credits.sum(:amount)
end
def refundable_total
@@ -65,5 +67,9 @@ module Spree
def display_refund_total
Spree::Money.new(refund_total, currency: currency)
end
+
+ def display_refunded_total
+ Spree::Money.new(refunded_total, currency: currency)
+ end
end
end
diff --git a/spree/core/app/models/spree/return_authorization.rb b/spree/core/app/models/spree/return_authorization.rb
deleted file mode 100644
index d0b7e2bf13..0000000000
--- a/spree/core/app/models/spree/return_authorization.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-module Spree
- class ReturnAuthorization < Spree.base_class
- has_prefix_id :ra
-
- include Spree::Core::NumberGenerator.new(prefix: 'RA', length: 9)
- include Spree::NumberIdentifier
-
- publishes_lifecycle_events
-
- belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
-
- has_many :return_items, inverse_of: :return_authorization, dependent: :destroy
- with_options through: :return_items do
- has_many :fulfillment_items, class_name: 'Spree::FulfillmentItem'
- has_many :customer_returns
- end
- has_many :inventory_units, through: :return_items, source: :fulfillment_item, deprecated: true
-
- has_many :reimbursements, through: :customer_returns
- has_many :refunds, through: :reimbursements
-
- belongs_to :stock_location
- belongs_to :reason, class_name: 'Spree::ReturnAuthorizationReason', foreign_key: :return_authorization_reason_id
-
- after_save :generate_expedited_exchange_reimbursements
-
- accepts_nested_attributes_for :return_items, allow_destroy: true
-
- validates :order, :reason, :stock_location, presence: true
- validate :must_have_shipped_units, on: :create
-
- # These are called prior to generating expedited exchanges shipments.
- # Should respond to a "call" method that takes the list of return items
- class_attribute :pre_expedited_exchange_hooks
- self.pre_expedited_exchange_hooks = []
-
- state_machine initial: :authorized do
- before_transition to: :canceled, do: :cancel_return_items
- after_transition to: :canceled, do: :publish_return_authorization_canceled_event
-
- event :cancel do
- transition to: :canceled, from: :authorized, if: ->(return_authorization) { return_authorization.can_cancel_return_items? }
- end
- end
-
- extend DisplayMoney
- money_methods :pre_tax_total
-
- self.whitelisted_ransackable_attributes = ['memo', 'number', 'state']
- self.whitelisted_ransackable_associations = ['order']
-
- def pre_tax_total
- return_items.sum(:pre_tax_amount)
- end
-
- def currency
- # FIXME: we should associate ReturnAuthorization with Store
- order.nil? ? Spree::Store.default.default_currency : order.currency
- end
-
- def refundable_amount
- order.pre_tax_item_amount + order.discount_total
- end
-
- def customer_returned_items?
- customer_returns.exists?
- end
-
- def can_cancel_return_items?
- return_items.any?(&:can_cancel?) || return_items.blank?
- end
-
- private
-
- def must_have_shipped_units
- if order.nil? || order.inventory_units.shipped.none?
- errors.add(:order, Spree.t(:has_no_shipped_units))
- end
- end
-
- def cancel_return_items
- return_items.each { |item| item.cancel! if item.can_cancel? }
- end
-
- def publish_return_authorization_canceled_event
- publish_event('return_authorization.canceled')
- end
-
- def generate_expedited_exchange_reimbursements
- return unless Spree::Config[:expedited_exchanges]
-
- items_to_exchange = return_items.select(&:exchange_required?)
- items_to_exchange.each(&:attempt_accept)
- items_to_exchange.select!(&:accepted?)
-
- return if items_to_exchange.blank?
-
- pre_expedited_exchange_hooks.each { |h| h.call items_to_exchange }
-
- reimbursement = Reimbursement.new(return_items: items_to_exchange, order: order)
-
- if reimbursement.save
- reimbursement.perform!
- else
- errors.add(:base, reimbursement.errors.full_messages)
- raise ActiveRecord::RecordInvalid, self
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_authorization_reason.rb b/spree/core/app/models/spree/return_authorization_reason.rb
index 4e613ccd70..249e9d16a8 100644
--- a/spree/core/app/models/spree/return_authorization_reason.rb
+++ b/spree/core/app/models/spree/return_authorization_reason.rb
@@ -1,9 +1,14 @@
-module Spree
- class ReturnAuthorizationReason < Spree.base_class
- has_prefix_id :rar
+# frozen_string_literal: true
- include Spree::NamedType
+module Spree
+ # Deprecation alias for Spree::ReturnReason, renamed in 6.0 along with the
+ # removal of the ReturnAuthorization chain. Retained for one release so
+ # existing code and extensions keep working; removed in 6.1.
+ #
+ # A true constant alias — the class, table (spree_return_reasons), prefix
+ # (rar) and model_name are all Spree::ReturnReason, so is_a?, polymorphic
+ # type strings and class_name: references keep resolving correctly.
+ ReturnAuthorizationReason = ReturnReason
- has_many :return_authorizations, dependent: :restrict_with_error
- end
+ Spree::Deprecation.warn('Spree::ReturnAuthorizationReason is deprecated and will be removed in Spree 6.1. Use Spree::ReturnReason instead.')
end
diff --git a/spree/core/app/models/spree/return_item.rb b/spree/core/app/models/spree/return_item.rb
deleted file mode 100644
index 0c7969099a..0000000000
--- a/spree/core/app/models/spree/return_item.rb
+++ /dev/null
@@ -1,291 +0,0 @@
-module Spree
- class ReturnItem < Spree.base_class
- has_prefix_id :ri
-
- COMPLETED_RECEPTION_STATUSES = %w(received given_to_customer)
-
- class_attribute :return_eligibility_validator
- self.return_eligibility_validator = ReturnItem::EligibilityValidator::Default
-
- def return_quantity=(value)
- @_return_quantity = value.to_i
- end
-
- def pre_tax_amount=(amount)
- self[:pre_tax_amount] = Spree::LocalizedNumber.parse(amount)
- end
-
- def return_quantity
- @_return_quantity.nil? ? inventory_unit.quantity : @_return_quantity
- end
-
- class_attribute :exchange_variant_engine
- self.exchange_variant_engine = ReturnItem::ExchangeVariantEligibility::SameProduct
-
- class_attribute :refund_amount_calculator
- self.refund_amount_calculator = Calculator::Returns::DefaultRefundAmount
-
- with_options inverse_of: :return_items do
- belongs_to :return_authorization
- belongs_to :fulfillment_item, class_name: 'Spree::FulfillmentItem'
- belongs_to :customer_return
- belongs_to :reimbursement
- end
- # @deprecated legacy names — remove in 6.1
- alias_method :inventory_unit, :fulfillment_item
- alias_method :inventory_unit=, :fulfillment_item=
- alias_attribute :inventory_unit_id, :fulfillment_item_id
- has_many :exchange_inventory_units, class_name: 'Spree::FulfillmentItem',
- foreign_key: :original_return_item_id,
- inverse_of: :original_return_item
- belongs_to :exchange_variant, class_name: 'Spree::Variant'
- belongs_to :preferred_reimbursement_type, class_name: 'Spree::ReimbursementType'
- belongs_to :override_reimbursement_type, class_name: 'Spree::ReimbursementType'
- has_one :line_item, through: :fulfillment_item
-
- validate :eligible_exchange_variant
- validate :belongs_to_same_customer_order
- validate :validate_acceptance_status_for_reimbursement
- validates :fulfillment_item, presence: true
- validate :validate_no_other_completed_return_items, on: :create
- validates :return_quantity, numericality: { greater_than_or_equal_to: 1 }
- validate :sufficient_quantity_for_return
-
- after_create :cancel_others, unless: :cancelled?
-
- scope :awaiting_return, -> { where(reception_status: 'awaiting') }
- scope :received, -> { where(reception_status: 'received') }
- scope :not_cancelled, -> { where.not(reception_status: 'cancelled') }
- scope :pending, -> { where(acceptance_status: 'pending') }
- scope :accepted, -> { where(acceptance_status: 'accepted') }
- scope :rejected, -> { where(acceptance_status: 'rejected') }
- scope :manual_intervention_required, -> { where(acceptance_status: 'manual_intervention_required') }
- scope :undecided, -> { where(acceptance_status: %w(pending manual_intervention_required)) }
- scope :decided, -> { where.not(acceptance_status: %w(pending manual_intervention_required)) }
- scope :reimbursed, -> { where.not(reimbursement_id: nil) }
- scope :not_reimbursed, -> { where(reimbursement_id: nil) }
- scope :exchange_requested, -> { where.not(exchange_variant: nil) }
- scope :exchange_processed, -> { joins(:exchange_inventory_units).distinct }
- scope :exchange_required, -> { eager_load(:exchange_inventory_units).where(Spree::FulfillmentItem.table_name => { original_return_item_id: nil }).distinct }
- scope :resellable, -> { where resellable: true }
-
- if Rails::VERSION::STRING >= '7.1.0'
- serialize :acceptance_status_errors, coder: YAML
- else
- serialize :acceptance_status_errors
- end
-
- delegate :eligible_for_return?, :requires_manual_intervention?, to: :validator
- delegate :variant, to: :inventory_unit
- delegate :shipment, to: :inventory_unit
-
- before_create :extract_inventory_unit, unless: -> { inventory_unit.quantity == return_quantity }
- before_create :set_default_pre_tax_amount, unless: :pre_tax_amount_changed?
-
- before_save :set_exchange_pre_tax_amount
-
- state_machine :reception_status, initial: :awaiting do
- after_transition to: :received, do: :attempt_accept
- after_transition to: :received, do: :process_inventory_unit!
- after_transition to: :received, do: :publish_return_item_received_event
-
- event :receive do
- transition to: :received, from: :awaiting
- end
-
- event :cancel do
- transition to: :cancelled, from: :awaiting
- end
- after_transition to: :cancelled, do: :publish_return_item_canceled_event
-
- event :give do
- transition to: :given_to_customer, from: :awaiting
- end
- after_transition to: :given_to_customer, do: :publish_return_item_given_event
- end
-
- extend DisplayMoney
- money_methods :pre_tax_amount, :total
-
- def reception_completed?
- COMPLETED_RECEPTION_STATUSES.include?(reception_status)
- end
-
- state_machine :acceptance_status, initial: :pending do
- event :attempt_accept do
- transition to: :accepted, from: :accepted
- transition to: :accepted, from: :pending, if: ->(return_item) { return_item.eligible_for_return? }
- transition to: :manual_intervention_required, from: :pending, if: ->(return_item) { return_item.requires_manual_intervention? }
- transition to: :rejected, from: :pending
- end
-
- # bypasses eligibility checks
- event :accept do
- transition to: :accepted, from: [:accepted, :pending, :manual_intervention_required]
- end
-
- # bypasses eligibility checks
- event :reject do
- transition to: :rejected, from: [:accepted, :pending, :manual_intervention_required]
- end
-
- # bypasses eligibility checks
- event :require_manual_intervention do
- transition to: :manual_intervention_required, from: [:accepted, :pending, :manual_intervention_required]
- end
-
- after_transition any => any, do: :persist_acceptance_status_errors
- end
-
- def self.from_inventory_unit(inventory_unit)
- not_cancelled.find_by(fulfillment_item: inventory_unit) ||
- new(fulfillment_item: inventory_unit).tap(&:set_default_pre_tax_amount)
- end
-
- def exchange_requested?
- exchange_variant.present?
- end
-
- def exchange_processed?
- exchange_inventory_units.present?
- end
-
- def exchange_required?
- exchange_requested? && !exchange_processed?
- end
-
- def total
- pre_tax_amount + included_tax_total + additional_tax_total
- end
-
- def eligible_exchange_variants
- exchange_variant_engine.eligible_variants(variant)
- end
-
- def build_default_exchange_inventory_unit
- # The inventory unit needs to have the new variant
- # but it also needs to know the original line item
- # for pricing information for if the inventory unit is
- # ever returned. This means that the inventory unit's line_item
- # will have a different variant than the inventory unit itself
- return unless exchange_required?
-
- exchange_inventory_units.build(variant: exchange_variant, line_item: inventory_unit.line_item,
- order: inventory_unit.order, quantity: return_quantity)
- end
-
- def exchange_shipments
- exchange_inventory_units.map(&:shipment).uniq
- end
-
- def set_default_pre_tax_amount
- self.pre_tax_amount = refund_amount_calculator.new.compute(self)
- end
-
- def currency
- return_authorization.try(:currency) || Spree::Store.default.default_currency
- end
-
- private
-
- def persist_acceptance_status_errors
- update(acceptance_status_errors: validator.errors)
- end
-
- def stock_item
- return unless customer_return
-
- Spree::StockItem.find_by(variant_id: inventory_unit.variant_id,
- stock_location_id: customer_return.stock_location_id)
- end
-
- def process_inventory_unit!
- inventory_unit.return!
- if should_restock?
- Spree::StockMovement.create!(
- stock_item_id: stock_item.id,
- quantity: inventory_unit.quantity,
- originator: return_authorization
- )
- end
- end
-
- # This logic is also present in the customer return. The reason for the
- # duplication and not having a validates_associated on the customer_return
- # is that it would lead to duplicate error messages for the customer return.
- # Not specifying a stock location for example would add an error message about
- # the mandatory field when validating the customer return and again when saving
- # the associated return items.
- def belongs_to_same_customer_order
- return unless customer_return && inventory_unit
-
- if customer_return.order_id != inventory_unit.order_id
- errors.add(:base, Spree.t(:return_items_cannot_be_associated_with_multiple_orders))
- end
- end
-
- def eligible_exchange_variant
- return unless exchange_variant && exchange_variant_id_changed?
-
- unless eligible_exchange_variants.include?(exchange_variant)
- errors.add(:base, Spree.t(:invalid_exchange_variant))
- end
- end
-
- def validator
- @validator ||= return_eligibility_validator.new(self)
- end
-
- def validate_acceptance_status_for_reimbursement
- if reimbursement && !accepted?
- errors.add(:reimbursement, :cannot_be_associated_unless_accepted)
- end
- end
-
- def sufficient_quantity_for_return
- # Only perform the check if everything is good so far
- return unless errors.empty? && return_quantity > inventory_unit.quantity
-
- errors.add(:return_quantity, Spree.t(:cannot_return_more_than_bought_quantity))
- end
-
- def extract_inventory_unit
- self.inventory_unit = inventory_unit.split_inventory!(return_quantity)
- end
-
- def set_exchange_pre_tax_amount
- self.pre_tax_amount = 0.0.to_d if exchange_requested?
- end
-
- def validate_no_other_completed_return_items
- other_return_item = Spree::ReturnItem.where(inventory_unit_id: inventory_unit_id,
- reception_status: COMPLETED_RECEPTION_STATUSES).first
-
- if other_return_item
- errors.add(:inventory_unit, :other_completed_return_item_exists, inventory_unit_id: inventory_unit_id,
- return_item_id: other_return_item.id)
- end
- end
-
- def cancel_others
- Spree::ReturnItem.where(inventory_unit_id: inventory_unit_id).where.not(id: id).
- not_cancelled.each(&:cancel!)
- end
-
- def should_restock?
- resellable? && variant.should_track_inventory? && stock_item && Spree::Config[:restock_inventory]
- end
-
- def publish_return_item_received_event
- publish_event('return_item.received')
- end
-
- def publish_return_item_canceled_event
- publish_event('return_item.canceled')
- end
-
- def publish_return_item_given_event
- publish_event('return_item.given')
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/base_validator.rb b/spree/core/app/models/spree/return_item/eligibility_validator/base_validator.rb
deleted file mode 100644
index 460096fd1c..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/base_validator.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::BaseValidator
- attr_reader :errors
-
- def initialize(return_item)
- @return_item = return_item
- @errors = {}
- end
-
- def eligible_for_return?
- raise NotImplementedError, Spree.t(:implement_eligible_for_return)
- end
-
- def requires_manual_intervention?
- raise NotImplementedError, Spree.t(:implement_requires_manual_intervention)
- end
-
- private
-
- def add_error(key, error)
- @errors[key] = error
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/default.rb b/spree/core/app/models/spree/return_item/eligibility_validator/default.rb
deleted file mode 100644
index 6aca480c57..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/default.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::Default < Spree::ReturnItem::EligibilityValidator::BaseValidator
- class_attribute :permitted_eligibility_validators
- self.permitted_eligibility_validators = [
- ReturnItem::EligibilityValidator::OrderCompleted,
- ReturnItem::EligibilityValidator::TimeSincePurchase,
- ReturnItem::EligibilityValidator::RMARequired,
- ReturnItem::EligibilityValidator::InventoryShipped,
- ReturnItem::EligibilityValidator::NoReimbursements
- ]
-
- def eligible_for_return?
- validators.all?(&:eligible_for_return?)
- end
-
- def requires_manual_intervention?
- validators.any?(&:requires_manual_intervention?)
- end
-
- def errors
- validators.map(&:errors).reduce({}, :merge)
- end
-
- private
-
- def validators
- @validators ||= permitted_eligibility_validators.map { |v| v.new(@return_item) }
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb b/spree/core/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb
deleted file mode 100644
index 0547168046..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/inventory_shipped.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::InventoryShipped < Spree::ReturnItem::EligibilityValidator::BaseValidator
- def eligible_for_return?
- if @return_item.inventory_unit.shipped?
- true
- else
- add_error(:inventory_unit_shipped, Spree.t('return_item_inventory_unit_ineligible'))
- false
- end
- end
-
- def requires_manual_intervention?
- @errors.present?
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb b/spree/core/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb
deleted file mode 100644
index 29fbce37c0..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/no_reimbursements.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::NoReimbursements < Spree::ReturnItem::EligibilityValidator::BaseValidator
- def eligible_for_return?
- if Spree::ReturnItem.where(fulfillment_item: @return_item.fulfillment_item).where.not(reimbursement_id: nil).any?
- add_error(:inventory_unit_reimbursed, Spree.t('return_item_inventory_unit_reimbursed'))
- false
- else
- true
- end
- end
-
- def requires_manual_intervention?
- @errors.present?
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/order_completed.rb b/spree/core/app/models/spree/return_item/eligibility_validator/order_completed.rb
deleted file mode 100644
index d6af132e81..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/order_completed.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::OrderCompleted < Spree::ReturnItem::EligibilityValidator::BaseValidator
- def eligible_for_return?
- if @return_item.inventory_unit.order.completed?
- true
- else
- add_error(:order_not_completed, Spree.t('return_item_order_not_completed'))
- false
- end
- end
-
- def requires_manual_intervention?
- false
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/rma_required.rb b/spree/core/app/models/spree/return_item/eligibility_validator/rma_required.rb
deleted file mode 100644
index acad3e382a..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/rma_required.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::RMARequired < Spree::ReturnItem::EligibilityValidator::BaseValidator
- def eligible_for_return?
- if @return_item.return_authorization.present?
- true
- else
- add_error(:rma_required, Spree.t('return_item_rma_ineligible'))
- false
- end
- end
-
- def requires_manual_intervention?
- false
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb b/spree/core/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb
deleted file mode 100644
index 8180abf843..0000000000
--- a/spree/core/app/models/spree/return_item/eligibility_validator/time_since_purchase.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-module Spree
- class ReturnItem::EligibilityValidator::TimeSincePurchase < Spree::ReturnItem::EligibilityValidator::BaseValidator
- def eligible_for_return?
- if (@return_item.inventory_unit.order.completed_at + Spree::Config[:return_eligibility_number_of_days].days) > Time.current
- true
- else
- add_error(:number_of_days, Spree.t('return_item_time_period_ineligible'))
- false
- end
- end
-
- def requires_manual_intervention?
- false
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb b/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb
deleted file mode 100644
index 29cecd714a..0000000000
--- a/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_option_value.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Spree
- module ReturnItem::ExchangeVariantEligibility
- class SameOptionValue
- class_attribute :option_type_restrictions
- self.option_type_restrictions = []
- # This can be configured in an initializer, e.g.:
- # Spree::ReturnItem::ExchangeVariantEligibility::SameOptionValue.option_type_restrictions = ["size", "color"]
- #
- # This restriction causes only variants that share the same option value for the
- # specified option types to be returned. e.g.:
- #
- # option_type_restrictions = ["color", "waist"]
- # Variant: blue pants with 32 waist and 30 inseam
- #
- # can be exchanged for:
- # blue pants with 32 waist and 31 inseam
- #
- # cannot be exchanged for:
- # green pants with 32 waist and 30 inseam
- # blue pants with 34 waist and 32 inseam
-
- def self.eligible_variants(variant)
- product_variants = SameProduct.eligible_variants(variant).includes(option_values: :option_type)
-
- relevant_option_values = variant.option_values.select { |ov| option_type_restrictions.include? ov.option_type.name }
- if relevant_option_values.present?
- product_variants.select { |v| (relevant_option_values & v.option_values) == relevant_option_values }
- else
- product_variants
- end
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb b/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb
deleted file mode 100644
index 34c91f4b58..0000000000
--- a/spree/core/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Spree
- module ReturnItem::ExchangeVariantEligibility
- class SameProduct
- def self.eligible_variants(variant)
- Spree::Variant.where(product_id: variant.product_id).in_stock_or_backorderable
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/return_line_item.rb b/spree/core/app/models/spree/return_line_item.rb
index 77d5f27093..61030cbce7 100644
--- a/spree/core/app/models/spree/return_line_item.rb
+++ b/spree/core/app/models/spree/return_line_item.rb
@@ -1,9 +1,8 @@
module Spree
# One line on a {Spree::Return} — a quantity of a fulfilled item coming back.
#
- # Named ReturnLineItem rather than ReturnItem because the legacy
- # Spree::ReturnItem (part of the ReturnAuthorization chain) is still in
- # service; the two coexist until the legacy chain is dropped.
+ # Named for {Spree::LineItem}, which it mirrors: `quantity` is what the
+ # customer said was coming, `received_quantity` what the warehouse counted.
class ReturnLineItem < Spree.base_class
has_prefix_id :rli
diff --git a/spree/core/app/models/spree/return_reason.rb b/spree/core/app/models/spree/return_reason.rb
new file mode 100644
index 0000000000..849fb0eca2
--- /dev/null
+++ b/spree/core/app/models/spree/return_reason.rb
@@ -0,0 +1,18 @@
+module Spree
+ # Why a customer is sending items back — "wrong size", "changed mind",
+ # "not as described". Shared by returns and exchanges.
+ #
+ # Renamed from Spree::ReturnAuthorizationReason in 6.0 now that the
+ # ReturnAuthorization chain is gone; Spree::ReturnAuthorizationReason
+ # remains as a deprecated alias for one release.
+ class ReturnReason < Spree.base_class
+ has_prefix_id :rar
+
+ include Spree::NamedType
+
+ self.whitelisted_ransackable_attributes = %w[name active mutable]
+
+ has_many :returns, class_name: 'Spree::Return', inverse_of: :reason, dependent: :restrict_with_error
+ has_many :exchanges, class_name: 'Spree::Exchange', inverse_of: :reason, dependent: :restrict_with_error
+ end
+end
diff --git a/spree/core/app/models/spree/returns_calculator.rb b/spree/core/app/models/spree/returns_calculator.rb
deleted file mode 100644
index a590ff436f..0000000000
--- a/spree/core/app/models/spree/returns_calculator.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-module Spree
- class ReturnsCalculator < Calculator
- def compute(_return_item)
- raise NotImplementedError, "Please implement 'compute(return_item)' in your calculator: #{self.class.name}"
- end
- end
-end
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index 683e471744..a6795ca531 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -79,8 +79,9 @@ module Spree
has_many :fulfillments, through: :orders, class_name: 'Spree::Fulfillment'
has_many :shipments, through: :orders, class_name: 'Spree::Fulfillment', source: :fulfillments, deprecated: true
has_many :payments, through: :orders, class_name: 'Spree::Payment'
- has_many :return_authorizations, through: :orders, class_name: 'Spree::ReturnAuthorization'
- # has_many :reimbursements, through: :orders, class_name: 'Spree::Reimbursement' FIXME: we should fetch this via Customer Return
+ has_many :returns, class_name: 'Spree::Return', inverse_of: :store
+ has_many :exchanges, class_name: 'Spree::Exchange', inverse_of: :store
+ has_many :claims, class_name: 'Spree::Claim', inverse_of: :store
# :nullify (not :destroy) — clearing the collection must not cascade into
# Promotion#not_used? / payment records; orphaned rows are detached, not deleted.
@@ -95,7 +96,6 @@ module Spree
has_many :fulfillment_items, through: :variants, class_name: 'Spree::FulfillmentItem'
has_many :inventory_units, through: :variants, class_name: 'Spree::FulfillmentItem', source: :fulfillment_items, deprecated: true
has_many :option_value_variants, through: :variants, class_name: 'Spree::OptionValueVariant'
- has_many :customer_returns, class_name: 'Spree::CustomerReturn', inverse_of: :store
has_many :store_credits, class_name: 'Spree::StoreCredit'
has_many :store_credit_events, through: :store_credits, class_name: 'Spree::StoreCreditEvent'
diff --git a/spree/core/app/models/spree/store_credit_category.rb b/spree/core/app/models/spree/store_credit_category.rb
index 9ac7bfd32f..77431e4be7 100644
--- a/spree/core/app/models/spree/store_credit_category.rb
+++ b/spree/core/app/models/spree/store_credit_category.rb
@@ -35,9 +35,17 @@ module Spree
end
class << self
- def default_reimbursement_category(_options = {})
+ # The category store credit is issued under when a return, exchange or
+ # claim pays the customer back internally.
+ def default_refund_category(_options = {})
Spree::StoreCreditCategory.first
end
+
+ # @deprecated use {.default_refund_category}
+ def default_reimbursement_category(options = {})
+ Spree::Deprecation.warn('Spree::StoreCreditCategory.default_reimbursement_category is deprecated and will be removed in Spree 6.1. Use .default_refund_category instead.')
+ default_refund_category(options)
+ end
end
end
end
diff --git a/spree/core/app/services/spree/seeds/returns_environment.rb b/spree/core/app/services/spree/seeds/returns_environment.rb
index 161a6a71b3..aa90d6b567 100644
--- a/spree/core/app/services/spree/seeds/returns_environment.rb
+++ b/spree/core/app/services/spree/seeds/returns_environment.rb
@@ -3,24 +3,36 @@ module Spree
class ReturnsEnvironment
prepend Spree::ServiceModule::Base
+ RETURN_REASONS = [
+ 'Better price available',
+ 'Missed estimated delivery date',
+ 'Missing parts or accessories',
+ 'Damaged/Defective',
+ 'Different from what was ordered',
+ 'Different from description',
+ 'No longer needed/wanted',
+ 'Accidental order',
+ 'Unauthorized purchase'
+ ].freeze
+
+ # Why the merchant got it wrong, rather than why the customer changed
+ # their mind — see Spree::ClaimReason.
+ CLAIM_REASONS = [
+ 'Arrived damaged',
+ 'Never arrived',
+ 'Wrong item sent',
+ 'Missing item from order',
+ 'Item not as described'
+ ].freeze
+
def call
- Spree::RefundReason.find_or_create_by!(name: 'Return processing', mutable: false)
- [
- 'Better price available',
- 'Missed estimated delivery date',
- 'Missing parts or accessories',
- 'Damaged/Defective',
- 'Different from what was ordered',
- 'Different from description',
- 'No longer needed/wanted',
- 'Accidental order',
- 'Unauthorized purchase',
- ].each do |name|
- Spree::ReturnAuthorizationReason.find_or_create_by!(name: name)
- end
- Spree::ReimbursementType.find_or_create_by!(name: 'Store Credit', type: 'Spree::ReimbursementType::StoreCredit')
- Spree::ReimbursementType.find_or_create_by!(name: 'Exchange', type: 'Spree::ReimbursementType::Exchange')
- Spree::ReimbursementType.find_or_create_by!(name: 'Original payment', type: 'Spree::ReimbursementType::OriginalPayment')
+ # Through the model helper, not a literal — the workflows look this
+ # row up by the same constant, so a hard-coded string here would
+ # silently create a second, unfindable reason if the name ever moves.
+ Spree::RefundReason.return_processing_reason
+
+ RETURN_REASONS.each { |name| Spree::ReturnReason.find_or_create_by!(name: name) }
+ CLAIM_REASONS.each { |name| Spree::ClaimReason.find_or_create_by!(name: name) }
end
end
end
diff --git a/spree/core/app/subscribers/spree/order_status_subscriber.rb b/spree/core/app/subscribers/spree/order_status_subscriber.rb
index 7d89c3b0c2..80bb693dc2 100644
--- a/spree/core/app/subscribers/spree/order_status_subscriber.rb
+++ b/spree/core/app/subscribers/spree/order_status_subscriber.rb
@@ -1,6 +1,6 @@
module Spree
# The trigger side of derive-then-persist statuses: any payment, refund,
- # fulfillment or return-item change recomputes the owning order's
+ # fulfillment or return change recomputes the owning order's
# payment_status / fulfillment_status through the single writer
# (Spree::Orders::UpdateStatuses). Synchronous so API responses right
# after a capture/void/fulfill already carry the fresh status. Cart-owned
@@ -10,7 +10,7 @@ module Spree
'payment.completed', 'payment.voided',
'refund.created', 'refund.updated',
'fulfillment.created', 'fulfillment.updated', 'fulfillment.deleted',
- 'return_item.received', 'return_item.canceled', 'return_item.given',
+ 'return.received', 'return.refunded', 'return.canceled',
async: false
def handle(event)
@@ -27,7 +27,7 @@ module Spree
'payment' => Spree::Payment,
'refund' => Spree::Refund,
'fulfillment' => Spree::Fulfillment,
- 'return_item' => Spree::ReturnItem
+ 'return' => Spree::Return
}[event.resource_type]
return if resource_class.nil?
@@ -38,7 +38,7 @@ module Spree
return if record.nil?
owner = record.try(:owner) || record.try(:order) ||
- record.try(:payment)&.try(:owner) || record.try(:return_authorization)&.order
+ record.try(:payment)&.try(:owner)
owner.is_a?(Spree::Order) ? owner : nil
end
end
diff --git a/spree/core/app/workflows/spree/claims/create.rb b/spree/core/app/workflows/spree/claims/create.rb
index 93823d33df..52f7996e19 100644
--- a/spree/core/app/workflows/spree/claims/create.rb
+++ b/spree/core/app/workflows/spree/claims/create.rb
@@ -13,7 +13,7 @@ module Spree
# @param items [Array<Hash>] `[{ line_item:, quantity:, description:,
# send_replacement:, replacement_variant:, refund_amount: }]`
# @param claim_type [String] one of Spree::Claim.claim_types
- # @param reason [Spree::ReturnAuthorizationReason, nil]
+ # @param reason [Spree::ClaimReason, nil]
# @param memo [String, nil]
# @param created_by [Object, nil] nil for customer self-service
def perform(order:, items:, claim_type: 'other', reason: nil, memo: nil, created_by: nil)
diff --git a/spree/core/app/workflows/spree/claims/resolve.rb b/spree/core/app/workflows/spree/claims/resolve.rb
index a06a74ecd5..d21a52802f 100644
--- a/spree/core/app/workflows/spree/claims/resolve.rb
+++ b/spree/core/app/workflows/spree/claims/resolve.rb
@@ -115,7 +115,7 @@ module Spree
customer: claim.order.customer,
amount: @amount_to_refund,
currency: claim.currency,
- category: Spree::StoreCreditCategory.default_reimbursement_category,
+ category: Spree::StoreCreditCategory.default_refund_category,
created_by: resolver,
originator: claim,
memo: "Claim #{claim.number}"
diff --git a/spree/core/app/workflows/spree/exchanges/create.rb b/spree/core/app/workflows/spree/exchanges/create.rb
index 426ce9649d..965b8c2ab8 100644
--- a/spree/core/app/workflows/spree/exchanges/create.rb
+++ b/spree/core/app/workflows/spree/exchanges/create.rb
@@ -10,7 +10,7 @@ module Spree
# @param order [Spree::Order]
# @param items [Array<Hash>] `[{ fulfillment_item:, new_variant:, quantity: }]`
# @param stock_location [Spree::StockLocation, nil]
- # @param reason [Spree::ReturnAuthorizationReason, nil]
+ # @param reason [Spree::ReturnReason, nil]
# @param memo [String, nil]
# @param created_by [Object, nil] nil for customer self-service
def perform(order:, items:, stock_location: nil, reason: nil, memo: nil, created_by: nil)
diff --git a/spree/core/app/workflows/spree/exchanges/fulfill.rb b/spree/core/app/workflows/spree/exchanges/fulfill.rb
index 9ce5c14f31..85426a568b 100644
--- a/spree/core/app/workflows/spree/exchanges/fulfill.rb
+++ b/spree/core/app/workflows/spree/exchanges/fulfill.rb
@@ -94,7 +94,7 @@ module Spree
customer: exchange.order.customer,
amount: credit_amount,
currency: exchange.currency,
- category: Spree::StoreCreditCategory.default_reimbursement_category,
+ category: Spree::StoreCreditCategory.default_refund_category,
created_by: refunder,
originator: exchange,
memo: "Exchange #{exchange.number}"
diff --git a/spree/core/app/workflows/spree/returns/create.rb b/spree/core/app/workflows/spree/returns/create.rb
index d45d294175..07bd02fa38 100644
--- a/spree/core/app/workflows/spree/returns/create.rb
+++ b/spree/core/app/workflows/spree/returns/create.rb
@@ -16,7 +16,7 @@ module Spree
# @param items [Array<Hash>] `[{ fulfillment_item:, quantity: }]`
# @param stock_location [Spree::StockLocation, nil] where the goods come
# back to; defaults to the location that shipped them
- # @param reason [Spree::ReturnAuthorizationReason, nil]
+ # @param reason [Spree::ReturnReason, nil]
# @param memo [String, nil] customer- or staff-supplied note
# @param created_by [Object, nil] the admin opening it; nil for
# customer self-service
diff --git a/spree/core/app/workflows/spree/returns/refund.rb b/spree/core/app/workflows/spree/returns/refund.rb
index e56a6bfdc4..a6558b65dd 100644
--- a/spree/core/app/workflows/spree/returns/refund.rb
+++ b/spree/core/app/workflows/spree/returns/refund.rb
@@ -79,7 +79,7 @@ module Spree
customer: return_record.order.customer,
amount: @amount_to_refund,
currency: return_record.currency,
- category: Spree::StoreCreditCategory.default_reimbursement_category,
+ category: Spree::StoreCreditCategory.default_refund_category,
created_by: refunder,
originator: return_record,
memo: "Return #{return_record.number}"
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.yml
index 11b0a3839d..7e3a100f4a 100644
--- a/spree/core/config/locales/en.yml
+++ b/spree/core/config/locales/en.yml
@@ -50,8 +50,6 @@ en:
spree/customer_group:
description: Description
name: Name
- spree/customer_return:
- stock_location_id: Stock Location
spree/gift_card:
amount_used: Amount used
expires_at: Expires at
@@ -169,8 +167,6 @@ en:
spree/property:
name: Name
presentation: Presentation
- spree/return_authorization:
- amount: Amount
spree/role:
name: Name
spree/shipment:
@@ -247,6 +243,7 @@ en:
errors:
messages:
blank: can't be blank
+ immutable_named_type: cannot be changed because Spree depends on this record
unregistered_fulfillment_types: 'contains unregistered fulfillment types: %{types}'
models:
spree/allowed_origin:
@@ -350,16 +347,6 @@ en:
attributes:
amount:
greater_than_allowed: is greater than the allowed amount.
- spree/reimbursement:
- attributes:
- base:
- return_items_order_id_does_not_match: One or more of the return items specified do not belong to the same order as the reimbursement.
- spree/return_item:
- attributes:
- inventory_unit:
- other_completed_return_item_exists: "%{inventory_unit_id} has already been taken by return item %{return_item_id}"
- reimbursement:
- cannot_be_associated_unless_accepted: cannot be associated to a return item that is not accepted.
spree/shipping_method:
attributes:
base:
@@ -429,9 +416,6 @@ en:
spree/customer_group_user:
one: Customer Group User
other: Customer Group Users
- spree/customer_return:
- one: Customer Return
- other: Customer Returns
spree/digital:
one: Digital asset
other: Digital assets
@@ -501,18 +485,12 @@ en:
spree/refund_reason:
one: Refund Reason
other: Refund Reasons
- spree/reimbursement:
- one: Reimbursement
- other: Reimbursements
- spree/reimbursement_type:
- one: Reimbursement Type
- other: Reimbursement Types
- spree/return_authorization:
- one: Return Authorization
- other: Return Authorizations
- spree/return_authorization_reason:
- one: Return Authorization Reason
- other: Return Authorization Reasons
+ spree/return:
+ one: Return
+ other: Returns
+ spree/return_reason:
+ one: Return Reason
+ other: Return Reasons
spree/role:
one: Roles
other: Roles
@@ -781,7 +759,6 @@ en:
coupon_codes: Coupon codes
create: Create
create_new: Create new
- create_reimbursement: Create reimbursement
created_at: Created at
created_by: Created by
credit: Credit
@@ -807,8 +784,6 @@ en:
ignore_notice: If you did not request a password reset, you can safely ignore this email. Your password will not be changed.
instructions: We received a request to reset your password. Click the button below to choose a new password.
subject: Password Reset Instructions
- customer_return: Customer Return
- customer_returns: Customer Returns
customer_support_email: Customer Support Email
customers: Customers
cut: Cut
@@ -821,7 +796,6 @@ en:
default_country: Default Country
default_currency: Default currency
default_locale: Default locale
- default_refund_amount: Default Refund Amount
default_shipping_address: Default shipping address
default_stock_location_name: Shop location
default_tax: Default Tax
@@ -1103,7 +1077,6 @@ en:
min: Min
min_quantity: Min Quantity
minimal_amount: Minimal Amount
- missing_return_authorization: Missing Return Authorization for %{item_name}.
month: Month
more: More
move: Move
@@ -1122,7 +1095,6 @@ en:
new_price_list: New Price List
new_product: New Product
new_promotion: New Promotion
- new_return_authorization: New Return Authorization
new_state: New State
new_user: New User
new_variant: New Variant
@@ -1238,7 +1210,6 @@ en:
powered_by: Powered by
pre_tax_amount: Pre-Tax Amount
pre_tax_total: Pre-Tax Total
- preferred_reimbursement_type: Preferred Reimbursement Type
presentation: Presentation
preview: Preview
previous: Previous
@@ -1346,22 +1317,6 @@ en:
registration: Registration
reimburse: Reimburse
reimbursed: Reimbursed
- reimbursement: Reimbursement
- reimbursement_mailer:
- reimbursement_email:
- days_to_send: You have %{days} days to send back any items awaiting exchange.
- dear_customer: Dear %{name},
- exchange_summary: Exchange Summary
- instructions: Your reimbursement has been processed.
- refund_summary: Refund Summary
- store_team: "%{store_name} Team"
- subject: Reimbursement Notification
- thanks: Thank you for your business.
- total_refunded: 'Total refunded: %{total}'
- reimbursement_status: Reimbursement status
- reimbursement_type: Reimbursement type
- reimbursement_types: Reimbursement Types
- reimbursements: Reimbursements
reject: Reject
rejected: Rejected
remember_me: Remember me
@@ -1389,18 +1344,18 @@ en:
resume: resume
resumed: Resumed
return: return
- return_authorization: Return Authorization
- return_authorization_canceled: Return authorization canceled
- return_authorizations: Return Authorizations
return_errors:
outside_window: This order is outside the %{days}-day return window
- return_item_inventory_unit_ineligible: Return item's inventory unit must be shipped
- return_item_inventory_unit_reimbursed: Return item's inventory unit is already reimbursed
- return_item_order_not_completed: Return item's order must be completed
- return_item_rma_ineligible: Return item requires an RMA
- return_item_time_period_ineligible: Return item is outside the eligible time period
- return_items: Return Items
- return_items_cannot_be_associated_with_multiple_orders: Return items cannot be associated with multiple orders.
+ return_mailer:
+ refunded_email:
+ dear_customer: Dear %{name},
+ instructions: Your return for order %{number} has been refunded.
+ refund_summary: Refund Summary
+ returned_items: Returned Items
+ store_team: "%{store_name} Team"
+ subject: Return Refunded
+ thanks: Thank you for your business.
+ total_refunded: 'Total refunded: %{total}'
return_quantity: Return Quantity
returned: Returned
returns: Returns
diff --git a/spree/core/db/migrate/20260805100001_rename_return_authorization_reasons_to_return_reasons.rb b/spree/core/db/migrate/20260805100001_rename_return_authorization_reasons_to_return_reasons.rb
new file mode 100644
index 0000000000..4662b117a5
--- /dev/null
+++ b/spree/core/db/migrate/20260805100001_rename_return_authorization_reasons_to_return_reasons.rb
@@ -0,0 +1,18 @@
+class RenameReturnAuthorizationReasonsToReturnReasons < ActiveRecord::Migration[8.1]
+ def change
+ rename_table :spree_return_authorization_reasons, :spree_return_reasons
+
+ # Claim reasons are a separate vocabulary from return reasons — "arrived
+ # damaged" and "never arrived" are not answers to "why are you sending
+ # this back" (docs/plans/decisions.md 2026-08-05). Claims already carry a
+ # generic reason_id; it now points here instead of at return reasons.
+ create_table :spree_claim_reasons do |t|
+ t.string :name, null: false
+ t.boolean :active, null: false, default: true
+ t.boolean :mutable, null: false, default: true
+ t.timestamps
+ end
+
+ add_index :spree_claim_reasons, :name, unique: true
+ end
+end
diff --git a/spree/core/db/sample_data/orders.rb b/spree/core/db/sample_data/orders.rb
index 5d0b9b3554..505354fa8e 100644
--- a/spree/core/db/sample_data/orders.rb
+++ b/spree/core/db/sample_data/orders.rb
@@ -134,6 +134,17 @@ end
# event subscribers, so recompute explicitly.
orders.each { |order| order.reload.update_statuses! }
-# Reimbursement
+# A return in progress, so the admin has something to look at. Built through
+# the workflows rather than by direct writes — they own every transition.
first_complete_order = Spree::Order.complete.first
-Spree::Reimbursement.create(order: first_complete_order) if first_complete_order
+if first_complete_order && first_complete_order.fulfillment_items.any?
+ fulfillment_item = first_complete_order.fulfillment_items.first
+
+ Spree::Returns::Create.call(
+ order: first_complete_order,
+ items: [{ fulfillment_item: fulfillment_item, quantity: 1 }],
+ stock_location: fulfillment_item.fulfillment&.stock_location || Spree::StockLocation.first,
+ reason: Spree::ReturnReason.first,
+ memo: 'Sample return'
+ )
+end
diff --git a/spree/core/lib/spree/core/engine.rb b/spree/core/lib/spree/core/engine.rb
index ab64245add..0e456df81f 100644
--- a/spree/core/lib/spree/core/engine.rb
+++ b/spree/core/lib/spree/core/engine.rb
@@ -347,9 +347,10 @@ module Spree
Rails.application.config.spree.metafields.enabled_resources = [
Spree::Address,
Spree::Asset,
+ Spree::Claim,
Spree::Collection,
Spree::CreditCard,
- Spree::CustomerReturn,
+ Spree::Exchange,
Spree::GiftCard,
Spree::Image,
Spree::LineItem,
@@ -364,6 +365,7 @@ module Spree
Spree::ProductType,
Spree::Promotion,
Spree::Refund,
+ Spree::Return,
Spree::Fulfillment,
Spree::DeliveryMethod,
Spree::StockItem,
diff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rb
index 90bc0a5055..15715879aa 100644
--- a/spree/core/lib/spree/permitted_attributes.rb
+++ b/spree/core/lib/spree/permitted_attributes.rb
@@ -11,7 +11,6 @@ module Spree
:cms_section_attributes,
:custom_domain_attributes,
:customer_group_attributes,
- :customer_return_attributes,
:digital_attributes,
:digital_link_attributes,
:export_attributes,
@@ -47,11 +46,9 @@ module Spree
:promotion_action_attributes,
:refund_attributes,
:refund_reason_attributes,
- :reimbursement_attributes,
- :reimbursement_type_attributes,
:report_attributes,
- :return_authorization_attributes,
- :return_authorization_reason_attributes,
+ :return_reason_attributes,
+ :claim_reason_attributes,
:role_attributes,
:shipment_attributes,
:shipping_method_attributes,
@@ -113,11 +110,6 @@ module Spree
@@customer_group_attributes = [:name, :description]
- @@customer_return_attributes = [:stock_location_id, {
- return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount,
- :acceptance_status, :exchange_variant_id, :resellable, :return_quantity]
- }]
-
@@digital_attributes = [:attachment, :variant_id]
@@digital_link_attributes = [:access_counter]
@@ -210,30 +202,17 @@ module Spree
@@refund_attributes = [:amount, :refund_reason_id]
- @@refund_reason_attributes = [:name, :active, :mutable]
-
- @@reimbursement_attributes = [return_items_attributes: [:id, :override_reimbursement_type_id, :pre_tax_amount, :exchange_variant_id]]
-
- @@reimbursement_type_attributes = [:name, :type, :active, :mutable]
+ # `mutable` is deliberately absent: core seeds reasons it looks up by name
+ # (RefundReason::RETURN_PROCESSING_REASON) and marks them immutable, so a
+ # client that could flip the flag could then rename or delete the record
+ # that lookup depends on.
+ @@refund_reason_attributes = [:name, :active]
@@report_attributes = [:type, :date_from, :date_to, :currency]
- @@return_authorization_attributes = [
- :amount, :memo, :stock_location_id, :inventory_units_attributes,
- :return_authorization_reason_id, {
- return_items_attributes: [
- :_destroy,
- :id, :inventory_unit_id,
- :preferred_reimbursement_type_id,
- :return_authorization_id, :returned, :pre_tax_amount,
- :acceptance_status, :exchange_variant_id, :resellable, :return_quantity
- ]
- }
- ]
-
- @@return_authorization_reason_attributes = [:name, :active]
+ @@return_reason_attributes = [:name, :active]
- @@return_item_attributes = [:inventory_unit_id, :return_authorization_id, :returned, :pre_tax_amount, :acceptance_status, :exchange_variant_id, :resellable, :return_quantity]
+ @@claim_reason_attributes = [:name, :active]
@@role_attributes = [:name]
diff --git a/spree/core/lib/spree/testing_support/factories/customer_return_factory.rb b/spree/core/lib/spree/testing_support/factories/customer_return_factory.rb
deleted file mode 100644
index 068e23465d..0000000000
--- a/spree/core/lib/spree/testing_support/factories/customer_return_factory.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-FactoryBot.define do
- # for the case when you want to supply existing return items instead of generating some
- factory :customer_return_without_return_items, class: Spree::CustomerReturn do
- association(:stock_location, factory: :stock_location)
-
- before(:create) do |customer_return, _evaluator|
- if customer_return.store.nil?
- default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil
- store = default_store || create(:store)
-
- customer_return.store = store
- end
- end
-
- factory :customer_return, class: Spree::CustomerReturn do
- transient do
- line_items_count { 1 }
- return_items_count { line_items_count }
- end
-
- before(:create) do |customer_return, evaluator|
- shipped_order = create(:shipped_order, line_items_count: evaluator.line_items_count, store: customer_return.store)
-
- shipped_order.fulfillment_items.take(evaluator.return_items_count).each do |inventory_unit|
- customer_return.return_items << build(:return_item, inventory_unit: inventory_unit)
- end
- end
-
- factory :customer_return_with_accepted_items do
- after(:create) do |customer_return|
- customer_return.return_items.each(&:accept!)
- end
- end
- end
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/reimbursement_credit_factory.rb b/spree/core/lib/spree/testing_support/factories/reimbursement_credit_factory.rb
deleted file mode 100644
index 8a03944383..0000000000
--- a/spree/core/lib/spree/testing_support/factories/reimbursement_credit_factory.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-FactoryBot.define do
- factory :reimbursement_credit, class: Spree::Reimbursement::Credit do
- reimbursement
-
- amount { 100.00 }
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/reimbursement_factory.rb b/spree/core/lib/spree/testing_support/factories/reimbursement_factory.rb
deleted file mode 100644
index aeec6d325f..0000000000
--- a/spree/core/lib/spree/testing_support/factories/reimbursement_factory.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-FactoryBot.define do
- factory :reimbursement, class: Spree::Reimbursement do
- transient do
- return_items_count { 1 }
- end
-
- customer_return { create(:customer_return_with_accepted_items, line_items_count: return_items_count) }
-
- before(:create) do |reimbursement, _evaluator|
- reimbursement.order ||= reimbursement.customer_return.order
- if reimbursement.return_items.empty?
- reimbursement.return_items = reimbursement.customer_return.return_items
- end
- end
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/reimbursement_type_factory.rb b/spree/core/lib/spree/testing_support/factories/reimbursement_type_factory.rb
deleted file mode 100644
index 1ba226a6cf..0000000000
--- a/spree/core/lib/spree/testing_support/factories/reimbursement_type_factory.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-FactoryBot.define do
- factory :reimbursement_type, class: Spree::ReimbursementType do
- sequence(:name) { |n| "Reimbursement Type #{n}" }
- active { true }
- mutable { true }
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/return_authorization_factory.rb b/spree/core/lib/spree/testing_support/factories/return_authorization_factory.rb
deleted file mode 100644
index f9ef13bba5..0000000000
--- a/spree/core/lib/spree/testing_support/factories/return_authorization_factory.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-FactoryBot.define do
- factory :return_authorization, class: Spree::ReturnAuthorization do
- association(:order, factory: :shipped_order)
- association(:stock_location, factory: :stock_location)
- association(:reason, factory: :return_authorization_reason)
-
- memo { 'Items were broken' }
- end
-
- factory :new_return_authorization, class: Spree::ReturnAuthorization do
- association(:order, factory: :shipped_order)
- association(:stock_location, factory: :stock_location)
- association(:reason, factory: :return_authorization_reason)
- end
-
- factory :return_authorization_reason, class: Spree::ReturnAuthorizationReason do
- sequence(:name) { |n| "Defect #{n}" }
- active { true }
- mutable { false }
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/return_item_factory.rb b/spree/core/lib/spree/testing_support/factories/return_item_factory.rb
deleted file mode 100644
index 09f2114bee..0000000000
--- a/spree/core/lib/spree/testing_support/factories/return_item_factory.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-FactoryBot.define do
- factory :return_item, class: Spree::ReturnItem do
- association(:inventory_unit, factory: :inventory_unit, state: :shipped, strategy: :create)
- association(:return_authorization, factory: :return_authorization, strategy: :create)
-
- factory :exchange_return_item do
- after(:build) do |return_item|
- # set track_inventory to false to ensure it passes the in_stock check
- return_item.inventory_unit.variant.update_column(:track_inventory, false)
- return_item.exchange_variant = return_item.inventory_unit.variant
- end
- end
- end
-end
diff --git a/spree/core/lib/spree/testing_support/factories/return_reason_factory.rb b/spree/core/lib/spree/testing_support/factories/return_reason_factory.rb
new file mode 100644
index 0000000000..7d2953b23b
--- /dev/null
+++ b/spree/core/lib/spree/testing_support/factories/return_reason_factory.rb
@@ -0,0 +1,13 @@
+FactoryBot.define do
+ factory :return_reason, class: Spree::ReturnReason do
+ sequence(:name) { |n| "Return Reason #{n}" }
+ active { true }
+ mutable { true }
+ end
+
+ factory :claim_reason, class: Spree::ClaimReason do
+ sequence(:name) { |n| "Claim Reason #{n}" }
+ active { true }
+ mutable { true }
+ end
+end
diff --git a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml
index 985d7fb318..6500aa44c9 100644
--- a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml
+++ b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml
@@ -121,6 +121,37 @@ steps:
migration. spree_adjustments stays intact as the rollback source.
Idempotent — orders that already have typed rows are skipped.
+ - id: migrate_returns
+ name: "Move returns onto the new returns models"
+ task: "spree:upgrade:migrate_returns"
+ notes: |
+ Converts each ReturnAuthorization into a Spree::Return, or a
+ Spree::Exchange when any of its return items named an exchange variant,
+ copying line items with their received quantities and refundable
+ amounts. Refunds produced through a reimbursement are re-pointed at the
+ new record via the polymorphic originator, so the money history stays
+ visible in the admin.
+
+ Run AFTER migrate_adjustments_to_typed_rows, which freezes orders
+ carrying ReturnAuthorization adjustments for exactly this step.
+
+ Reads the legacy tables by name (the legacy models are gone in 6.0) and
+ writes history without validation, so rows referencing deleted variants
+ or stock locations still copy. The legacy tables stay in place as a
+ safety net and are dropped in 6.1.
+
+ Resumable by construction: the legacy number is copied onto the new
+ record and uniquely indexed there, so the task scopes itself to the
+ authorizations whose number isn't present yet. An interrupted run picks
+ up where it stopped and re-running when nothing is left is a no-op —
+ no cursor to track, no state to reset. Tune the load size with
+ BATCH_SIZE (default 500).
+
+ A row that can't be migrated is reported and skipped, not fatal — one
+ unconvertible authorization must not block a release. The task therefore
+ exits 0 even when rows failed, so read the printed list: every failure is
+ retried by simply running the task again.
+
- id: backfill_delivery_and_stock_store_ids
name: "Bind delivery methods and stock locations to the default store"
task: "spree:backfill_delivery_and_stock_store_ids"
diff --git a/spree/core/lib/tasks/migrate_returns.rake b/spree/core/lib/tasks/migrate_returns.rake
new file mode 100644
index 0000000000..151e7c6a93
--- /dev/null
+++ b/spree/core/lib/tasks/migrate_returns.rake
@@ -0,0 +1,269 @@
+# Defined here rather than in lib/spree/core/ — this is a one-release upgrade
+# step that dies with the legacy tables in 6.1, not engine infrastructure.
+# Same placement as Spree::TypedAdjustmentsMigration in the sibling task.
+module Spree
+ # Copies the legacy ReturnAuthorization chain onto the 6.0 Return and
+ # Exchange models. Driven by `rake spree:upgrade:migrate_returns`.
+ #
+ # Reads the legacy tables through throwaway model classes rather than the
+ # legacy models, which no longer exist in 6.0. Historical rows are written
+ # with `save(validate: false)`: they can reference deleted variants and
+ # stock locations that today's validations reject, and refusing to copy
+ # history is worse than copying it imperfectly.
+ #
+ # Resumable by construction. The legacy `number` is copied onto the new
+ # record and uniquely indexed there, so the work still outstanding is a
+ # query — `where.not(number: already_migrated)` — rather than tracked
+ # state. An interrupted run picks up exactly where it stopped, a re-run is
+ # a no-op, and there is no cursor or checkpoint that can drift out of sync
+ # with what was actually written.
+ class ReturnsMigrator
+ LEGACY_TABLE = 'spree_return_authorizations'.freeze
+
+ def initialize(batch_size: 500)
+ @batch_size = batch_size
+ @returns = 0
+ @exchanges = 0
+ @skipped = 0
+ @failed = []
+ # Schema facts, fixed for the life of the run. The column outlives the
+ # table by a release: Spree::Refund stopped declaring the association
+ # in 6.0 and the column drops in 6.1.
+ @relink_refunds = connection.table_exists?('spree_reimbursements') &&
+ connection.column_exists?(Spree::Refund.table_name, :reimbursement_id)
+ end
+
+ # @return [Hash, nil] counts, or nil when there is nothing to migrate
+ def call
+ return nil unless connection.table_exists?(LEGACY_TABLE)
+
+ pending.find_each(batch_size: batch_size) do |authorization|
+ migrate_one(authorization)
+ end
+
+ { returns: @returns, exchanges: @exchanges, skipped: @skipped, failed: @failed }
+ end
+
+ private
+
+ attr_reader :batch_size
+
+ def connection
+ ActiveRecord::Base.connection
+ end
+
+ # Authorizations whose number hasn't been carried across yet.
+ #
+ # Two subqueries rather than a plucked IN-list: on a resumed run over a
+ # large store the list would be every number already migrated, shipped back
+ # as bind params. Both sides hit the unique index on `number`. Same shape as
+ # migrate_users_to_customers' `where.not(id: customer_model.select(:id))`.
+ def pending
+ legacy_authorization.
+ where.not(number: Spree::Return.select(:number)).
+ where.not(number: Spree::Exchange.select(:number))
+ end
+
+ def legacy_authorization
+ @legacy_authorization ||= Class.new(Spree.base_class) do
+ self.table_name = LEGACY_TABLE
+ def self.name = 'LegacyReturnAuthorization'
+ end
+ end
+
+ def legacy_item
+ @legacy_item ||= Class.new(Spree.base_class) do
+ self.table_name = 'spree_return_items'
+ def self.name = 'LegacyReturnItem'
+ end
+ end
+
+ def migrate_one(authorization)
+ items = legacy_item.where(return_authorization_id: authorization.id).to_a
+ order = Spree::Order.find_by(id: authorization.order_id)
+
+ if items.empty? || order.nil?
+ @skipped += 1
+ return
+ end
+
+ # One lookup for the whole authorization rather than one per item.
+ fulfillment_items = Spree::FulfillmentItem.
+ where(id: items.filter_map(&:fulfillment_item_id).uniq).index_by(&:id)
+
+ exchange = items.any? { |item| item.exchange_variant_id.present? }
+
+ ActiveRecord::Base.transaction do
+ record =
+ if exchange
+ build_exchange(authorization, items, order, fulfillment_items)
+ else
+ build_return(authorization, items, order, fulfillment_items)
+ end
+
+ relink_refunds(items, record)
+ end
+
+ # After the transaction commits, never before: a row that raises is
+ # recorded in @failed only, so the counts and the failure list can't
+ # both claim the same authorization.
+ exchange ? @exchanges += 1 : @returns += 1
+ rescue StandardError => error
+ @failed << "##{authorization.id} (#{authorization.number || 'no number'}): #{error.message}"
+ end
+
+ # A legacy authorization only ever reached "authorized" or "canceled";
+ # how far the return actually got is recorded on its items instead.
+ #
+ # `settled_as` is what a reimbursed row becomes: a Return was refunded,
+ # an Exchange was fulfilled — money back on an exchange is the price
+ # difference, which the legacy chain settled at reimbursement time.
+ def status_for(authorization, items, settled_as: 'refunded')
+ return 'canceled' if authorization.state == 'canceled'
+ return settled_as if items.any? { |item| item.reimbursement_id.present? }
+ return 'received' if items.any? { |item| item.reception_status == 'received' }
+
+ 'approved'
+ end
+
+ # The header both record types share: same attributes, same preserved
+ # number, same unvalidated save. Only the class and the settled status
+ # differ, and keeping this in one place is what stops the two save paths
+ # drifting apart.
+ def build_header(klass, authorization, order, status)
+ record = klass.new(
+ store: order.store,
+ order: order,
+ stock_location_id: authorization.stock_location_id,
+ reason_id: authorization.return_authorization_reason_id,
+ memo: authorization.memo,
+ status: status,
+ created_at: authorization.created_at,
+ updated_at: authorization.updated_at
+ )
+ # Required, not an optimisation: NumberGenerator assigns the number in a
+ # before_validation hook, which save!(validate: false) below skips — so
+ # without this the NOT NULL constraint on `number` rejects the row. The
+ # legacy number is also what makes a re-run idempotent, so a generated
+ # one would break resumption as well as lose the link to history.
+ #
+ # A legacy row with no number can't participate in either, so it falls
+ # back to a generated one: copying it once is better than refusing it,
+ # and the `skipped` tally below keeps a re-run from duplicating it.
+ record.number = authorization.number.presence || record.generate_permalink(klass)
+ record.save!(validate: false)
+ record
+ end
+
+ def build_return(authorization, items, order, fulfillment_items)
+ record = build_header(Spree::Return, authorization, order, status_for(authorization, items))
+
+ items.each do |item|
+ fulfillment_item = fulfillment_items[item.fulfillment_item_id]
+
+ record.return_line_items.new(
+ line_attributes_for(item, fulfillment_item).merge(
+ variant_id: fulfillment_item&.variant_id,
+ pre_tax_amount: item.pre_tax_amount,
+ resellable: item.resellable
+ )
+ ).save!(validate: false)
+ end
+
+ record
+ end
+
+ def build_exchange(authorization, items, order, fulfillment_items)
+ record = build_header(
+ Spree::Exchange, authorization, order,
+ status_for(authorization, items, settled_as: 'fulfilled')
+ )
+
+ items.each do |item|
+ next if item.exchange_variant_id.blank?
+
+ fulfillment_item = fulfillment_items[item.fulfillment_item_id]
+
+ record.exchange_line_items.new(
+ line_attributes_for(item, fulfillment_item).merge(
+ original_variant_id: fulfillment_item&.variant_id,
+ new_variant_id: item.exchange_variant_id
+ )
+ ).save!(validate: false)
+ end
+
+ record
+ end
+
+ def line_attributes_for(item, fulfillment_item)
+ {
+ fulfillment_item_id: item.fulfillment_item_id,
+ line_item_id: fulfillment_item&.line_item_id,
+ quantity: 1,
+ received_quantity: item.reception_status == 'received' ? 1 : 0,
+ created_at: item.created_at,
+ updated_at: item.updated_at
+ }
+ end
+
+ # Keeps the money history attached to something the admin can still see.
+ #
+ # Addresses spree_refunds.reimbursement_id by column name rather than
+ # through the association: Spree::Refund no longer declares it in 6.0,
+ # and the column itself is dropped in 6.1.
+ def relink_refunds(items, record)
+ return unless @relink_refunds
+
+ reimbursement_ids = items.filter_map(&:reimbursement_id).uniq
+ return if reimbursement_ids.empty?
+
+ Spree::Refund.where(reimbursement_id: reimbursement_ids).
+ update_all(originator_type: record.class.to_s, originator_id: record.id)
+ end
+ end
+end
+
+namespace :spree do
+ namespace :upgrade do
+ desc <<~DESC
+ Moves the legacy ReturnAuthorization chain onto the 6.0 returns models
+ (docs/plans/6.0-returns-exchanges-claims.md).
+
+ Each +spree_return_authorizations+ row becomes a +Spree::Return+, or a
+ +Spree::Exchange+ when any of its return items named an exchange variant.
+ Refunds produced through a reimbursement are re-pointed at the new record
+ via the polymorphic +originator+, so the money history stays attached to
+ something the admin can still see.
+
+ Resumable by construction: the legacy +number+ is copied onto the new
+ record and uniquely indexed there, so the task scopes itself to the
+ authorizations whose number isn't present yet. An interrupted run picks
+ up exactly where it stopped, and re-running when nothing is left is a
+ no-op — no cursor to track, no state to reset.
+
+ Reads the legacy tables by name through throwaway model classes; the
+ legacy models themselves are deleted in 6.0. The tables stay in place as
+ a rollback safety net and drop in 6.1.
+
+ Set BATCH_SIZE to tune how many authorizations are loaded at a time
+ (default 500).
+ DESC
+ task migrate_returns: :environment do
+ options = ENV['BATCH_SIZE'] ? { batch_size: ENV['BATCH_SIZE'].to_i } : {}
+ result = Spree::ReturnsMigrator.new(**options).call
+
+ if result.nil?
+ puts ' spree_return_authorizations not found — nothing to migrate.'
+ next
+ end
+
+ puts " Migrated #{result[:returns]} return(s) and #{result[:exchanges]} exchange(s); " \
+ "skipped #{result[:skipped]}."
+
+ if result[:failed].any?
+ puts " #{result[:failed].size} row(s) could not be migrated — re-run to retry them:"
+ result[:failed].each { |line| puts " #{line}" }
+ end
+ end
+ end
+end
diff --git a/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb b/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
index 7ea389e98f..627a6bdf06 100644
--- a/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
+++ b/spree/core/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb
@@ -43,18 +43,4 @@ describe Spree::Core::ControllerHelpers::StrongParameters, type: :controller do
end
end
- # Regression test for #13003
- describe 'return_quantity in permitted attributes' do
- it 'includes return_quantity in return_authorization nested return_items_attributes' do
- nested = Spree::PermittedAttributes.return_authorization_attributes.find { |a| a.is_a?(Hash) && a.key?(:return_items_attributes) }
- expect(nested).not_to be_nil
- expect(nested[:return_items_attributes]).to include(:return_quantity)
- end
-
- it 'includes return_quantity in customer_return nested return_items_attributes' do
- nested = Spree::PermittedAttributes.customer_return_attributes.find { |a| a.is_a?(Hash) && a.key?(:return_items_attributes) }
- expect(nested).not_to be_nil
- expect(nested[:return_items_attributes]).to include(:return_quantity)
- end
- end
end
diff --git a/spree/core/spec/lib/tasks/migrate_returns_spec.rb b/spree/core/spec/lib/tasks/migrate_returns_spec.rb
new file mode 100644
index 0000000000..67b71d8b01
--- /dev/null
+++ b/spree/core/spec/lib/tasks/migrate_returns_spec.rb
@@ -0,0 +1,169 @@
+require 'spec_helper'
+
+# The migrator lives in the rake file (it is a one-release upgrade step, not
+# engine infrastructure), so load it the way the task does.
+load Spree::Core::Engine.root.join('lib', 'tasks', 'migrate_returns.rake') unless defined?(Spree::ReturnsMigrator)
+
+RSpec.describe Spree::ReturnsMigrator do
+ let(:order) { create(:shipped_order, store: @default_store) }
+ let(:fulfillment_item) { order.fulfillment_items.first }
+ let(:stock_location) { order.fulfillments.first.stock_location }
+
+ subject(:migrate) { described_class.new.call }
+
+ # The legacy models are gone, so seed the old tables the same way the
+ # migrator reads them — by name.
+ def insert_authorization(state: 'authorized', number: 'RA100')
+ ActiveRecord::Base.connection.insert(<<~SQL.squish)
+ INSERT INTO spree_return_authorizations
+ (number, state, order_id, memo, stock_location_id, created_at, updated_at)
+ VALUES
+ ('#{number}', '#{state}', #{order.id}, 'Legacy memo', #{stock_location.id},
+ '#{1.day.ago.to_fs(:db)}', '#{1.day.ago.to_fs(:db)}')
+ SQL
+ end
+
+ def insert_item(authorization_id, exchange_variant_id: nil, reception_status: 'awaiting',
+ reimbursement_id: nil, pre_tax_amount: 10.0)
+ ActiveRecord::Base.connection.insert(<<~SQL.squish)
+ INSERT INTO spree_return_items
+ (return_authorization_id, fulfillment_item_id, exchange_variant_id, reception_status,
+ reimbursement_id, pre_tax_amount, resellable, created_at, updated_at)
+ VALUES
+ (#{authorization_id}, #{fulfillment_item.id},
+ #{exchange_variant_id || 'NULL'}, '#{reception_status}',
+ #{reimbursement_id || 'NULL'}, #{pre_tax_amount}, 1,
+ '#{1.day.ago.to_fs(:db)}', '#{1.day.ago.to_fs(:db)}')
+ SQL
+ end
+
+ context 'with a plain return authorization' do
+ before do
+ id = insert_authorization
+ insert_item(id, reception_status: 'received')
+ end
+
+ it 'creates a return carrying the legacy number and memo' do
+ expect { migrate }.to change(Spree::Return, :count).by(1)
+
+ return_record = Spree::Return.last
+ expect(return_record.number).to eq('RA100')
+ expect(return_record.memo).to eq('Legacy memo')
+ expect(return_record.order).to eq(order)
+ expect(return_record.stock_location).to eq(stock_location)
+ expect(return_record.status).to eq('received')
+ end
+
+ it 'reports what it did' do
+ expect(migrate).to include(returns: 1, exchanges: 0, skipped: 0)
+ end
+
+ it 'copies the line with its received quantity and amount' do
+ migrate
+
+ line = Spree::Return.last.return_line_items.first
+ expect(line.fulfillment_item).to eq(fulfillment_item)
+ expect(line.variant).to eq(fulfillment_item.variant)
+ expect(line.pre_tax_amount).to eq(10.0)
+ expect(line.received_quantity).to eq(1)
+ end
+ end
+
+ context 'when a return item names an exchange variant' do
+ let(:replacement) { create(:variant) }
+
+ before do
+ id = insert_authorization(number: 'RA200')
+ insert_item(id, exchange_variant_id: replacement.id, reception_status: 'received')
+ end
+
+ it 'creates an exchange rather than a return' do
+ expect { migrate }.to change(Spree::Exchange, :count).by(1).and change(Spree::Return, :count).by(0)
+
+ exchange = Spree::Exchange.last
+ expect(exchange.number).to eq('RA200')
+
+ line = exchange.exchange_line_items.first
+ expect(line.original_variant).to eq(fulfillment_item.variant)
+ expect(line.new_variant).to eq(replacement)
+ end
+ end
+
+ context 'when the authorization was canceled' do
+ before do
+ id = insert_authorization(state: 'canceled', number: 'RA300')
+ insert_item(id)
+ end
+
+ it 'carries the canceled status across' do
+ migrate
+ expect(Spree::Return.last.status).to eq('canceled')
+ end
+ end
+
+ # The scoping that replaces a cursor: already-migrated numbers are excluded
+ # by the query, so a re-run is a no-op and an interrupted run resumes.
+ describe 'scoping to unmigrated rows' do
+ before do
+ id = insert_authorization(number: 'RA400')
+ insert_item(id)
+ end
+
+ # A fresh instance per run — each invocation is a separate `rake` call.
+ it 'does not duplicate rows on a second run' do
+ migrate
+ expect { described_class.new.call }.not_to change(Spree::Return, :count)
+ end
+
+ it 'migrates only what is left when a previous run was interrupted' do
+ migrate
+ later = insert_authorization(number: 'RA401')
+ insert_item(later)
+
+ expect { described_class.new.call }.to change(Spree::Return, :count).by(1)
+ expect(Spree::Return.pluck(:number)).to match_array(%w[RA400 RA401])
+ end
+ end
+
+ # NumberGenerator runs in a before_validation hook, which save!(validate: false)
+ # skips — so a numberless legacy row would hit the NOT NULL constraint without
+ # an explicit fallback.
+ context 'when the legacy row has no number' do
+ before do
+ id = ActiveRecord::Base.connection.insert(<<~SQL.squish)
+ INSERT INTO spree_return_authorizations
+ (number, state, order_id, stock_location_id, created_at, updated_at)
+ VALUES
+ (NULL, 'authorized', #{order.id}, #{stock_location.id},
+ '#{1.day.ago.to_fs(:db)}', '#{1.day.ago.to_fs(:db)}')
+ SQL
+ insert_item(id)
+ end
+
+ it 'migrates it with a generated number' do
+ expect { migrate }.to change(Spree::Return, :count).by(1)
+ expect(Spree::Return.last.number).to be_present
+ end
+
+ it 'does not report it as both migrated and failed' do
+ result = migrate
+ expect(result[:failed]).to be_empty
+ expect(result[:returns]).to eq(1)
+ end
+ end
+
+ context 'when the authorization has no items' do
+ before { insert_authorization(number: 'RA500') }
+
+ it 'skips it rather than creating an invalid return' do
+ expect { migrate }.not_to change(Spree::Return, :count)
+ expect(described_class.new.call).to include(skipped: 1)
+ end
+ end
+
+ context 'when there is nothing to migrate' do
+ it 'reports zero counts' do
+ expect(migrate).to include(returns: 0, exchanges: 0)
+ end
+ end
+end
diff --git a/spree/core/spec/models/spree/admin_user_spec.rb b/spree/core/spec/models/spree/admin_user_spec.rb
index 122210b465..02a4f7f9e9 100644
--- a/spree/core/spec/models/spree/admin_user_spec.rb
+++ b/spree/core/spec/models/spree/admin_user_spec.rb
@@ -53,7 +53,7 @@ describe Spree.admin_user_class, type: :model do
let!(:gift_card_batches) { create_list(:gift_card_batch, 2, created_by: admin_user, amount: 100, prefix: 'TEST') }
let!(:gift_cards) { create_list(:gift_card, 2, created_by: admin_user) }
let!(:refunds) { create_list(:refund, 2, refunder: admin_user, amount: 1) }
- let!(:reimbursements) { create_list(:reimbursement, 2, performed_by: admin_user) }
+ let!(:returns) { create_list(:return, 2, created_by: admin_user) }
let!(:reports) { create_list(:report, 2, user: admin_user) }
let!(:store_credits) { create_list(:store_credit, 2, created_by: admin_user) }
let!(:exports) { create_list(:export, 2, user: admin_user) }
@@ -66,7 +66,7 @@ describe Spree.admin_user_class, type: :model do
expect(gift_card_batches.all? { |batch| batch.reload.created_by_id.nil? }).to be_truthy
expect(gift_cards.all? { |gift_card| gift_card.reload.created_by_id.nil? }).to be_truthy
expect(refunds.all? { |refund| refund.reload.refunder_id.nil? }).to be_truthy
- expect(reimbursements.all? { |reimbursement| reimbursement.reload.performed_by_id.nil? }).to be_truthy
+ expect(returns.all? { |return_record| return_record.reload.created_by_id.nil? }).to be_truthy
expect(store_credits.all? { |store_credit| store_credit.reload.created_by_id.nil? }).to be_truthy
end
end
diff --git a/spree/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb b/spree/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb
deleted file mode 100644
index 773ab7c005..0000000000
--- a/spree/core/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'spec_helper'
-
-describe Spree::Calculator::Returns::DefaultRefundAmount, type: :model do
- subject { calculator.compute(return_item) }
-
- let(:order) { create(:order) }
- let(:line_item_quantity) { 2 }
- let(:item_price) { 100.0 }
- let(:pre_tax_amount) { line_item_quantity * item_price }
- let(:line_item) { create(:line_item, price: item_price, quantity: line_item_quantity) }
- let(:inventory_unit) { build(:inventory_unit, order: order, line_item: line_item, quantity: 1) }
- let(:return_item) { build(:return_item, inventory_unit: inventory_unit) }
- let(:calculator) { Spree::Calculator::Returns::DefaultRefundAmount.new }
-
- before { order.line_items << line_item }
-
- context 'not an exchange' do
- context 'no promotions or taxes' do
- it { is_expected.to eq pre_tax_amount / line_item_quantity }
- end
-
- context 'with a discount on the line item' do
- let(:discount_amount) { -10.0 }
-
- before do
- create(:discount, order: order, line_item: line_item, amount: discount_amount, label: 'Discount', kind: 'manual')
- order.recalculate_totals!
- line_item.reload
- end
-
- it { is_expected.to eq (pre_tax_amount - discount_amount.abs) / line_item_quantity }
- end
-
- context 'with a fulfillment-level discount' do
- let!(:shipment) { create(:shipment, order: order, cost: 50) }
-
- before do
- create(:discount, order: order, fulfillment: shipment, amount: -50, label: 'Free shipping', kind: 'promotion')
- order.recalculate_totals!
- end
-
- it 'does not affect the line item refund' do
- is_expected.to eq pre_tax_amount / line_item_quantity
- end
- end
- end
-
- context 'an exchange' do
- let(:return_item) { build(:exchange_return_item) }
-
- it { is_expected.to eq 0.0 }
- end
-end
diff --git a/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb b/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb
index f3a8a242aa..a3776bc089 100644
--- a/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb
+++ b/spree/core/spec/models/spree/concerns/admin_user_methods_spec.rb
@@ -12,7 +12,9 @@ describe Spree::AdminUserMethods do
it { expect(admin_user).to have_many(:created_gift_cards) }
it { expect(admin_user).to have_many(:created_gift_card_batches) }
it { expect(admin_user).to have_many(:refunded_refunds) }
- it { expect(admin_user).to have_many(:performed_reimbursements) }
+ it { expect(admin_user).to have_many(:created_returns) }
+ it { expect(admin_user).to have_many(:created_exchanges) }
+ it { expect(admin_user).to have_many(:created_claims) }
it { expect(admin_user).to have_many(:created_store_credits) }
it { expect(admin_user).to have_many(:reports) }
it { expect(admin_user).to have_many(:exports) }
@@ -142,7 +144,7 @@ describe Spree::AdminUserMethods do
let!(:gift_card) { create(:gift_card, created_by: admin_user) }
let!(:gift_card_batch) { create(:gift_card_batch, created_by: admin_user, amount: 100, prefix: 'TEST') }
let!(:refund) { create(:refund, refunder: admin_user, amount: 1) }
- let!(:reimbursement) { create(:reimbursement, performed_by: admin_user) }
+ let!(:return_record) { create(:return, created_by: admin_user) }
let!(:store_credit) { create(:store_credit, created_by: admin_user) }
let!(:report) { create(:report, user: admin_user) }
let!(:export) { create(:export, user: admin_user) }
@@ -172,9 +174,9 @@ describe Spree::AdminUserMethods do
expect(refund.reload.refunder_id).to be_nil
end
- it 'nullifies performed_by_id on reimbursements' do
+ it 'nullifies created_by_id on returns' do
admin_user.destroy
- expect(reimbursement.reload.performed_by_id).to be_nil
+ expect(return_record.reload.created_by_id).to be_nil
end
it 'nullifies created_by_id on store credits' do
diff --git a/spree/core/spec/models/spree/concerns/named_type_spec.rb b/spree/core/spec/models/spree/concerns/named_type_spec.rb
new file mode 100644
index 0000000000..4e9238e04b
--- /dev/null
+++ b/spree/core/spec/models/spree/concerns/named_type_spec.rb
@@ -0,0 +1,55 @@
+require 'spec_helper'
+
+RSpec.describe Spree::NamedType do
+ # RefundReason is the one core model that seeds immutable records, so it is
+ # the honest subject for the lock guard.
+ describe 'immutable records' do
+ let!(:locked) { Spree::RefundReason.return_processing_reason }
+
+ it 'refuses a rename' do
+ locked.name = 'Something else'
+
+ expect(locked.save).to be(false)
+ expect(locked.errors[:name]).to be_present
+ end
+
+ it 'refuses a destroy' do
+ expect { locked.destroy }.not_to change(Spree::RefundReason, :count)
+ expect(locked.errors[:base]).to be_present
+ end
+
+ it 'still allows deactivating it' do
+ expect(locked.update(active: false)).to be(true)
+ end
+
+ it 'reports that it cannot be deleted' do
+ expect(locked.can_be_deleted?).to be(false)
+ end
+ end
+
+ describe 'ordinary records' do
+ let!(:reason) { create(:return_reason, name: 'Wrong size') }
+
+ it 'can be renamed' do
+ expect(reason.update(name: 'Too small')).to be(true)
+ end
+
+ it 'can be deleted' do
+ expect { reason.destroy }.to change(Spree::ReturnReason, :count).by(-1)
+ end
+
+ it 'reports that it can be deleted' do
+ expect(reason.can_be_deleted?).to be(true)
+ end
+ end
+
+ # StoreCreditCategory has no mutable column; the guard must not assume one.
+ describe 'a NamedType without a mutable column' do
+ it 'behaves normally' do
+ category = create(:store_credit_category, name: 'Refund')
+
+ expect(category.update(name: 'Goodwill')).to be(true)
+ expect(category.can_be_deleted?).to be(true)
+ end
+ end
+end
diff --git a/spree/core/spec/models/spree/customer_return_spec.rb b/spree/core/spec/models/spree/customer_return_spec.rb
deleted file mode 100644
index bada15f534..0000000000
--- a/spree/core/spec/models/spree/customer_return_spec.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-require 'spec_helper'
-
-describe Spree::CustomerReturn, type: :model do
- before do
- allow_any_instance_of(Spree::Order).to receive_messages(return!: true)
- end
-
- it_behaves_like 'metadata'
-
- describe 'lifecycle events', events: true do
- describe 'customer_return.created' do
- it 'publishes created event when record is created' do
- customer_return = build(:customer_return_without_return_items, store: create(:store))
- shipped_order = create(:shipped_order, line_items_count: 1, store: customer_return.store)
- customer_return.return_items << build(:return_item, inventory_unit: shipped_order.inventory_units.first)
-
- expect(customer_return).to receive(:publish_event).with('customer_return.created')
- allow(customer_return).to receive(:publish_event).with(anything)
-
- customer_return.save!
- end
- end
-
- describe 'customer_return.updated' do
- it 'publishes updated event when record is updated' do
- record = create(:customer_return)
- expect(record).to receive(:publish_event).with('customer_return.updated')
- allow(record).to receive(:publish_event).with(anything)
-
- Timecop.travel(1.minute.from_now) do
- record.update_attribute(:updated_at, Time.current)
- end
- end
- end
-
- describe 'customer_return.deleted' do
- it 'publishes deleted event when record is destroyed' do
- record = create(:customer_return)
- expect(record).to receive(:publish_event).with('customer_return.deleted', kind_of(Hash))
- allow(record).to receive(:publish_event).with(anything)
-
- record.destroy!
- end
- end
- end
-
- describe '.validation' do
- describe '#must_have_return_authorization' do
- subject { customer_return.valid? }
-
- let(:customer_return) { build(:customer_return, store: create(:store)) }
-
- let(:inventory_unit) { create(:inventory_unit) }
- let(:return_item) { build(:return_item, inventory_unit: inventory_unit) }
-
- before do
- customer_return.return_items << return_item
- end
-
- context 'return item does not belong to return authorization' do
- before do
- return_item.return_authorization = nil
- end
-
- it 'is not valid' do
- expect(subject).to eq false
- end
-
- it 'adds an error message' do
- subject
- expect(customer_return.errors.full_messages).to include(Spree.t(:missing_return_authorization, item_name: inventory_unit.variant.name))
- end
- end
-
- context 'return item belongs to return authorization' do
- it 'is valid' do
- expect(subject).to eq true
- end
- end
- end
-
- describe '#return_items_belong_to_same_order' do
- subject { customer_return.valid? }
-
- let(:customer_return) { build(:customer_return, store: create(:store)) }
-
- let(:first_inventory_unit) { create(:inventory_unit) }
- let(:first_return_item) { build(:return_item, inventory_unit: first_inventory_unit) }
-
- let(:second_inventory_unit) { create(:inventory_unit, order: second_order) }
- let(:second_return_item) { build(:return_item, inventory_unit: second_inventory_unit) }
-
- before do
- customer_return.return_items << first_return_item
- customer_return.return_items << second_return_item
- end
-
- context 'return items are part of different orders' do
- let(:second_order) { create(:order) }
-
- it 'is not valid' do
- expect(subject).to eq false
- end
-
- it 'adds an error message' do
- subject
- expect(customer_return.errors.full_messages).to include(Spree.t(:return_items_cannot_be_associated_with_multiple_orders))
- end
- end
-
- context 'return items are part of the same order' do
- let(:second_order) { first_inventory_unit.order }
-
- it 'is valid' do
- expect(subject).to eq true
- end
- end
- end
- end
-
- describe 'whitelisted_ransackable_attributes' do
- it { expect(Spree::CustomerReturn.whitelisted_ransackable_attributes).to eq(%w(number)) }
- end
-
- describe '#display_pre_tax_total' do
- subject { customer_return.display_pre_tax_total.to_s }
-
- let(:pre_tax_amount) { 15.0 }
- let(:customer_return) { create(:customer_return, line_items_count: 2) }
-
- before do
- Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(pre_tax_amount: pre_tax_amount)
- end
-
- it { is_expected.to eq '$30.00' }
- end
-
- describe '#pre_tax_total' do
- subject { customer_return.pre_tax_total }
-
- let(:pre_tax_amount) { 15.0 }
- let(:customer_return) { create(:customer_return, line_items_count: 2) }
-
- before do
- Spree::ReturnItem.where(customer_return_id: customer_return.id).update_all(pre_tax_amount: pre_tax_amount)
- end
-
- it "returns the sum of the return item's pre_tax_amount" do
- expect(subject).to eq (pre_tax_amount * 2)
- end
- end
-
- describe '#display_pre_tax_total' do
- let(:customer_return) { Spree::CustomerReturn.new }
-
- it 'returns a Spree::Money' do
- allow(customer_return).to receive_messages(pre_tax_total: 21.22)
- expect(customer_return.display_pre_tax_total).to eq(Spree::Money.new(21.22))
- end
- end
-
- describe '#currency' do
- subject { customer_return.currency }
-
- let(:return_item) { create(:return_item) }
- let(:customer_return) { build(:customer_return, return_items: [return_item]) }
- let(:order) { create(:order, currency: test_currency) }
- let(:test_currency) { 'EUR' }
-
- before { return_item.inventory_unit.update(order: order)}
-
- it { is_expected.to eq test_currency }
- end
-
- describe '#order' do
- subject { customer_return.order }
-
- let(:return_item) { create(:return_item) }
- let(:customer_return) { build(:customer_return, return_items: [return_item]) }
-
- it "returns the order associated with the return item's inventory unit" do
- expect(subject).to eq return_item.inventory_unit.order
- end
-
- context 'return item without inventory unit' do
- before do
- return_item.inventory_unit.destroy
- return_item.reload
- end
-
- it 'returns nil' do
- expect(subject).to be_nil
- end
- end
- end
-
- describe '#order_id' do
- subject { customer_return.order_id }
-
- context 'return item is not associated yet' do
- let(:customer_return) { build(:customer_return) }
-
- it 'is nil' do
- expect(subject).to be_nil
- end
- end
-
- context 'has an associated return item' do
- let(:return_item) { create(:return_item) }
- let(:customer_return) { build(:customer_return, return_items: [return_item]) }
-
- it "is the return item's inventory unit's order id" do
- expect(subject).to eq return_item.inventory_unit.order.id
- end
- end
- end
-
- context '.after_save' do
- let(:inventory_unit) { create(:inventory_unit, state: 'shipped', order: create(:shipped_order)) }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
-
- context 'to the initial stock location' do
- it 'marks all inventory units are returned' do
- create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: inventory_unit.shipment.stock_location_id)
- expect(inventory_unit.reload.state).to eq 'returned'
- end
-
- it 'updates the stock item counts in the stock location' do
- expect do
- create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: inventory_unit.shipment.stock_location_id)
- end.to change { inventory_unit.find_stock_item.count_on_hand }.by(1)
- end
-
- context 'with Config.track_inventory_levels == false' do
- before do
- Spree::Config.track_inventory_levels = false
- expect(Spree::StockItem).not_to receive(:find_by)
- expect(Spree::StockMovement).not_to receive(:create!)
- end
-
- it 'does not update the stock item counts in the stock location' do
- count_on_hand = inventory_unit.find_stock_item.count_on_hand
- create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: inventory_unit.shipment.stock_location_id)
- expect(inventory_unit.find_stock_item.count_on_hand).to eql count_on_hand
- end
- end
- end
-
- context 'to a different stock location' do
- let!(:new_stock_location) { create(:stock_location, name: 'other', propagate_all_variants: true) }
-
- before do
- perform_enqueued_jobs
- end
-
- it 'updates the stock item counts in new stock location' do
- expect do
- create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: new_stock_location.id)
- end.to change {
- Spree::StockItem.where(variant_id: inventory_unit.variant_id, stock_location_id: new_stock_location.id).first.count_on_hand
- }.by(1)
- end
-
- it 'does not raise an error when no stock item exists in the stock location' do
- inventory_unit.find_stock_item.destroy
- expect { create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: new_stock_location.id) }.not_to raise_error
- end
-
- it 'does not update the stock item counts in the original stock location' do
- count_on_hand = inventory_unit.find_stock_item.count_on_hand
- create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: new_stock_location.id)
- expect(inventory_unit.find_stock_item.count_on_hand).to eq(count_on_hand)
- end
- end
- end
-
- describe '#fully_reimbursed?' do
- subject { customer_return.fully_reimbursed? }
-
- let(:customer_return) { create(:customer_return) }
-
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
-
- context 'when some return items are undecided' do
- it { is_expected.to be false }
- end
-
- context 'when all return items are decided' do
- context 'when all return items are rejected' do
- before { customer_return.return_items.each(&:reject!) }
-
- it { is_expected.to be true }
- end
-
- context 'when all return items are accepted' do
- before { customer_return.return_items.each(&:accept!) }
-
- context 'when some return items have no reimbursement' do
- it { is_expected.to be false }
- end
-
- context 'when all return items have a reimbursement' do
- let!(:reimbursement) { create(:reimbursement, customer_return: customer_return) }
-
- context 'when some reimbursements are not reimbursed' do
- it { is_expected.to be false }
- end
-
- context 'when all reimbursements are reimbursed' do
- before { reimbursement.perform! }
-
- it { is_expected.to be true }
- end
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/inventory_unit_spec.rb b/spree/core/spec/models/spree/inventory_unit_spec.rb
index e32619e391..7c7b3f66cd 100644
--- a/spree/core/spec/models/spree/inventory_unit_spec.rb
+++ b/spree/core/spec/models/spree/inventory_unit_spec.rb
@@ -148,41 +148,6 @@ describe Spree::InventoryUnit, type: :model do
end
end
- describe '#current_or_new_return_item' do
- subject { inventory_unit.current_or_new_return_item }
-
- before { allow(inventory_unit).to receive_messages(pre_tax_amount: 100.0) }
-
- context 'associated with a return item' do
- let(:return_item) { create(:return_item) }
- let(:inventory_unit) { return_item.inventory_unit }
-
- it 'returns a persisted return item' do
- expect(subject).to be_persisted
- end
-
- it "returns it's associated return_item" do
- expect(subject).to eq return_item
- end
-
- it 'connects return_authorizations' do
- expect(inventory_unit.return_authorizations).to eq [return_item.return_authorization]
- end
- end
-
- context 'no associated return item' do
- let(:inventory_unit) { create(:inventory_unit) }
-
- it 'returns a new return item' do
- expect(subject).not_to be_persisted
- end
-
- it 'associates itself to the new return_item' do
- expect(subject.inventory_unit).to eq inventory_unit
- end
- end
- end
-
describe '#additional_tax_total' do
subject do
build(:inventory_unit, line_item: line_item)
diff --git a/spree/core/spec/models/spree/order/payment_spec.rb b/spree/core/spec/models/spree/order/payment_spec.rb
index 2073e68551..8c804f7c45 100644
--- a/spree/core/spec/models/spree/order/payment_spec.rb
+++ b/spree/core/spec/models/spree/order/payment_spec.rb
@@ -148,27 +148,26 @@ module Spree
expect(order.outstanding_balance).to be_within(0.001).of(-2.00)
end
- it 'incorporates refund reimbursements' do
- # Creates an order w/total 20
- reimbursement = create :reimbursement
- order = reimbursement.order
- # Sync totals (the factory leaves the delivery repricing unapplied),
- # then set the payment amount to the order total of 20
- order.recalculate_totals!
- order.payments.first.update_column :amount, order.total
- # Creates a refund of 20
- create :refund, amount: order.total,
- payment: order.payments.first,
- reimbursement: reimbursement
- order = reimbursement.order.reload
- # Update the order totals so payment_total goes to 0 reflecting the refund..
+ # Refunds — whatever triggered them — are netted out of payment_total by
+ # the totals workflow, so the money handed back reappears as balance the
+ # order no longer has covered. There is no separate reimbursement term.
+ it 'treats a refund issued for a return as reducing what was paid' do
+ order = create(:completed_order_with_totals)
+ calculator = order.fulfillments.first.delivery_method.calculator
+
+ calculator.set_preference(:amount, order.fulfillments.first.cost)
+ calculator.save!
+
+ order.payments << create(:payment, state: :completed, order: order, amount: order.total)
+ return_record = create(:received_return, order: order, store: order.store)
+
+ create(:refund, amount: 10, payment: order.payments.first, originator: return_record)
order.recalculate_totals!
- # Order Total - (Payment Total + Reimbursed)
- # 20 - (0 + 20) = 0
- expect(order.outstanding_balance).to eq 0
+
+ expect(order.outstanding_balance).to eq 10
end
- it 'does not incorporate refunds without a reimbursement' do
+ it 'treats a manual refund the same way' do
order = create(:completed_order_with_totals)
calculator = order.fulfillments.first.delivery_method.calculator
@@ -179,8 +178,7 @@ module Spree
create(:refund, amount: 10, payment: order.payments.first)
order.recalculate_totals!
- # Order Total - (Payment Total + Reimbursed)
- # 10 - (0 + 0) = 0
+
expect(order.outstanding_balance).to eq 10
end
end
diff --git a/spree/core/spec/models/spree/order_spec.rb b/spree/core/spec/models/spree/order_spec.rb
index dc20954861..408138a9f9 100644
--- a/spree/core/spec/models/spree/order_spec.rb
+++ b/spree/core/spec/models/spree/order_spec.rb
@@ -1046,45 +1046,6 @@ describe Spree::Order, type: :model do
end
end
- describe '#has_non_reimbursement_related_refunds?' do
- subject do
- order.has_non_reimbursement_related_refunds?
- end
-
- context 'no refunds exist' do
- it { is_expected.to eq false }
- end
-
- context 'a non-reimbursement related refund exists' do
- let(:order) { refund.payment.order }
- let(:refund) { create(:refund, reimbursement_id: nil, amount: 5) }
-
- it { is_expected.to eq true }
- end
-
- context 'an old-style refund exists' do
- let(:order) { create(:order_ready_to_ship) }
- let(:payment) { order.payments.first.tap { |p| allow(p).to receive_messages(profiles_supported: false) } }
- let!(:refund_payment) do
- build(:payment, amount: -1, order: order, state: 'completed', source: payment).tap do |p|
- allow(p).to receive_messages(profiles_supported?: false)
- allow(p).to receive_messages(payment_method_available_for_order: nil)
- p.save!
- end
- end
-
- it { is_expected.to eq true }
- end
-
- context 'a reimbursement related refund exists' do
- let(:order) { refund.payment.order }
- let(:reimbursement) { create(:reimbursement) }
- let(:refund) { create(:refund, reimbursement_id: reimbursement.id, amount: 5) }
-
- it { is_expected.to eq false }
- end
- end
-
describe '#rebuild_fulfillments!' do
context 'has unassociated inventory units' do
let!(:inventory_unit) { create(:inventory_unit, order: subject) }
diff --git a/spree/core/spec/models/spree/permission_sets/order_management_spec.rb b/spree/core/spec/models/spree/permission_sets/order_management_spec.rb
index 5a13eb163e..f911edabb4 100644
--- a/spree/core/spec/models/spree/permission_sets/order_management_spec.rb
+++ b/spree/core/spec/models/spree/permission_sets/order_management_spec.rb
@@ -32,16 +32,16 @@ RSpec.describe Spree::PermissionSets::OrderManagement do
expect(ability.can?(:manage, Spree::LineItem)).to be true
end
- it 'grants manage access to ReturnAuthorization' do
- expect(ability.can?(:manage, Spree::ReturnAuthorization)).to be true
+ it 'grants manage access to Return' do
+ expect(ability.can?(:manage, Spree::Return)).to be true
end
- it 'grants manage access to CustomerReturn' do
- expect(ability.can?(:manage, Spree::CustomerReturn)).to be true
+ it 'grants manage access to Exchange' do
+ expect(ability.can?(:manage, Spree::Exchange)).to be true
end
- it 'grants manage access to Reimbursement' do
- expect(ability.can?(:manage, Spree::Reimbursement)).to be true
+ it 'grants manage access to Claim' do
+ expect(ability.can?(:manage, Spree::Claim)).to be true
end
it 'grants manage access to Refund' do
diff --git a/spree/core/spec/models/spree/refund_spec.rb b/spree/core/spec/models/spree/refund_spec.rb
index 0d6d53cb58..f9734b658d 100644
--- a/spree/core/spec/models/spree/refund_spec.rb
+++ b/spree/core/spec/models/spree/refund_spec.rb
@@ -188,28 +188,21 @@ describe Spree::Refund, type: :model do
end
end
- describe 'total_amount_reimbursed_for' do
- subject { Spree::Refund.total_amount_reimbursed_for(reimbursement) }
+ describe '#return_line_items' do
+ subject { refund.return_line_items }
- let(:customer_return) { reimbursement.customer_return }
- let(:reimbursement) { create(:reimbursement) }
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
+ let(:refund) { create(:refund, amount: 10, originator: originator) }
- context 'with reimbursements performed' do
- before { reimbursement.perform! }
+ context 'when the refund came from a return' do
+ let(:originator) { create(:received_return) }
- it 'returns the total amount' do
- amount = Spree::Refund.total_amount_reimbursed_for(reimbursement)
- expect(amount).to be > 0
- expect(amount).to eq reimbursement.total
- end
+ it { is_expected.to match_array(originator.return_line_items) }
end
- context 'without reimbursements performed' do
- it 'returns zero' do
- amount = Spree::Refund.total_amount_reimbursed_for(reimbursement)
- expect(amount).to eq 0
- end
+ context 'when the refund was issued manually' do
+ let(:originator) { nil }
+
+ it { is_expected.to eq([]) }
end
end
end
diff --git a/spree/core/spec/models/spree/reimbursement/credit_spec.rb b/spree/core/spec/models/spree/reimbursement/credit_spec.rb
deleted file mode 100644
index f1e4a0fb6f..0000000000
--- a/spree/core/spec/models/spree/reimbursement/credit_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe Reimbursement::Credit, type: :model do
- context 'class methods' do
- describe '.total_amount_reimbursed_for' do
- subject { Spree::Reimbursement::Credit.total_amount_reimbursed_for(reimbursement) }
-
- let(:reimbursement) { create(:reimbursement) }
- let(:credit_double) { double(amount: 99.99) }
-
- before { allow(reimbursement).to receive(:credits).and_return([credit_double, credit_double]) }
-
- it 'sums the amounts of all of the reimbursements credits' do
- expect(subject).to eq BigDecimal('199.98')
- end
- end
- end
-
- describe '#description' do
- let(:credit) { Spree::Reimbursement::Credit.new(amount: 100, creditable: create(:check_payment_method)) }
-
- it "is the creditable's class name" do
- expect(credit.description).to eq 'Check'
- end
- end
-
- describe '#display_amount' do
- let(:credit) { Spree::Reimbursement::Credit.new(amount: 100) }
-
- it 'is a money object' do
- expect(credit.display_amount).to eq Spree::Money.new(100, currency: 'USD')
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb b/spree/core/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb
deleted file mode 100644
index 66fedb2e50..0000000000
--- a/spree/core/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe Reimbursement::ReimbursementTypeEngine, type: :model do
- describe '#calculate_reimbursement_types' do
- subject { reimbursement_type_engine.calculate_reimbursement_types }
-
- let(:return_item) { create(:return_item) }
- let(:return_items) { [return_item] }
- let(:reimbursement_type_engine) { Spree::Reimbursement::ReimbursementTypeEngine.new(return_items) }
- let(:expired_reimbursement_type) { Spree::ReimbursementType::OriginalPayment }
- let(:override_reimbursement_type) { Spree::ReimbursementType::OriginalPayment.new }
- let(:preferred_reimbursement_type) { Spree::ReimbursementType::OriginalPayment.new }
- let(:calculated_reimbursement_types) { subject }
- let(:all_reimbursement_types) do
- [
- reimbursement_type_engine.default_reimbursement_type,
- reimbursement_type_engine.exchange_reimbursement_type,
- expired_reimbursement_type,
- override_reimbursement_type,
- preferred_reimbursement_type
- ]
- end
-
- shared_examples_for 'reimbursement type hash' do
- it 'contain all keys that respond to reimburse' do
- expect(calculated_reimbursement_types.keys).to all(respond_to(:reimburse))
- end
- end
-
- before do
- reimbursement_type_engine.expired_reimbursement_type = expired_reimbursement_type
- allow(return_item.inventory_unit.shipment).to receive(:shipped_at).and_return(Date.yesterday)
- allow(return_item).to receive(:exchange_required?).and_return(false)
- end
-
- context 'the return item requires exchange' do
- before { allow(return_item).to receive(:exchange_required?).and_return(true) }
-
- it 'returns a hash with the exchange reimbursement type associated to the return items' do
- expect(calculated_reimbursement_types[reimbursement_type_engine.exchange_reimbursement_type]).to eq(return_items)
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [reimbursement_type_engine.exchange_reimbursement_type]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
-
- context 'the return item does not require exchange' do
- context 'the return item has an override reimbursement type' do
- before { allow(return_item).to receive(:override_reimbursement_type).and_return(override_reimbursement_type) }
-
- it 'returns a hash with the override reimbursement type associated to the return items' do
- expect(calculated_reimbursement_types[override_reimbursement_type.class]).to eq(return_items)
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [override_reimbursement_type.class]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
-
- context 'the return item does not have an override reimbursement type' do
- context 'the return item has a preferred reimbursement type' do
- before { allow(return_item).to receive(:preferred_reimbursement_type).and_return(preferred_reimbursement_type) }
-
- context 'the reimbursement type is not valid for the return item' do
- before { expect(reimbursement_type_engine).to receive(:valid_preferred_reimbursement_type?).and_return(false) }
-
- it 'returns a hash with no return items associated to the preferred reimbursement type' do
- expect(calculated_reimbursement_types[preferred_reimbursement_type]).to eq([])
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [preferred_reimbursement_type]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
-
- context 'the reimbursement type is valid for the return item' do
- it 'returns a hash with the expired reimbursement type associated to the return items' do
- expect(calculated_reimbursement_types[preferred_reimbursement_type.class]).to eq(return_items)
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [preferred_reimbursement_type.class]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
- end
-
- context 'the return item does not have a preferred reimbursement type' do
- context 'the return item is past the time constraint' do
- before { allow(reimbursement_type_engine).to receive(:past_reimbursable_time_period?).and_return(true) }
-
- it 'returns a hash with the expired reimbursement type associated to the return items' do
- expect(calculated_reimbursement_types[expired_reimbursement_type]).to eq(return_items)
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [expired_reimbursement_type]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
-
- context 'the return item is within the time constraint' do
- it 'returns a hash with the default reimbursement type associated to the return items' do
- expect(calculated_reimbursement_types[reimbursement_type_engine.default_reimbursement_type]).to eq(return_items)
- end
-
- it 'the return items are not included in any of the other reimbursement types' do
- (all_reimbursement_types - [reimbursement_type_engine.default_reimbursement_type]).each do |r_type|
- expect(calculated_reimbursement_types[r_type]).to eq([])
- end
- end
-
- it_behaves_like 'reimbursement type hash'
- end
- end
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb b/spree/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb
deleted file mode 100644
index 873b8e1f60..0000000000
--- a/spree/core/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe Reimbursement::ReimbursementTypeValidator, type: :model do
- class DummyClass
- include Spree::Reimbursement::ReimbursementTypeValidator
-
- class_attribute :expired_reimbursement_type
- self.expired_reimbursement_type = Spree::ReimbursementType::Credit
-
- class_attribute :refund_time_constraint
- self.refund_time_constraint = 90.days
- end
-
- let(:return_item) do
- create(
- :return_item,
- preferred_reimbursement_type: preferred_reimbursement_type
- )
- end
- let(:dummy) { DummyClass.new }
- let(:preferred_reimbursement_type) { Spree::ReimbursementType::Credit.new }
-
- describe '#valid_preferred_reimbursement_type?' do
- subject { dummy.valid_preferred_reimbursement_type?(return_item) }
-
- before do
- allow(dummy).to receive(:past_reimbursable_time_period?).and_return(true)
- end
-
- context 'is valid' do
- it 'if it is not past the reimbursable time period' do
- allow(dummy).to receive(:past_reimbursable_time_period?).and_return(false)
- expect(subject).to be true
- end
-
- it 'if the return items preferred method of reimbursement is the expired method of reimbursement' do
- expect(subject).to be true
- end
- end
-
- context 'is invalid' do
- it 'if the return item is past the eligible time period and the preferred method of reimbursement is not the expired method of reimbursement' do
- return_item.preferred_reimbursement_type =
- Spree::ReimbursementType::OriginalPayment.new
- expect(subject).to be false
- end
- end
- end
-
- describe '#past_reimbursable_time_period?' do
- subject { dummy.past_reimbursable_time_period?(return_item) }
-
- before do
- allow(return_item).to receive_message_chain(:inventory_unit, :shipment, :shipped_at).and_return(shipped_at)
- end
-
- context 'it has not shipped' do
- let(:shipped_at) { nil }
-
- it 'is not past the reimbursable time period' do
- expect(subject).to be_falsey
- end
- end
-
- context 'it has shipped and it is more recent than the time constraint' do
- let(:shipped_at) { (dummy.refund_time_constraint - 1.day).ago }
-
- it 'is not past the reimbursable time period' do
- expect(subject).to be false
- end
- end
-
- context 'it has shipped and it is further in the past than the time constraint' do
- let(:shipped_at) { (dummy.refund_time_constraint + 1.day).ago }
-
- it 'is past the reimbursable time period' do
- expect(subject).to be true
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_performer_spec.rb b/spree/core/spec/models/spree/reimbursement_performer_spec.rb
deleted file mode 100644
index 4fea69ec01..0000000000
--- a/spree/core/spec/models/spree/reimbursement_performer_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReimbursementPerformer, type: :model do
- let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
- let(:return_item) { reimbursement.return_items.first }
- let(:reimbursement_type) { double('ReimbursementType') }
- let(:reimbursement_type_hash) { { reimbursement_type => [return_item] } }
- let(:reimbursement_type_engine) { Spree::Reimbursement::ReimbursementTypeEngine }
-
- before do
- allow_any_instance_of(reimbursement_type_engine).to receive(:calculate_reimbursement_types).and_return(reimbursement_type_hash)
- end
-
- describe '.simulate' do
- it 'reimburses each calculated reimbursement types with the correct return items as a simulation' do
- expect(reimbursement_type).to receive(:reimburse).with(reimbursement, [return_item], true)
- Spree::ReimbursementPerformer.simulate(reimbursement)
- end
- end
-
- describe '.perform' do
- it 'reimburses each calculated reimbursement types with the correct return items as a performance' do
- expect(reimbursement_type).to receive(:reimburse).with(reimbursement, [return_item], false)
- Spree::ReimbursementPerformer.perform(reimbursement)
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_spec.rb b/spree/core/spec/models/spree/reimbursement_spec.rb
deleted file mode 100644
index 14f2e49710..0000000000
--- a/spree/core/spec/models/spree/reimbursement_spec.rb
+++ /dev/null
@@ -1,240 +0,0 @@
-require 'spec_helper'
-
-describe Spree::Reimbursement, type: :model do
- let(:store) { @default_store }
-
- describe '#display_total' do
- subject { reimbursement.display_total }
-
- let(:total) { 100.50 }
- let(:currency) { 'USD' }
- let(:order) { build(:order, store: store, currency: currency) }
- let(:reimbursement) { described_class.new(total: total, order: order) }
-
- it 'returns the value as a Spree::Money instance' do
- expect(subject).to eq Spree::Money.new(total)
- end
-
- it "uses the order's currency" do
- expect(subject.money.currency.to_s).to eq currency
- end
- end
-
- describe '#store' do
- subject { reimbursement.store }
-
- let(:total) { 100.50 }
- let(:currency) { 'USD' }
- let(:order) { build(:order, store: store, currency: currency) }
- let(:reimbursement) { described_class.new(total: total, order: order) }
-
- it 'returns order store' do
- expect(subject).to eq(store)
- end
- end
-
- describe '#perform!' do
- subject { reimbursement.perform! }
-
- let!(:adjustments) { [] } # placeholder to ensure it gets run prior the "before" at this level
-
- let!(:tax_rate) { nil }
- let!(:tax_zone) { create(:zone_with_country, default_tax: true) }
-
- let(:store) { @default_store }
- let(:order) { create(:shipped_order, line_items_count: 1, line_items_price: line_items_price, shipment_cost: 0, store: store) }
- let(:line_items_price) { BigDecimal(10) }
- let(:line_item) { order.line_items.first }
- let(:inventory_unit) { line_item.inventory_units.first }
- let(:payment) { order.payments.first }
- let(:payment_amount) { order.total }
- let(:customer_return) { build(:customer_return, return_items: [return_item], store: store) }
- let(:return_item) { build(:return_item, inventory_unit: inventory_unit) }
-
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
-
- let(:reimbursement) { create(:reimbursement, customer_return: customer_return, order: order, return_items: [return_item]) }
-
- let(:store_credit_reimbursement_type) { create(:reimbursement_type, name: 'StoreCredit', type: 'Spree::ReimbursementType::StoreCredit') }
-
- before do
- customer_return.save!
- return_item.accept!
- end
-
- it 'refunds the total amount' do
- subject
- expect(reimbursement.unpaid_amount).to eq 0
- end
-
- it 'creates a refund' do
- expect do
- subject
- end.to change { Spree::Refund.count }.by(1)
- expect(Spree::Refund.last.amount).to eq order.total
- end
-
- context 'with additional tax' do
- let!(:tax_rate) { create(:tax_rate, name: 'Sales Tax', amount: 0.10, included_in_price: false, zone: tax_zone) }
-
- it 'saves the additional tax and refunds the total' do
- expect do
- subject
- end.to change { Spree::Refund.count }.by(1)
- return_item.reload
- expect(return_item.additional_tax_total).to be > 0
- expect(return_item.additional_tax_total).to eq line_item.additional_tax_total
- expect(reimbursement.total).to eq line_item.pre_tax_amount + line_item.additional_tax_total
- expect(Spree::Refund.last.amount).to eq line_item.pre_tax_amount + line_item.additional_tax_total
- end
- end
-
- context 'when performer is provided' do
- let(:performer) { create(:admin_user) }
-
- it 'sets the performer' do
- reimbursement.perform!(performer)
- expect(reimbursement.performed_by).to eq performer
- end
-
- it 'refunds the total amount' do
- subject
- expect(reimbursement.unpaid_amount).to eq 0
- end
-
- it 'creates a refund' do
- expect do
- subject
- end.to change { Spree::Refund.count }.by(1)
- expect(Spree::Refund.last.amount).to eq order.total
- end
- end
-
- context 'with included tax' do
- let!(:tax_rate) { create(:tax_rate, name: 'VAT Tax', amount: 0.1, included_in_price: true, zone: tax_zone) }
-
- it 'saves the included tax and refunds the total' do
- expect do
- subject
- end.to change { Spree::Refund.count }.by(1)
- return_item.reload
- expect(return_item.included_tax_total).to be > 0
- expect(return_item.included_tax_total).to eq line_item.included_tax_total
- expect(reimbursement.total).to eq (line_item.pre_tax_amount + line_item.included_tax_total).round(2)
- expect(Spree::Refund.last.amount).to eq (line_item.pre_tax_amount + line_item.included_tax_total).round(2)
- end
- end
-
- context 'when reimbursement cannot be fully performed' do
- let!(:non_return_refund) { create(:refund, amount: 1, payment: payment) }
-
- it 'raises IncompleteReimbursement error' do
- expect { subject }.to raise_error(Spree::Reimbursement::IncompleteReimbursementError)
- end
- end
-
- context 'when reimbursement is performed using store credits' do
- it 'succeeds' do
- reimbursement.return_items.last.update(preferred_reimbursement_type_id: store_credit_reimbursement_type.id)
- expect { subject }.not_to raise_error
- end
- end
-
- context 'when exchange is required' do
- # we need to have a variant that will pass eligibility checks
- # so it needs to be a variant of the same product
- let!(:exchange_variant) { create(:variant, product: inventory_unit.variant.product) }
-
- before { return_item.exchange_variant = exchange_variant }
-
- it 'generates an exchange shipment for the order for the exchange items' do
- expect { subject }.to change { order.reload.shipments.count }.by 1
- expect(order.shipments.last.inventory_units.first.variant).to eq exchange_variant
- end
- end
- end
-
- describe '#return_items_requiring_exchange' do
- it 'returns only the return items that require an exchange' do
- return_items = [double(exchange_required?: true), double(exchange_required?: true), double(exchange_required?: false)]
- allow(subject).to receive(:return_items) { return_items }
- expect(subject.return_items_requiring_exchange).to eq return_items.take(2)
- end
- end
-
- describe '#calculated_total' do
- context 'with return item amounts that would round up if added' do
- subject { reimbursement.calculated_total }
-
- let(:reimbursement) { Spree::Reimbursement.new }
-
- before do
- reimbursement.return_items << Spree::ReturnItem.new(pre_tax_amount: 10.003)
- reimbursement.return_items << Spree::ReturnItem.new(pre_tax_amount: 10.003)
- end
-
- it 'rounds down' do
- expect(subject).to eq 20
- end
- end
-
- context 'with a return item amount that should round up' do
- subject { reimbursement.calculated_total }
-
- let(:reimbursement) { Spree::Reimbursement.new }
-
- before do
- reimbursement.return_items << Spree::ReturnItem.new(pre_tax_amount: 19.998)
- end
-
- it 'rounds up' do
- expect(subject).to eq 20
- end
- end
- end
-
- describe '.build_from_customer_return' do
- subject { Spree::Reimbursement.build_from_customer_return(customer_return) }
-
- let(:customer_return) { create(:customer_return, line_items_count: 5, store: store) }
-
- let!(:pending_return_item) { customer_return.return_items.first.tap { |ri| ri.update!(acceptance_status: 'pending') } }
- let!(:accepted_return_item) { customer_return.return_items.second.tap(&:accept!) }
- let!(:rejected_return_item) { customer_return.return_items.third.tap(&:reject!) }
- let!(:manual_intervention_return_item) { customer_return.return_items.fourth.tap(&:require_manual_intervention!) }
- let!(:already_reimbursed_return_item) { customer_return.return_items.fifth }
-
- let!(:previous_reimbursement) { create(:reimbursement, order: customer_return.order, return_items: [already_reimbursed_return_item]) }
-
- it 'connects data' do
- expect(subject.return_items.to_a).to eq [accepted_return_item]
- expect(subject.order).to eq customer_return.order
- expect(subject.customer_return).to eq customer_return
- end
- end
-
- describe 'custom events', events: true do
- describe 'reimbursement.reimbursed' do
- let(:order) { create(:shipped_order, line_items_count: 1, line_items_price: BigDecimal(10), shipment_cost: 0, store: store) }
- let(:line_item) { order.line_items.first }
- let(:inventory_unit) { line_item.inventory_units.first }
- let(:customer_return) { build(:customer_return, return_items: [return_item], store: store) }
- let(:return_item) { build(:return_item, inventory_unit: inventory_unit) }
- let(:reimbursement) { create(:reimbursement, customer_return: customer_return, order: order, return_items: [return_item]) }
-
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
-
- before do
- customer_return.save!
- return_item.accept!
- end
-
- it 'publishes reimbursement.reimbursed event when performed' do
- expect(reimbursement).to receive(:publish_event).with('reimbursement.reimbursed')
- allow(reimbursement).to receive(:publish_event).with(anything)
-
- reimbursement.perform!
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_tax_calculator_spec.rb b/spree/core/spec/models/spree/reimbursement_tax_calculator_spec.rb
deleted file mode 100644
index 3352dd624c..0000000000
--- a/spree/core/spec/models/spree/reimbursement_tax_calculator_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReimbursementTaxCalculator, type: :model do
- subject do
- Spree::ReimbursementTaxCalculator.call(reimbursement)
- end
-
- let!(:tax_rate) { nil }
-
- let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
- let(:return_item) { reimbursement.return_items.first }
- let(:line_item) { return_item.inventory_unit.line_item }
-
- context 'without taxes' do
- let!(:tax_rate) { nil }
-
- it 'leaves the return items additional_tax_total and included_tax_total at zero' do
- subject
-
- expect(return_item.additional_tax_total).to eq 0
- expect(return_item.included_tax_total).to eq 0
- end
- end
-
- context 'with additional tax' do
- let!(:tax_rate) do
- create :tax_rate,
- name: 'Sales Tax',
- amount: 0.10,
- included_in_price: false,
- tax_category: create(:tax_category),
- zone: create(:zone_with_country, default_tax: true)
- end
-
- it 'sets additional_tax_total on the return items' do
- subject
- return_item.reload
-
- expect(return_item.additional_tax_total).to be > 0
- expect(return_item.additional_tax_total).to eq line_item.additional_tax_total
- end
- end
-
- context 'with included tax' do
- let!(:tax_rate) do
- create :tax_rate,
- name: 'VAT Tax',
- amount: 0.10,
- included_in_price: true,
- tax_category: create(:tax_category),
- zone: create(:zone_with_country, default_tax: true)
- end
-
- it 'sets included_tax_total on the return items' do
- subject
- return_item.reload
-
- expect(return_item.included_tax_total).to be > 0
- expect(return_item.included_tax_total).to eq line_item.included_tax_total
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_type/credit_spec.rb b/spree/core/spec/models/spree/reimbursement_type/credit_spec.rb
deleted file mode 100644
index 366f55e682..0000000000
--- a/spree/core/spec/models/spree/reimbursement_type/credit_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReimbursementType::Credit, type: :model do
- subject { Spree::ReimbursementType::Credit.reimburse(reimbursement, [return_item], simulate) }
-
- let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
- let(:return_item) { reimbursement.return_items.first }
- let(:payment) { reimbursement.order.payments.first }
- let(:simulate) { false }
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
- let(:creditable) { DummyCreditable.new(amount: 99.99) }
-
- class DummyCreditable < Spree::Base
- attr_accessor :amount
- self.table_name = 'spree_payments' # Your creditable class should not use this table
- end
-
- before do
- reimbursement.update!(total: reimbursement.calculated_total)
- allow(Spree::StoreCredit).to receive(:new).and_return(creditable)
- end
-
- describe '.reimburse' do
- context 'simulate is true' do
- let(:simulate) { true }
-
- it 'creates one readonly lump credit for all outstanding balance payable to the customer' do
- expect(subject.map(&:class)).to eq [Spree::Reimbursement::Credit]
- expect(subject.map(&:readonly?)).to eq [true]
- expect(subject.sum(&:amount)).to eq reimbursement.return_items.to_a.sum(&:total)
- end
-
- it 'does not save to the database' do
- expect { subject }.not_to change { Spree::Reimbursement::Credit.count }
- end
- end
-
- context 'simulate is false' do
- let(:simulate) { false }
-
- before do
- expect(creditable).to receive(:save).and_return(true)
- end
-
- it 'creates one lump credit for all outstanding balance payable to the customer' do
- expect { subject }.to change { Spree::Reimbursement::Credit.count }.by(1)
- expect(subject.sum(&:amount)).to eq reimbursement.return_items.to_a.sum(&:total)
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_type/exchange_processor_spec.rb b/spree/core/spec/models/spree/reimbursement_type/exchange_processor_spec.rb
deleted file mode 100644
index 240fa474ab..0000000000
--- a/spree/core/spec/models/spree/reimbursement_type/exchange_processor_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReimbursementType::ExchangeProcessor, type: :model do
- let(:order) { Spree::Order.new }
-
- let(:return_item_1) { build(:exchange_return_item) }
- let(:return_item_2) { build(:exchange_return_item) }
- let(:return_items) { [return_item_1, return_item_2] }
- let(:exchange) { ReimbursementType::ExchangeProcessor.new(order, return_items) }
-
- describe '#description' do
- before do
- allow(return_item_1).to receive(:variant) { double(options_text: 'foo') }
- allow(return_item_1).to receive(:exchange_variant) { double(options_text: 'bar') }
- allow(return_item_2).to receive(:variant) { double(options_text: 'baz') }
- allow(return_item_2).to receive(:exchange_variant) { double(options_text: 'qux') }
- end
-
- it "describes the return items' change in options" do
- expect(exchange.description).to match(/foo => bar/)
- expect(exchange.description).to match(/baz => qux/)
- end
- end
-
- describe '#display_amount' do
- it 'is the total amount of all return items' do
- expect(exchange.display_amount).to eq Spree::Money.new(0.0)
- end
- end
-
- describe '#perform!' do
- subject { exchange.perform! }
-
- let(:return_item) { create(:exchange_return_item) }
- let(:return_items) { [return_item] }
- let(:order) { return_item.return_authorization.order }
-
- before { return_item.exchange_variant.stock_items.first.adjust_count_on_hand(20) }
-
- it 'creates shipments for the order with the return items exchange inventory units' do
- expect { subject }.to change { order.shipments.count }.by(1)
- new_shipment = order.shipments.last
- expect(new_shipment).to be_ready
- new_inventory_units = new_shipment.inventory_units
- expect(new_inventory_units.count).to eq 1
- expect(new_inventory_units.first.original_return_item).to eq return_item
- expect(new_inventory_units.first.line_item).to eq return_item.inventory_unit.line_item
- end
-
- context 'when it cannot create shipments for all items' do
- before do
- StockItem.where(variant_id: return_item.exchange_variant_id).delete_all
- end
-
- it 'raises an UnableToCreateShipments error' do
- expect do
- subject
- end.to raise_error(Spree::ReimbursementType::ExchangeProcessor::UnableToCreateShipments)
- end
- end
- end
-
- describe '#to_key' do # for dom_id
- it { expect(ReimbursementType::ExchangeProcessor.new(nil, nil).to_key).to be_nil }
- end
-
- describe '.param_key' do # for dom_id
- it { expect(ReimbursementType::ExchangeProcessor.param_key).to eq 'spree_exchange' }
- end
-
- describe '.model_name' do # for dom_id
- it { expect(ReimbursementType::ExchangeProcessor.model_name).to eq Spree::ReimbursementType::ExchangeProcessor }
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_type/exchange_spec.rb b/spree/core/spec/models/spree/reimbursement_type/exchange_spec.rb
deleted file mode 100644
index b4208a5721..0000000000
--- a/spree/core/spec/models/spree/reimbursement_type/exchange_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReimbursementType::Exchange, type: :model do
- describe '.reimburse' do
- subject { Spree::ReimbursementType::Exchange.reimburse(reimbursement, return_items, simulate) }
-
- let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
- let(:return_items) { reimbursement.return_items }
- let(:new_exchange) { double('Exchange') }
- let(:simulate) { true }
-
- context 'return items are supplied' do
- before do
- expect(Spree::ReimbursementType::ExchangeProcessor).to receive(:new).with(reimbursement.order, return_items).and_return(new_exchange)
- end
-
- context 'simulate is true' do
- it 'does not perform an exchange and returns the exchange object' do
- expect(new_exchange).not_to receive(:perform!)
- expect(subject).to eq [new_exchange]
- end
- end
-
- context 'simulate is false' do
- let(:simulate) { false }
-
- it 'performs an exchange and returns the exchange object' do
- expect(new_exchange).to receive(:perform!)
- expect(subject).to eq [new_exchange]
- end
- end
- end
-
- context 'no return items are supplied' do
- let(:return_items) { [] }
-
- it 'does not perform an exchange and returns an empty array' do
- expect(new_exchange).not_to receive(:perform!)
- expect(subject).to eq []
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_type/original_payment_spec.rb b/spree/core/spec/models/spree/reimbursement_type/original_payment_spec.rb
deleted file mode 100644
index f2f40bff89..0000000000
--- a/spree/core/spec/models/spree/reimbursement_type/original_payment_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReimbursementType::OriginalPayment, type: :model do
- subject { Spree::ReimbursementType::OriginalPayment.reimburse(reimbursement, [return_item], simulate) }
-
- let(:reimbursement) { create(:reimbursement, return_items_count: 1) }
- let(:return_item) { reimbursement.return_items.first }
- let(:payment) { reimbursement.order.payments.first }
- let(:simulate) { false }
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
-
- before { reimbursement.update!(total: reimbursement.calculated_total) }
-
- describe '.reimburse' do
- context 'simulate is true' do
- let(:simulate) { true }
-
- it 'returns an array of readonly refunds' do
- expect(subject.map(&:class)).to eq [Spree::Refund]
- expect(subject.map(&:readonly?)).to eq [true]
- end
- end
-
- context 'simulate is false' do
- it 'performs the refund' do
- expect do
- subject
- end.to change { payment.refunds.count }.by(1)
- expect(payment.refunds.sum(:amount)).to eq reimbursement.return_items.to_a.sum(&:total)
- end
- end
-
- context 'when no credit is allowed on the payment' do
- before do
- expect_any_instance_of(Spree::Payment).to receive(:credit_allowed).and_return 0
- end
-
- it 'returns an empty array' do
- expect(subject).to eq []
- end
- end
-
- context 'when a payment is negative' do
- before do
- expect_any_instance_of(Spree::Payment).to receive(:amount).and_return(-100)
- end
-
- it 'returns an empty array' do
- expect(subject).to eq []
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/reimbursement_type/store_credit_spec.rb b/spree/core/spec/models/spree/reimbursement_type/store_credit_spec.rb
deleted file mode 100644
index ebec09fdbe..0000000000
--- a/spree/core/spec/models/spree/reimbursement_type/store_credit_spec.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReimbursementType::StoreCredit do
- subject do
- Spree::ReimbursementType::StoreCredit.reimburse(reimbursement, [return_item, return_item2],
- simulate)
- end
-
- let(:reimbursement) { create(:reimbursement, return_items_count: 2) }
- let(:return_item) { reimbursement.return_items.first }
- let(:return_item2) { reimbursement.return_items.last }
- let(:payment) { reimbursement.order.payments.first }
- let(:simulate) { false }
- let!(:default_refund_reason) do
- Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON,
- mutable: false)
- end
-
- let!(:primary_credit_type) { create(:primary_credit_type) }
- let!(:created_by_user) { create(:admin_user) }
- let!(:default_reimbursement_category) { create(:store_credit_category) }
-
- before { reimbursement.update!(total: reimbursement.calculated_total) }
-
- describe '.reimburse' do
- context 'simulate is true' do
- let(:simulate) { true }
-
- context 'for store credits that the customer used' do
- before do
- allow(reimbursement).to receive_message_chain('order.payments.completed.store_credits').and_return([payment])
- end
-
- it 'creates readonly refunds for all store credit payments' do
- expect(subject.map(&:class)).to eq [Spree::Refund]
- expect(subject.map(&:readonly?)).to eq [true]
- end
-
- it 'does not save to the database' do
- expect { subject }.not_to change { payment.refunds.count }
- end
- end
-
- context 'for return items that were not paid for with store credit' do
- context 'creates one readonly lump credit for all outstanding balance payable to the customer' do
- it 'creates a credit that is read only' do
- expect(subject.map(&:class)).to eq [Spree::Reimbursement::Credit]
- expect(subject.map(&:readonly?)).to eq [true]
- end
-
- it 'creates a credit which amounts to the sum of the return items rounded down' do
- allow(return_item).to receive(:total).and_return(10.0076)
- allow(return_item2).to receive(:total).and_return(10.0023)
- expect(subject.sum(&:amount)).to eq 20.0
- end
- end
-
- it 'does not save to the database' do
- expect { subject }.not_to change { Spree::Reimbursement::Credit.count }
- end
- end
- end
-
- context 'simulate is false' do
- let(:simulate) { false }
-
- context 'for store credits that the customer used' do
- before do
- allow(reimbursement).to receive_message_chain('order.payments.completed.store_credits').and_return([payment])
- end
-
- it 'performs refunds for all store credit payments' do
- expect { subject }.to change { payment.refunds.count }.by(1)
- expect(payment.refunds.sum(:amount)).to eq reimbursement.return_items.to_a.sum(&:total)
- end
- end
-
- context 'for return items that were not paid for with store credit' do
- before do
- allow(Spree::ReimbursementType::StoreCredit).to receive(:store_credit_payments).and_return([])
- end
-
- it 'creates one lump credit for all outstanding balance payable to the customer' do
- expect { subject }.to change { Spree::Reimbursement::Credit.count }.by(1)
- expect(subject.sum(&:amount)).to eq reimbursement.return_items.to_a.sum(&:total)
- end
-
- it "creates a store credit with the same currency as the reimbursement's order" do
- expect { subject }.to change { Spree::StoreCredit.count }.by(1)
- expect(Spree::StoreCredit.last.currency).to eq reimbursement.order.currency
- end
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_authorization_spec.rb b/spree/core/spec/models/spree/return_authorization_spec.rb
deleted file mode 100644
index 080da1d865..0000000000
--- a/spree/core/spec/models/spree/return_authorization_spec.rb
+++ /dev/null
@@ -1,286 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnAuthorization, type: :model do
- let(:order) { create(:shipped_order) }
- let(:stock_location) { create(:stock_location) }
- let(:rma_reason) { create(:return_authorization_reason) }
- let(:inventory_unit_1) { order.inventory_units.first }
-
- let(:variant) { order.variants.first }
- let(:return_authorization) do
- Spree::ReturnAuthorization.new(order: order,
- stock_location_id: stock_location.id,
- return_authorization_reason_id: rma_reason.id)
- end
-
- describe 'lifecycle events', events: true do
- describe 'return_authorization.created' do
- it 'publishes created event when record is created' do
- shipped_order = create(:shipped_order)
- record = build(:new_return_authorization, order: shipped_order)
- expect(record).to receive(:publish_event).with('return_authorization.created')
- allow(record).to receive(:publish_event).with(anything)
-
- record.save!
- end
- end
-
- describe 'return_authorization.updated' do
- it 'publishes updated event when record is updated' do
- record = create(:return_authorization)
- expect(record).to receive(:publish_event).with('return_authorization.updated')
- allow(record).to receive(:publish_event).with(anything)
-
- Timecop.travel(1.minute.from_now) do
- record.update_attribute(:updated_at, Time.current)
- end
- end
- end
-
- describe 'return_authorization.deleted' do
- it 'publishes deleted event when record is destroyed' do
- record = create(:return_authorization)
- expect(record).to receive(:publish_event).with('return_authorization.deleted', kind_of(Hash))
- allow(record).to receive(:publish_event).with(anything)
-
- record.destroy!
- end
- end
- end
-
- context 'save' do
- let(:order) { Spree::Order.create }
-
- it 'is invalid when order has no inventory units' do
- return_authorization.save
- expect(return_authorization.errors[:order]).to eq(['has no shipped units'])
- end
-
- context 'expedited exchanges are configured' do
- subject { create(:return_authorization, order: order, return_items: [exchange_return_item, return_item]) }
-
- let(:order) { create(:shipped_order, line_items_count: 2) }
- let(:exchange_return_item) { create(:exchange_return_item, inventory_unit: order.inventory_units.first) }
- let(:return_item) { create(:return_item, inventory_unit: order.inventory_units.last) }
-
- before do
- @expediteted_exchanges_config = Spree::Config[:expedited_exchanges]
- Spree::Config[:expedited_exchanges] = true
- @pre_exchange_hooks = subject.class.pre_expedited_exchange_hooks
- end
-
- after do
- Spree::Config[:expedited_exchanges] = @expediteted_exchanges_config
- subject.class.pre_expedited_exchange_hooks = Array(@pre_exchange_hooks)
- end
-
- context 'no items to exchange' do
- subject { create(:return_authorization, order: order) }
-
- it 'does not create a reimbursement' do
- expect { subject.save }.not_to change { Spree::Reimbursement.count }
- end
- end
-
- context 'items to exchange' do
- it 'calls pre_expedited_exchange hooks with the return items to exchange' do
- hook = double(:as_null_object)
- expect(hook).to receive(:call).with [exchange_return_item]
- subject.class.pre_expedited_exchange_hooks = [hook]
- subject.save
- end
-
- it 'attempts to accept all return items requiring exchange' do
- expect(exchange_return_item).to receive :attempt_accept
- expect(return_item).not_to receive :attempt_accept
- subject.save
- end
-
- it 'performs an exchange reimbursement for the exchange return items' do
- subject.save
- reimbursement = Spree::Reimbursement.last
- expect(reimbursement.order).to eq subject.order
- expect(reimbursement.return_items).to eq [exchange_return_item]
- expect(exchange_return_item.reload.exchange_shipments).to be_present
- end
-
- context 'the reimbursement fails' do
- before do
- allow_any_instance_of(Spree::Reimbursement).to receive(:save).and_return(false)
- allow_any_instance_of(Spree::Reimbursement).to receive(:errors) { double(full_messages: 'foo') }
- end
-
- it 'puts errors on the return authorization' do
- subject.save
- expect(subject.errors[:base]).to include 'foo'
- end
- end
- end
- end
- end
-
- describe 'whitelisted_ransackable_attributes' do
- it { expect(Spree::ReturnAuthorization.whitelisted_ransackable_attributes).to eq(%w(memo number state)) }
- end
-
- describe 'whitelisted_ransackable_associations' do
- it { expect(Spree::ReturnAuthorization.whitelisted_ransackable_associations).to eq(%w(order)) }
- end
-
- context '#currency' do
- before { allow(order).to receive(:currency).and_return('ABC') }
-
- it 'returns the order currency' do
- expect(return_authorization.currency).to eq('ABC')
- end
- end
-
- describe '#pre_tax_total' do
- subject { return_authorization.pre_tax_total }
-
- let(:pre_tax_amount_1) { 15.0 }
- let!(:return_item_1) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_1) }
-
- let(:pre_tax_amount_2) { 50.0 }
- let!(:return_item_2) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_2) }
-
- let(:pre_tax_amount_3) { 5.0 }
- let!(:return_item_3) { create(:return_item, return_authorization: return_authorization, pre_tax_amount: pre_tax_amount_3) }
-
- it "sums it's associated return_item's pre-tax amounts" do
- expect(subject).to eq (pre_tax_amount_1 + pre_tax_amount_2 + pre_tax_amount_3)
- end
- end
-
- describe '#display_pre_tax_total' do
- it 'returns a Spree::Money' do
- allow(return_authorization).to receive_messages(pre_tax_total: 21.22)
- expect(return_authorization.display_pre_tax_total).to eq(Spree::Money.new(21.22))
- end
- end
-
- describe '#refundable_amount' do
- subject { return_authorization.refundable_amount }
-
- let(:weighted_line_item_pre_tax_amount) { 5.0 }
- let(:line_item_count) { return_authorization.order.line_items.count }
-
- before do
- return_authorization.order.line_items.update_all(pre_tax_amount: weighted_line_item_pre_tax_amount)
- return_authorization.order.update_attribute(:promo_total, promo_total)
- end
-
- context 'no promotions' do
- let(:promo_total) { 0.0 }
-
- it 'returns the pre-tax line item total' do
- expect(subject).to eq (weighted_line_item_pre_tax_amount * line_item_count)
- end
- end
-
- context 'promotions' do
- let(:promo_total) { -10.0 }
-
- it 'returns the pre-tax line item total minus the order level promotion value' do
- expect(subject).to eq (weighted_line_item_pre_tax_amount * line_item_count) + promo_total
- end
- end
- end
-
- describe '#customer_returned_items?' do
- subject { return_authorization.customer_returned_items? }
-
- before do
- allow_any_instance_of(Spree::Order).to receive_messages(return!: true)
- end
-
- context 'has associated customer returns' do
- let(:customer_return) { create(:customer_return) }
- let(:return_authorization) { customer_return.return_authorizations.first }
-
- it 'returns true' do
- expect(subject).to eq true
- end
- end
-
- context 'does not have associated customer returns' do
- let(:return_authorization) { create(:return_authorization) }
-
- it 'returns false' do
- expect(subject).to eq false
- end
- end
- end
-
- describe 'cancel_return_items' do
- subject do
- return_authorization.cancel!
- end
-
- let(:return_authorization) { create(:return_authorization, return_items: return_items) }
- let(:return_items) { [return_item] }
- let(:return_item) { create(:return_item) }
-
- it 'cancels the associated return items' do
- subject
- expect(return_item.reception_status).to eq 'cancelled'
- end
-
- context 'some return items cannot be cancelled' do
- let(:return_items) { [return_item, return_item_2] }
- let(:return_item_2) { create(:return_item, reception_status: 'received') }
-
- it 'cancels those that can be cancelled' do
- subject
- expect(return_item.reception_status).to eq 'cancelled'
- expect(return_item_2.reception_status).to eq 'received'
- end
- end
- end
-
- describe '#can_cancel?' do
- subject { create(:return_authorization, return_items: return_items).can_cancel? }
-
- let(:return_items) { [return_item_1, return_item_2] }
- let(:return_item_1) { create(:return_item) }
- let(:return_item_2) { create(:return_item) }
-
- context 'all items can be cancelled' do
- it 'returns true' do
- expect(subject).to eq true
- end
- end
-
- context 'at least one return item can be cancelled' do
- let(:return_item_2) { create(:return_item, reception_status: 'received') }
-
- it { is_expected.to eq true }
- end
-
- context 'no items can be cancelled' do
- let(:return_item_1) { create(:return_item, reception_status: 'received') }
- let(:return_item_2) { create(:return_item, reception_status: 'received') }
-
- it { is_expected.to eq false }
- end
-
- context 'when return_authorization has no return_items' do
- let(:return_items) { [] }
-
- it { is_expected.to eq true }
- end
- end
-
- describe 'custom events', events: true do
- describe 'return_authorization.canceled' do
- let(:return_authorization) { create(:return_authorization) }
-
- it 'publishes return_authorization.canceled event when canceled' do
- expect(return_authorization).to receive(:publish_event).with('return_authorization.canceled')
- allow(return_authorization).to receive(:publish_event).with(anything)
-
- return_authorization.cancel!
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/default_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/default_spec.rb
deleted file mode 100644
index 5d81e1eea0..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/default_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::Default, type: :model do
- let(:return_item) { create(:return_item) }
- let(:validator) { Spree::ReturnItem::EligibilityValidator::Default.new(return_item) }
-
- let(:time_eligibility_class) { double('TimeEligibilityValidatorClass') }
- let(:rma_eligibility_class) { double('RMAEligibilityValidatorClass') }
-
- let(:time_eligibility_instance) { double(errors: time_error) }
- let(:rma_eligibility_instance) { double(errors: rma_error) }
-
- let(:time_error) { {} }
- let(:rma_error) { {} }
-
- before do
- validator.permitted_eligibility_validators = [time_eligibility_class, rma_eligibility_class]
-
- expect(time_eligibility_class).to receive(:new).and_return(time_eligibility_instance)
- expect(rma_eligibility_class).to receive(:new).and_return(rma_eligibility_instance)
- end
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- it 'checks that all permitted eligibility validators are eligible for return' do
- expect(time_eligibility_instance).to receive(:eligible_for_return?).and_return(true)
- expect(rma_eligibility_instance).to receive(:eligible_for_return?).and_return(true)
-
- expect(subject).to be true
- end
- end
-
- describe '#requires_manual_intervention?' do
- subject { validator.requires_manual_intervention? }
-
- context 'any of the permitted eligibility validators require manual intervention' do
- it 'returns true' do
- expect(time_eligibility_instance).to receive(:requires_manual_intervention?).and_return(false)
- expect(rma_eligibility_instance).to receive(:requires_manual_intervention?).and_return(true)
-
- expect(subject).to be true
- end
- end
-
- context 'no permitted eligibility validators require manual intervention' do
- it 'returns false' do
- expect(time_eligibility_instance).to receive(:requires_manual_intervention?).and_return(false)
- expect(rma_eligibility_instance).to receive(:requires_manual_intervention?).and_return(false)
-
- expect(subject).to be false
- end
- end
- end
-
- describe '#errors' do
- subject { validator.errors }
-
- context 'the validator errors are empty' do
- it 'returns an empty hash' do
- expect(subject).to eq({})
- end
- end
-
- context 'the validators have errors' do
- let(:time_error) { { time: time_error_text } }
- let(:rma_error) { { rma: rma_error_text } }
-
- let(:time_error_text) { 'Time eligibility error' }
- let(:rma_error_text) { 'RMA eligibility error' }
-
- it 'gathers all errors from permitted eligibility validators into a single errors hash' do
- expect(subject).to eq(time: time_error_text, rma: rma_error_text)
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb
deleted file mode 100644
index 9004a3fcc6..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::InventoryShipped do
- let(:return_item) { create(:return_item) }
- let(:validator) { described_class.new(return_item) }
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- before { allow(return_item.inventory_unit).to receive(:shipped?).and_return(true) }
-
- context 'the associated inventory unit is shipped' do
- it 'returns true' do
- expect(subject).to eq true
- end
- end
-
- context 'the associated inventory unit is not shipped' do
- before { allow(return_item.inventory_unit).to receive(:shipped?).and_return(false) }
-
- it 'returns false' do
- expect(subject).to eq false
- end
-
- it 'sets an error' do
- subject
- expect(validator.errors[:inventory_unit_shipped]).to eq Spree.t('return_item_inventory_unit_ineligible')
- end
- end
- end
-
- describe '#requires_manual_intervention?' do
- subject { validator.requires_manual_intervention? }
-
- context 'not eligible for return' do
- before do
- allow(return_item.inventory_unit).to receive(:shipped?).and_return(false)
- validator.eligible_for_return?
- end
-
- it 'returns true if errors were added' do
- expect(subject).to eq true
- end
- end
-
- context 'eligible for return' do
- before do
- allow(return_item.inventory_unit).to receive(:shipped?).and_return(true)
- validator.eligible_for_return?
- end
-
- it 'returns false if no errors were added' do
- expect(subject).to eq false
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
deleted file mode 100644
index eba3e01e36..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::NoReimbursements do
- let(:validator) { described_class.new(return_item) }
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- context 'inventory unit has already been reimbursed' do
- let(:reimbursement) { create(:reimbursement) }
- let(:return_item) { reimbursement.return_items.last }
-
- it 'returns false' do
- expect(subject).to eq false
- end
-
- it 'sets an error' do
- subject
- expect(validator.errors[:inventory_unit_reimbursed]).to eq Spree.t('return_item_inventory_unit_reimbursed')
- end
- end
-
- context 'inventory unit has not been reimbursed' do
- let(:return_item) { create(:return_item) }
-
- it 'returns true' do
- expect(subject).to eq true
- end
- end
- end
-
- describe '#requires_manual_intervention?' do
- subject { validator.requires_manual_intervention? }
-
- context 'not eligible for return' do
- let(:reimbursement) { create(:reimbursement) }
- let(:return_item) { reimbursement.return_items.last }
-
- before do
- validator.eligible_for_return?
- end
-
- it 'returns true if errors were added' do
- expect(subject).to eq true
- end
- end
-
- context 'eligible for return' do
- let(:return_item) { create(:return_item) }
-
- before do
- validator.eligible_for_return?
- end
-
- it 'returns false if no errors were added' do
- expect(subject).to eq false
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb
deleted file mode 100644
index 8779d74881..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::OrderCompleted do
- let(:inventory_unit) { create(:inventory_unit, order: order) }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
- let(:validator) { described_class.new(return_item) }
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- context 'the order was completed' do
- let(:order) { create(:completed_order_with_totals) }
-
- it 'returns true' do
- expect(subject).to be true
- end
- end
-
- context 'the order is not completed' do
- let(:order) { create(:order) }
-
- it 'returns false' do
- expect(subject).to be false
- end
-
- it 'sets an error' do
- subject
- expect(validator.errors[:order_not_completed]).to eq Spree.t('return_item_order_not_completed')
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
deleted file mode 100644
index 10332f0e7d..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::RMARequired, type: :model do
- let(:return_item) { create(:return_item) }
- let(:validator) { Spree::ReturnItem::EligibilityValidator::RMARequired.new(return_item) }
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- context 'there is an rma on the return item' do
- it 'returns true' do
- expect(subject).to be true
- end
- end
-
- context 'there is no rma on the return item' do
- before { allow(return_item).to receive(:return_authorization).and_return(nil) }
-
- it 'returns false abd error' do
- expect(subject).to be false
- expect(validator.errors[:rma_required]).to eq Spree.t('return_item_rma_ineligible')
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb b/spree/core/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb
deleted file mode 100644
index d3f9ba3e4d..0000000000
--- a/spree/core/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper'
-
-describe Spree::ReturnItem::EligibilityValidator::TimeSincePurchase, type: :model do
- let(:inventory_unit) { create(:inventory_unit, order: create(:shipped_order)) }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
- let(:validator) { Spree::ReturnItem::EligibilityValidator::TimeSincePurchase.new(return_item) }
-
- describe '#eligible_for_return?' do
- subject { validator.eligible_for_return? }
-
- context 'it is within the return timeframe' do
- it 'returns true' do
- completed_at = return_item.inventory_unit.order.completed_at - (Spree::Config[:return_eligibility_number_of_days].days / 2)
- return_item.inventory_unit.order.update(completed_at: completed_at)
- expect(subject).to be true
- end
- end
-
- context 'it is past the return timeframe' do
- before do
- completed_at = return_item.inventory_unit.order.completed_at - Spree::Config[:return_eligibility_number_of_days].days - 1.day
- return_item.inventory_unit.order.update(completed_at: completed_at)
- end
-
- it 'returns false' do
- expect(subject).to be false
- end
-
- it 'sets an error' do
- subject
- expect(validator.errors[:number_of_days]).to eq Spree.t('return_item_time_period_ineligible')
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb b/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb
deleted file mode 100644
index d38ea54834..0000000000
--- a/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'spec_helper'
-
-module Spree
- module ReturnItem::ExchangeVariantEligibility
- describe SameOptionValue, type: :model do
- describe '.eligible_variants' do
- subject { SameOptionValue.eligible_variants(variant.reload) }
-
- let(:color_option_type) { create(:option_type, name: 'color') }
- let(:waist_option_type) { create(:option_type, name: 'waist') }
- let(:inseam_option_type) { create(:option_type, name: 'inseam') }
-
- let(:blue_option_value) { create(:option_value, name: 'blue', option_type: color_option_type) }
- let(:red_option_value) { create(:option_value, name: 'red', option_type: color_option_type) }
-
- let(:three_two_waist_option_value) { create(:option_value, name: 32, option_type: waist_option_type) }
- let(:three_four_waist_option_value) { create(:option_value, name: 34, option_type: waist_option_type) }
-
- let(:three_zero_inseam_option_value) { create(:option_value, name: 30, option_type: inseam_option_type) }
- let(:three_one_inseam_option_value) { create(:option_value, name: 31, option_type: inseam_option_type) }
-
- let(:product) { create(:product, option_types: [color_option_type, waist_option_type, inseam_option_type]) }
-
- let!(:variant) { create(:variant, product: product, option_values: [blue_option_value, three_two_waist_option_value, three_zero_inseam_option_value]) }
- let!(:same_option_values_variant) { create(:variant, product: product, option_values: [blue_option_value, three_two_waist_option_value, three_one_inseam_option_value]) }
- let!(:different_color_option_value_variant) { create(:variant, product: product, option_values: [red_option_value, three_two_waist_option_value, three_one_inseam_option_value]) }
- let!(:different_waist_option_value_variant) { create(:variant, product: product, option_values: [blue_option_value, three_four_waist_option_value, three_one_inseam_option_value]) }
-
- before do
- @original_option_type_restrictions = SameOptionValue.option_type_restrictions
- SameOptionValue.option_type_restrictions = ['color', 'waist']
- end
-
- after { SameOptionValue.option_type_restrictions = @original_option_type_restrictions }
-
- it 'returns all other variants for the same product with the same option value for the specified option type' do
- Spree::StockItem.update_all(count_on_hand: 10)
-
- expect(subject.sort).to eq [variant, same_option_values_variant].sort
- end
-
- it 'does not return variants for another product' do
- other_product_variant = create(:variant)
- expect(subject).not_to include other_product_variant
- end
-
- context 'no option value restrictions are specified' do
- before do
- @original_option_type_restrictions = SameOptionValue.option_type_restrictions
- SameOptionValue.option_type_restrictions = []
- end
-
- after { SameOptionValue.option_type_restrictions = @original_option_type_restrictions }
-
- it 'returns all variants for the product' do
- Spree::StockItem.update_all(count_on_hand: 10)
-
- expect(subject.sort).to eq product.reload.variants.to_a.sort
- end
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb b/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb
deleted file mode 100644
index 7f2bb74fca..0000000000
--- a/spree/core/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'spec_helper'
-
-module Spree
- module ReturnItem::ExchangeVariantEligibility
- describe SameProduct, type: :model do
- let(:store) { @default_store }
-
- describe '.eligible_variants' do
- context 'product has no variants' do
- it 'returns the default variant for the same product' do
- product = create(:product)
- product.default_variant.stock_items.first.update_column(:count_on_hand, 10)
-
- expect(SameProduct.eligible_variants(product.default_variant)).to eq [product.default_variant]
- end
- end
-
- context 'product has variants' do
- it 'returns all variants for the same product' do
- product = create(:product, variants: Array.new(3) { create(:variant) })
- product.variants.map { |v| v.stock_items.first.update_column(:count_on_hand, 10) }
-
- expect(SameProduct.eligible_variants(product.variants.first).sort).to eq product.variants.sort
- end
- end
-
- it 'does not return variants for another product' do
- variant = create(:variant)
- other_product_variant = create(:variant)
- expect(SameProduct.eligible_variants(variant)).not_to include other_product_variant
- end
-
- it 'only returns variants that are on hand or backorderable' do
- product = create(:product, variants: Array.new(3) { create(:variant) })
- in_stock_variant = product.variants.first
- backorderable_variant = product.variants.second
- not_backorderable_variant = product.variants.third
-
- in_stock_variant.stock_items.first.update_column(:count_on_hand, 10)
- not_backorderable_variant.stock_items.first.update_column(:backorderable, false)
-
- expect(SameProduct.eligible_variants(in_stock_variant)).to include(in_stock_variant)
- expect(SameProduct.eligible_variants(in_stock_variant)).to include(backorderable_variant)
- end
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/return_item_spec.rb b/spree/core/spec/models/spree/return_item_spec.rb
deleted file mode 100644
index 581aaf10a7..0000000000
--- a/spree/core/spec/models/spree/return_item_spec.rb
+++ /dev/null
@@ -1,811 +0,0 @@
-require 'spec_helper'
-
-shared_examples 'an invalid state transition' do |status, expected_status|
- let(:status) { status }
-
- it "cannot transition to #{expected_status}" do
- expect { subject }.to raise_error(StateMachines::InvalidTransition)
- end
-end
-
-describe Spree::ReturnItem, type: :model do
- all_reception_statuses = Spree::ReturnItem.state_machines[:reception_status].states.map(&:name).map(&:to_s)
- all_acceptance_statuses = Spree::ReturnItem.state_machines[:acceptance_status].states.map(&:name).map(&:to_s)
-
- before do
- allow_any_instance_of(Spree::Order).to receive_messages(return!: true)
- end
-
- describe '#receive!' do
- subject { return_item.receive! }
-
- let(:now) { Time.current }
- let(:inventory_unit) { create(:inventory_unit, state: 'shipped') }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
-
- before do
- inventory_unit.update!(state: 'shipped')
- return_item.update!(reception_status: 'awaiting')
- allow(return_item).to receive(:eligible_for_return?).and_return(true)
- end
-
- it 'returns the inventory unit' do
- subject
- expect(inventory_unit.reload.state).to eq 'returned'
- end
-
- it 'attempts to accept the return item' do
- expect(return_item).to receive(:attempt_accept)
- subject
- end
-
- context 'with a stock location' do
- let(:stock_item) { inventory_unit.find_stock_item }
- let!(:customer_return) { create(:customer_return_without_return_items, return_items: [return_item], stock_location_id: inventory_unit.shipment.stock_location_id) }
-
- before do
- inventory_unit.update!(state: 'shipped')
- return_item.update!(reception_status: 'awaiting')
- end
-
- it 'increases the count on hand' do
- expect { subject }.to change { stock_item.reload.count_on_hand }.by(1)
- end
-
- context 'when the variant is not resellable' do
- before { return_item.update(resellable: false) }
-
- it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
- end
-
- context 'when variant does not track inventory' do
- before do
- inventory_unit.update!(state: 'shipped')
- inventory_unit.variant.update!(track_inventory: false)
- return_item.update!(reception_status: 'awaiting')
- end
-
- it 'does not increase the count on hand' do
- expect { subject }.not_to change { stock_item.reload.count_on_hand }
- end
- end
-
- context 'when the restock_inventory preference is false' do
- before do
- Spree::Config[:restock_inventory] = false
- end
-
- it 'does not increase the count on hand' do
- expect { subject }.not_to change { stock_item.reload.count_on_hand }
- end
- end
- end
- end
-
- describe '#display_pre_tax_amount' do
- let(:pre_tax_amount) { 21.22 }
- let(:return_item) { build(:return_item, pre_tax_amount: pre_tax_amount) }
-
- it 'returns a Spree::Money' do
- expect(return_item.display_pre_tax_amount).to eq(Spree::Money.new(pre_tax_amount))
- end
- end
-
- describe '#pre_tax_amount=' do
- let(:return_item) { build :return_item }
- let(:amount) { '3,0A0' }
-
- before do
- return_item.pre_tax_amount = amount
- end
-
- it 'is expected to equal to localized number' do
- expect(return_item.pre_tax_amount).to eq(Spree::LocalizedNumber.parse(amount))
- end
- end
-
- describe '.default_refund_amount_calculator' do
- it 'defaults to the default refund amount calculator' do
- expect(Spree::ReturnItem.refund_amount_calculator).to eq Spree::Calculator::Returns::DefaultRefundAmount
- end
- end
-
- describe 'pre_tax_amount calculations on create' do
- let(:inventory_unit) { build(:inventory_unit) }
-
- before { subject.save! }
-
- context 'pre tax amount is not specified' do
- subject { build(:return_item, inventory_unit: inventory_unit) }
-
- context 'not an exchange' do
- it { expect(subject.pre_tax_amount).to eq Spree::Calculator::Returns::DefaultRefundAmount.new.compute(subject) }
- end
-
- context 'an exchange' do
- subject { create(:exchange_return_item) }
-
- it { expect(subject.pre_tax_amount).to eq 0.0 }
- end
- end
-
- context 'pre tax amount is specified' do
- subject { build(:return_item, inventory_unit: inventory_unit, pre_tax_amount: 100) }
-
- it { expect(subject.pre_tax_amount).to eq 100 }
- end
- end
-
- describe '.from_inventory_unit' do
- subject { Spree::ReturnItem.from_inventory_unit(inventory_unit) }
-
- let(:inventory_unit) { build(:inventory_unit) }
-
- context 'with a cancelled return item' do
- let!(:return_item) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'cancelled') }
-
- it { is_expected.not_to be_persisted }
- end
-
- context 'with a non-cancelled return item' do
- let!(:return_item) { create(:return_item, inventory_unit: inventory_unit) }
-
- it { is_expected.to be_persisted }
- end
- end
-
- describe 'reception_status state_machine' do
- subject(:return_item) { create(:return_item) }
-
- it 'starts off in the awaiting state' do
- expect(return_item).to be_awaiting
- end
- end
-
- describe 'acceptance_status state_machine' do
- subject(:return_item) { create(:return_item) }
-
- it 'starts off in the pending state' do
- expect(return_item).to be_pending
- end
- end
-
- describe '#receive' do
- subject { return_item.receive! }
-
- let(:inventory_unit) { create(:inventory_unit, order: create(:shipped_order)) }
- let(:return_item) { create(:return_item, reception_status: status, inventory_unit: inventory_unit) }
-
- context 'awaiting status' do
- let(:status) { 'awaiting' }
-
- before do
- expect(return_item.inventory_unit).to receive(:return!)
- subject
- end
-
- it 'transitions successfully' do
- expect(return_item).to be_received
- end
- end
-
- (all_reception_statuses - ['awaiting']).each do |invalid_transition_status|
- context "return_item has a reception status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'received'
- end
- end
- end
-
- describe '#cancel' do
- subject { return_item.cancel! }
-
- let(:return_item) { create(:return_item, reception_status: status) }
-
- context 'awaiting status' do
- let(:status) { 'awaiting' }
-
- before { subject }
-
- it 'transitions successfully' do
- expect(return_item).to be_cancelled
- end
- end
-
- (all_reception_statuses - ['awaiting']).each do |invalid_transition_status|
- context "return_item has a reception status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'cancelled'
- end
- end
- end
-
- describe '#give' do
- subject { return_item.give! }
-
- let(:return_item) { create(:return_item, reception_status: status) }
-
- context 'awaiting status' do
- let(:status) { 'awaiting' }
-
- before { subject }
-
- it 'transitions successfully' do
- expect(return_item).to be_given_to_customer
- end
- end
-
- (all_reception_statuses - ['awaiting']).each do |invalid_transition_status|
- context "return_item has a reception status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'give_to_customer'
- end
- end
- end
-
- describe '#attempt_accept' do
- subject { return_item.attempt_accept! }
-
- let(:return_item) { create(:return_item, acceptance_status: status) }
- let(:validator_errors) { {} }
- let(:validator_double) { double(errors: validator_errors) }
-
- before do
- allow(return_item).to receive(:validator).and_return(validator_double)
- end
-
- context 'pending status' do
- let(:status) { 'pending' }
-
- before do
- allow(return_item).to receive(:eligible_for_return?).and_return(true)
- subject
- end
-
- it 'transitions successfully' do
- expect(return_item).to be_accepted
- end
-
- it 'has no acceptance status errors' do
- expect(return_item.acceptance_status_errors).to be_empty
- end
- end
-
- (all_acceptance_statuses - ['accepted', 'pending']).each do |invalid_transition_status|
- context "return_item has an acceptance status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'accepted'
- end
- end
-
- context 'not eligible for return' do
- let(:status) { 'pending' }
- let(:validator_errors) { { number_of_days: 'Return Item is outside the eligible time period' } }
-
- before do
- allow(return_item).to receive(:eligible_for_return?).and_return(false)
- end
-
- context 'manual intervention required' do
- before do
- allow(return_item).to receive(:requires_manual_intervention?).and_return(true)
- subject
- end
-
- it 'transitions to manual intervention required' do
- expect(return_item).to be_manual_intervention_required
- end
-
- it 'sets the acceptance status errors' do
- expect(return_item.acceptance_status_errors).to eq validator_errors
- end
- end
-
- context 'manual intervention not required' do
- before do
- allow(return_item).to receive(:requires_manual_intervention?).and_return(false)
- subject
- end
-
- it 'transitions to rejected' do
- expect(return_item).to be_rejected
- end
-
- it 'sets the acceptance status errors' do
- expect(return_item.acceptance_status_errors).to eq validator_errors
- end
- end
- end
- end
-
- describe '#reject' do
- subject { return_item.reject! }
-
- let(:return_item) { create(:return_item, acceptance_status: status) }
-
- context 'pending status' do
- let(:status) { 'pending' }
-
- before { subject }
-
- it 'transitions successfully' do
- expect(return_item).to be_rejected
- end
-
- it 'has no acceptance status errors' do
- expect(return_item.acceptance_status_errors).to be_empty
- end
- end
-
- (all_acceptance_statuses - ['accepted', 'pending', 'manual_intervention_required']).each do |invalid_transition_status|
- context "return_item has an acceptance status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'rejected'
- end
- end
- end
-
- describe '#accept' do
- subject { return_item.accept! }
-
- let(:return_item) { create(:return_item, acceptance_status: status) }
-
- context 'pending status' do
- let(:status) { 'pending' }
-
- before { subject }
-
- it 'transitions successfully' do
- expect(return_item).to be_accepted
- end
-
- it 'has no acceptance status errors' do
- expect(return_item.acceptance_status_errors).to be_empty
- end
- end
-
- (all_acceptance_statuses - ['accepted', 'pending', 'manual_intervention_required']).each do |invalid_transition_status|
- context "return_item has an acceptance status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'accepted'
- end
- end
- end
-
- describe '#require_manual_intervention' do
- subject { return_item.require_manual_intervention! }
-
- let(:return_item) { create(:return_item, acceptance_status: status) }
-
- context 'pending status' do
- let(:status) { 'pending' }
-
- before { subject }
-
- it 'transitions successfully' do
- expect(return_item).to be_manual_intervention_required
- end
-
- it 'has no acceptance status errors' do
- expect(return_item.acceptance_status_errors).to be_empty
- end
- end
-
- (all_acceptance_statuses - ['accepted', 'pending', 'manual_intervention_required']).each do |invalid_transition_status|
- context "return_item has an acceptance status of #{invalid_transition_status}" do
- it_behaves_like 'an invalid state transition', invalid_transition_status, 'manual_intervention_required'
- end
- end
- end
-
- describe 'validity for reimbursements' do
- subject { return_item }
-
- let(:return_item) { create(:return_item, acceptance_status: acceptance_status) }
- let(:acceptance_status) { 'pending' }
-
- before { return_item.reimbursement = build(:reimbursement) }
-
- context 'when acceptance_status is accepted' do
- let(:acceptance_status) { 'accepted' }
-
- it 'is valid' do
- expect(subject).to be_valid
- end
- end
-
- context 'when acceptance_status is accepted' do
- let(:acceptance_status) { 'pending' }
-
- it 'is valid' do
- expect(subject).not_to be_valid
- expect(subject.errors.messages).to eq(reimbursement: [I18n.t(:cannot_be_associated_unless_accepted, scope: 'activerecord.errors.models.spree/return_item.attributes.reimbursement')])
- end
- end
- end
-
- describe '#exchange_requested?' do
- context 'exchange variant exists' do
- before { allow(subject).to receive(:exchange_variant) { build(:variant) } }
-
- it { expect(subject.exchange_requested?).to eq true }
- end
-
- context 'exchange variant does not exist' do
- before { allow(subject).to receive(:exchange_variant).and_return(nil) }
-
- it { expect(subject.exchange_requested?).to eq false }
- end
- end
-
- describe '#exchange_processed?' do
- context 'exchange inventory unit exists' do
- before { allow(subject).to receive(:exchange_inventory_units) { build_list(:inventory_unit, 1) } }
-
- it { expect(subject.exchange_processed?).to eq true }
- end
-
- context 'exchange inventory unit does not exist' do
- before { allow(subject).to receive(:exchange_inventory_units).and_return([]) }
-
- it { expect(subject.exchange_processed?).to eq false }
- end
- end
-
- describe '#exchange_required?' do
- context 'exchange has been requested and not yet processed' do
- before do
- allow(subject).to receive(:exchange_requested?).and_return(true)
- allow(subject).to receive(:exchange_processed?).and_return(false)
- end
-
- it { expect(subject.exchange_required?).to be true }
- end
-
- context 'exchange has not been requested' do
- before { allow(subject).to receive(:exchange_requested?).and_return(false) }
-
- it { expect(subject.exchange_required?).to be false }
- end
-
- context 'exchange has been requested and processed' do
- before do
- allow(subject).to receive(:exchange_requested?).and_return(true)
- allow(subject).to receive(:exchange_processed?).and_return(true)
- end
-
- it { expect(subject.exchange_required?).to be false }
- end
- end
-
- describe '#eligible_exchange_variants' do
- it 'uses the exchange variant calculator to compute possible variants to exchange for' do
- return_item = build(:return_item)
- expect(Spree::ReturnItem.exchange_variant_engine).to receive(:eligible_variants).with(return_item.variant)
- return_item.eligible_exchange_variants
- end
- end
-
- describe '.exchange_variant_engine' do
- it 'defaults to the same product calculator' do
- expect(Spree::ReturnItem.exchange_variant_engine).to eq Spree::ReturnItem::ExchangeVariantEligibility::SameProduct
- end
- end
-
- describe 'exchange pre_tax_amount' do
- let(:return_item) { build(:return_item) }
-
- context 'the return item is intended to be exchanged' do
- before do
- return_item.inventory_unit.variant.update_column(:track_inventory, false)
- return_item.exchange_variant = return_item.inventory_unit.variant
- end
-
- it do
- return_item.pre_tax_amount = 5.0
- return_item.save!
- expect(return_item.reload.pre_tax_amount).to eq 0.0
- end
- end
-
- context 'the return item is not intended to be exchanged' do
- it do
- return_item.pre_tax_amount = 5.0
- return_item.save!
- expect(return_item.reload.pre_tax_amount).to eq 5.0
- end
- end
- end
-
- describe '#build_default_exchange_inventory_unit' do
- subject { return_item.build_default_exchange_inventory_unit }
-
- let(:return_item) { build(:return_item) }
-
- context 'the return item is intended to be exchanged' do
- before { allow(return_item).to receive(:exchange_variant).and_return(build(:variant)) }
-
- context 'an exchange inventory unit already exists' do
- before do
- allow(return_item).to receive(:exchange_inventory_units).and_return(build_list(:inventory_unit, 1))
- end
-
- it { expect(subject).to be_nil }
- end
-
- context 'no exchange inventory unit exists' do
- it 'builds a pending inventory unit with references to the return item, variant, and previous inventory unit' do
- expect(subject.variant).to eq return_item.exchange_variant
- expect(subject.pending).to eq true
- expect(subject).not_to be_persisted
- expect(subject.original_return_item).to eq return_item
- expect(subject.line_item).to eq return_item.inventory_unit.line_item
- expect(subject.order).to eq return_item.inventory_unit.order
- end
- end
- end
-
- context 'the return item is not intended to be exchanged' do
- it { expect(subject).to be_nil }
- end
- end
-
- describe '#exchange_shipments' do
- it "returns the exchange inventory unit's shipment" do
- inventory_unit = build(:inventory_unit)
- subject.exchange_inventory_units << inventory_unit
- expect(subject.exchange_shipments).to include inventory_unit.shipment
- end
- end
-
- describe '#shipment' do
- it "returns the inventory unit's shipment" do
- inventory_unit = build(:inventory_unit)
- subject.inventory_unit = inventory_unit
- expect(subject.shipment).to eq inventory_unit.shipment
- end
- end
-
- describe 'inventory_unit uniqueness' do
- subject do
- build(:return_item, return_authorization: old_return_item.return_authorization,
- inventory_unit: old_return_item.inventory_unit)
- end
-
- let!(:old_return_item) { create(:return_item, reception_status: old_reception_status) }
- let(:old_reception_status) { 'awaiting' }
-
- context 'with other awaiting return items exist for the same inventory unit' do
- let(:old_reception_status) { 'awaiting' }
-
- it 'cancels the others' do
- expect do
- subject.save!
- end.to change { old_return_item.reload.reception_status }.from('awaiting').to('cancelled')
- end
-
- it 'does not cancel itself' do
- subject.save!
- expect(subject).to be_awaiting
- end
- end
-
- context 'with other cancelled return items exist for the same inventory unit' do
- let(:old_reception_status) { 'cancelled' }
-
- it 'succeeds' do
- expect { subject.save! }.not_to raise_error
- end
- end
-
- context 'with other received return items exist for the same inventory unit' do
- let(:old_reception_status) { 'received' }
-
- it 'is invalid' do
- expect(subject).not_to be_valid
- expect(subject.errors.to_a).to eq ["Inventory unit #{subject.inventory_unit_id} has already been taken by return item #{old_return_item.id}"]
- end
- end
-
- context 'with other given_to_customer return items exist for the same inventory unit' do
- let(:old_reception_status) { 'given_to_customer' }
-
- it 'is invalid' do
- expect(subject).not_to be_valid
- expect(subject.errors.to_a).to eq ["Inventory unit #{subject.inventory_unit_id} has already been taken by return item #{old_return_item.id}"]
- end
- end
- end
-
- describe 'valid exchange variant' do
- subject { return_item }
-
- before { subject.save }
-
- context "return item doesn't have an exchange variant" do
- let(:return_item) { create(:return_item) }
-
- it 'is valid' do
- expect(subject).to be_valid
- end
- end
-
- context 'return item has an exchange variant' do
- let(:return_item) { create(:exchange_return_item) }
- let(:exchange_variant) { create(:on_demand_variant, product: return_item.inventory_unit.variant.product) }
-
- context 'the exchange variant is eligible' do
- before { return_item.exchange_variant = exchange_variant }
-
- it 'is valid' do
- expect(subject).to be_valid
- end
- end
-
- context 'the exchange variant is not eligible' do
- context 'new return item' do
- let(:return_item) { build(:return_item) }
- let(:exchange_variant) { create(:variant, product: return_item.inventory_unit.variant.product) }
-
- before do
- exchange_variant.stock_items.each do |item|
- item.update_column(:backorderable, false)
- end
- return_item.exchange_variant = exchange_variant
- end
-
- it 'is invalid' do
- expect(subject).not_to be_valid
- end
-
- it 'adds an error message about the invalid exchange variant' do
- subject.valid?
- expect(subject.errors.to_a).to eq ['Invalid exchange variant.']
- end
- end
-
- context 'the exchange variant has been updated' do
- before do
- other_variant = create(:variant)
- return_item.exchange_variant_id = other_variant.id
- subject.valid?
- end
-
- it 'is invalid' do
- expect(subject).not_to be_valid
- end
-
- it 'adds an error message about the invalid exchange variant' do
- expect(subject.errors.to_a).to eq ['Invalid exchange variant.']
- end
- end
-
- context 'the exchange variant has not been updated' do
- before do
- other_variant = create(:variant)
- return_item.update_column(:exchange_variant_id, other_variant.id)
- return_item.reload
- subject.valid?
- end
-
- it 'is valid' do
- expect(subject).to be_valid
- end
- end
- end
- end
- end
-
- describe 'included tax in total' do
- let(:inventory_unit) { create(:inventory_unit, state: 'shipped') }
- let(:return_item) do
- create(
- :return_item,
- inventory_unit: inventory_unit,
- included_tax_total: 10
- )
- end
-
- it 'includes included tax total' do
- expect(return_item.pre_tax_amount).to eq 10
- expect(return_item.included_tax_total).to eq 10
- expect(return_item.total).to eq 20
- end
- end
-
- describe '#process_inventory_unit!' do
- subject { return_item.send(:process_inventory_unit!) }
-
- let(:inventory_unit) { create(:inventory_unit, state: 'shipped') }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'awaiting') }
- let!(:stock_item) { inventory_unit.find_stock_item }
-
- before { return_item.update!(reception_status: 'awaiting') }
-
- it { expect { subject }.to change(inventory_unit, :state).to('returned').from('shipped') }
-
- context 'stock should restock' do
- let(:stock_movement_attributes) do
- {
- stock_item_id: stock_item.id,
- quantity: 1,
- originator: return_item.return_authorization
- }
- end
-
- it { expect(subject).to eq(Spree::StockMovement.find_by(stock_movement_attributes)) }
- end
-
- context 'stock should not restock' do
- context 'return_item is not resellable' do
- before { return_item.resellable = false }
-
- it { expect(subject).to be_nil }
- it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
- end
-
- context 'variant should not track inventory' do
- before { return_item.variant.track_inventory = false }
-
- it { expect(subject).to be_nil }
- it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
- end
-
- context 'stock_item not present' do
- before { stock_item.destroy }
-
- it { expect(subject).to be_nil }
- it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
- end
-
- context 'when restock inventory preference false' do
- before { Spree::Config[:restock_inventory] = false }
-
- it { expect(subject).to be_nil }
- it { expect { subject }.not_to change { stock_item.reload.count_on_hand } }
- end
- end
-
- describe '#currency' do
- subject { return_item }
-
- it 'responds to currency method' do
- expect(subject.respond_to?(:currency)).to eq true
- end
- end
- end
-
- describe 'custom events', events: true do
- describe 'return_item.received' do
- let(:inventory_unit) { create(:inventory_unit, state: 'shipped') }
- let(:return_item) { create(:return_item, inventory_unit: inventory_unit, reception_status: 'awaiting') }
-
- before do
- allow(return_item).to receive(:eligible_for_return?).and_return(true)
- end
-
- it 'publishes return_item.received event when received' do
- expect(return_item).to receive(:publish_event).with('return_item.received')
- allow(return_item).to receive(:publish_event).with(anything)
-
- return_item.receive!
- end
- end
-
- describe 'return_item.canceled' do
- let(:return_item) { create(:return_item, reception_status: 'awaiting') }
-
- it 'publishes return_item.canceled event when canceled' do
- expect(return_item).to receive(:publish_event).with('return_item.canceled')
- allow(return_item).to receive(:publish_event).with(anything)
-
- return_item.cancel!
- end
- end
-
- describe 'return_item.given' do
- let(:return_item) { create(:return_item, reception_status: 'awaiting') }
-
- it 'publishes return_item.given event when given to customer' do
- expect(return_item).to receive(:publish_event).with('return_item.given')
- allow(return_item).to receive(:publish_event).with(anything)
-
- return_item.give!
- end
- end
- end
-end
diff --git a/spree/core/spec/models/spree/returns_calculator_spec.rb b/spree/core/spec/models/spree/returns_calculator_spec.rb
deleted file mode 100644
index cdad35a47c..0000000000
--- a/spree/core/spec/models/spree/returns_calculator_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-module Spree
- describe ReturnsCalculator, type: :model do
- subject { ReturnsCalculator.new }
-
- let(:return_item) { build(:return_item) }
-
- it 'compute_shipment must be overridden' do
- expect do
- subject.compute(return_item)
- end.to raise_error(NotImplementedError)
- end
- end
-end
diff --git a/spree/core/spec/models/spree/store_spec.rb b/spree/core/spec/models/spree/store_spec.rb
index 9f7d073ddd..95dd5c119b 100644
--- a/spree/core/spec/models/spree/store_spec.rb
+++ b/spree/core/spec/models/spree/store_spec.rb
@@ -67,13 +67,13 @@ describe Spree::Store, type: :model, without_global_store: true do
it { expect(subject.shipments).to eq([shipment]) }
end
- describe '#return_authorizations' do
+ describe '#returns' do
let!(:order) { create(:shipped_order, store: subject) }
let!(:order_2) { create(:shipped_order, store: create(:store)) }
- let!(:return_authorization) { create(:return_authorization, order: order) }
- let!(:return_authorization_2) { create(:return_authorization, order: order_2) }
+ let!(:return_record) { create(:return, order: order, store: subject) }
+ let!(:return_record_2) { create(:return, order: order_2, store: order_2.store) }
- it { expect(subject.return_authorizations).to eq([return_authorization]) }
+ it { expect(subject.returns).to eq([return_record]) }
end
describe '#inventory_units' do
diff --git a/spree/core/spec/services/spree/seeds/returns_environment_spec.rb b/spree/core/spec/services/spree/seeds/returns_environment_spec.rb
index c5a2d3579b..d9ef79deda 100644
--- a/spree/core/spec/services/spree/seeds/returns_environment_spec.rb
+++ b/spree/core/spec/services/spree/seeds/returns_environment_spec.rb
@@ -19,70 +19,46 @@ RSpec.describe Spree::Seeds::ReturnsEnvironment do
end
end
- describe 'ReturnAuthorizationReason' do
- let(:expected_reasons) do
- [
- 'Better price available',
- 'Missed estimated delivery date',
- 'Missing parts or accessories',
- 'Damaged/Defective',
- 'Different from what was ordered',
- 'Different from description',
- 'No longer needed/wanted',
- 'Accidental order',
- 'Unauthorized purchase'
- ]
- end
+ describe 'ReturnReason' do
+ let(:expected_reasons) { described_class::RETURN_REASONS }
- it 'creates all ReturnAuthorizationReasons' do
- expect { subject }.to change(Spree::ReturnAuthorizationReason, :count).by(expected_reasons.count)
+ it 'creates all ReturnReasons' do
+ expect { subject }.to change(Spree::ReturnReason, :count).by(expected_reasons.count)
expected_reasons.each do |reason|
- expect(Spree::ReturnAuthorizationReason.find_by(name: reason)).to be_present
+ expect(Spree::ReturnReason.find_by(name: reason)).to be_present
end
end
- context 'when ReturnAuthorizationReasons already exist' do
+ context 'when ReturnReasons already exist' do
before do
- expected_reasons.each do |reason|
- Spree::ReturnAuthorizationReason.create!(name: reason)
- end
+ expected_reasons.each { |reason| Spree::ReturnReason.create!(name: reason) }
end
- it "doesn't create new ReturnAuthorizationReasons" do
- expect { subject }.not_to change(Spree::ReturnAuthorizationReason, :count)
+ it "doesn't create new ReturnReasons" do
+ expect { subject }.not_to change(Spree::ReturnReason, :count)
end
end
end
- describe 'ReimbursementType' do
- let(:expected_types) do
- [
- { name: 'Store Credit', type: 'Spree::ReimbursementType::StoreCredit' },
- { name: 'Exchange', type: 'Spree::ReimbursementType::Exchange' },
- { name: 'Original payment', type: 'Spree::ReimbursementType::OriginalPayment' }
- ]
- end
+ describe 'ClaimReason' do
+ let(:expected_reasons) { described_class::CLAIM_REASONS }
- it 'creates all ReimbursementTypes' do
- expect { subject }.to change(Spree::ReimbursementType, :count).by(expected_types.count)
+ it 'creates all ClaimReasons' do
+ expect { subject }.to change(Spree::ClaimReason, :count).by(expected_reasons.count)
- expected_types.each do |type_attrs|
- reimbursement_type = Spree::ReimbursementType.find_by(name: type_attrs[:name])
- expect(reimbursement_type).to be_present
- expect(reimbursement_type.type).to eq(type_attrs[:type])
+ expected_reasons.each do |reason|
+ expect(Spree::ClaimReason.find_by(name: reason)).to be_present
end
end
- context 'when ReimbursementTypes already exist' do
+ context 'when ClaimReasons already exist' do
before do
- expected_types.each do |type_attrs|
- Spree::ReimbursementType.create!(name: type_attrs[:name], type: type_attrs[:type])
- end
+ expected_reasons.each { |reason| Spree::ClaimReason.create!(name: reason) }
end
- it "doesn't create new ReimbursementTypes" do
- expect { subject }.not_to change(Spree::ReimbursementType, :count)
+ it "doesn't create new ClaimReasons" do
+ expect { subject }.not_to change(Spree::ClaimReason, :count)
end
end
end
diff --git a/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb b/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb
index 1d6da416b5..14b29e1b69 100644
--- a/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb
+++ b/spree/core/spec/subscribers/spree/order_status_subscriber_spec.rb
@@ -6,10 +6,21 @@ RSpec.describe Spree::OrderStatusSubscriber do
it 'subscribes to every status-bearing record family' do
expect(described_class.subscription_patterns).to include(
'payment.completed', 'payment.voided', 'refund.created',
- 'fulfillment.updated', 'return_item.received'
+ 'fulfillment.updated', 'return.received'
)
end
+ it 'recomputes the owning order statuses when a return is received' do
+ return_record = create(:approved_return, order: order, store: order.store)
+ Spree::Returns::Receive.call(return_record: return_record)
+ order.update_columns(fulfillment_status: nil)
+
+ event = Spree::Event.new(name: 'return.received', payload: { 'id' => return_record.prefixed_id }, store_id: order.store_id)
+ described_class.new.handle(event)
+
+ expect(order.reload.fulfillment_status).to be_present
+ end
+
it 'recomputes the owning order statuses through the single writer' do
payment = create(:payment, order: order, cart: nil, amount: order.total, state: 'completed')
order.update_columns(payment_status: nil)
diff --git a/spree/emails/app/mailers/spree/reimbursement_mailer.rb b/spree/emails/app/mailers/spree/reimbursement_mailer.rb
deleted file mode 100644
index 2b2f751491..0000000000
--- a/spree/emails/app/mailers/spree/reimbursement_mailer.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Spree
- class ReimbursementMailer < BaseMailer
- helper Spree::MailHelper
-
- def reimbursement_email(reimbursement, resend = false)
- @reimbursement = reimbursement.respond_to?(:id) ? reimbursement : Spree::Reimbursement.find(reimbursement)
- @order = @reimbursement.order
- current_store = @reimbursement.store || Spree::Store.default
- with_store_locale(current_store, @order.locale) do
- subject = order_email_subject(current_store, Spree.t('reimbursement_mailer.reimbursement_email.subject'), @order.number, resend: resend)
- mail(to: @order.email, subject: subject, store_url: current_store.storefront_url)
- end
- end
- end
-end
diff --git a/spree/emails/app/mailers/spree/return_mailer.rb b/spree/emails/app/mailers/spree/return_mailer.rb
new file mode 100644
index 0000000000..383df9a524
--- /dev/null
+++ b/spree/emails/app/mailers/spree/return_mailer.rb
@@ -0,0 +1,17 @@
+module Spree
+ class ReturnMailer < BaseMailer
+ helper Spree::MailHelper
+
+ # Tells the customer their returned items were refunded. Replaces the
+ # reimbursement email dropped with the ReturnAuthorization chain in 6.0.
+ def refunded_email(return_record, resend = false)
+ @return = return_record.respond_to?(:id) ? return_record : Spree::Return.find(return_record)
+ @order = @return.order
+ current_store = @return.store || Spree::Store.default
+ with_store_locale(current_store, @order.locale) do
+ subject = order_email_subject(current_store, Spree.t('return_mailer.refunded_email.subject'), @order.number, resend: resend)
+ mail(to: @order.email, subject: subject, store_url: current_store.storefront_url)
+ end
+ end
+ end
+end
diff --git a/spree/emails/app/subscribers/spree/reimbursement_email_subscriber.rb b/spree/emails/app/subscribers/spree/reimbursement_email_subscriber.rb
deleted file mode 100644
index 39287c5a79..0000000000
--- a/spree/emails/app/subscribers/spree/reimbursement_email_subscriber.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-module Spree
- class ReimbursementEmailSubscriber < Spree::Subscriber
- subscribes_to 'reimbursement.reimbursed'
-
- def handle(event)
- reimbursement = find_reimbursement(event)
- return unless reimbursement
-
- store = reimbursement.store
- return unless store.prefers_send_consumer_transactional_emails?
-
- ReimbursementMailer.reimbursement_email(reimbursement.id).deliver_later
- end
-
- private
-
- def find_reimbursement(event)
- reimbursement_id = event.payload['id']
- Spree::Reimbursement.find_by_prefix_id(reimbursement_id)
- end
- end
-end
diff --git a/spree/emails/app/subscribers/spree/return_email_subscriber.rb b/spree/emails/app/subscribers/spree/return_email_subscriber.rb
new file mode 100644
index 0000000000..913d023b84
--- /dev/null
+++ b/spree/emails/app/subscribers/spree/return_email_subscriber.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Spree
+ class ReturnEmailSubscriber < Spree::Subscriber
+ subscribes_to 'return.refunded'
+
+ def handle(event)
+ return_record = find_return(event)
+ return unless return_record
+
+ store = return_record.store
+ return unless store.prefers_send_consumer_transactional_emails?
+
+ ReturnMailer.refunded_email(return_record.id).deliver_later
+ end
+
+ private
+
+ def find_return(event)
+ Spree::Return.find_by_prefix_id(event.payload['id'])
+ end
+ end
+end
diff --git a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb b/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb
deleted file mode 100644
index 4cdf1623de..0000000000
--- a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<%= render 'spree/shared/purchased_items_styles' %>
-
-<%= render layout: 'spree/shared/mailer_hero' do %>
- <h1><%= Spree.t('reimbursement_mailer.reimbursement_email.subject') %></h1>
- <p class="greeting"><%= Spree.t('reimbursement_mailer.reimbursement_email.dear_customer', name: name_for(@order)) %></p>
- <p><%= Spree.t('reimbursement_mailer.reimbursement_email.instructions') %></p>
-<% end %>
-
-<table class="section" width="100%" cellpadding="0" cellspacing="0" role="presentation">
- <tr>
- <td>
- <h3 class="f-fallback"><%= Spree.t('reimbursement_mailer.reimbursement_email.refund_summary') %></h3>
- <p class="strong f-fallback"><%= Spree.t('reimbursement_mailer.reimbursement_email.total_refunded', total: @reimbursement.display_total) %></p>
- </td>
- </tr>
-</table>
-
-<% exchange_items = @reimbursement.return_items.exchange_requested.to_a %>
-<% if exchange_items.any? %>
- <table class="section" width="100%" cellpadding="0" cellspacing="0" role="presentation">
- <tr>
- <td>
- <h3 class="f-fallback"><%= Spree.t('reimbursement_mailer.reimbursement_email.exchange_summary') %></h3>
- <% exchange_items.each do |return_item| %>
- <% product_url = spree_storefront_resource_url(return_item.variant.product) %>
- <table class="item" width="100%" cellpadding="0" cellspacing="0" role="presentation">
- <tr>
- <td class="item_image" width="96" valign="middle">
- <% image = return_item.variant.primary_media || return_item.variant.product.primary_media %>
- <%= render 'spree/shared/item_thumbnail_link', image: image, product_url: product_url, alt: return_item.variant.name %>
- </td>
- <td class="item_info" valign="middle">
- <%= link_to return_item.variant.name, product_url, class: 'f-fallback item_name' %>
- <% if return_item.exchange_variant.options_text.present? %>
- <p class="item_meta"><%= return_item.exchange_variant.options_text %></p>
- <% end %>
- </td>
- </tr>
- </table>
- <% end %>
- <% if @reimbursement.return_items.awaiting_return.exists? && Spree::Config[:expedited_exchanges] %>
- <p class="sub f-fallback"><%= Spree.t('reimbursement_mailer.reimbursement_email.days_to_send', days: Spree::Config[:expedited_exchanges_days_window]) %></p>
- <% end %>
- </td>
- </tr>
- </table>
-<% end %>
diff --git a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb b/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb
deleted file mode 100644
index 499227576c..0000000000
--- a/spree/emails/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-<%= Spree.t('reimbursement_mailer.reimbursement_email.dear_customer', name: name_for(@reimbursement.order)) %>
-
-<%= Spree.t('reimbursement_mailer.reimbursement_email.instructions') %>
-
-============================================================
-<%= Spree.t('reimbursement_mailer.reimbursement_email.refund_summary') %>
-============================================================
-<%= Spree.t('reimbursement_mailer.reimbursement_email.total_refunded', total: @reimbursement.display_total) %>
-
-<% if @reimbursement.return_items.exchange_requested.present? %>
-============================================================
-<%= Spree.t('reimbursement_mailer.reimbursement_email.exchange_summary') %>
-============================================================
-<% @reimbursement.return_items.exchange_requested.each do |return_item| %>
-<%= return_item.variant.sku %> <%= return_item.variant.product.name %> <%= "(#{return_item.variant.options_text})" if return_item.variant.options_text.present? -%> -> <%= return_item.exchange_variant.sku %> <%= return_item.exchange_variant.product.name if return_item.exchange_variant.options_text.present? %> <%= "(#{return_item.exchange_variant.options_text})" -%>
-<% end %>
-
-
-<% if @reimbursement.return_items.awaiting_return.present? && Spree::Config[:expedited_exchanges] %>
-<%= Spree.t('reimbursement_mailer.reimbursement_email.days_to_send', days: Spree::Config[:expedited_exchanges_days_window]) %>
-<% end %>
-<% end %>
-<%= Spree.t('reimbursement_mailer.reimbursement_email.thanks') %>
-<%= Spree.t('reimbursement_mailer.reimbursement_email.store_team', store_name: current_store.name) %>
diff --git a/spree/emails/app/views/spree/return_mailer/refunded_email.html.erb b/spree/emails/app/views/spree/return_mailer/refunded_email.html.erb
new file mode 100644
index 0000000000..7d14fdc137
--- /dev/null
+++ b/spree/emails/app/views/spree/return_mailer/refunded_email.html.erb
@@ -0,0 +1,22 @@
+<%= render 'spree/shared/purchased_items_styles' %>
+
+<%= render layout: 'spree/shared/mailer_hero' do %>
+ <h1><%= Spree.t('return_mailer.refunded_email.subject') %></h1>
+ <p class="greeting"><%= Spree.t('return_mailer.refunded_email.dear_customer', name: name_for(@order)) %></p>
+ <p><%= Spree.t('return_mailer.refunded_email.instructions', number: @order.number) %></p>
+<% end %>
+
+<table class="section" width="100%" cellpadding="0" cellspacing="0" role="presentation">
+ <tr>
+ <td>
+ <h3 class="f-fallback"><%= Spree.t('return_mailer.refunded_email.refund_summary') %></h3>
+ <p class="strong f-fallback"><%= Spree.t('return_mailer.refunded_email.total_refunded', total: @return.display_refunded_total) %></p>
+ </td>
+ </tr>
+</table>
+
+<%= render 'spree/shared/order_summary_section',
+ heading: Spree.t('return_mailer.refunded_email.returned_items'),
+ line_items: @return.return_line_items.map(&:line_item),
+ order: @order,
+ totals: false %>
diff --git a/spree/emails/app/views/spree/return_mailer/refunded_email.text.erb b/spree/emails/app/views/spree/return_mailer/refunded_email.text.erb
new file mode 100644
index 0000000000..de628150ed
--- /dev/null
+++ b/spree/emails/app/views/spree/return_mailer/refunded_email.text.erb
@@ -0,0 +1,19 @@
+<%= Spree.t('return_mailer.refunded_email.dear_customer', name: name_for(@order)) %>
+
+<%= Spree.t('return_mailer.refunded_email.instructions', number: @order.number) %>
+
+============================================================
+<%= Spree.t('return_mailer.refunded_email.refund_summary') %>
+============================================================
+<%= Spree.t('return_mailer.refunded_email.total_refunded', total: @return.display_refunded_total) %>
+
+============================================================
+<%= Spree.t('return_mailer.refunded_email.returned_items') %>
+============================================================
+<% @return.return_line_items.each do |line| %>
+ <%= line.variant.sku %> <%= line.variant.product.name %> <%= line.variant.options_text %>
+<% end %>
+============================================================
+
+<%= Spree.t('return_mailer.refunded_email.thanks') %>
+<%= Spree.t('return_mailer.refunded_email.store_team', store_name: current_store.name) %>
diff --git a/spree/emails/lib/spree/emails/engine.rb b/spree/emails/lib/spree/emails/engine.rb
index e31714def4..521e2d175f 100644
--- a/spree/emails/lib/spree/emails/engine.rb
+++ b/spree/emails/lib/spree/emails/engine.rb
@@ -22,7 +22,7 @@ module Spree
Spree.subscribers.concat [
Spree::OrderEmailSubscriber,
Spree::FulfillmentEmailSubscriber,
- Spree::ReimbursementEmailSubscriber,
+ Spree::ReturnEmailSubscriber,
Spree::NewsletterSubscriberEmailSubscriber,
Spree::CustomerEmailSubscriber
]
diff --git a/spree/emails/lib/spree/emails/previews/reimbursement_preview.rb b/spree/emails/lib/spree/emails/previews/reimbursement_preview.rb
deleted file mode 100644
index 228012a8d6..0000000000
--- a/spree/emails/lib/spree/emails/previews/reimbursement_preview.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'spree/core/previews/preview_data'
-
-# Preview Spree reimbursement emails at /rails/mailers/spree/reimbursement
-class Spree::ReimbursementPreview < ActionMailer::Preview
- include Spree::PreviewData::LocaleParam
-
- def reimbursement_email
- reimbursement = Spree::Reimbursement.last
- reimbursement.order.locale = locale if reimbursement && locale.present?
- Spree::ReimbursementMailer.reimbursement_email(reimbursement)
- end
-end
diff --git a/spree/emails/lib/spree/emails/previews/return_preview.rb b/spree/emails/lib/spree/emails/previews/return_preview.rb
new file mode 100644
index 0000000000..46835c97eb
--- /dev/null
+++ b/spree/emails/lib/spree/emails/previews/return_preview.rb
@@ -0,0 +1,12 @@
+require 'spree/core/previews/preview_data'
+
+# Preview Spree return emails at /rails/mailers/spree/return
+class Spree::ReturnPreview < ActionMailer::Preview
+ include Spree::PreviewData::LocaleParam
+
+ def refunded_email
+ return_record = Spree::Return.refunded.last
+ return_record.order.locale = locale if return_record && locale.present?
+ Spree::ReturnMailer.refunded_email(return_record)
+ end
+end
diff --git a/spree/emails/spec/mailers/spree/reimbursement_mailer_spec.rb b/spree/emails/spec/mailers/spree/reimbursement_mailer_spec.rb
deleted file mode 100644
index 1ddf91cbed..0000000000
--- a/spree/emails/spec/mailers/spree/reimbursement_mailer_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'spec_helper'
-require 'email_spec'
-
-describe Spree::ReimbursementMailer, type: :mailer do
- include EmailSpec::Helpers
- include EmailSpec::Matchers
-
- let(:reimbursement) { create(:reimbursement) }
-
- context ':from not set explicitly' do
- it 'uses store mail from address' do
- message = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
- expect(message.from).to eq [@default_store.mail_from_address]
- end
- end
-
- context ':reply_to not set explicitly' do
- it 'uses store customer support email' do
- message = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
- expect(message.reply_to).to eq [@default_store.customer_support_email]
- end
- end
-
- it 'accepts a reimbursement id as an alternative to a Reimbursement object' do
- expect(Spree::Reimbursement).to receive(:find).with(reimbursement.id).and_return(reimbursement)
-
- expect do
- Spree::ReimbursementMailer.reimbursement_email(reimbursement.id).body
- end.not_to raise_error
- end
-
- context 'when order has no customer\'s name' do
- before { allow(reimbursement.order).to receive(:name).and_return(nil) }
-
- specify 'shows Dear Customer in email body' do
- reimbursement_email = described_class.reimbursement_email(reimbursement)
- expect(reimbursement_email).to have_body_text('Dear Customer')
- end
- end
-
- context 'when order has customer\'s name' do
- before { allow(reimbursement.order).to receive(:name).and_return('Test User') }
-
- specify 'shows order\'s user name in email body' do
- reimbursement_email = described_class.reimbursement_email(reimbursement)
- expect(reimbursement_email).to have_body_text('Dear Test User')
- end
- end
-
- context 'emails must be translatable' do
- context 'reimbursement_email' do
- context 'pt-BR locale' do
- before do
- reimbursement
- I18n.enforce_available_locales = false
- pt_br_shipped_email = { spree: { reimbursement_mailer: { reimbursement_email: { dear_customer: 'Caro Cliente,' } } } }
- I18n.backend.store_translations :'pt-BR', pt_br_shipped_email
- allow_any_instance_of(Spree::Store).to receive(:default_locale).and_return('pt-BR')
- end
-
- after do
- I18n.enforce_available_locales = true
- end
-
- it 'localized in HTML template' do
- reimbursement_email = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
- reimbursement_email.html_part.to include('Caro Cliente,')
- end
-
- it 'localized in text template' do
- reimbursement_email = Spree::ReimbursementMailer.reimbursement_email(reimbursement)
- reimbursement_email.text_part.to include('Caro Cliente,')
- end
- end
- end
- end
-end
diff --git a/spree/emails/spec/mailers/spree/return_mailer_spec.rb b/spree/emails/spec/mailers/spree/return_mailer_spec.rb
new file mode 100644
index 0000000000..163055a77d
--- /dev/null
+++ b/spree/emails/spec/mailers/spree/return_mailer_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper'
+require 'email_spec'
+
+describe Spree::ReturnMailer, type: :mailer do
+ include EmailSpec::Helpers
+ include EmailSpec::Matchers
+
+ let(:store) { @default_store }
+ let(:order) { create(:shipped_order, store: store, email: '[email protected]', user: nil) }
+ let(:return_record) { create(:received_return, order: order, store: store) }
+
+ subject(:message) { described_class.refunded_email(return_record) }
+
+ context ':from not set explicitly' do
+ it 'falls back to store mail from address' do
+ expect(message.from).to eq([store.mail_from_address])
+ end
+ end
+
+ context ':reply_to not set explicitly' do
+ it 'uses store customer support email' do
+ expect(message.reply_to).to eq([store.customer_support_email])
+ end
+ end
+
+ it 'goes to the address on the order' do
+ expect(message.to).to eq([order.email])
+ end
+
+ it 'names the returned items' do
+ variant = return_record.return_line_items.first.variant
+ expect(message.body.encoded).to include(variant.product.name)
+ end
+
+ it 'accepts an id as well as a record' do
+ expect(described_class.refunded_email(return_record.id).to).to eq([order.email])
+ end
+end
diff --git a/spree/emails/spec/models/spree/reimbursement_spec.rb b/spree/emails/spec/models/spree/reimbursement_spec.rb
deleted file mode 100644
index d4c84d5786..0000000000
--- a/spree/emails/spec/models/spree/reimbursement_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require 'spec_helper'
-
-describe Spree::Reimbursement, type: :model do
- describe '#perform!' do
- let!(:adjustments) { [] } # placeholder to ensure it gets run prior the "before" at this level
-
- let!(:tax_rate) { nil }
- let!(:tax_zone) { create(:zone_with_country, default_tax: true) }
-
- let(:store) { @default_store }
- let(:order) { create(:shipped_order, line_items_count: 1, line_items_price: line_items_price, shipment_cost: 0, store: store) }
- let(:line_items_price) { BigDecimal(10) }
- let(:line_item) { order.line_items.first }
- let(:inventory_unit) { line_item.inventory_units.first }
- let(:payment) { order.payments.first }
- let(:payment_amount) { order.total }
- let(:customer_return) { build(:customer_return, return_items: [return_item], store: store) }
- let(:return_item) { build(:return_item, inventory_unit: inventory_unit) }
-
- let!(:default_refund_reason) { Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false) }
-
- let(:reimbursement) { create(:reimbursement, customer_return: customer_return, order: order, return_items: [return_item]) }
-
- let(:store_credit_reimbursement_type) { create(:reimbursement_type, name: 'StoreCredit', type: 'Spree::ReimbursementType::StoreCredit') }
-
- before do
- customer_return.save!
- return_item.accept!
- end
-
- it 'publishes reimbursement.reimbursed event when performing', events: true do
- expect(reimbursement).to receive(:publish_event).with('reimbursement.reimbursed')
- allow(reimbursement).to receive(:publish_event).with(anything)
-
- reimbursement.perform!
- end
- end
-end
diff --git a/spree/emails/spec/subscribers/spree/reimbursement_email_subscriber_spec.rb b/spree/emails/spec/subscribers/spree/reimbursement_email_subscriber_spec.rb
deleted file mode 100644
index 21685b24a0..0000000000
--- a/spree/emails/spec/subscribers/spree/reimbursement_email_subscriber_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Spree::ReimbursementEmailSubscriber do
- let(:reimbursement) { create(:reimbursement) }
- let(:store) { reimbursement.store }
- let(:subscriber) { described_class.new }
-
- def mock_event(reimbursement)
- double('Event', payload: { 'id' => reimbursement.prefixed_id })
- end
-
- before do
- store.update!(preferences: store.preferences.merge(send_consumer_transactional_emails: true))
- end
-
- describe 'reimbursement.reimbursed event' do
- it 'sends reimbursement email' do
- expect(Spree::ReimbursementMailer).to receive(:reimbursement_email).with(reimbursement.id).and_return(double(deliver_later: true))
-
- subscriber.handle(mock_event(reimbursement))
- end
-
- context 'when store does not prefer transactional emails' do
- before do
- store.update!(preferences: store.preferences.merge(send_consumer_transactional_emails: false))
- end
-
- it 'does not send reimbursement email' do
- expect(Spree::ReimbursementMailer).not_to receive(:reimbursement_email)
-
- subscriber.handle(mock_event(reimbursement))
- end
- end
-
- context 'when reimbursement not found' do
- it 'does not raise an error' do
- reimbursement.destroy
-
- expect { subscriber.handle(mock_event(reimbursement)) }.not_to raise_error
- end
- end
- end
-end