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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Admin API: Orders CRUD, state transitions, line items, and full test coverage
Damian Legawiec3c33d00b76ee
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yamlindex c8153c4281..ad4155feed 100644--- a/docs/api-reference/admin.yaml+++ b/docs/api-reference/admin.yaml@@ -90,8 +90,8 @@ paths:viewable_type: Spree::Variantposition: 1alt:- created_at: '2026-03-06T19:22:55.186Z'- updated_at: '2026-03-06T19:22:55.193Z'+ created_at: '2026-03-06T19:36:27.564Z'+ updated_at: '2026-03-06T19:36:27.571Z'meta:page: 1limit: 25@@ -209,8 +209,8 @@ paths:viewable_type: Spree::Variantposition: 1alt: Updated alt text- created_at: '2026-03-06T19:22:55.988Z'- updated_at: '2026-03-06T19:22:56.288Z'+ created_at: '2026-03-06T19:36:28.322Z'+ updated_at: '2026-03-06T19:36:28.611Z'requestBody:content:application/json:@@ -596,6 +596,1752 @@ paths:responses:'204':description: option type deleted+ "/api/v3/admin/orders/{order_id}/line_items":+ get:+ summary: List line items+ tags:+ - Line Items+ security:+ - api_key: []+ bearer_auth: []+ description: Returns all line items for an order.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: line items found+ content:+ application/json:+ example:+ data:+ - id: li_UkLWZg9DAJ+ variant_id: variant_gbHJdmfrXB+ quantity: 2+ currency: USD+ name: Product 55441+ slug: product-55441+ options_text: 'Size: S'+ price: '10.0'+ display_price: "$10.00"+ total: '20.0'+ display_total: "$20.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '20.0'+ display_pre_tax_amount: "$20.00"+ discounted_amount: '20.0'+ display_discounted_amount: "$20.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:31.951Z'+ updated_at: '2026-03-06T19:36:31.951Z'+ compare_at_amount:+ thumbnail_url:+ option_values:+ - id: optval_UkLWZg9DAJ+ option_type_id: opt_UkLWZg9DAJ+ name: size-1+ presentation: S+ position: 1+ option_type_name: foo-size-10+ option_type_presentation: Size+ digital_links: []+ metadata:+ meta:+ page: 1+ limit: 25+ count: 1+ pages: 1+ from: 1+ to: 1+ in: 1+ previous:+ next:+ post:+ summary: Add a line item+ tags:+ - Line Items+ security:+ - api_key: []+ bearer_auth: []+ description: Adds a new line item to the order.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '201':+ description: line item added+ content:+ application/json:+ example:+ id: li_gbHJdmfrXB+ variant_id: variant_VqXmZF31wY+ quantity: 3+ currency: USD+ name: Product 75077+ slug: product-75077+ options_text: 'Size: S'+ price: '19.99'+ display_price: "$19.99"+ total: '59.97'+ display_total: "$59.97"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '59.97'+ display_pre_tax_amount: "$59.97"+ discounted_amount: '59.97'+ display_discounted_amount: "$59.97"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:32.908Z'+ updated_at: '2026-03-06T19:36:32.908Z'+ compare_at_amount:+ thumbnail_url:+ option_values:+ - id: optval_gbHJdmfrXB+ option_type_id: opt_gbHJdmfrXB+ name: size-3+ presentation: S+ position: 1+ option_type_name: foo-size-12+ option_type_presentation: Size+ digital_links: []+ metadata:+ 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}/line_items/{id}":+ get:+ summary: Show a line item+ tags:+ - Line Items+ security:+ - api_key: []+ bearer_auth: []+ description: Returns details of a specific line item.+ 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 prefixed ID+ schema:+ type: string+ - name: id+ in: path+ required: true+ description: Line item prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: line item found+ content:+ application/json:+ example:+ id: li_UkLWZg9DAJ+ variant_id: variant_gbHJdmfrXB+ quantity: 2+ currency: USD+ name: Product 8356+ slug: product-8356+ options_text: 'Size: S'+ price: '10.0'+ display_price: "$10.00"+ total: '20.0'+ display_total: "$20.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '20.0'+ display_pre_tax_amount: "$20.00"+ discounted_amount: '20.0'+ display_discounted_amount: "$20.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:33.265Z'+ updated_at: '2026-03-06T19:36:33.265Z'+ compare_at_amount:+ thumbnail_url:+ option_values:+ - id: optval_UkLWZg9DAJ+ option_type_id: opt_UkLWZg9DAJ+ name: size-4+ presentation: S+ position: 1+ option_type_name: foo-size-13+ option_type_presentation: Size+ digital_links: []+ metadata:+ patch:+ summary: Update a line item+ tags:+ - Line Items+ security:+ - api_key: []+ bearer_auth: []+ description: Updates a line item quantity or metadata.+ 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 prefixed ID+ schema:+ type: string+ - name: id+ in: path+ required: true+ description: Line item prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: line item updated+ content:+ application/json:+ example:+ id: li_UkLWZg9DAJ+ variant_id: variant_gbHJdmfrXB+ quantity: 5+ currency: USD+ name: Product 94615+ slug: product-94615+ options_text: 'Size: S'+ price: '19.99'+ display_price: "$19.99"+ total: '99.95'+ display_total: "$99.95"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '99.95'+ display_pre_tax_amount: "$99.95"+ discounted_amount: '99.95'+ display_discounted_amount: "$99.95"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:33.864Z'+ updated_at: '2026-03-06T19:36:34.175Z'+ compare_at_amount:+ thumbnail_url:+ option_values:+ - id: optval_UkLWZg9DAJ+ option_type_id: opt_UkLWZg9DAJ+ name: size-5+ presentation: S+ position: 1+ option_type_name: foo-size-14+ option_type_presentation: Size+ digital_links: []+ metadata:+ requestBody:+ content:+ application/json:+ schema:+ type: object+ properties:+ quantity:+ type: integer+ delete:+ summary: Remove a line item+ tags:+ - Line Items+ security:+ - api_key: []+ bearer_auth: []+ description: Removes a line item from the order.+ 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 prefixed ID+ schema:+ type: string+ - name: id+ in: path+ required: true+ description: Line item prefixed ID+ schema:+ type: string+ responses:+ '204':+ description: line item 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.+ 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+ responses:+ '200':+ description: orders found+ content:+ application/json:+ example:+ data:+ - id: or_UkLWZg9DAJ+ number: R670769835+ state: cart+ checkout_steps:+ - address+ - delivery+ - complete+ token: SmvvUsahJSmjVxKW5arvpTCDXDroPWwxTor+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 0+ state_lock_version: 0+ shipment_state:+ payment_state:+ item_total: '0.0'+ display_item_total: "$0.00"+ ship_total: '0.0'+ display_ship_total: "$0.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '0.0'+ display_total: "$0.00"+ completed_at:+ created_at: '2026-03-06T19:36:35.061Z'+ updated_at: '2026-03-06T19:36:35.061Z'+ order_promotions: []+ line_items: []+ shipments: []+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 6 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_15+ state_abbr: STATE_ABBR_15+ quick_checkout: false+ state_name: STATE_NAME_15+ ship_address:+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at:+ approved_at:+ metadata:+ canceler_id:+ created_by_id:+ meta:+ page: 1+ limit: 25+ count: 1+ pages: 1+ from: 1+ to: 1+ in: 1+ previous:+ next:+ '401':+ description: unauthorized+ content:+ application/json:+ example:+ error:+ code: invalid_token+ message: Valid secret API key required+ schema:+ "$ref": "#/components/schemas/ErrorResponse"+ post:+ summary: Create a draft order+ tags:+ - Orders+ security:+ - api_key: []+ bearer_auth: []+ description: Creates a new draft order. Optionally assign a user and set initial+ attributes.+ 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+ content:+ application/json:+ example:+ id: or_gbHJdmfrXB+ number: R196811022+ state: cart+ checkout_steps:+ - address+ - delivery+ - complete+ token: ar0qWypfbUdHJE2-iA3ewA1772825796448+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 0+ state_lock_version: 0+ shipment_state:+ payment_state:+ item_total: '0.0'+ display_item_total: "$0.00"+ ship_total: '0.0'+ display_ship_total: "$0.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '0.0'+ display_total: "$0.00"+ completed_at:+ created_at: '2026-03-06T19:36:36.450Z'+ updated_at: '2026-03-06T19:36:36.450Z'+ order_promotions: []+ line_items: []+ shipments: []+ payments: []+ bill_address:+ ship_address:+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 2+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at:+ approved_at:+ metadata:+ canceler_id:+ created_by_id:+ requestBody:+ content:+ application/json:+ schema:+ type: object+ properties:+ email:+ type: string+ example: [email protected]+ user_id:+ type: string+ description: Prefixed user ID to assign+ currency:+ type: string+ example: USD+ channel:+ type: string+ example: admin+ internal_note:+ type: string+ "/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.+ 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 prefixed ID (e.g., or_xxx)+ schema:+ type: string+ - name: expand+ in: query+ required: false+ description: Comma-separated associations to expand (e.g., user)+ schema:+ type: string+ responses:+ '200':+ description: order found+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R835227695+ state: cart+ checkout_steps:+ - address+ - delivery+ - complete+ token: MvRgXzzRybWEerm4oXPZweuyPuwPV648cBy+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 0+ state_lock_version: 0+ shipment_state:+ payment_state:+ item_total: '0.0'+ display_item_total: "$0.00"+ ship_total: '0.0'+ display_ship_total: "$0.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '0.0'+ display_total: "$0.00"+ completed_at:+ created_at: '2026-03-06T19:36:36.726Z'+ updated_at: '2026-03-06T19:36:36.726Z'+ order_promotions: []+ line_items: []+ shipments: []+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 9 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_18+ state_abbr: STATE_ABBR_18+ quick_checkout: false+ state_name: STATE_NAME_18+ ship_address:+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at:+ approved_at:+ metadata:+ canceler_id:+ created_by_id:+ '404':+ description: order not found+ content:+ application/json:+ example:+ error:+ code: order_not_found+ message: Couldn't find Spree::Order with 'id'=245546638656678833+ [WHERE "spree_orders"."store_id" = ?]+ 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.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: order updated+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R491915587+ state: cart+ checkout_steps:+ - address+ - delivery+ - complete+ token: oa4uDeV51XSQ69coVJfwTg8NfqpQTQMbqH2+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 0+ state_lock_version: 1+ shipment_state:+ payment_state:+ item_total: '0.0'+ display_item_total: "$0.00"+ ship_total: '0.0'+ display_ship_total: "$0.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '0.0'+ display_total: "$0.00"+ completed_at:+ created_at: '2026-03-06T19:36:37.823Z'+ updated_at: '2026-03-06T19:36:38.104Z'+ order_promotions: []+ line_items: []+ shipments: []+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 11 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_20+ state_abbr: STATE_ABBR_20+ quick_checkout: false+ state_name: STATE_NAME_20+ ship_address:+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at:+ approved_at:+ metadata:+ canceler_id:+ created_by_id:+ requestBody:+ content:+ application/json:+ schema:+ type: object+ properties:+ email:+ type: string+ special_instructions:+ type: string+ internal_note:+ type: string+ channel:+ type: string+ 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+ line_items:+ type: array+ items:+ type: object+ properties:+ variant_id:+ type: string+ quantity:+ type: integer+ delete:+ summary: Delete a draft order+ tags:+ - Orders+ security:+ - api_key: []+ bearer_auth: []+ description: Deletes a draft order. Completed orders cannot be deleted.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '204':+ description: order deleted+ "/api/v3/admin/orders/{id}/cancel":+ patch:+ summary: Cancel an order+ tags:+ - Orders+ security:+ - api_key: []+ bearer_auth: []+ description: Cancels a completed order.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: order canceled+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R135697035+ state: canceled+ checkout_steps:+ - address+ - delivery+ - payment+ - complete+ token: SCYNJvFFruNxrmnpqDnHREfZdA7hVcgz156+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 1+ state_lock_version: 1+ shipment_state: canceled+ payment_state: void+ item_total: '10.0'+ display_item_total: "$10.00"+ ship_total: '10.0'+ display_ship_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '20.0'+ display_total: "$20.00"+ completed_at: '2026-03-06T19:36:39.033Z'+ created_at: '2026-03-06T19:36:38.941Z'+ updated_at: '2026-03-06T19:36:39.384Z'+ order_promotions: []+ line_items:+ - id: li_UkLWZg9DAJ+ variant_id: variant_UkLWZg9DAJ+ quantity: 1+ currency: USD+ name: Product 11635+ slug: product-11635+ options_text: ''+ price: '10.0'+ display_price: "$10.00"+ total: '10.0'+ display_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '10.0'+ display_pre_tax_amount: "$10.00"+ discounted_amount: '10.0'+ display_discounted_amount: "$10.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:38.978Z'+ updated_at: '2026-03-06T19:36:38.978Z'+ compare_at_amount:+ thumbnail_url:+ option_values: []+ digital_links: []+ metadata:+ shipments:+ - id: ship_UkLWZg9DAJ+ number: H24460167975+ state: canceled+ tracking: U10000+ tracking_url:+ cost: '10.0'+ display_cost: "$10.00"+ shipped_at:+ created_at: '2026-03-06T19:36:38.989Z'+ updated_at: '2026-03-06T19:36:39.378Z'+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ stock_location:+ id: sloc_UkLWZg9DAJ+ state_abbr: STATE_ABBR_22+ name: Shaunna Heller+ address1: 1600 Pennsylvania Ave NW+ city: Washington+ zipcode: '20500'+ country_iso: US+ country_name: United States of America+ state_text: STATE_ABBR_22+ shipping_rates:+ - id: shpr_EfhxLZ9ck8+ shipping_method_id: shpm_UkLWZg9DAJ+ name: UPS Ground+ selected: true+ cost: '10.0'+ display_cost: "$10.00"+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 13 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_22+ state_abbr: STATE_ABBR_22+ quick_checkout: false+ state_name: STATE_NAME_22+ ship_address:+ id: addr_gbHJdmfrXB+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 14 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_23+ state_abbr: STATE_ABBR_23+ quick_checkout: false+ state_name: STATE_NAME_23+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at: '2026-03-06T19:36:39.326Z'+ approved_at:+ metadata:+ canceler_id: 1+ created_by_id:+ "/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).+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: order approved+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R067718188+ state: complete+ checkout_steps:+ - address+ - delivery+ - payment+ - complete+ token: EYUiSfU7NdXYcHEYzf8Bf2DbaqZkXWqU2cY+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 1+ state_lock_version: 1+ shipment_state:+ payment_state:+ item_total: '10.0'+ display_item_total: "$10.00"+ ship_total: '100.0'+ display_ship_total: "$100.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '110.0'+ display_total: "$110.00"+ completed_at: '2026-03-06T19:36:39.785Z'+ created_at: '2026-03-06T19:36:39.717Z'+ updated_at: '2026-03-06T19:36:39.785Z'+ order_promotions: []+ line_items:+ - id: li_UkLWZg9DAJ+ variant_id: variant_UkLWZg9DAJ+ quantity: 1+ currency: USD+ name: Product 123202+ slug: product-123202+ options_text: ''+ price: '10.0'+ display_price: "$10.00"+ total: '10.0'+ display_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '10.0'+ display_pre_tax_amount: "$10.00"+ discounted_amount: '10.0'+ display_discounted_amount: "$10.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:39.762Z'+ updated_at: '2026-03-06T19:36:39.762Z'+ compare_at_amount:+ thumbnail_url:+ option_values: []+ digital_links: []+ metadata:+ shipments:+ - id: ship_UkLWZg9DAJ+ number: H69744456357+ state: pending+ tracking: U10000+ tracking_url:+ cost: '100.0'+ display_cost: "$100.00"+ shipped_at:+ created_at: '2026-03-06T19:36:39.768Z'+ updated_at: '2026-03-06T19:36:39.783Z'+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ stock_location:+ id: sloc_UkLWZg9DAJ+ state_abbr: STATE_ABBR_24+ name: Kerry Ledner+ address1: 1600 Pennsylvania Ave NW+ city: Washington+ zipcode: '20500'+ country_iso: US+ country_name: United States of America+ state_text: STATE_ABBR_24+ shipping_rates:+ - id: shpr_gbHJdmfrXB+ shipping_method_id: shpm_UkLWZg9DAJ+ name: UPS Ground+ selected: true+ cost: '10.0'+ display_cost: "$10.00"+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 15 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_24+ state_abbr: STATE_ABBR_24+ quick_checkout: false+ state_name: STATE_NAME_24+ ship_address:+ id: addr_gbHJdmfrXB+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 16 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_25+ state_abbr: STATE_ABBR_25+ quick_checkout: false+ state_name: STATE_NAME_25+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id: 1+ canceled_at:+ approved_at: '2026-03-06T19:36:40.076Z'+ metadata:+ canceler_id:+ created_by_id:+ "/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.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: order resumed+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R013995765+ state: resumed+ checkout_steps:+ - address+ - delivery+ - payment+ - complete+ token: fL2iAYWMZNnyBCr3MEo2Bp1EmFbxQV2ZXcX+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 1+ state_lock_version: 1+ shipment_state: canceled+ payment_state: void+ item_total: '10.0'+ display_item_total: "$10.00"+ ship_total: '10.0'+ display_ship_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '20.0'+ display_total: "$20.00"+ completed_at: '2026-03-06T19:36:40.412Z'+ created_at: '2026-03-06T19:36:40.360Z'+ updated_at: '2026-03-06T19:36:40.749Z'+ order_promotions: []+ line_items:+ - id: li_UkLWZg9DAJ+ variant_id: variant_UkLWZg9DAJ+ quantity: 1+ currency: USD+ name: Product 137493+ slug: product-137493+ options_text: ''+ price: '10.0'+ display_price: "$10.00"+ total: '10.0'+ display_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '10.0'+ display_pre_tax_amount: "$10.00"+ discounted_amount: '10.0'+ display_discounted_amount: "$10.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:40.389Z'+ updated_at: '2026-03-06T19:36:40.722Z'+ compare_at_amount:+ thumbnail_url:+ option_values: []+ digital_links: []+ metadata:+ shipments:+ - id: ship_UkLWZg9DAJ+ number: H13016636197+ state: pending+ tracking: U10000+ tracking_url:+ cost: '10.0'+ display_cost: "$10.00"+ shipped_at:+ created_at: '2026-03-06T19:36:40.395Z'+ updated_at: '2026-03-06T19:36:40.743Z'+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ stock_location:+ id: sloc_UkLWZg9DAJ+ state_abbr: STATE_ABBR_26+ name: Caterina Bechtelar+ address1: 1600 Pennsylvania Ave NW+ city: Washington+ zipcode: '20500'+ country_iso: US+ country_name: United States of America+ state_text: STATE_ABBR_26+ shipping_rates:+ - id: shpr_EfhxLZ9ck8+ shipping_method_id: shpm_UkLWZg9DAJ+ name: UPS Ground+ selected: true+ cost: '10.0'+ display_cost: "$10.00"+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 17 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_26+ state_abbr: STATE_ABBR_26+ quick_checkout: false+ state_name: STATE_NAME_26+ ship_address:+ id: addr_gbHJdmfrXB+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 18 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_27+ state_abbr: STATE_ABBR_27+ quick_checkout: false+ state_name: STATE_NAME_27+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at: '2026-03-06T19:36:40.690Z'+ approved_at:+ metadata:+ canceler_id: 1+ created_by_id:+ "/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.+ 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 prefixed ID+ schema:+ type: string+ responses:+ '200':+ description: confirmation resent+ content:+ application/json:+ example:+ id: or_UkLWZg9DAJ+ number: R435313423+ state: complete+ checkout_steps:+ - address+ - delivery+ - payment+ - complete+ token: d7jpBYqhqVkkALwqJxFCh4J8xVm188VDExV+ email: [email protected]+ special_instructions:+ currency: USD+ locale: en+ item_count: 1+ state_lock_version: 0+ shipment_state:+ payment_state:+ item_total: '10.0'+ display_item_total: "$10.00"+ ship_total: '100.0'+ display_ship_total: "$100.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ tax_total: '0.0'+ display_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ total: '110.0'+ display_total: "$110.00"+ completed_at: '2026-03-06T19:36:41.088Z'+ created_at: '2026-03-06T19:36:41.037Z'+ updated_at: '2026-03-06T19:36:41.087Z'+ order_promotions: []+ line_items:+ - id: li_UkLWZg9DAJ+ variant_id: variant_UkLWZg9DAJ+ quantity: 1+ currency: USD+ name: Product 149448+ slug: product-149448+ options_text: ''+ price: '10.0'+ display_price: "$10.00"+ total: '10.0'+ display_total: "$10.00"+ adjustment_total: '0.0'+ display_adjustment_total: "$0.00"+ additional_tax_total: '0.0'+ display_additional_tax_total: "$0.00"+ included_tax_total: '0.0'+ display_included_tax_total: "$0.00"+ promo_total: '0.0'+ display_promo_total: "$0.00"+ pre_tax_amount: '10.0'+ display_pre_tax_amount: "$10.00"+ discounted_amount: '10.0'+ display_discounted_amount: "$10.00"+ display_compare_at_amount: "$0.00"+ created_at: '2026-03-06T19:36:41.065Z'+ updated_at: '2026-03-06T19:36:41.065Z'+ compare_at_amount:+ thumbnail_url:+ option_values: []+ digital_links: []+ metadata:+ shipments:+ - id: ship_UkLWZg9DAJ+ number: H51301757117+ state: pending+ tracking: U10000+ tracking_url:+ cost: '100.0'+ display_cost: "$100.00"+ shipped_at:+ created_at: '2026-03-06T19:36:41.070Z'+ updated_at: '2026-03-06T19:36:41.085Z'+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ stock_location:+ id: sloc_UkLWZg9DAJ+ state_abbr: STATE_ABBR_28+ name: Hedwig Ledner+ address1: 1600 Pennsylvania Ave NW+ city: Washington+ zipcode: '20500'+ country_iso: US+ country_name: United States of America+ state_text: STATE_ABBR_28+ shipping_rates:+ - id: shpr_gbHJdmfrXB+ shipping_method_id: shpm_UkLWZg9DAJ+ name: UPS Ground+ selected: true+ cost: '10.0'+ display_cost: "$10.00"+ shipping_method:+ id: shpm_UkLWZg9DAJ+ name: UPS Ground+ code: UPS_GROUND+ payments: []+ bill_address:+ id: addr_UkLWZg9DAJ+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 19 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_28+ state_abbr: STATE_ABBR_28+ quick_checkout: false+ state_name: STATE_NAME_28+ ship_address:+ id: addr_gbHJdmfrXB+ firstname: John+ lastname: Doe+ full_name: John Doe+ address1: 20 Lovely Street+ address2: Northwest+ city: Herndon+ zipcode: '35005'+ phone: 555-555-0199+ company: Company+ country_name: United States of America+ country_iso: US+ state_text: STATE_ABBR_29+ state_abbr: STATE_ABBR_29+ quick_checkout: false+ state_name: STATE_NAME_29+ payment_methods: []+ channel: spree+ last_ip_address:+ considered_risky: false+ confirmation_delivered: false+ store_owner_notification_delivered:+ internal_note:+ id:+ name: internal_note+ body:+ record_type: Spree::Order+ record_id: 1+ created_at:+ updated_at:+ locale: en+ approver_id:+ canceled_at:+ approved_at:+ metadata:+ canceler_id:+ created_by_id:"/api/v3/admin/products":get:summary: List products@@ -661,17 +2407,20 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 53028+ name: Product 157975description: |-- Veniam voluptatem possimus atque recusandae fugiat harum minima iure. Non expedita eaque animi voluptatibus quod tempore. Earum sapiente adipisci ipsam nulla doloremque aut inventore. Repudiandae aperiam maxime eaque atque sint voluptatem reiciendis suscipit. Eaque neque accusantium consequatur occaecati modi.- Dolorem minima repellat voluptas sunt a nobis. Commodi at saepe mollitia dignissimos veritatis. Nihil minima voluptatum illo neque ratione ea reprehenderit nam. Voluptas placeat eum fugiat rerum.- slug: product-53028+ Corrupti repellat nostrum incidunt perferendis. Facere minus ex distinctio ipsam quia id corporis. Magnam occaecati dolor accusantium dolorem unde. Quasi corrupti non tenetur officia.+ Maiores dicta dolorum autem adipisci odio. Veniam quis aut ducimus aliquid. Possimus quos cum accusamus impedit quae odio tempore dolore. Sapiente dolorem animi maiores officiis vitae.+ Cupiditate harum possimus magni est corrupti. Veniam maiores laborum sit dicta voluptates. Eius ratione nihil dolore deserunt nobis commodi laborum. Ex praesentium quam nisi necessitatibus quae modi impedit. In tempora labore aperiam dicta similique totam.+ Id adipisci soluta cum ratione fuga blanditiis quaerat maxime. Saepe explicabo quos impedit quisquam dolor quam veritatis. Eligendi eveniet tenetur rem et maxime vero repellat.+ Exercitationem eos nobis tempore odit. Eum a facilis pariatur eius error repudiandae. Corrupti ullam harum voluptate quia impedit autem corporis repellendus. Totam cumque nulla aspernatur consequuntur non impedit in. Tempore minima tempora necessitatibus nesciunt sunt commodi assumenda id.+ slug: product-157975meta_description:meta_keywords:variant_count: 0- available_on: '2025-03-06T19:22:59.347Z'- created_at: '2026-03-06T19:22:59.378Z'- updated_at: '2026-03-06T19:22:59.392Z'+ available_on: '2025-03-06T19:36:41.396Z'+ created_at: '2026-03-06T19:36:41.409Z'+ updated_at: '2026-03-06T19:36:41.421Z'purchasable: truein_stock: falsebackorderable: true@@ -690,11 +2439,11 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-03-06T19:22:59.381Z'- updated_at: '2026-03-06T19:22:59.381Z'+ created_at: '2026-03-06T19:36:41.411Z'+ updated_at: '2026-03-06T19:36:41.411Z'original_price:status: active- make_active_at: '2025-03-06T19:22:59.347Z'+ make_active_at: '2025-03-06T19:36:41.396Z'discontinue_on:deleted_at:cost_price: '17.0'@@ -769,8 +2518,8 @@ paths:meta_keywords:variant_count: 0available_on:- created_at: '2026-03-06T19:23:00.368Z'- updated_at: '2026-03-06T19:23:00.373Z'+ created_at: '2026-03-06T19:36:42.377Z'+ updated_at: '2026-03-06T19:36:42.381Z'purchasable: falsein_stock: falsebackorderable: false@@ -789,8 +2538,8 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_gbHJdmfrXB- created_at: '2026-03-06T19:23:00.370Z'- updated_at: '2026-03-06T19:23:00.370Z'+ created_at: '2026-03-06T19:36:42.379Z'+ updated_at: '2026-03-06T19:36:42.379Z'original_price:status: draftmake_active_at:@@ -933,20 +2682,18 @@ paths:application/json:example:id: prod_UkLWZg9DAJ- name: Product 9735+ name: Product 197566description: |-- Suscipit vitae ea placeat quod. Deleniti voluptas tempora in ipsum. Qui aliquam eius doloremque saepe.- Sint eaque magnam inventore commodi architecto porro. Odit tempore sapiente maiores impedit. Asperiores commodi nisi perspiciatis eveniet. Est in reiciendis similique soluta a veniam dignissimos.- Doloremque itaque voluptates animi corrupti modi sequi consequuntur at. Soluta recusandae nihil dolore quaerat error laboriosam eligendi. Nostrum consequuntur voluptatum distinctio at animi repellat suscipit excepturi.- Ad amet accusantium itaque nostrum nihil corrupti impedit. Neque natus quisquam atque aspernatur placeat. Quam rerum ipsam eius eos aliquam sequi alias. Libero sapiente eligendi dolor fuga ea ab.- Provident omnis voluptas nemo libero quod veniam nobis rem. Aperiam commodi voluptatem laborum cumque placeat quis omnis cupiditate. Saepe aliquam vitae voluptatem ullam reiciendis repellendus veritatis.- slug: product-9735+ Sint laborum quae fuga deleniti. Laborum dolores neque fugiat officiis possimus accusantium. Hic sed facere incidunt fugiat qui occaecati commodi. Esse distinctio voluptate incidunt neque eos tempora deserunt. Porro illum ratione est ad.+ Totam exercitationem a velit sint recusandae inventore modi magnam. Libero distinctio iusto saepe quos veritatis aspernatur. Cupiditate quos aliquid ipsum iure corporis libero id. Est recusandae ipsum in numquam asperiores nobis sit facilis. Corrupti eaque necessitatibus nulla officia cupiditate.+ Nesciunt provident aliquid commodi similique non debitis. Asperiores harum nam quas magnam. Vero omnis fuga alias facere error cum. Animi ducimus perferendis repellendus ullam nihil commodi.+ slug: product-197566meta_description:meta_keywords:variant_count: 0- available_on: '2025-03-06T19:23:00.750Z'- created_at: '2026-03-06T19:23:00.764Z'- updated_at: '2026-03-06T19:23:00.776Z'+ available_on: '2025-03-06T19:36:42.732Z'+ created_at: '2026-03-06T19:36:42.743Z'+ updated_at: '2026-03-06T19:36:42.754Z'purchasable: truein_stock: falsebackorderable: true@@ -965,11 +2712,11 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-03-06T19:23:00.766Z'- updated_at: '2026-03-06T19:23:00.766Z'+ created_at: '2026-03-06T19:36:42.744Z'+ updated_at: '2026-03-06T19:36:42.744Z'original_price:status: active- make_active_at: '2025-03-06T19:23:00.750Z'+ make_active_at: '2025-03-06T19:36:42.732Z'discontinue_on:deleted_at:cost_price: '17.0'@@ -1022,17 +2769,18 @@ paths:example:id: prod_UkLWZg9DAJname: Updated Name- description: Tenetur fugiat dolore sapiente quas nam voluptatibus- ratione. Autem amet possimus nam magni commodi. Fuga quas suscipit- sit placeat alias iusto iste. Autem veniam quis quasi aliquid nobis- et sunt minus.- slug: product-119031+ description: |-+ Totam asperiores ullam corrupti dolor distinctio tempora aspernatur ratione. Laudantium dicta occaecati id ea eum. Nesciunt necessitatibus odit quod voluptatibus.+ Minima aliquam vel architecto tempore consequatur dolor. Eius nulla libero magni assumenda blanditiis nesciunt. Reiciendis cupiditate impedit vitae nisi nesciunt magnam suscipit praesentium.+ Laudantium tempora quam quae magnam dolorum libero quaerat. Quae in natus nostrum itaque. Atque ipsum veniam enim labore quidem voluptatibus quod. Eaque blanditiis reprehenderit modi eligendi neque.+ Delectus quo iure facilis earum. Sed a sunt consequatur animi. Quidem ipsum soluta nulla error debitis libero expedita. Deleniti sunt quae perspiciatis vero architecto inventore labore.+ slug: product-216275meta_description:meta_keywords:variant_count: 0- available_on: '2025-03-06T19:23:01.409Z'- created_at: '2026-03-06T19:23:01.422Z'- updated_at: '2026-03-06T19:23:01.731Z'+ available_on: '2025-03-06T19:36:43.365Z'+ created_at: '2026-03-06T19:36:43.378Z'+ updated_at: '2026-03-06T19:36:43.679Z'purchasable: truein_stock: falsebackorderable: true@@ -1051,11 +2799,11 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_UkLWZg9DAJ- created_at: '2026-03-06T19:23:01.423Z'- updated_at: '2026-03-06T19:23:01.423Z'+ created_at: '2026-03-06T19:36:43.380Z'+ updated_at: '2026-03-06T19:36:43.380Z'original_price:status: active- make_active_at: '2025-03-06T19:23:01.409Z'+ make_active_at: '2025-03-06T19:36:43.365Z'discontinue_on:deleted_at:cost_price: '17.0'@@ -1223,26 +2971,26 @@ paths:- id: txnmy_UkLWZg9DAJname: Categoriesposition: 1- created_at: '2026-03-06T19:22:54.957Z'- updated_at: '2026-03-06T19:22:54.980Z'+ created_at: '2026-03-06T19:36:27.349Z'+ updated_at: '2026-03-06T19:36:27.370Z'root_id: txn_UkLWZg9DAJ- id: txnmy_gbHJdmfrXBname: Brandsposition: 2- created_at: '2026-03-06T19:22:54.981Z'- updated_at: '2026-03-06T19:22:54.989Z'+ created_at: '2026-03-06T19:36:27.371Z'+ updated_at: '2026-03-06T19:36:27.380Z'root_id: txn_gbHJdmfrXB- id: txnmy_EfhxLZ9ck8name: Collectionsposition: 3- created_at: '2026-03-06T19:22:54.991Z'- updated_at: '2026-03-06T19:22:55.055Z'+ created_at: '2026-03-06T19:36:27.381Z'+ updated_at: '2026-03-06T19:36:27.440Z'root_id: txn_EfhxLZ9ck8- id: txnmy_VqXmZF31wYname: taxonomy_1position: 4- created_at: '2026-03-06T19:23:02.439Z'- updated_at: '2026-03-06T19:23:02.447Z'+ created_at: '2026-03-06T19:36:44.342Z'+ updated_at: '2026-03-06T19:36:44.350Z'root_id: txn_OIJLhNcSbfmeta:page: 1@@ -1305,8 +3053,8 @@ paths:id: txnmy_uw2YK1rnl0name: New Taxonomyposition: 5- created_at: '2026-03-06T19:23:03.338Z'- updated_at: '2026-03-06T19:23:03.348Z'+ created_at: '2026-03-06T19:36:45.233Z'+ updated_at: '2026-03-06T19:36:45.243Z'root_id: txn_AXs1igzRC6schema:"$ref": "#/components/schemas/AdminTaxonomy"@@ -1379,8 +3127,8 @@ paths:id: txnmy_VqXmZF31wYname: taxonomy_5position: 4- created_at: '2026-03-06T19:23:03.653Z'- updated_at: '2026-03-06T19:23:03.664Z'+ created_at: '2026-03-06T19:36:45.537Z'+ updated_at: '2026-03-06T19:36:45.545Z'root_id: txn_OIJLhNcSbfschema:"$ref": "#/components/schemas/AdminTaxonomy"@@ -1430,8 +3178,8 @@ paths:id: txnmy_VqXmZF31wYname: Updated Taxonomyposition: 4- created_at: '2026-03-06T19:23:04.256Z'- updated_at: '2026-03-06T19:23:04.555Z'+ created_at: '2026-03-06T19:36:46.117Z'+ updated_at: '2026-03-06T19:36:46.411Z'root_id: txn_OIJLhNcSbfschema:"$ref": "#/components/schemas/AdminTaxonomy"@@ -1544,8 +3292,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:22:54.968Z'- updated_at: '2026-03-06T19:22:54.978Z'+ created_at: '2026-03-06T19:36:27.359Z'+ updated_at: '2026-03-06T19:36:27.368Z'parent_id:taxonomy_id: txnmy_UkLWZg9DAJdescription: ''@@ -1566,8 +3314,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:22:54.983Z'- updated_at: '2026-03-06T19:22:54.988Z'+ created_at: '2026-03-06T19:36:27.374Z'+ updated_at: '2026-03-06T19:36:27.378Z'parent_id:taxonomy_id: txnmy_gbHJdmfrXBdescription: ''@@ -1588,8 +3336,8 @@ paths:meta_description:meta_keywords:children_count: 2- created_at: '2026-03-06T19:22:54.993Z'- updated_at: '2026-03-06T19:22:55.054Z'+ created_at: '2026-03-06T19:36:27.383Z'+ updated_at: '2026-03-06T19:36:27.439Z'parent_id:taxonomy_id: txnmy_EfhxLZ9ck8description: ''@@ -1610,8 +3358,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:22:55.008Z'- updated_at: '2026-03-06T19:22:55.010Z'+ created_at: '2026-03-06T19:36:27.396Z'+ updated_at: '2026-03-06T19:36:27.398Z'parent_id: txn_EfhxLZ9ck8taxonomy_id: txnmy_EfhxLZ9ck8description: ''@@ -1632,8 +3380,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:22:55.020Z'- updated_at: '2026-03-06T19:22:55.021Z'+ created_at: '2026-03-06T19:36:27.407Z'+ updated_at: '2026-03-06T19:36:27.409Z'parent_id: txn_EfhxLZ9ck8taxonomy_id: txnmy_EfhxLZ9ck8description: ''@@ -1654,8 +3402,8 @@ paths:meta_description:meta_keywords:children_count: 1- created_at: '2026-03-06T19:23:05.176Z'- updated_at: '2026-03-06T19:23:05.190Z'+ created_at: '2026-03-06T19:36:47.021Z'+ updated_at: '2026-03-06T19:36:47.033Z'parent_id:taxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -1676,8 +3424,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:05.183Z'- updated_at: '2026-03-06T19:23:05.189Z'+ created_at: '2026-03-06T19:36:47.027Z'+ updated_at: '2026-03-06T19:36:47.032Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -1770,8 +3518,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:05.794Z'- updated_at: '2026-03-06T19:23:05.800Z'+ created_at: '2026-03-06T19:36:47.647Z'+ updated_at: '2026-03-06T19:36:47.653Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -1851,8 +3599,8 @@ paths:meta_description:meta_keywords:children_count: 1- created_at: '2026-03-06T19:23:06.399Z'- updated_at: '2026-03-06T19:23:06.415Z'+ created_at: '2026-03-06T19:36:48.253Z'+ updated_at: '2026-03-06T19:36:48.272Z'parent_id:taxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -1873,8 +3621,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:06.407Z'- updated_at: '2026-03-06T19:23:06.414Z'+ created_at: '2026-03-06T19:36:48.262Z'+ updated_at: '2026-03-06T19:36:48.271Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -1949,8 +3697,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:07.002Z'- updated_at: '2026-03-06T19:23:07.009Z'+ created_at: '2026-03-06T19:36:48.859Z'+ updated_at: '2026-03-06T19:36:48.866Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -2066,8 +3814,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:07.337Z'- updated_at: '2026-03-06T19:23:07.344Z'+ created_at: '2026-03-06T19:36:49.184Z'+ updated_at: '2026-03-06T19:36:49.191Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -2139,8 +3887,8 @@ paths:meta_description:meta_keywords:children_count: 0- created_at: '2026-03-06T19:23:07.939Z'- updated_at: '2026-03-06T19:23:08.228Z'+ created_at: '2026-03-06T19:36:49.788Z'+ updated_at: '2026-03-06T19:36:50.092Z'parent_id: txn_OIJLhNcSbftaxonomy_id: txnmy_VqXmZF31wYdescription: ''@@ -2287,13 +4035,13 @@ paths:data:- id: variant_UkLWZg9DAJproduct_id: prod_UkLWZg9DAJ- sku: SKU-14+ sku: SKU-30is_master: trueoptions_text: ''track_inventory: trueimage_count: 0- created_at: '2026-03-06T19:23:08.877Z'- updated_at: '2026-03-06T19:23:08.887Z'+ created_at: '2026-03-06T19:36:50.789Z'+ updated_at: '2026-03-06T19:36:50.802Z'thumbnail:purchasable: falsein_stock: false@@ -2325,21 +4073,21 @@ paths:total_on_hand: 0- id: variant_gbHJdmfrXBproduct_id: prod_UkLWZg9DAJ- sku: SKU-15+ sku: SKU-31is_master: falseoptions_text: 'Size: S'track_inventory: trueimage_count: 0- created_at: '2026-03-06T19:23:08.899Z'- updated_at: '2026-03-06T19:23:08.913Z'+ created_at: '2026-03-06T19:36:50.814Z'+ updated_at: '2026-03-06T19:36:50.826Z'thumbnail:purchasable: truein_stock: falsebackorderable: true- weight: 141.64- height: 42.69- width: 47.17- depth: 36.86+ weight: 65.12+ height: 36.3+ width: 134.5+ depth: 3.89price:id: price_gbHJdmfrXBamount: '19.99'@@ -2351,16 +4099,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_gbHJdmfrXB- created_at: '2026-03-06T19:23:08.900Z'- updated_at: '2026-03-06T19:23:08.900Z'+ created_at: '2026-03-06T19:36:50.815Z'+ updated_at: '2026-03-06T19:36:50.815Z'original_price:option_values:- id: optval_UkLWZg9DAJoption_type_id: opt_UkLWZg9DAJ- name: size-1+ name: size-7presentation: Sposition: 1- option_type_name: foo-size-10+ option_type_name: foo-size-16option_type_presentation: Sizeposition: 2tax_category_id: 1@@ -2421,8 +4169,8 @@ paths:options_text: 'Size: XL'track_inventory: trueimage_count: 0- created_at: '2026-03-06T19:23:09.564Z'- updated_at: '2026-03-06T19:23:09.566Z'+ created_at: '2026-03-06T19:36:51.479Z'+ updated_at: '2026-03-06T19:36:51.482Z'thumbnail:purchasable: falsein_stock: false@@ -2442,8 +4190,8 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_EfhxLZ9ck8- created_at: '2026-03-06T19:23:09.565Z'- updated_at: '2026-03-06T19:23:09.565Z'+ created_at: '2026-03-06T19:36:51.480Z'+ updated_at: '2026-03-06T19:36:51.480Z'original_price:option_values:- id: optval_gbHJdmfrXB@@ -2600,21 +4348,21 @@ paths:example:id: variant_gbHJdmfrXBproduct_id: prod_UkLWZg9DAJ- sku: SKU-21+ sku: SKU-37is_master: falseoptions_text: 'Size: S'track_inventory: trueimage_count: 0- created_at: '2026-03-06T19:23:09.961Z'- updated_at: '2026-03-06T19:23:09.972Z'+ created_at: '2026-03-06T19:36:51.879Z'+ updated_at: '2026-03-06T19:36:51.889Z'thumbnail:purchasable: truein_stock: falsebackorderable: true- weight: 70.18- height: 153.3- width: 22.5- depth: 87.39+ weight: 102.26+ height: 72.23+ width: 188.79+ depth: 179.21price:id: price_gbHJdmfrXBamount: '19.99'@@ -2626,16 +4374,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_gbHJdmfrXB- created_at: '2026-03-06T19:23:09.963Z'- updated_at: '2026-03-06T19:23:09.963Z'+ created_at: '2026-03-06T19:36:51.880Z'+ updated_at: '2026-03-06T19:36:51.880Z'original_price:option_values:- id: optval_UkLWZg9DAJoption_type_id: opt_UkLWZg9DAJ- name: size-4+ name: size-10presentation: Sposition: 1- option_type_name: foo-size-13+ option_type_name: foo-size-19option_type_presentation: Sizeposition: 2tax_category_id: 1@@ -2700,16 +4448,16 @@ paths:options_text: 'Size: S'track_inventory: trueimage_count: 0- created_at: '2026-03-06T19:23:10.648Z'- updated_at: '2026-03-06T19:23:10.946Z'+ created_at: '2026-03-06T19:36:52.558Z'+ updated_at: '2026-03-06T19:36:52.863Z'thumbnail:purchasable: truein_stock: falsebackorderable: true- weight: 124.1- height: 75.25- width: 177.81- depth: 69.72+ weight: 135.4+ height: 59.23+ width: 99.22+ depth: 15.96price:id: price_gbHJdmfrXBamount: '19.99'@@ -2721,16 +4469,16 @@ paths:display_compare_at_amount:price_list_id:variant_id: variant_gbHJdmfrXB- created_at: '2026-03-06T19:23:10.649Z'- updated_at: '2026-03-06T19:23:10.649Z'+ created_at: '2026-03-06T19:36:52.559Z'+ updated_at: '2026-03-06T19:36:52.559Z'original_price:option_values:- id: optval_UkLWZg9DAJoption_type_id: opt_UkLWZg9DAJ- name: size-6+ name: size-12presentation: Sposition: 1- option_type_name: foo-size-15+ option_type_name: foo-size-21option_type_presentation: Sizeposition: 2tax_category_id: 1diff --git a/packages/sdk/scripts/generate-admin-client.ts b/packages/sdk/scripts/generate-admin-client.tsindex 7d5469c368..6619e44e19 100644--- a/packages/sdk/scripts/generate-admin-client.ts+++ b/packages/sdk/scripts/generate-admin-client.ts@@ -253,11 +253,33 @@ function analyzeResources(spec: OpenApiSpec): Resource[] {let parentParam: string | undefined;if (segments.length >= 3 && segments[1].startsWith('{') && segments[1].endsWith('}')) {- // Nested: /products/{product_id}/variants...- parentName = segments[0];- parentParam = segments[1].slice(1, -1); // remove { }- resourceName = segments[2];- basePath = `${API_PREFIX}/${segments[0]}/${segments[1]}/${segments[2]}`;+ // Check if this is a member action (e.g., /orders/{id}/cancel) vs a nested resource+ // Member actions: only have /parent/{id}/action (no further /{id})+ // Nested resources: have /parent/{id}/resource and /parent/{id}/resource/{id}+ const isMemberAction = segments.length === 3 && !segments[2].startsWith('{');++ // Look ahead: is there a collection endpoint for this sub-path?+ // If there's only single-verb endpoints and no collection/show patterns, treat as member action+ const subPathPrefix = `${API_PREFIX}/${segments[0]}/${segments[1]}/${segments[2]}`;+ const hasCollectionOrMember = Object.keys(spec.paths).some(+ (p) => p.startsWith(subPathPrefix) && p !== fullPath && p.includes('/{id}')+ );+ const hasCollectionEndpoint = Object.keys(spec.paths).some(+ (p) => p === subPathPrefix && spec.paths[p]?.get+ );++ if (isMemberAction && !hasCollectionOrMember && !hasCollectionEndpoint) {+ // This is a member action on the parent resource (e.g., PATCH /orders/{id}/cancel)+ resourceName = segments[0];+ basePath = `${API_PREFIX}/${segments[0]}`;+ // Classify as a custom action on the parent resource+ } else {+ // Nested resource: /products/{product_id}/variants...+ parentName = segments[0];+ parentParam = segments[1].slice(1, -1); // remove { }+ resourceName = segments[2];+ basePath = `${API_PREFIX}/${segments[0]}/${segments[1]}/${segments[2]}`;+ }} else {resourceName = segments[0];basePath = `${API_PREFIX}/${segments[0]}`;diff --git a/packages/sdk/src/admin-client.ts b/packages/sdk/src/admin-client.tsindex 7223e92a83..d53c265a0e 100644--- a/packages/sdk/src/admin-client.ts+++ b/packages/sdk/src/admin-client.ts@@ -7,7 +7,9 @@ import type {PaginatedResponse,ListParams,AdminAsset,+ AdminLineItem,AdminOptionType,+ AdminOrder,AdminProduct,AdminTaxon,AdminTaxonomy,@@ -16,8 +18,12 @@ import type {import type {AdminAssetCreateParams,AdminAssetUpdateParams,+ AdminLineItemCreateParams,+ AdminLineItemUpdateParams,AdminOptionTypeCreateParams,AdminOptionTypeUpdateParams,+ AdminOrderCreateParams,+ AdminOrderUpdateParams,AdminProductCreateParams,AdminProductUpdateParams,AdminTaxonCreateParams,@@ -31,8 +37,12 @@ import type {export type {AdminAssetCreateParams,AdminAssetUpdateParams,+ AdminLineItemCreateParams,+ AdminLineItemUpdateParams,AdminOptionTypeCreateParams,AdminOptionTypeUpdateParams,+ AdminOrderCreateParams,+ AdminOrderUpdateParams,AdminProductCreateParams,AdminProductUpdateParams,AdminTaxonCreateParams,@@ -112,6 +122,164 @@ export class AdminClient {};+ // ============================================+ // Orders+ // ============================================++ readonly orders = {+ /** List orders */+ list: (+ params?: ListParams,+ options?: RequestOptions+ ): Promise<PaginatedResponse<AdminOrder>> =>+ this.request<PaginatedResponse<AdminOrder>>('GET', '/orders', {+ ...options,+ params: transformListParams({ ...params }),+ }),++ /** Create a draft order */+ create: (+ params: AdminOrderCreateParams,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('POST', '/orders', {+ ...options,+ body: params,+ }),++ /** Show an order */+ get: (+ id: string,+ params?: { expand?: string[] },+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('GET', `/orders/${id}`, {+ ...options,+ params: getParams(params),+ }),++ /** Update an order */+ update: (+ id: string,+ params: AdminOrderUpdateParams,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('PATCH', `/orders/${id}`, {+ ...options,+ body: params,+ }),++ /** Delete a draft order */+ delete: (+ id: string,+ options?: RequestOptions+ ): Promise<void> =>+ this.request<void>('DELETE', `/orders/${id}`, options),++ /** Cancel an order */+ cancel: (+ id: string,+ params?: Record<string, unknown>,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('PATCH', `/orders/${id}/cancel`, {+ ...options,+ body: params,+ }),++ /** Approve an order */+ approve: (+ id: string,+ params?: Record<string, unknown>,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('PATCH', `/orders/${id}/approve`, {+ ...options,+ body: params,+ }),++ /** Resume a canceled order */+ resume: (+ id: string,+ params?: Record<string, unknown>,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('PATCH', `/orders/${id}/resume`, {+ ...options,+ body: params,+ }),++ /** Resend confirmation email */+ resendConfirmation: (+ id: string,+ params?: Record<string, unknown>,+ options?: RequestOptions+ ): Promise<AdminOrder> =>+ this.request<AdminOrder>('POST', `/orders/${id}/resend_confirmation`, {+ ...options,+ body: params,+ }),++ /** Nested: orders/{id}/line_items */+ lineItems: {+ /** List line items */+ list: (+ orderId: string,+ params?: ListParams,+ options?: RequestOptions+ ): Promise<PaginatedResponse<AdminLineItem>> =>+ this.request<PaginatedResponse<AdminLineItem>>('GET', `/orders/${orderId}/line_items`, {+ ...options,+ params: transformListParams({ ...params }),+ }),++ /** Add a line item */+ create: (+ orderId: string,+ params: AdminLineItemCreateParams,+ options?: RequestOptions+ ): Promise<AdminLineItem> =>+ this.request<AdminLineItem>('POST', `/orders/${orderId}/line_items`, {+ ...options,+ body: params,+ }),++ /** Show a line item */+ get: (+ orderId: string,+ id: string,+ params?: { expand?: string[] },+ options?: RequestOptions+ ): Promise<AdminLineItem> =>+ this.request<AdminLineItem>('GET', `/orders/${orderId}/line_items/${id}`, {+ ...options,+ params: getParams(params),+ }),++ /** Update a line item */+ update: (+ orderId: string,+ id: string,+ params: AdminLineItemUpdateParams,+ options?: RequestOptions+ ): Promise<AdminLineItem> =>+ this.request<AdminLineItem>('PATCH', `/orders/${orderId}/line_items/${id}`, {+ ...options,+ body: params,+ }),++ /** Remove a line item */+ delete: (+ orderId: string,+ id: string,+ options?: RequestOptions+ ): Promise<void> =>+ this.request<void>('DELETE', `/orders/${orderId}/line_items/${id}`, options),++ },++ };+// ============================================// Products// ============================================diff --git a/packages/sdk/src/admin-params.ts b/packages/sdk/src/admin-params.tsindex 3032351c84..be2e61b021 100644--- a/packages/sdk/src/admin-params.ts+++ b/packages/sdk/src/admin-params.ts@@ -41,6 +41,54 @@ export interface AdminOptionTypeUpdateParams {}>;}+export interface AdminLineItemCreateParams {+ variant_id: string;+ quantity?: number;+}++export interface AdminLineItemUpdateParams {+ quantity?: number;+}++export interface AdminOrderCreateParams {+ email?: string;+ user_id?: string;+ currency?: string;+ channel?: string;+ internal_note?: string;+}++export interface AdminOrderUpdateParams {+ email?: string;+ special_instructions?: string;+ internal_note?: string;+ channel?: string;+ ship_address?: {+ firstname?: string;+ lastname?: string;+ address1?: string;+ city?: string;+ zipcode?: string;+ country_iso?: string;+ state_abbr?: string;+ phone?: string;+ };+ bill_address?: {+ firstname?: string;+ lastname?: string;+ address1?: string;+ city?: string;+ zipcode?: string;+ country_iso?: string;+ state_abbr?: string;+ phone?: string;+ };+ line_items?: Array<{+ variant_id?: string;+ quantity?: number;+ }>;+}+export interface AdminProductCreateParams {name: string;price: number;diff --git a/packages/sdk/tests/admin/option-types.test.ts b/packages/sdk/tests/admin/option-types.test.tsnew file mode 100644index 0000000000..6807a15e41--- /dev/null+++ b/packages/sdk/tests/admin/option-types.test.ts@@ -0,0 +1,58 @@+import { describe, it, expect, beforeAll } from 'vitest';+import { createAdminTestClient } from '../helpers';+import { adminFixtures } from '../mocks/admin-handlers';+import type { SpreeClient } from '../../src';++describe('admin / optionTypes', () => {+ let client: SpreeClient;+ beforeAll(() => { client = createAdminTestClient(); });++ describe('list', () => {+ it('returns paginated option types', async () => {+ const result = await client.admin.optionTypes.list();++ expect(result.data).toHaveLength(1);+ expect(result.data[0].name).toBe('color');+ expect(result.meta.page).toBe(1);+ expect(result.meta.count).toBe(1);+ });+ });++ describe('create', () => {+ it('creates an option type', async () => {+ const result = await client.admin.optionTypes.create({+ name: 'color',+ presentation: 'Color',+ });++ expect(result.name).toBe(adminFixtures.optionType.name);+ expect(result.presentation).toBe('Color');+ });+ });++ describe('get', () => {+ it('returns an option type by ID', async () => {+ const result = await client.admin.optionTypes.get('ot_1');++ expect(result.name).toBe(adminFixtures.optionType.name);+ });+ });++ describe('update', () => {+ it('updates an option type', async () => {+ const result = await client.admin.optionTypes.update('ot_1', {+ presentation: 'Updated Color',+ });++ expect(result.presentation).toBe('Updated Color');+ });+ });++ describe('delete', () => {+ it('deletes an option type', async () => {+ await expect(+ client.admin.optionTypes.delete('ot_1')+ ).resolves.toBeUndefined();+ });+ });+});diff --git a/packages/sdk/tests/admin/orders.test.ts b/packages/sdk/tests/admin/orders.test.tsnew file mode 100644index 0000000000..2abeb3ea1d--- /dev/null+++ b/packages/sdk/tests/admin/orders.test.ts@@ -0,0 +1,127 @@+import { describe, it, expect, beforeAll } from 'vitest';+import { createAdminTestClient } from '../helpers';+import { adminFixtures } from '../mocks/admin-handlers';+import type { SpreeClient } from '../../src';++describe('admin / orders', () => {+ let client: SpreeClient;+ beforeAll(() => { client = createAdminTestClient(); });++ describe('list', () => {+ it('returns paginated orders', async () => {+ const result = await client.admin.orders.list();++ expect(result.data).toHaveLength(1);+ expect(result.data[0].number).toBe('R100001');+ expect(result.meta.page).toBe(1);+ });+ });++ describe('create', () => {+ it('creates a draft order', async () => {+ const result = await client.admin.orders.create({+ email: '[email protected]',+ });++ expect(result.email).toBe('[email protected]');+ });+ });++ describe('get', () => {+ it('returns an order by ID', async () => {+ const result = await client.admin.orders.get('or_1');++ expect(result.id).toBe(adminFixtures.order.id);+ expect(result.email).toBe('[email protected]');+ });+ });++ describe('update', () => {+ it('updates an order', async () => {+ const result = await client.admin.orders.update('or_1', {+ email: '[email protected]',+ });++ expect(result.email).toBe('[email protected]');+ });+ });++ describe('delete', () => {+ it('deletes a draft order', async () => {+ await expect(+ client.admin.orders.delete('or_1')+ ).resolves.toBeUndefined();+ });+ });++ describe('cancel', () => {+ it('cancels an order', async () => {+ const result = await client.admin.orders.cancel('or_1');++ expect(result.state).toBe('canceled');+ });+ });++ describe('approve', () => {+ it('approves an order', async () => {+ const result = await client.admin.orders.approve('or_1');++ expect(result.approved_at).toBe('2026-03-06T12:00:00.000Z');+ });+ });++ describe('resume', () => {+ it('resumes a canceled order', async () => {+ const result = await client.admin.orders.resume('or_1');++ expect(result.state).toBe('resumed');+ });+ });++ describe('resendConfirmation', () => {+ it('resends confirmation email', async () => {+ const result = await client.admin.orders.resendConfirmation('or_1');++ expect(result.id).toBe(adminFixtures.order.id);+ });+ });++ describe('lineItems', () => {+ it('lists line items', async () => {+ const result = await client.admin.orders.lineItems.list('or_1');++ expect(result.data).toHaveLength(1);+ expect(result.data[0].quantity).toBe(2);+ });++ it('creates a line item', async () => {+ const result = await client.admin.orders.lineItems.create('or_1', {+ variant_id: 'var_1',+ quantity: 2,+ });++ expect(result.variant_id).toBe('var_1');+ expect(result.quantity).toBe(2);+ });++ it('gets a line item', async () => {+ const result = await client.admin.orders.lineItems.get('or_1', 'li_1');++ expect(result.id).toBe(adminFixtures.lineItem.id);+ });++ it('updates a line item', async () => {+ const result = await client.admin.orders.lineItems.update('or_1', 'li_1', {+ quantity: 5,+ });++ expect(result.quantity).toBe(5);+ });++ it('deletes a line item', async () => {+ await expect(+ client.admin.orders.lineItems.delete('or_1', 'li_1')+ ).resolves.toBeUndefined();+ });+ });+});diff --git a/packages/sdk/tests/admin/products.test.ts b/packages/sdk/tests/admin/products.test.tsnew file mode 100644index 0000000000..86cfdf4dd4--- /dev/null+++ b/packages/sdk/tests/admin/products.test.ts@@ -0,0 +1,127 @@+import { describe, it, expect, beforeAll } from 'vitest';+import { createAdminTestClient } from '../helpers';+import { adminFixtures } from '../mocks/admin-handlers';+import type { SpreeClient } from '../../src';++describe('admin / products', () => {+ let client: SpreeClient;+ beforeAll(() => { client = createAdminTestClient(); });++ describe('list', () => {+ it('returns paginated products', async () => {+ const result = await client.admin.products.list();++ expect(result.data).toHaveLength(1);+ expect(result.data[0].name).toBe('Admin Product');+ expect(result.meta.page).toBe(1);+ });+ });++ describe('create', () => {+ it('creates a product', async () => {+ const result = await client.admin.products.create({+ name: 'New Product',+ price: 29.99,+ shipping_category_id: 'sc_1',+ });++ expect(result.name).toBe(adminFixtures.product.name);+ });+ });++ describe('get', () => {+ it('returns a product by ID', async () => {+ const result = await client.admin.products.get('prod_1');++ expect(result.name).toBe(adminFixtures.product.name);+ expect(result.slug).toBe('admin-product');+ });+ });++ describe('update', () => {+ it('updates a product', async () => {+ const result = await client.admin.products.update('prod_1', {+ name: 'Updated Product',+ });++ expect(result.name).toBe('Updated Product');+ });+ });++ describe('delete', () => {+ it('deletes a product', async () => {+ await expect(+ client.admin.products.delete('prod_1')+ ).resolves.toBeUndefined();+ });+ });++ describe('assets', () => {+ it('lists product assets', async () => {+ const result = await client.admin.products.assets.list('prod_1');++ expect(result.data).toHaveLength(1);+ expect(result.data[0].alt).toBe('Product image');+ });++ it('creates an asset', async () => {+ const result = await client.admin.products.assets.create('prod_1', {+ alt: 'New image',+ });++ expect(result.alt).toBe(adminFixtures.asset.alt);+ });++ it('updates an asset', async () => {+ const result = await client.admin.products.assets.update('prod_1', 'asset_1', {+ alt: 'Updated alt',+ });++ expect(result.alt).toBe('Updated alt');+ });++ it('deletes an asset', async () => {+ await expect(+ client.admin.products.assets.delete('prod_1', 'asset_1')+ ).resolves.toBeUndefined();+ });+ });++ describe('variants', () => {+ it('lists product variants', async () => {+ const result = await client.admin.products.variants.list('prod_1');++ expect(result.data).toHaveLength(1);+ expect(result.data[0].sku).toBe('VAR-001');+ });++ it('creates a variant', async () => {+ const result = await client.admin.products.variants.create('prod_1', {+ sku: 'VAR-NEW',+ price: 19.99,+ });++ expect(result.sku).toBe(adminFixtures.variant.sku);+ });++ it('gets a variant', async () => {+ const result = await client.admin.products.variants.get('prod_1', 'var_1');++ expect(result.id).toBe(adminFixtures.variant.id);+ });++ it('updates a variant', async () => {+ const result = await client.admin.products.variants.update('prod_1', 'var_1', {+ sku: 'VAR-UPDATED',+ });++ expect(result.sku).toBe('VAR-UPDATED');+ });++ it('deletes a variant', async () => {+ await expect(+ client.admin.products.variants.delete('prod_1', 'var_1')+ ).resolves.toBeUndefined();+ });+ });+});diff --git a/packages/sdk/tests/admin/taxonomies.test.ts b/packages/sdk/tests/admin/taxonomies.test.tsnew file mode 100644index 0000000000..419eb4f4ec--- /dev/null+++ b/packages/sdk/tests/admin/taxonomies.test.ts@@ -0,0 +1,92 @@+import { describe, it, expect, beforeAll } from 'vitest';+import { createAdminTestClient } from '../helpers';+import { adminFixtures } from '../mocks/admin-handlers';+import type { SpreeClient } from '../../src';++describe('admin / taxonomies', () => {+ let client: SpreeClient;+ beforeAll(() => { client = createAdminTestClient(); });++ describe('list', () => {+ it('returns paginated taxonomies', async () => {+ const result = await client.admin.taxonomies.list();++ expect(result.data).toHaveLength(1);+ expect(result.data[0].name).toBe('Categories');+ expect(result.meta.page).toBe(1);+ });+ });++ describe('create', () => {+ it('creates a taxonomy', async () => {+ const result = await client.admin.taxonomies.create({+ name: 'Categories',+ });++ expect(result.name).toBe(adminFixtures.taxonomy.name);+ });+ });++ describe('get', () => {+ it('returns a taxonomy by ID', async () => {+ const result = await client.admin.taxonomies.get('txmy_1');++ expect(result.name).toBe(adminFixtures.taxonomy.name);+ });+ });++ describe('update', () => {+ it('updates a taxonomy', async () => {+ const result = await client.admin.taxonomies.update('txmy_1', {+ name: 'Updated Categories',+ });++ expect(result.name).toBe('Updated Categories');+ });+ });++ describe('delete', () => {+ it('deletes a taxonomy', async () => {+ await expect(+ client.admin.taxonomies.delete('txmy_1')+ ).resolves.toBeUndefined();+ });+ });++ describe('taxons', () => {+ it('lists taxonomy taxons', async () => {+ const result = await client.admin.taxonomies.taxons.list('txmy_1');++ expect(result.data).toHaveLength(1);+ expect(result.data[0].name).toBe('Clothing');+ });++ it('creates a taxon', async () => {+ const result = await client.admin.taxonomies.taxons.create('txmy_1', {+ name: 'Clothing',+ });++ expect(result.name).toBe(adminFixtures.taxon.name);+ });++ it('gets a taxon', async () => {+ const result = await client.admin.taxonomies.taxons.get('txmy_1', 'txon_1');++ expect(result.id).toBe(adminFixtures.taxon.id);+ });++ it('updates a taxon', async () => {+ const result = await client.admin.taxonomies.taxons.update('txmy_1', 'txon_1', {+ name: 'Updated Clothing',+ });++ expect(result.name).toBe('Updated Clothing');+ });++ it('deletes a taxon', async () => {+ await expect(+ client.admin.taxonomies.taxons.delete('txmy_1', 'txon_1')+ ).resolves.toBeUndefined();+ });+ });+});diff --git a/packages/sdk/tests/admin/taxons.test.ts b/packages/sdk/tests/admin/taxons.test.tsnew file mode 100644index 0000000000..d2c0899f0a--- /dev/null+++ b/packages/sdk/tests/admin/taxons.test.ts@@ -0,0 +1,28 @@+import { describe, it, expect, beforeAll } from 'vitest';+import { createAdminTestClient } from '../helpers';+import { adminFixtures } from '../mocks/admin-handlers';+import type { SpreeClient } from '../../src';++describe('admin / taxons', () => {+ let client: SpreeClient;+ beforeAll(() => { client = createAdminTestClient(); });++ describe('list', () => {+ it('returns paginated taxons', async () => {+ const result = await client.admin.taxons.list();++ expect(result.data).toHaveLength(1);+ expect(result.data[0].name).toBe('Clothing');+ expect(result.meta.page).toBe(1);+ });+ });++ describe('get', () => {+ it('returns a taxon by ID', async () => {+ const result = await client.admin.taxons.get('txon_1');++ expect(result.name).toBe(adminFixtures.taxon.name);+ expect(result.permalink).toBe('categories/clothing');+ });+ });+});diff --git a/packages/sdk/tests/helpers.ts b/packages/sdk/tests/helpers.tsindex cf1a80806e..0b827bae26 100644--- a/packages/sdk/tests/helpers.ts+++ b/packages/sdk/tests/helpers.ts@@ -2,6 +2,7 @@ import { createClient } from '../src';export const TEST_BASE_URL = 'https://demo.spreecommerce.org';export const TEST_API_KEY = 'test-publishable-key';+export const TEST_SECRET_KEY = 'spree_sk_test_admin';export function createTestClient() {return createClient({@@ -9,3 +10,10 @@ export function createTestClient() {publishableKey: TEST_API_KEY,});}++export function createAdminTestClient() {+ return createSpreeClient({+ baseUrl: TEST_BASE_URL,+ secretKey: TEST_SECRET_KEY,+ });+}diff --git a/packages/sdk/tests/mocks/admin-handlers.ts b/packages/sdk/tests/mocks/admin-handlers.tsnew file mode 100644index 0000000000..f801b54ddb--- /dev/null+++ b/packages/sdk/tests/mocks/admin-handlers.ts@@ -0,0 +1,277 @@+import { http, HttpResponse } from 'msw';++const BASE_URL = 'https://demo.spreecommerce.org';+const API_PREFIX = `${BASE_URL}/api/v3/admin`;++export const adminFixtures = {+ product: {+ id: 'prod_1',+ name: 'Admin Product',+ description: 'An admin product',+ slug: 'admin-product',+ price: '29.99',+ status: 'active',+ cost_price: '10.00',+ sku: 'ADMIN-001',+ },+ variant: {+ id: 'var_1',+ sku: 'VAR-001',+ price: '29.99',+ weight: '1.5',+ track_inventory: true,+ },+ asset: {+ id: 'asset_1',+ alt: 'Product image',+ position: 1,+ type: 'Spree::Image',+ },+ order: {+ id: 'or_1',+ number: 'R100001',+ state: 'cart',+ email: '[email protected]',+ total: '0.00',+ item_total: '0.00',+ channel: 'admin',+ considered_risky: false,+ approved_at: null,+ internal_note: null,+ },+ lineItem: {+ id: 'li_1',+ quantity: 2,+ price: '29.99',+ variant_id: 'var_1',+ },+ optionType: {+ id: 'ot_1',+ name: 'color',+ presentation: 'Color',+ position: 1,+ filterable: true,+ },+ taxonomy: {+ id: 'txmy_1',+ name: 'Categories',+ position: 1,+ },+ taxon: {+ id: 'txon_1',+ name: 'Clothing',+ permalink: 'categories/clothing',+ position: 1,+ },+};++const paginationMeta = { page: 1, limit: 25, count: 1, pages: 1 };++export const adminHandlers = [+ // ============================================+ // Option Types+ // ============================================+ http.get(`${API_PREFIX}/option_types`, () =>+ HttpResponse.json({ data: [adminFixtures.optionType], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/option_types`, () =>+ HttpResponse.json(adminFixtures.optionType, { status: 201 })+ ),++ http.get(`${API_PREFIX}/option_types/:id`, () =>+ HttpResponse.json(adminFixtures.optionType)+ ),++ http.patch(`${API_PREFIX}/option_types/:id`, () =>+ HttpResponse.json({ ...adminFixtures.optionType, presentation: 'Updated Color' })+ ),++ http.delete(`${API_PREFIX}/option_types/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Orders+ // ============================================+ http.get(`${API_PREFIX}/orders`, () =>+ HttpResponse.json({ data: [adminFixtures.order], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/orders`, () =>+ HttpResponse.json({ ...adminFixtures.order, email: '[email protected]' }, { status: 201 })+ ),++ http.get(`${API_PREFIX}/orders/:id`, () =>+ HttpResponse.json(adminFixtures.order)+ ),++ http.patch(`${API_PREFIX}/orders/:id/cancel`, () =>+ HttpResponse.json({ ...adminFixtures.order, state: 'canceled' })+ ),++ http.patch(`${API_PREFIX}/orders/:id/approve`, () =>+ HttpResponse.json({ ...adminFixtures.order, approved_at: '2026-03-06T12:00:00.000Z' })+ ),++ http.patch(`${API_PREFIX}/orders/:id/resume`, () =>+ HttpResponse.json({ ...adminFixtures.order, state: 'resumed' })+ ),++ http.post(`${API_PREFIX}/orders/:id/resend_confirmation`, () =>+ HttpResponse.json(adminFixtures.order)+ ),++ http.patch(`${API_PREFIX}/orders/:id`, () =>+ HttpResponse.json({ ...adminFixtures.order, email: '[email protected]' })+ ),++ http.delete(`${API_PREFIX}/orders/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Order Line Items+ // ============================================+ http.get(`${API_PREFIX}/orders/:orderId/line_items`, () =>+ HttpResponse.json({ data: [adminFixtures.lineItem], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/orders/:orderId/line_items`, () =>+ HttpResponse.json(adminFixtures.lineItem, { status: 201 })+ ),++ http.get(`${API_PREFIX}/orders/:orderId/line_items/:id`, () =>+ HttpResponse.json(adminFixtures.lineItem)+ ),++ http.patch(`${API_PREFIX}/orders/:orderId/line_items/:id`, () =>+ HttpResponse.json({ ...adminFixtures.lineItem, quantity: 5 })+ ),++ http.delete(`${API_PREFIX}/orders/:orderId/line_items/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Products+ // ============================================+ http.get(`${API_PREFIX}/products`, () =>+ HttpResponse.json({ data: [adminFixtures.product], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/products`, () =>+ HttpResponse.json(adminFixtures.product, { status: 201 })+ ),++ http.get(`${API_PREFIX}/products/:id`, () =>+ HttpResponse.json(adminFixtures.product)+ ),++ http.patch(`${API_PREFIX}/products/:id`, () =>+ HttpResponse.json({ ...adminFixtures.product, name: 'Updated Product' })+ ),++ http.delete(`${API_PREFIX}/products/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Product Assets+ // ============================================+ http.get(`${API_PREFIX}/products/:productId/assets`, () =>+ HttpResponse.json({ data: [adminFixtures.asset], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/products/:productId/assets`, () =>+ HttpResponse.json(adminFixtures.asset, { status: 201 })+ ),++ http.patch(`${API_PREFIX}/products/:productId/assets/:id`, () =>+ HttpResponse.json({ ...adminFixtures.asset, alt: 'Updated alt' })+ ),++ http.delete(`${API_PREFIX}/products/:productId/assets/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Product Variants+ // ============================================+ http.get(`${API_PREFIX}/products/:productId/variants`, () =>+ HttpResponse.json({ data: [adminFixtures.variant], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/products/:productId/variants`, () =>+ HttpResponse.json(adminFixtures.variant, { status: 201 })+ ),++ http.get(`${API_PREFIX}/products/:productId/variants/:id`, () =>+ HttpResponse.json(adminFixtures.variant)+ ),++ http.patch(`${API_PREFIX}/products/:productId/variants/:id`, () =>+ HttpResponse.json({ ...adminFixtures.variant, sku: 'VAR-UPDATED' })+ ),++ http.delete(`${API_PREFIX}/products/:productId/variants/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Taxonomies+ // ============================================+ http.get(`${API_PREFIX}/taxonomies`, () =>+ HttpResponse.json({ data: [adminFixtures.taxonomy], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/taxonomies`, () =>+ HttpResponse.json(adminFixtures.taxonomy, { status: 201 })+ ),++ http.get(`${API_PREFIX}/taxonomies/:id`, () =>+ HttpResponse.json(adminFixtures.taxonomy)+ ),++ http.patch(`${API_PREFIX}/taxonomies/:id`, () =>+ HttpResponse.json({ ...adminFixtures.taxonomy, name: 'Updated Categories' })+ ),++ http.delete(`${API_PREFIX}/taxonomies/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Taxonomy Taxons+ // ============================================+ http.get(`${API_PREFIX}/taxonomies/:taxonomyId/taxons`, () =>+ HttpResponse.json({ data: [adminFixtures.taxon], meta: paginationMeta })+ ),++ http.post(`${API_PREFIX}/taxonomies/:taxonomyId/taxons`, () =>+ HttpResponse.json(adminFixtures.taxon, { status: 201 })+ ),++ http.get(`${API_PREFIX}/taxonomies/:taxonomyId/taxons/:id`, () =>+ HttpResponse.json(adminFixtures.taxon)+ ),++ http.patch(`${API_PREFIX}/taxonomies/:taxonomyId/taxons/:id`, () =>+ HttpResponse.json({ ...adminFixtures.taxon, name: 'Updated Clothing' })+ ),++ http.delete(`${API_PREFIX}/taxonomies/:taxonomyId/taxons/:id`, () =>+ new HttpResponse(null, { status: 204 })+ ),++ // ============================================+ // Taxons (flat)+ // ============================================+ http.get(`${API_PREFIX}/taxons`, () =>+ HttpResponse.json({ data: [adminFixtures.taxon], meta: paginationMeta })+ ),++ http.get(`${API_PREFIX}/taxons/:id`, () =>+ HttpResponse.json(adminFixtures.taxon)+ ),+];diff --git a/packages/sdk/tests/mocks/server.ts b/packages/sdk/tests/mocks/server.tsindex e52fee0a67..152d13cbe9 100644--- a/packages/sdk/tests/mocks/server.ts+++ b/packages/sdk/tests/mocks/server.ts@@ -1,4 +1,5 @@import { setupServer } from 'msw/node';import { handlers } from './handlers';+import { adminHandlers } from './admin-handlers';-export const server = setupServer(...handlers);+export const server = setupServer(...handlers, ...adminHandlers);diff --git a/spree/api/ADMIN_API_PLAN.md b/spree/api/ADMIN_API_PLAN.mdindex 1c70462604..e30cb9a1e6 100644--- a/spree/api/ADMIN_API_PLAN.md+++ b/spree/api/ADMIN_API_PLAN.md@@ -205,11 +205,7 @@ Here's the endpoint list we need to implement:- [x] `PATCH /api/v3/admin/products/:product_id/variants/:id` — Update variant- [x] `DELETE /api/v3/admin/products/:product_id/variants/:id` — Soft-delete variant-### Prices (nested under Variants)-- [x] `GET /api/v3/admin/variants/:variant_id/prices` — List prices for variant-- [x] `POST /api/v3/admin/variants/:variant_id/prices` — Create price-- [x] `PATCH /api/v3/admin/variants/:variant_id/prices/:id` — Update price-- [x] `DELETE /api/v3/admin/variants/:variant_id/prices/:id` — Delete price+### Prices (managed via nested variant params, no standalone endpoints needed)### Product Assets (nested under Products)- [x] `GET /api/v3/admin/products/:product_id/assets` — List product assets (filterable by type: image, video, etc.)@@ -262,24 +258,24 @@ Here's the endpoint list we need to implement:- [ ] `DELETE /api/v3/admin/taxons/:taxon_id/classifications/:id` — Remove product from taxon### Orders (⭐ high priority)-- [ ] `GET /api/v3/admin/orders` — List orders (with Ransack filtering, sorting, pagination)-- [ ] `GET /api/v3/admin/orders/:id` — Show order-- [ ] `POST /api/v3/admin/orders` — Create draft order-- [ ] `PATCH /api/v3/admin/orders/:id` — Update order-- [ ] `DELETE /api/v3/admin/orders/:id` — Delete draft order-- [ ] `PATCH /api/v3/admin/orders/:id/next` — Push the order to the next state-- [ ] `PATCH /api/v3/admin/orders/:id/advance` — Advance the order to the furthest state-- [ ] `PATCH /api/v3/admin/orders/:id/complete` — Complete the order-- [ ] `PATCH /api/v3/admin/orders/:id/cancel` — Cancel order-- [ ] `PATCH /api/v3/admin/orders/:id/approve` — Approve order-- [ ] `PATCH /api/v3/admin/orders/:id/resume` — Resume canceled order-- [ ] `POST /api/v3/admin/orders/:id/resend_confirmation` — Resend confirmation email+- [x] `GET /api/v3/admin/orders` — List orders (with Ransack filtering, sorting, pagination)+- [x] `GET /api/v3/admin/orders/:id` — Show order+- [x] `POST /api/v3/admin/orders` — Create draft order+- [x] `PATCH /api/v3/admin/orders/:id` — Update order+- [x] `DELETE /api/v3/admin/orders/:id` — Delete draft order+- [x] `PATCH /api/v3/admin/orders/:id/next` — Push the order to the next state+- [x] `PATCH /api/v3/admin/orders/:id/advance` — Advance the order to the furthest state+- [x] `PATCH /api/v3/admin/orders/:id/complete` — Complete the order+- [x] `PATCH /api/v3/admin/orders/:id/cancel` — Cancel order+- [x] `PATCH /api/v3/admin/orders/:id/approve` — Approve order+- [x] `PATCH /api/v3/admin/orders/:id/resume` — Resume canceled order+- [x] `POST /api/v3/admin/orders/:id/resend_confirmation` — Resend confirmation email### Line Items (nested under Orders)-- [ ] `GET /api/v3/admin/orders/:order_id/line_items` — List line items-- [ ] `POST /api/v3/admin/orders/:order_id/line_items` — Add line item-- [ ] `PATCH /api/v3/admin/orders/:order_id/line_items/:id` — Update line item (quantity, price)-- [ ] `DELETE /api/v3/admin/orders/:order_id/line_items/:id` — Remove line item+- [x] `GET /api/v3/admin/orders/:order_id/line_items` — List line items+- [x] `POST /api/v3/admin/orders/:order_id/line_items` — Add line item+- [x] `PATCH /api/v3/admin/orders/:order_id/line_items/:id` — Update line item (quantity, price)+- [x] `DELETE /api/v3/admin/orders/:order_id/line_items/:id` — Remove line item### Shipments (nested under Orders)- [ ] `GET /api/v3/admin/orders/:order_id/shipments` — List shipmentsdiff --git a/spree/api/app/controllers/spree/api/v3/admin/orders/line_items_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders/line_items_controller.rbnew file mode 100644index 0000000000..5a790bdd07--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/admin/orders/line_items_controller.rb@@ -0,0 +1,108 @@+module Spree+ module Api+ module V3+ module Admin+ module Orders+ class LineItemsController < ResourceController+ include Spree::Api::V3::OrderLock++ before_action :authorize_order_access!+ skip_before_action :set_resource, only: [:index, :create]+ before_action :set_line_item, only: [:show, :update, :destroy]++ # POST /api/v3/admin/orders/:order_id/line_items+ def create+ with_order_lock do+ result = Spree.cart_add_item_service.call(+ order: @parent,+ variant: variant,+ quantity: permitted_params[:quantity] || 1,+ options: permitted_params[:options] || {}+ )++ if result.success?+ render json: serialize_resource(result.value), status: :created+ else+ render_service_error(result.error, code: ERROR_CODES[:insufficient_stock])+ end+ end+ end++ # PATCH /api/v3/admin/orders/:order_id/line_items/:id+ def update+ with_order_lock do+ if permitted_params[:quantity].present?+ result = Spree.cart_set_item_quantity_service.call(+ order: @parent,+ line_item: @resource,+ quantity: permitted_params[:quantity]+ )++ if result.success?+ render json: serialize_resource(@resource.reload)+ else+ render_service_error(result.error, code: ERROR_CODES[:invalid_quantity])+ end+ else+ if @resource.update(permitted_params.except(:variant_id, :quantity))+ render json: serialize_resource(@resource)+ else+ render_errors(@resource.errors)+ end+ end+ end+ end++ # DELETE /api/v3/admin/orders/:order_id/line_items/:id+ def destroy+ with_order_lock do+ Spree.cart_remove_line_item_service.call(+ order: @parent,+ line_item: @resource+ )++ head :no_content+ end+ end++ protected++ def model_class+ Spree::LineItem+ end++ def serializer_class+ Spree.api.admin_line_item_serializer+ end++ def parent_association+ :line_items+ end++ def set_parent+ @parent = current_store.orders.find_by_prefix_id!(params[:order_id])+ @order = @parent # needed for OrderLock+ end++ def authorize_order_access!+ authorize!(:show, @parent)+ end++ def set_line_item+ @resource = @parent.line_items.find_by_prefix_id!(params[:id])+ authorize_resource!(@resource)+ end++ def variant+ @variant ||= current_store.variants.find_by_prefix_id!(permitted_params[:variant_id])+ end++ def permitted_params+ params.permit(:variant_id, :quantity, { metadata: {}, options: {} })+ end+ end+ end+ end+ end+ end+enddiff --git a/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rbnew file mode 100644index 0000000000..cd9a165af8--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/admin/orders_controller.rb@@ -0,0 +1,205 @@+module Spree+ module Api+ module V3+ module Admin+ class OrdersController < ResourceController+ include Spree::Api::V3::OrderLock++ skip_before_action :set_resource, only: [:index, :create]+ before_action :set_resource, only: [:show, :update, :destroy, :next, :advance, :complete, :cancel, :approve, :resume, :resend_confirmation]++ # POST /api/v3/admin/orders+ def create+ authorize!(:create, Spree::Order)++ result = Spree.cart_create_service.call(+ user: resolve_user,+ store: current_store,+ currency: params[:currency] || current_store.default_currency,+ order_params: order_create_params+ )++ if result.success?+ @resource = result.value+ render json: serialize_resource(@resource), status: :created+ else+ render_service_error(result.error)+ end+ end++ # PATCH /api/v3/admin/orders/:id+ def update+ with_order_lock do+ result = Spree.order_update_service.call(+ order: @resource,+ params: order_update_params+ )++ if result.success?+ render json: serialize_resource(@resource.reload)+ else+ render_result_error(result)+ end+ end+ end++ # DELETE /api/v3/admin/orders/:id+ # CanCanCan restricts destroy to orders where can_be_deleted? is true+ def destroy+ @resource.destroy+ head :no_content+ end++ # PATCH /api/v3/admin/orders/:id/next+ def next+ with_order_lock do+ result = Spree.checkout_next_service.call(order: @resource)++ if result.success?+ render json: serialize_resource(@resource.reload)+ else+ render_service_error(result.error, code: ERROR_CODES[:order_cannot_transition])+ end+ end+ end++ # PATCH /api/v3/admin/orders/:id/advance+ def advance+ with_order_lock do+ result = Spree.checkout_advance_service.call(order: @resource)++ if result.success?+ render json: serialize_resource(@resource.reload)+ else+ render_service_error(result.error, code: ERROR_CODES[:order_cannot_transition])+ end+ end+ end++ # PATCH /api/v3/admin/orders/:id/complete+ def complete+ with_order_lock do+ result = Spree.checkout_complete_service.call(order: @resource)++ if result.success?+ render json: serialize_resource(@resource.reload)+ else+ render_service_error(result.error, code: ERROR_CODES[:order_already_completed])+ end+ end+ end++ # PATCH /api/v3/admin/orders/:id/cancel+ def cancel+ with_order_lock do+ @resource.canceled_by(try_spree_current_user)+ render json: serialize_resource(@resource.reload)+ end+ end++ # PATCH /api/v3/admin/orders/:id/approve+ def approve+ with_order_lock do+ @resource.approved_by(try_spree_current_user)+ render json: serialize_resource(@resource.reload)+ end+ end++ # PATCH /api/v3/admin/orders/:id/resume+ def resume+ with_order_lock do+ @resource.resume!+ render json: serialize_resource(@resource.reload)+ end+ end++ # POST /api/v3/admin/orders/:id/resend_confirmation+ def resend_confirmation+ @resource.publish_event('order.completed')+ render json: serialize_resource(@resource)+ end++ protected++ def model_class+ Spree::Order+ end++ def serializer_class+ Spree.api.admin_order_serializer+ end++ # Override scope — Order uses SingleStoreResource (for_store)+ def scope+ current_store.orders.accessible_by(current_ability, :show).preload_associations_lazily+ end++ def set_resource+ @resource = scope.find_by_prefix_id!(params[:id])+ @order = @resource # needed for OrderLock+ authorize_resource!(@resource)+ end++ # Map state transition actions to :update permission+ def authorize_resource!(resource = @resource, action = action_name.to_sym)+ mapped_action = case action+ when :next, :advance, :complete, :cancel, :approve, :resume, :resend_confirmation+ :update+ else+ action+ end+ authorize!(mapped_action, resource)+ end++ def collection_includes+ [:line_items, :user]+ end++ private++ def render_result_error(result)+ error = result.error+ errors = error.respond_to?(:value) ? error.value : error++ if errors.is_a?(ActiveModel::Errors)+ render_validation_error(errors)+ else+ render_service_error(error)+ end+ end++ def resolve_user+ return unless params[:user_id].present?++ Spree.user_class.find_by_prefix_id!(params[:user_id])+ end++ def order_create_params+ {+ email: params[:email],+ channel: params[:channel],+ internal_note: params[:internal_note]+ }.compact+ end++ def order_update_params+ params.permit(+ :email, :special_instructions, :internal_note, :channel,+ ship_address: address_params,+ bill_address: address_params,+ line_items: [:variant_id, :quantity, { metadata: {} }]+ )+ end++ def address_params+ [+ :id, :firstname, :lastname, :address1, :address2,+ :city, :zipcode, :phone, :company,+ :country_iso, :state_abbr, :state_name+ ]+ end+ end+ end+ end+ end+enddiff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rbindex 59df23eeb4..12f8b67f8a 100644--- a/spree/api/config/routes.rb+++ b/spree/api/config/routes.rb@@ -110,6 +110,21 @@ Spree::Core::Engine.add_routes do# Option Types (with nested option_values in payload)resources :option_types++ # Orders+ resources :orders do+ member do+ patch :next+ patch :advance+ patch :complete+ patch :cancel+ patch :approve+ patch :resume+ post :resend_confirmation+ end++ resources :line_items, controller: 'orders/line_items'+ endendendenddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/orders/line_items_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/orders/line_items_controller_spec.rbnew file mode 100644index 0000000000..6ef6c7010f--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/admin/orders/line_items_controller_spec.rb@@ -0,0 +1,67 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Admin::Orders::LineItemsController, type: :controller do+ render_views++ include_context 'API v3 Admin authenticated'++ let!(:order) { create(:order, store: store, state: 'cart') }+ let!(:variant) { create(:variant, product: create(:product, stores: [store])) }++ describe 'GET #index' do+ let!(:line_item) { create(:line_item, order: order, variant: variant) }++ subject { get :index, params: { order_id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'returns line items' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['data']).to be_an(Array)+ expect(json_response['data'].length).to eq(1)+ end+ end++ describe 'POST #create' do+ subject { post :create, params: { order_id: order.prefixed_id, variant_id: variant.prefixed_id, quantity: 2 }, as: :json }++ before { request.headers.merge!(headers) }++ it 'adds a line item' do+ expect { subject }.to change(order.line_items, :count).by(1)++ expect(response).to have_http_status(:created)+ expect(json_response['quantity']).to eq(2)+ end+ end++ describe 'PATCH #update' do+ let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 1) }++ subject { patch :update, params: { order_id: order.prefixed_id, id: line_item.prefixed_id, quantity: 5 }, as: :json }++ before { request.headers.merge!(headers) }++ it 'updates the line item quantity' do+ subject++ expect(response).to have_http_status(:ok)+ expect(line_item.reload.quantity).to eq(5)+ end+ end++ describe 'DELETE #destroy' do+ let!(:line_item) { create(:line_item, order: order, variant: variant) }++ subject { delete :destroy, params: { order_id: order.prefixed_id, id: line_item.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'removes the line item' do+ subject+ expect(response).to have_http_status(:no_content)+ end+ end+enddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rbnew file mode 100644index 0000000000..525ce950f1--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/admin/orders_controller_spec.rb@@ -0,0 +1,213 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Admin::OrdersController, type: :controller do+ render_views++ include_context 'API v3 Admin authenticated'++ let!(:order) { create(:order, store: store, state: 'cart') }++ describe 'GET #index' do+ subject { get :index, params: {}, as: :json }++ before { request.headers.merge!(headers) }++ it 'returns orders list' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['data']).to be_an(Array)+ expect(json_response['data'].length).to eq(1)+ expect(json_response['data'].first['id']).to eq(order.prefixed_id)+ end++ it 'includes admin-only fields' do+ subject++ data = json_response['data'].first+ expect(data).to have_key('channel')+ expect(data).to have_key('considered_risky')+ end++ it 'returns pagination metadata' do+ subject++ expect(json_response['meta']).to include('page', 'limit', 'count', 'pages')+ end++ context 'with ransack filtering' do+ let!(:completed_order) { create(:completed_order_with_totals, store: store) }++ it 'filters by state' do+ get :index, params: { q: { state_eq: 'complete' } }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['data'].length).to eq(1)+ expect(json_response['data'].first['id']).to eq(completed_order.prefixed_id)+ end+ end++ context 'without authentication' do+ let(:headers) { {} }++ it 'returns 401 unauthorized' do+ subject+ expect(response).to have_http_status(:unauthorized)+ end+ end+ end++ describe 'GET #show' do+ subject { get :show, params: { id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'returns the order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['id']).to eq(order.prefixed_id)+ expect(json_response['number']).to eq(order.number)+ end++ it 'includes admin-only fields' do+ subject++ expect(json_response).to have_key('channel')+ expect(json_response).to have_key('considered_risky')+ expect(json_response).to have_key('internal_note')+ end++ context 'with non-existent order' do+ it 'returns 404' do+ get :show, params: { id: 'or_nonexistent' }, as: :json+ expect(response).to have_http_status(:not_found)+ end+ end+ end++ describe 'POST #create' do+ subject { post :create, params: create_params, as: :json }++ before { request.headers.merge!(headers) }++ let(:create_params) { { email: '[email protected]' } }++ it 'creates a draft order' do+ expect { subject }.to change(Spree::Order, :count).by(1)++ expect(response).to have_http_status(:created)+ expect(json_response['email']).to eq('[email protected]')+ expect(json_response['state']).to eq('cart')+ end++ context 'with user assignment' do+ let(:customer) { create(:user) }+ let(:create_params) { { user_id: customer.prefixed_id } }++ it 'creates order assigned to the user' do+ subject++ expect(response).to have_http_status(:created)+ created_order = Spree::Order.find_by_prefix_id(json_response['id'])+ expect(created_order.user).to eq(customer)+ end+ end+ end++ describe 'PATCH #update' do+ subject { patch :update, params: { id: order.prefixed_id, email: '[email protected]' }, as: :json }++ before { request.headers.merge!(headers) }++ it 'updates the order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['email']).to eq('[email protected]')+ end+ end++ describe 'DELETE #destroy' do+ subject { delete :destroy, params: { id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'deletes a draft order' do+ subject+ expect(response).to have_http_status(:no_content)+ end++ context 'with completed order' do+ let!(:order) { create(:completed_order_with_totals, store: store) }++ it 'returns 403 (cannot delete completed orders)' do+ subject+ expect(response).to have_http_status(:forbidden)+ end+ end+ end++ describe 'PATCH #cancel' do+ let!(:order) { create(:completed_order_with_totals, store: store) }++ subject { patch :cancel, params: { id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'cancels the order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['state']).to eq('canceled')+ end+ end++ describe 'PATCH #approve' do+ let!(:order) { create(:completed_order_with_totals, store: store) }++ subject { patch :approve, params: { id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'approves the order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['approved_at']).to be_present+ end+ end++ describe 'PATCH #resume' do+ let!(:order) { create(:completed_order_with_totals, store: store) }++ subject { patch :resume, params: { id: order.prefixed_id }, as: :json }++ before do+ request.headers.merge!(headers)+ order.canceled_by(admin_user)+ end++ it 'resumes the canceled order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['state']).to eq('resumed')+ end+ end++ describe 'POST #resend_confirmation' do+ let!(:order) { create(:completed_order_with_totals, store: store) }++ subject { post :resend_confirmation, params: { id: order.prefixed_id }, as: :json }++ before { request.headers.merge!(headers) }++ it 'returns the order' do+ subject++ expect(response).to have_http_status(:ok)+ expect(json_response['id']).to eq(order.prefixed_id)+ end+ end+enddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rbnew file mode 100644index 0000000000..d8af2a8359--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb@@ -0,0 +1,83 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Admin::Products::AssetsController, type: :controller do+ render_views++ include_context 'API v3 Admin authenticated'++ let!(:product) { create(:product, stores: [store]) }+ let!(:image) { create(:image, viewable: product.master) }++ before { request.headers.merge!(headers) }++ describe 'GET #index' do+ it 'returns assets for the product' do+ get :index, params: { product_id: product.prefixed_id }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['data']).to be_an(Array)+ ids = json_response['data'].map { |a| a['id'] }+ expect(ids).to include(image.prefixed_id)+ end++ context 'with product from another store' do+ let(:other_store) { create(:store) }+ let(:other_product) { create(:product, stores: [other_store]) }++ it 'returns 404' do+ get :index, params: { product_id: other_product.prefixed_id }, as: :json+ expect(response).to have_http_status(:not_found)+ end+ end+ end++ describe 'POST #create' do+ it 'returns validation error without attachment' do+ post :create, params: {+ product_id: product.prefixed_id,+ alt: 'New image',+ position: 1+ }, as: :json++ expect(response).to have_http_status(:unprocessable_content)+ end+ end++ describe 'PATCH #update' do+ it 'updates the asset alt text' do+ patch :update, params: {+ product_id: product.prefixed_id,+ id: image.prefixed_id,+ alt: 'Updated alt text'+ }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['alt']).to eq('Updated alt text')+ expect(image.reload.alt).to eq('Updated alt text')+ end++ it 'updates the asset position' do+ patch :update, params: {+ product_id: product.prefixed_id,+ id: image.prefixed_id,+ position: 5+ }, as: :json++ expect(response).to have_http_status(:ok)+ expect(image.reload.position).to eq(5)+ end+ end++ describe 'DELETE #destroy' do+ it 'deletes the asset' do+ expect {+ delete :destroy, params: {+ product_id: product.prefixed_id,+ id: image.prefixed_id+ }, as: :json+ }.to change(product.master.images, :count).by(-1)++ expect(response).to have_http_status(:no_content)+ end+ end+enddiff --git a/spree/api/spec/integration/spree/api/v3/admin/orders/line_items_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/orders/line_items_spec.rbnew file mode 100644index 0000000000..c71f07c779--- /dev/null+++ b/spree/api/spec/integration/spree/api/v3/admin/orders/line_items_spec.rb@@ -0,0 +1,154 @@+# frozen_string_literal: true++require 'swagger_helper'++RSpec.describe 'Admin Order Line Items API', type: :request, swagger_doc: 'api-reference/admin.yaml' do+ include_context 'API v3 Admin'++ let!(:product) { create(:product, stores: [store]) }+ let!(:variant) { create(:variant, product: product) }+ let!(:order) { create(:order, store: store, state: 'cart') }+ let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 2) }+ let(:Authorization) { "Bearer #{admin_jwt_token}" }++ path '/api/v3/admin/orders/{order_id}/line_items' do+ let(:order_id) { order.prefixed_id }++ get 'List line items' do+ tags 'Line Items'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns all line items for an order.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :order_id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '200', 'line items found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['data']).to be_an(Array)+ expect(data['data'].length).to eq(1)+ end+ end+ end++ post 'Add a line item' do+ tags 'Line Items'+ consumes 'application/json'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Adds a new line item to the order.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :order_id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'+ parameter name: :body, in: :body, schema: {+ type: :object,+ required: %w[variant_id],+ properties: {+ variant_id: { type: :string, description: 'Prefixed variant ID' },+ quantity: { type: :integer, default: 1 }+ }+ }++ response '201', 'line item added' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:new_variant) { create(:variant, product: create(:product, stores: [store])) }+ let(:body) { { variant_id: new_variant.prefixed_id, quantity: 3 } }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['quantity']).to eq(3)+ end+ end+ end+ end++ path '/api/v3/admin/orders/{order_id}/line_items/{id}' do+ let(:order_id) { order.prefixed_id }+ let(:id) { line_item.prefixed_id }++ get 'Show a line item' do+ tags 'Line Items'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns details of a specific line item.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :order_id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Line item prefixed ID'++ response '200', 'line item found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['id']).to eq(line_item.prefixed_id)+ end+ end+ end++ patch 'Update a line item' do+ tags 'Line Items'+ consumes 'application/json'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Updates a line item quantity or metadata.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :order_id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Line item prefixed ID'+ parameter name: :body, in: :body, schema: {+ type: :object,+ properties: {+ quantity: { type: :integer }+ }+ }++ response '200', 'line item updated' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:body) { { quantity: 5 } }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['quantity']).to eq(5)+ end+ end+ end++ delete 'Remove a line item' do+ tags 'Line Items'+ security [api_key: [], bearer_auth: []]+ description 'Removes a line item from the order.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :order_id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Line item prefixed ID'++ response '204', 'line item removed' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test!+ end+ end+ end+enddiff --git a/spree/api/spec/integration/spree/api/v3/admin/orders_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/orders_spec.rbnew file mode 100644index 0000000000..7719351e19--- /dev/null+++ b/spree/api/spec/integration/spree/api/v3/admin/orders_spec.rb@@ -0,0 +1,320 @@+# frozen_string_literal: true++require 'swagger_helper'++RSpec.describe 'Admin Orders API', type: :request, swagger_doc: 'api-reference/admin.yaml' do+ include_context 'API v3 Admin'++ let!(:order) { create(:order, store: store, state: 'cart', email: '[email protected]') }+ let(:Authorization) { "Bearer #{admin_jwt_token}" }++ path '/api/v3/admin/orders' do+ get 'List orders' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns a paginated list of orders for the current store.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :page, in: :query, type: :integer, required: false, description: 'Page number'+ parameter name: :limit, in: :query, type: :integer, required: false, description: 'Number of records per page'+ parameter name: :sort, in: :query, type: :string, required: false,+ description: 'Sort field (e.g., created_at, -created_at, completed_at)'+ parameter name: :'q[state_eq]', in: :query, type: :string, required: false,+ description: 'Filter by state (cart, address, delivery, payment, confirm, complete, canceled)'+ parameter name: :'q[email_cont]', in: :query, type: :string, required: false,+ description: 'Filter by email (contains)'+ parameter name: :'q[number_eq]', in: :query, type: :string, required: false,+ description: 'Filter by order number'+ parameter name: :'q[completed_at_gt]', in: :query, type: :string, required: false,+ description: 'Filter by completed after date'++ response '200', 'orders found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['data']).to be_an(Array)+ expect(data['meta']).to include('page', 'limit', 'count', 'pages')+ end+ end++ response '401', 'unauthorized' do+ let(:'x-spree-api-key') { 'invalid' }++ schema '$ref' => '#/components/schemas/ErrorResponse'++ run_test!+ end+ end++ post 'Create a draft order' do+ tags 'Orders'+ consumes 'application/json'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Creates a new draft order. Optionally assign a user and set initial attributes.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :body, in: :body, schema: {+ type: :object,+ properties: {+ email: { type: :string, example: '[email protected]' },+ user_id: { type: :string, description: 'Prefixed user ID to assign' },+ currency: { type: :string, example: 'USD' },+ channel: { type: :string, example: 'admin' },+ internal_note: { type: :string }+ }+ }++ response '201', 'order created' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:body) { { email: '[email protected]' } }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['email']).to eq('[email protected]')+ expect(data['state']).to eq('cart')+ end+ end+ end+ end++ path '/api/v3/admin/orders/{id}' do+ let(:id) { order.prefixed_id }++ get 'Show an order' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Returns full order details including admin-only fields.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID (e.g., or_xxx)'+ parameter name: :expand, in: :query, type: :string, required: false,+ description: 'Comma-separated associations to expand (e.g., user)'++ response '200', 'order found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['id']).to eq(order.prefixed_id)+ expect(data).to have_key('channel')+ expect(data).to have_key('considered_risky')+ end+ end++ response '404', 'order not found' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:id) { 'or_nonexistent' }++ schema '$ref' => '#/components/schemas/ErrorResponse'++ run_test!+ end+ end++ patch 'Update an order' do+ tags 'Orders'+ consumes 'application/json'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Updates an order. Supports updating email, addresses, special instructions, and line items.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'+ parameter name: :body, in: :body, schema: {+ type: :object,+ properties: {+ email: { type: :string },+ special_instructions: { type: :string },+ internal_note: { type: :string },+ channel: { type: :string },+ 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 }+ }+ },+ line_items: {+ type: :array,+ items: {+ type: :object,+ properties: {+ variant_id: { type: :string },+ quantity: { type: :integer }+ }+ }+ }+ }+ }++ response '200', 'order updated' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let(:body) { { email: '[email protected]' } }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['email']).to eq('[email protected]')+ end+ end+ end++ delete 'Delete a draft order' do+ tags 'Orders'+ security [api_key: [], bearer_auth: []]+ description 'Deletes a draft order. Completed orders cannot be deleted.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '204', 'order deleted' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }++ run_test!+ end+ end+ end++ path '/api/v3/admin/orders/{id}/cancel' do+ patch 'Cancel an order' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Cancels a completed order.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '200', 'order canceled' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let!(:order) { create(:completed_order_with_totals, store: store) }+ let(:id) { order.prefixed_id }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['state']).to eq('canceled')+ end+ end+ end+ end++ path '/api/v3/admin/orders/{id}/approve' do+ patch 'Approve an order' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Approves an order (e.g., for fraud review).'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '200', 'order approved' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let!(:order) { create(:completed_order_with_totals, store: store) }+ let(:id) { order.prefixed_id }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['approved_at']).to be_present+ end+ end+ end+ end++ path '/api/v3/admin/orders/{id}/resume' do+ patch 'Resume a canceled order' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Resumes a previously canceled order.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '200', 'order resumed' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let!(:order) { create(:completed_order_with_totals, store: store) }+ let(:id) { order.prefixed_id }++ before do+ order.canceled_by(admin_user)+ end++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['state']).to eq('resumed')+ end+ end+ end+ end++ path '/api/v3/admin/orders/{id}/resend_confirmation' do+ post 'Resend confirmation email' do+ tags 'Orders'+ produces 'application/json'+ security [api_key: [], bearer_auth: []]+ description 'Publishes the order.completed event to trigger confirmation email delivery.'++ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true+ parameter name: :Authorization, in: :header, type: :string, required: true,+ description: 'Bearer token for admin authentication'+ parameter name: :id, in: :path, type: :string, required: true,+ description: 'Order prefixed ID'++ response '200', 'confirmation resent' do+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }+ let!(:order) { create(:completed_order_with_totals, store: store) }+ let(:id) { order.prefixed_id }++ run_test! do |response|+ data = JSON.parse(response.body)+ expect(data['id']).to eq(order.prefixed_id)+ end+ end+ end+ end+end