Skip to content

armgit / spree

Public Imported from GitHub
0

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

Implement Customer Groups in Admin SPA

Damian Legawiec757478274109
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yaml
index ed332493f0..437aad33ec 100644
--- a/docs/api-reference/admin.yaml
+++ b/docs/api-reference/admin.yaml
@@ -82,11 +82,11 @@ paths:
example:
data:
- id: admin_UkLWZg9DAJ
- first_name: Jenniffer
- last_name: Murray
- created_at: '2026-05-13T22:25:22.374Z'
- updated_at: '2026-05-13T22:25:22.374Z'
+ first_name: Taisha
+ last_name: Upton
+ created_at: '2026-05-17T22:57:21.251Z'
+ updated_at: '2026-05-17T22:57:21.251Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -144,11 +144,11 @@ paths:
application/json:
example:
id: admin_UkLWZg9DAJ
- first_name: Aracely
- last_name: Durgan
- created_at: '2026-05-13T22:25:22.752Z'
- updated_at: '2026-05-13T22:25:22.752Z'
+ first_name: Bennie
+ last_name: Jerde
+ created_at: '2026-05-17T22:57:21.592Z'
+ updated_at: '2026-05-17T22:57:21.592Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -201,11 +201,11 @@ paths:
application/json:
example:
id: admin_UkLWZg9DAJ
first_name: Renamed
- last_name: Jerde
- created_at: '2026-05-13T22:25:23.034Z'
- updated_at: '2026-05-13T22:25:23.053Z'
+ last_name: Casper
+ created_at: '2026-05-17T22:57:21.878Z'
+ updated_at: '2026-05-17T22:57:21.895Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -314,32 +314,32 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-05-13T22:25:23.358Z'
- updated_at: '2026-05-13T22:25:23.358Z'
+ created_at: '2026-05-17T22:57:22.193Z'
+ updated_at: '2026-05-17T22:57:22.193Z'
revoked_at:
last_used_at:
- plaintext_token: pk_Kcdp8p1f9oLuAurK45tEKGBq
+ plaintext_token: pk_U35V1CMjxUn8ZqkAukTSrh6d
created_by_email:
- id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_kgtYUyKf5
+ token_prefix: sk_RgQsPziGM
scopes:
- write_all
- created_at: '2026-05-13T22:25:23.361Z'
- updated_at: '2026-05-13T22:25:23.361Z'
+ created_at: '2026-05-17T22:57:22.194Z'
+ updated_at: '2026-05-17T22:57:22.194Z'
revoked_at:
last_used_at:
plaintext_token:
created_by_email:
- id: key_EfhxLZ9ck8
- name: esse
+ name: hic
key_type: secret
- token_prefix: sk_AZwDFMUS5
+ token_prefix: sk_K32iSYt2g
scopes:
- write_all
- created_at: '2026-05-13T22:25:23.363Z'
- updated_at: '2026-05-13T22:25:23.363Z'
+ created_at: '2026-05-17T22:57:22.194Z'
+ updated_at: '2026-05-17T22:57:22.194Z'
revoked_at:
last_used_at:
plaintext_token:
@@ -402,15 +402,15 @@ paths:
id: key_VqXmZF31wY
name: CI key
key_type: secret
- token_prefix: sk_Yny6JAPFb
+ token_prefix: sk_AgmxxXG58
scopes:
- read_orders
- created_at: '2026-05-13T22:25:23.961Z'
- updated_at: '2026-05-13T22:25:23.961Z'
+ created_at: '2026-05-17T22:57:22.758Z'
+ updated_at: '2026-05-17T22:57:22.758Z'
revoked_at:
last_used_at:
- plaintext_token: sk_Yny6JAPFbyjQvyb2cdX8zDtp
- created_by_email: [email protected]
+ plaintext_token: sk_AgmxxXG58HsQVeszL9SN8yNm
+ created_by_email: [email protected]
'422':
description: validation error
content:
@@ -496,11 +496,11 @@ paths:
key_type: publishable
token_prefix:
scopes: []
- created_at: '2026-05-13T22:25:24.269Z'
- updated_at: '2026-05-13T22:25:24.269Z'
+ created_at: '2026-05-17T22:57:23.047Z'
+ updated_at: '2026-05-17T22:57:23.047Z'
revoked_at:
last_used_at:
- plaintext_token: pk_a7SnSEmz5RJCt8sA9yYugcMy
+ plaintext_token: pk_ZsR9RTxoWgMQbCRWVbza9nAi
created_by_email:
delete:
summary: Delete an API key
@@ -590,12 +590,12 @@ paths:
id: key_gbHJdmfrXB
name: Backend integration
key_type: secret
- token_prefix: sk_n8yGppQok
+ token_prefix: sk_9ntyVz4oF
scopes:
- write_all
- created_at: '2026-05-13T22:25:24.833Z'
- updated_at: '2026-05-13T22:25:25.111Z'
- revoked_at: '2026-05-13T22:25:25.110Z'
+ created_at: '2026-05-17T22:57:23.620Z'
+ updated_at: '2026-05-17T22:57:23.925Z'
+ revoked_at: '2026-05-17T22:57:23.923Z'
last_used_at:
plaintext_token:
created_by_email:
@@ -650,15 +650,15 @@ paths:
- id: coupon_UkLWZg9DAJ
code: AAA111
state: unused
- created_at: '2026-05-13T22:25:25.129Z'
- updated_at: '2026-05-13T22:25:25.129Z'
+ created_at: '2026-05-17T22:57:23.946Z'
+ updated_at: '2026-05-17T22:57:23.946Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
- id: coupon_gbHJdmfrXB
code: BBB222
state: unused
- created_at: '2026-05-13T22:25:25.130Z'
- updated_at: '2026-05-13T22:25:25.130Z'
+ created_at: '2026-05-17T22:57:23.947Z'
+ updated_at: '2026-05-17T22:57:23.947Z'
promotion_id: promo_UkLWZg9DAJ
order_id:
meta:
@@ -736,8 +736,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-13T22:25:25.423Z'
- updated_at: '2026-05-13T22:25:25.423Z'
+ created_at: '2026-05-17T22:57:24.250Z'
+ updated_at: '2026-05-17T22:57:24.250Z'
- id: cfdef_gbHJdmfrXB
namespace: custom
key: order_notes
@@ -745,8 +745,8 @@ paths:
field_type: short_text
resource_type: Spree::Order
storefront_visible: true
- created_at: '2026-05-13T22:25:25.424Z'
- updated_at: '2026-05-13T22:25:25.424Z'
+ created_at: '2026-05-17T22:57:24.251Z'
+ updated_at: '2026-05-17T22:57:24.251Z'
meta:
page: 1
limit: 25
@@ -809,8 +809,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-13T22:25:25.980Z'
- updated_at: '2026-05-13T22:25:25.980Z'
+ created_at: '2026-05-17T22:57:24.816Z'
+ updated_at: '2026-05-17T22:57:24.816Z'
requestBody:
content:
application/json:
@@ -893,8 +893,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: true
- created_at: '2026-05-13T22:25:25.982Z'
- updated_at: '2026-05-13T22:25:25.982Z'
+ created_at: '2026-05-17T22:57:24.818Z'
+ updated_at: '2026-05-17T22:57:24.818Z'
patch:
summary: Update a custom field definition
tags:
@@ -933,8 +933,8 @@ paths:
field_type: short_text
resource_type: Spree::Product
storefront_visible: false
- created_at: '2026-05-13T22:25:26.260Z'
- updated_at: '2026-05-13T22:25:26.538Z'
+ created_at: '2026-05-17T22:57:25.103Z'
+ updated_at: '2026-05-17T22:57:25.399Z'
requestBody:
content:
application/json:
@@ -975,6 +975,456 @@ paths:
responses:
'204':
description: definition deleted
+ "/api/v3/admin/customer_groups":
+ get:
+ summary: List customer groups
+ tags:
+ - Customers
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns the customer groups configured for the current store. Groups
+ segment customers for targeted promotions (see the `customer_group`
+ promotion rule) and reporting. The list endpoint never embeds the
+ member list — fetch a single group with `?expand=customers` if you
+ need them inline, or query `/admin/customers?customer_group_id_in=…`
+ for paginated membership.
+
+
+ **Required scope:** `read_customers` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const { data: groups } = await client.customerGroups.list({ page: 1, limit: 25 })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ description: Page number
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ description: Number of records per page
+ schema:
+ type: integer
+ - name: q[name_cont]
+ in: query
+ required: false
+ description: Filter by name (contains)
+ schema:
+ type: string
+ - name: sort
+ in: query
+ required: false
+ description: Sort by field. Prefix with `-` for descending (e.g., `-created_at`).
+ schema:
+ type: string
+ - name: fields
+ in: query
+ required: false
+ description: Comma-separated list of fields to include. id is always included.
+ schema:
+ type: string
+ responses:
+ '200':
+ description: customer groups found
+ content:
+ application/json:
+ example:
+ data:
+ - id: cg_UkLWZg9DAJ
+ name: VIPs
+ description: Top spenders
+ customers_count: 0
+ created_at: '2026-05-17T22:57:25.696Z'
+ updated_at: '2026-05-17T22:57:25.696Z'
+ - id: cg_gbHJdmfrXB
+ name: Wholesale
+ description:
+ customers_count: 0
+ created_at: '2026-05-17T22:57:25.697Z'
+ updated_at: '2026-05-17T22:57:25.697Z'
+ meta:
+ page: 1
+ limit: 25
+ count: 2
+ pages: 1
+ from: 1
+ to: 2
+ in: 2
+ previous:
+ next:
+ schema:
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ "$ref": "#/components/schemas/CustomerGroup"
+ meta:
+ "$ref": "#/components/schemas/PaginationMeta"
+ required:
+ - data
+ - meta
+ '401':
+ description: unauthorized
+ content:
+ application/json:
+ example:
+ error:
+ code: authentication_required
+ message: Authentication required
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ post:
+ summary: Create a customer group
+ tags:
+ - Customers
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Creates a customer group in the current store. `customer_ids` is
+ optional; when present, customers are attached at create time.
+ Pass prefixed IDs (e.g. `cus_…`) — the server decodes them
+ automatically.
+
+
+ **Required scope:** `write_customers` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ const group = await client.customerGroups.create({
+ name: 'VIP customers',
+ description: 'Top spenders, eligible for early access',
+ customer_ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
+ })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '201':
+ description: customer group created
+ content:
+ application/json:
+ example:
+ id: cg_EfhxLZ9ck8
+ name: Wholesale 2
+ description: B2B accounts
+ customers_count: 1
+ created_at: '2026-05-17T22:57:26.563Z'
+ updated_at: '2026-05-17T22:57:26.563Z'
+ schema:
+ "$ref": "#/components/schemas/CustomerGroup"
+ '422':
+ description: validation error
+ content:
+ application/json:
+ example:
+ error:
+ code: validation_error
+ message: Name can't be blank
+ details:
+ name:
+ - can't be blank
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ example: Wholesale
+ description:
+ type: string
+ example: B2B accounts
+ nullable: true
+ customer_ids:
+ type: array
+ items:
+ type: string
+ example:
+ - cus_UkLWZg9DAJ
+ "/api/v3/admin/customer_groups/{id}":
+ parameters:
+ - name: id
+ in: path
+ required: true
+ description: Customer group prefixed ID
+ schema:
+ type: string
+ get:
+ summary: Get a customer group
+ tags:
+ - Customers
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Returns a single customer group. Pass `?expand=customers` to embed
+ the full member list inline (recommended only for single-record
+ reads — embed cost scales with membership size).
+
+
+ **Required scope:** `read_customers` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ // Pass `expand: ['customers']` to embed the group's customers in the response
+ // — omit it for the much smaller index-payload shape.
+ const group = await client.customerGroups.get('cg_UkLWZg9DAJ', { expand: ['customers'] })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: expand
+ in: query
+ required: false
+ description: 'Comma-separated associations to embed. Supported: `customers`.'
+ schema:
+ type: string
+ - name: fields
+ in: query
+ required: false
+ description: Comma-separated list of fields to include. id is always included.
+ schema:
+ type: string
+ responses:
+ '200':
+ description: customer group with embedded customers
+ content:
+ application/json:
+ example:
+ id: cg_UkLWZg9DAJ
+ name: VIPs
+ description: Top spenders
+ customers_count: 1
+ created_at: '2026-05-17T22:57:27.194Z'
+ updated_at: '2026-05-17T22:57:27.194Z'
+ customers:
+ - id: cus_UkLWZg9DAJ
+ first_name: Drucilla
+ last_name: Mraz
+ phone:
+ accepts_email_marketing: false
+ full_name: Drucilla Mraz
+ available_store_credit_total: '0'
+ display_available_store_credit_total: "$0.00"
+ metadata: {}
+ last_sign_in_at:
+ current_sign_in_at:
+ created_at: '2026-05-17T22:57:27.460Z'
+ updated_at: '2026-05-17T22:57:27.460Z'
+ sign_in_count: 0
+ failed_attempts: 0
+ last_sign_in_ip:
+ current_sign_in_ip:
+ tags: []
+ internal_note_html:
+ default_billing_address_id:
+ default_shipping_address_id:
+ orders_count: 0
+ total_spent: '0.0'
+ display_total_spent: "$0.00"
+ last_order_completed_at:
+ schema:
+ "$ref": "#/components/schemas/CustomerGroup"
+ '404':
+ description: customer group not found
+ content:
+ application/json:
+ example:
+ error:
+ code: record_not_found
+ message: Customer group not found
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ patch:
+ summary: Update a customer group
+ tags:
+ - Customers
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Updates name, description, or membership. `customer_ids` is a
+ full-set replacement — the server reconciles the membership to
+ match the array, adding new IDs and removing ones not present.
+ Send `customer_ids: []` to clear all members.
+
+
+ **Required scope:** `write_customers` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ // `customer_ids` is a full-set update — the model reconciles the membership
+ // to match the array (adds new IDs, removes ones not present).
+ const group = await client.customerGroups.update('cg_UkLWZg9DAJ', {
+ name: 'VIP customers (Q1)',
+ customer_ids: ['cus_UkLWZg9DAJ'],
+ })
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '200':
+ description: customer group updated
+ content:
+ application/json:
+ example:
+ id: cg_UkLWZg9DAJ
+ name: VIP customers (Q1)
+ description: Top spenders
+ customers_count: 0
+ created_at: '2026-05-17T22:57:28.061Z'
+ updated_at: '2026-05-17T22:57:28.346Z'
+ schema:
+ "$ref": "#/components/schemas/CustomerGroup"
+ '422':
+ description: validation error
+ content:
+ application/json:
+ example:
+ error:
+ code: validation_error
+ message: Name can't be blank
+ details:
+ name:
+ - can't be blank
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ name:
+ type: string
+ example: VIP customers (Q1)
+ description:
+ type: string
+ example: Updated description
+ nullable: true
+ customer_ids:
+ type: array
+ items:
+ type: string
+ example:
+ - cus_UkLWZg9DAJ
+ delete:
+ summary: Delete a customer group
+ tags:
+ - Customers
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: |-
+ Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.
+
+ **Required scope:** `write_customers` (for API-key authentication).
+ x-codeSamples:
+ - lang: javascript
+ label: Spree Admin SDK
+ source: |-
+ import { createAdminClient } from '@spree/admin-sdk'
+
+ const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+ })
+
+ await client.customerGroups.delete('cg_UkLWZg9DAJ')
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ schema:
+ type: string
+ responses:
+ '204':
+ description: customer group deleted
"/api/v3/admin/customers/{customer_id}/addresses":
get:
summary: List customer addresses
@@ -1056,8 +1506,8 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-05-13T22:25:27.101Z'
- updated_at: '2026-05-13T22:25:27.101Z'
+ created_at: '2026-05-17T22:57:29.199Z'
+ updated_at: '2026-05-17T22:57:29.199Z'
customer_id: cus_UkLWZg9DAJ
meta:
page: 1
@@ -1145,8 +1595,8 @@ paths:
state_name: New York
label: Office
metadata: {}
- created_at: '2026-05-13T22:25:28.479Z'
- updated_at: '2026-05-13T22:25:28.479Z'
+ created_at: '2026-05-17T22:57:30.589Z'
+ updated_at: '2026-05-17T22:57:30.589Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
@@ -1257,8 +1707,8 @@ paths:
state_name: New York
label:
metadata: {}
- created_at: '2026-05-13T22:25:28.750Z'
- updated_at: '2026-05-13T22:25:29.293Z'
+ created_at: '2026-05-17T22:57:30.858Z'
+ updated_at: '2026-05-17T22:57:31.401Z'
customer_id: cus_UkLWZg9DAJ
requestBody:
content:
@@ -1391,8 +1841,8 @@ paths:
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-05-13T22:25:30.386Z'
- updated_at: '2026-05-13T22:25:30.386Z'
+ created_at: '2026-05-17T22:57:32.516Z'
+ updated_at: '2026-05-17T22:57:32.516Z'
meta:
page: 1
limit: 25
@@ -1479,8 +1929,8 @@ paths:
customer_id: cus_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
metadata: {}
- created_at: '2026-05-13T22:25:30.940Z'
- updated_at: '2026-05-13T22:25:30.940Z'
+ created_at: '2026-05-17T22:57:33.067Z'
+ updated_at: '2026-05-17T22:57:33.067Z'
delete:
summary: Delete a customer credit card
tags:
@@ -1599,8 +2049,8 @@ paths:
currency: USD
memo:
metadata: {}
- created_at: '2026-05-13T22:25:32.330Z'
- updated_at: '2026-05-13T22:25:32.330Z'
+ created_at: '2026-05-17T22:57:34.424Z'
+ updated_at: '2026-05-17T22:57:34.424Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
@@ -1675,8 +2125,8 @@ paths:
currency: USD
memo: Goodwill
metadata: {}
- created_at: '2026-05-13T22:25:33.437Z'
- updated_at: '2026-05-13T22:25:33.437Z'
+ created_at: '2026-05-17T22:57:35.514Z'
+ updated_at: '2026-05-17T22:57:35.514Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_gbHJdmfrXB
category_id: sccat_UkLWZg9DAJ
@@ -1767,8 +2217,8 @@ paths:
currency: USD
memo: Updated
metadata: {}
- created_at: '2026-05-13T22:25:33.975Z'
- updated_at: '2026-05-13T22:25:34.259Z'
+ created_at: '2026-05-17T22:57:36.047Z'
+ updated_at: '2026-05-17T22:57:36.325Z'
customer_id: cus_UkLWZg9DAJ
created_by_id: admin_UkLWZg9DAJ
category_id: sccat_UkLWZg9DAJ
@@ -1922,8 +2372,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-13T22:25:35.356Z'
- updated_at: '2026-05-13T22:25:35.356Z'
+ created_at: '2026-05-17T22:57:37.396Z'
+ updated_at: '2026-05-17T22:57:37.396Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2006,8 +2456,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-13T22:25:36.195Z'
- updated_at: '2026-05-13T22:25:36.195Z'
+ created_at: '2026-05-17T22:57:38.226Z'
+ updated_at: '2026-05-17T22:57:38.226Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2123,8 +2573,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-13T22:25:36.467Z'
- updated_at: '2026-05-13T22:25:36.467Z'
+ created_at: '2026-05-17T22:57:38.506Z'
+ updated_at: '2026-05-17T22:57:38.506Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2198,8 +2648,8 @@ paths:
metadata: {}
last_sign_in_at:
current_sign_in_at:
- created_at: '2026-05-13T22:25:37.020Z'
- updated_at: '2026-05-13T22:25:37.302Z'
+ created_at: '2026-05-17T22:57:39.051Z'
+ updated_at: '2026-05-17T22:57:39.332Z'
sign_in_count: 0
failed_attempts: 0
last_sign_in_ip:
@@ -2321,11 +2771,11 @@ paths:
example:
data:
- id: exp_UkLWZg9DAJ
- number: EF354229426
+ number: EF181505182
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-13T22:25:38.189Z'
- updated_at: '2026-05-13T22:25:38.189Z'
+ created_at: '2026-05-17T22:57:40.165Z'
+ updated_at: '2026-05-17T22:57:40.165Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -2392,11 +2842,11 @@ paths:
application/json:
example:
id: exp_gbHJdmfrXB
- number: EF951740789
+ number: EF196782958
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-13T22:25:38.491Z'
- updated_at: '2026-05-13T22:25:38.491Z'
+ created_at: '2026-05-17T22:57:40.457Z'
+ updated_at: '2026-05-17T22:57:40.457Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -2483,11 +2933,11 @@ paths:
application/json:
example:
id: exp_UkLWZg9DAJ
- number: EF058142402
+ number: EF446204860
type: Spree::Exports::Products
format: csv
- created_at: '2026-05-13T22:25:38.762Z'
- updated_at: '2026-05-13T22:25:38.762Z'
+ created_at: '2026-05-17T22:57:40.725Z'
+ updated_at: '2026-05-17T22:57:40.725Z'
user_id: admin_UkLWZg9DAJ
done: false
filename:
@@ -2638,15 +3088,15 @@ paths:
example:
data:
- id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-05-13T22:25:39.647Z'
- updated_at: '2026-05-13T22:25:39.647Z'
- expires_at: '2026-05-27T22:25:39.645Z'
+ created_at: '2026-05-17T22:57:41.583Z'
+ updated_at: '2026-05-17T22:57:41.583Z'
+ expires_at: '2026-05-31T22:57:41.581Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=tvSCG2gnbNnNcFEmp6VrB2ra"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=Sm1UZP3PfJPPUdSmcVoXpAX2"
meta:
page: 1
limit: 25
@@ -2703,13 +3153,13 @@ paths:
id: inv_gbHJdmfrXB
status: pending
- created_at: '2026-05-13T22:25:39.969Z'
- updated_at: '2026-05-13T22:25:39.969Z'
- expires_at: '2026-05-27T22:25:39.966Z'
+ created_at: '2026-05-17T22:57:41.880Z'
+ updated_at: '2026-05-17T22:57:41.880Z'
+ expires_at: '2026-05-31T22:57:41.878Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=1cjKhNef9wouzpwYaErfmWJa"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_gbHJdmfrXB?token=TemhXQKMdCgFXmyPhhDS37sy"
requestBody:
content:
application/json:
@@ -2812,15 +3262,15 @@ paths:
application/json:
example:
id: inv_UkLWZg9DAJ
status: pending
- created_at: '2026-05-13T22:25:40.534Z'
- updated_at: '2026-05-13T22:25:40.534Z'
- expires_at: '2026-05-27T22:25:40.531Z'
+ created_at: '2026-05-17T22:57:42.445Z'
+ updated_at: '2026-05-17T22:57:42.445Z'
+ expires_at: '2026-05-31T22:57:42.442Z'
role_id: role_UkLWZg9DAJ
role_name: admin
- inviter_email: [email protected]
- acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=KZkB9C13WmMsWb2M4gK8diYf"
+ inviter_email: [email protected]
+ acceptance_url: "/accept-invitation/inv_UkLWZg9DAJ?token=e8J3mdcca4TSodmoxqdbCoFi"
"/api/v3/admin/me":
get:
summary: Get current admin user and permissions
@@ -2866,11 +3316,11 @@ paths:
example:
user:
id: admin_UkLWZg9DAJ
- first_name: Tamra
- last_name: Grimes
- created_at: '2026-05-13T22:25:40.813Z'
- updated_at: '2026-05-13T22:25:40.813Z'
+ first_name: Delma
+ last_name: Lind
+ created_at: '2026-05-17T22:57:42.721Z'
+ updated_at: '2026-05-17T22:57:42.721Z'
roles:
- id: role_UkLWZg9DAJ
name: admin
@@ -3002,7 +3452,7 @@ paths:
- name: fields
in: query
required: false
- description: Comma-separated list of fields to include (e.g., name,presentation,position).
+ description: Comma-separated list of fields to include (e.g., name,label,position).
id is always included.
schema:
type: string
@@ -3019,9 +3469,9 @@ paths:
position: 1
kind: dropdown
metadata: {}
- created_at: '2026-05-13T22:25:40.854Z'
- updated_at: '2026-05-13T22:25:40.854Z'
- option_values: []
+ filterable: true
+ created_at: '2026-05-17T22:57:42.762Z'
+ updated_at: '2026-05-17T22:57:42.762Z'
meta:
page: 1
limit: 25
@@ -3111,9 +3561,9 @@ paths:
position: 2
kind: dropdown
metadata: {}
- created_at: '2026-05-13T22:25:41.433Z'
- updated_at: '2026-05-13T22:25:41.433Z'
- option_values: []
+ filterable: true
+ created_at: '2026-05-17T22:57:43.336Z'
+ updated_at: '2026-05-17T22:57:43.336Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -3140,7 +3590,7 @@ paths:
name:
type: string
example: color
- presentation:
+ label:
type: string
example: Color
position:
@@ -3157,14 +3607,14 @@ paths:
name:
type: string
example: red
- presentation:
+ label:
type: string
example: Red
position:
type: integer
required:
- name
- - presentation
+ - label
"/api/v3/admin/option_types/{id}":
get:
summary: Get an option type
@@ -3217,7 +3667,7 @@ paths:
- name: fields
in: query
required: false
- description: Comma-separated list of fields to include (e.g., name,presentation,position).
+ description: Comma-separated list of fields to include (e.g., name,label,position).
id is always included.
schema:
type: string
@@ -3233,9 +3683,9 @@ paths:
position: 1
kind: dropdown
metadata: {}
- created_at: '2026-05-13T22:25:41.720Z'
- updated_at: '2026-05-13T22:25:41.720Z'
- option_values: []
+ filterable: true
+ created_at: '2026-05-17T22:57:43.621Z'
+ updated_at: '2026-05-17T22:57:43.621Z'
schema:
"$ref": "#/components/schemas/OptionType"
'404':
@@ -3302,13 +3752,13 @@ paths:
example:
id: opt_UkLWZg9DAJ
name: foo-size-7
- label: Updated Presentation
+ label: Updated Label
position: 1
kind: dropdown
metadata: {}
- created_at: '2026-05-13T22:25:42.280Z'
- updated_at: '2026-05-13T22:25:42.559Z'
- option_values: []
+ filterable: true
+ created_at: '2026-05-17T22:57:44.197Z'
+ updated_at: '2026-05-17T22:57:44.475Z'
schema:
"$ref": "#/components/schemas/OptionType"
'422':
@@ -3333,7 +3783,7 @@ paths:
name:
type: string
example: color
- presentation:
+ label:
type: string
example: Color
position:
@@ -3353,7 +3803,7 @@ paths:
name:
type: string
example: red
- presentation:
+ label:
type: string
example: Red
position:
@@ -3467,7 +3917,7 @@ paths:
example:
data:
- id: ful_UkLWZg9DAJ
- number: H36961336885
+ number: H93726194260
tracking: U10000
tracking_url:
cost: '10.0'
@@ -3492,8 +3942,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:43.516Z'
- updated_at: '2026-05-13T22:25:43.609Z'
+ created_at: '2026-05-17T22:57:45.414Z'
+ updated_at: '2026-05-17T22:57:45.527Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
meta:
@@ -3576,7 +4026,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H30100893776
+ number: H67359691291
tracking: U10000
tracking_url:
cost: '10.0'
@@ -3601,8 +4051,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:44.219Z'
- updated_at: '2026-05-13T22:25:44.274Z'
+ created_at: '2026-05-17T22:57:46.167Z'
+ updated_at: '2026-05-17T22:57:46.285Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
patch:
@@ -3661,7 +4111,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H59375451147
+ number: H82376403615
tracking: 1Z999AA10123456784
tracking_url: https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z999AA10123456784
cost: '10.0'
@@ -3686,8 +4136,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:44.890Z'
- updated_at: '2026-05-13T22:25:45.231Z'
+ created_at: '2026-05-17T22:57:46.881Z'
+ updated_at: '2026-05-17T22:57:47.225Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
requestBody:
@@ -3756,7 +4206,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H13065437110
+ number: H42791123467
tracking: U10000
tracking_url:
cost: '10.0'
@@ -3773,7 +4223,7 @@ paths:
display_tax_total: "$0.00"
status: shipped
fulfillment_type: shipping
- fulfilled_at: '2026-05-13T22:25:45Z'
+ fulfilled_at: '2026-05-17T22:57:47Z'
items:
- item_id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
@@ -3781,8 +4231,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:45.553Z'
- updated_at: '2026-05-13T22:25:45.941Z'
+ created_at: '2026-05-17T22:57:47.543Z'
+ updated_at: '2026-05-17T22:57:47.892Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/cancel":
@@ -3840,7 +4290,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H92893904606
+ number: H68028933136
tracking: U10000
tracking_url:
cost: '10.0'
@@ -3865,8 +4315,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:46.302Z'
- updated_at: '2026-05-13T22:25:46.646Z'
+ created_at: '2026-05-17T22:57:48.220Z'
+ updated_at: '2026-05-17T22:57:48.568Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/resume":
@@ -3924,7 +4374,7 @@ paths:
application/json:
example:
id: ful_UkLWZg9DAJ
- number: H41345482330
+ number: H18035538721
tracking: U10000
tracking_url:
cost: '10.0'
@@ -3949,8 +4399,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:46.970Z'
- updated_at: '2026-05-13T22:25:47.316Z'
+ created_at: '2026-05-17T22:57:48.894Z'
+ updated_at: '2026-05-17T22:57:49.260Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/fulfillments/{id}/split":
@@ -4011,7 +4461,7 @@ paths:
example:
data:
- id: ful_gbHJdmfrXB
- number: H83321079654
+ number: H42674651588
tracking:
tracking_url:
cost: '10.0'
@@ -4036,8 +4486,8 @@ paths:
metadata: {}
adjustment_total: '0.0'
pre_tax_amount: '0.0'
- created_at: '2026-05-13T22:25:48.004Z'
- updated_at: '2026-05-13T22:25:48.054Z'
+ created_at: '2026-05-17T22:57:49.949Z'
+ updated_at: '2026-05-17T22:57:49.997Z'
order_id: or_UkLWZg9DAJ
stock_location_id: sloc_gbHJdmfrXB
requestBody:
@@ -4109,7 +4559,7 @@ paths:
application/json:
example:
id: gc_UkLWZg9DAJ
- code: 6E02932F280AE2EB
+ code: 0262137AC51DF7BF
status: active
currency: USD
amount: '10.0'
@@ -4123,8 +4573,8 @@ paths:
redeemed_at:
expired: false
active: true
- created_at: '2026-05-13T22:25:48.418Z'
- updated_at: '2026-05-13T22:25:48.738Z'
+ created_at: '2026-05-17T22:57:50.337Z'
+ updated_at: '2026-05-17T22:57:50.632Z'
requestBody:
content:
application/json:
@@ -4255,8 +4705,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 105812
- slug: product-105812
+ name: Product 103053
+ slug: product-103053
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -4288,12 +4738,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:25:49.489Z'
- updated_at: '2026-05-13T22:25:49.489Z'
+ created_at: '2026-05-17T22:57:51.306Z'
+ updated_at: '2026-05-17T22:57:51.306Z'
digital_links: []
metadata: {}
- created_at: '2026-05-13T22:25:49.787Z'
- updated_at: '2026-05-13T22:25:49.787Z'
+ created_at: '2026-05-17T22:57:51.591Z'
+ updated_at: '2026-05-17T22:57:51.591Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
meta:
@@ -4360,8 +4810,8 @@ paths:
variant_id: variant_VqXmZF31wY
quantity: 3
currency: USD
- name: Product 123195
- slug: product-123195
+ name: Product 128467
+ slug: product-128467
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -4393,12 +4843,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:25:50.724Z'
- updated_at: '2026-05-13T22:25:50.724Z'
+ created_at: '2026-05-17T22:57:52.529Z'
+ updated_at: '2026-05-17T22:57:52.529Z'
digital_links: []
metadata: {}
- created_at: '2026-05-13T22:25:50.755Z'
- updated_at: '2026-05-13T22:25:50.755Z'
+ created_at: '2026-05-17T22:57:52.559Z'
+ updated_at: '2026-05-17T22:57:52.559Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -4487,8 +4937,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 132252
- slug: product-132252
+ name: Product 135720
+ slug: product-135720
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -4520,12 +4970,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:25:50.831Z'
- updated_at: '2026-05-13T22:25:50.831Z'
+ created_at: '2026-05-17T22:57:52.633Z'
+ updated_at: '2026-05-17T22:57:52.633Z'
digital_links: []
metadata: {}
- created_at: '2026-05-13T22:25:51.119Z'
- updated_at: '2026-05-13T22:25:51.119Z'
+ created_at: '2026-05-17T22:57:52.918Z'
+ updated_at: '2026-05-17T22:57:52.918Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
patch:
@@ -4587,8 +5037,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 5
currency: USD
- name: Product 14381
- slug: product-14381
+ name: Product 14367
+ slug: product-14367
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -4620,12 +5070,12 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:25:51.463Z'
- updated_at: '2026-05-13T22:25:51.463Z'
+ created_at: '2026-05-17T22:57:53.243Z'
+ updated_at: '2026-05-17T22:57:53.243Z'
digital_links: []
metadata: {}
- created_at: '2026-05-13T22:25:51.756Z'
- updated_at: '2026-05-13T22:25:52.060Z'
+ created_at: '2026-05-17T22:57:53.531Z'
+ updated_at: '2026-05-17T22:57:53.828Z'
cost_price: '17.0'
tax_category_id: taxcat_UkLWZg9DAJ
requestBody:
@@ -4751,8 +5201,8 @@ paths:
data:
- id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-f397730d6772
- number: P0G10JOE
+ response_code: BGS-0cb507c6b6fd
+ number: PSQU5GQO
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -4770,14 +5220,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-13T22:25:53.136Z'
- updated_at: '2026-05-13T22:25:53.140Z'
+ created_at: '2026-05-17T22:57:54.817Z'
+ updated_at: '2026-05-17T22:57:54.821Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-13T22:25:53.139Z'
- updated_at: '2026-05-13T22:25:53.139Z'
+ created_at: '2026-05-17T22:57:54.820Z'
+ updated_at: '2026-05-17T22:57:54.820Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
meta:
@@ -4844,7 +5294,7 @@ paths:
id: py_gbHJdmfrXB
payment_method_id: pm_EfhxLZ9ck8
response_code:
- number: PUPSU7H2
+ number: PD00W24T
amount: '110.0'
display_amount: "$110.00"
status: checkout
@@ -4855,8 +5305,8 @@ paths:
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-13T22:25:54.446Z'
- updated_at: '2026-05-13T22:25:54.446Z'
+ created_at: '2026-05-17T22:57:56.148Z'
+ updated_at: '2026-05-17T22:57:56.148Z'
captured_amount: '0.0'
order_id: or_gbHJdmfrXB
requestBody:
@@ -4946,8 +5396,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-dbd60f9a66a6
- number: PSIJS96B
+ response_code: BGS-111160a6f3ed
+ number: PEQOW0S0
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -4965,14 +5415,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-13T22:25:54.817Z'
- updated_at: '2026-05-13T22:25:54.820Z'
+ created_at: '2026-05-17T22:57:56.525Z'
+ updated_at: '2026-05-17T22:57:56.527Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-13T22:25:54.818Z'
- updated_at: '2026-05-13T22:25:54.818Z'
+ created_at: '2026-05-17T22:57:56.526Z'
+ updated_at: '2026-05-17T22:57:56.526Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/payments/{id}/capture":
@@ -5031,8 +5481,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: BGS-f6514a220cff
- number: PQO0FMRZ
+ response_code: BGS-f5c608409d35
+ number: P2IQ5WXV
amount: '110.0'
display_amount: "$110.00"
status: completed
@@ -5050,14 +5500,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-13T22:25:55.479Z'
- updated_at: '2026-05-13T22:25:55.481Z'
+ created_at: '2026-05-17T22:57:57.172Z'
+ updated_at: '2026-05-17T22:57:57.175Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-13T22:25:55.480Z'
- updated_at: '2026-05-13T22:25:55.814Z'
+ created_at: '2026-05-17T22:57:57.174Z'
+ updated_at: '2026-05-17T22:57:57.517Z'
captured_amount: '110.0'
order_id: or_UkLWZg9DAJ
'422':
@@ -5126,8 +5576,8 @@ paths:
example:
id: py_UkLWZg9DAJ
payment_method_id: pm_UkLWZg9DAJ
- response_code: void-BGS-8fa8865275b4
- number: PLF9K7CF
+ response_code: void-BGS-a7822422048d
+ number: PHHVVBKB
amount: '110.0'
display_amount: "$110.00"
status: void
@@ -5145,14 +5595,14 @@ paths:
customer_id:
payment_method_id: pm_gbHJdmfrXB
metadata: {}
- created_at: '2026-05-13T22:25:56.917Z'
- updated_at: '2026-05-13T22:25:56.920Z'
+ created_at: '2026-05-17T22:57:58.605Z'
+ updated_at: '2026-05-17T22:57:58.608Z'
metadata: {}
avs_response:
cvv_response_code:
cvv_response_message:
- created_at: '2026-05-13T22:25:56.919Z'
- updated_at: '2026-05-13T22:25:57.222Z'
+ created_at: '2026-05-17T22:57:58.607Z'
+ updated_at: '2026-05-17T22:57:58.909Z'
captured_amount: '0.0'
order_id: or_UkLWZg9DAJ
"/api/v3/admin/orders/{order_id}/refunds":
@@ -5280,14 +5730,14 @@ paths:
application/json:
example:
id: re_UkLWZg9DAJ
- transaction_id: BGS-1b37d8a2a5c7
+ transaction_id: BGS-1e98d2337e15
amount: '5.0'
payment_id: py_UkLWZg9DAJ
refund_reason_id: rr_UkLWZg9DAJ
reimbursement_id:
metadata: {}
- created_at: '2026-05-13T22:25:58.597Z'
- updated_at: '2026-05-13T22:25:58.597Z'
+ created_at: '2026-05-17T22:58:00.262Z'
+ updated_at: '2026-05-17T22:58:00.262Z'
requestBody:
content:
application/json:
@@ -5359,8 +5809,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R298727549
+ number: R421111487
customer_note:
currency: USD
locale: en
@@ -5403,8 +5853,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:25:58.903Z'
- updated_at: '2026-05-13T22:25:58.956Z'
+ created_at: '2026-05-17T22:58:00.562Z'
+ updated_at: '2026-05-17T22:58:00.616Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -5575,8 +6025,8 @@ paths:
- id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R567031474
+ number: R960433554
customer_note:
currency: USD
locale: en
@@ -5619,8 +6069,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:00.724Z'
- updated_at: '2026-05-13T22:26:00.724Z'
+ created_at: '2026-05-17T22:58:02.356Z'
+ updated_at: '2026-05-17T22:58:02.356Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -5763,7 +6213,7 @@ paths:
id: or_gbHJdmfrXB
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R887063941
+ number: R338726767
customer_note:
currency: USD
@@ -5807,8 +6257,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:02.409Z'
- updated_at: '2026-05-13T22:26:02.412Z'
+ created_at: '2026-05-17T22:58:04.037Z'
+ updated_at: '2026-05-17T22:58:04.041Z'
preferred_stock_location_id: sloc_UkLWZg9DAJ
tags: []
internal_note:
@@ -5992,8 +6442,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R959765042
+ number: R077708501
customer_note:
currency: USD
locale: en
@@ -6036,8 +6486,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:02.688Z'
- updated_at: '2026-05-13T22:26:02.688Z'
+ created_at: '2026-05-17T22:58:04.316Z'
+ updated_at: '2026-05-17T22:58:04.316Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6108,7 +6558,7 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R918190740
+ number: R719018821
customer_note:
currency: USD
@@ -6152,8 +6602,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:03.801Z'
- updated_at: '2026-05-13T22:26:04.089Z'
+ created_at: '2026-05-17T22:58:05.432Z'
+ updated_at: '2026-05-17T22:58:05.724Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6334,8 +6784,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R883089560
+ number: R016462732
customer_note:
currency: USD
locale: en
@@ -6362,7 +6812,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status: ready
payment_status: paid
- completed_at: '2026-05-13T22:26:05.019Z'
+ completed_at: '2026-05-17T22:58:06.625Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -6378,8 +6828,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:04.957Z'
- updated_at: '2026-05-13T22:26:05.047Z'
+ created_at: '2026-05-17T22:58:06.570Z'
+ updated_at: '2026-05-17T22:58:06.651Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6460,8 +6910,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R025706527
+ number: R062143227
customer_note:
currency: USD
locale: en
@@ -6488,7 +6938,7 @@ paths:
display_delivery_total: "$10.00"
fulfillment_status: canceled
payment_status: void
- completed_at: '2026-05-13T22:26:06.299Z'
+ completed_at: '2026-05-17T22:58:07.890Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -6502,10 +6952,10 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-05-13T22:26:06.607Z'
+ canceled_at: '2026-05-17T22:58:08.177Z'
approved_at:
- created_at: '2026-05-13T22:26:06.244Z'
- updated_at: '2026-05-13T22:26:06.656Z'
+ created_at: '2026-05-17T22:58:07.834Z'
+ updated_at: '2026-05-17T22:58:08.218Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6564,8 +7014,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R259197379
+ number: R328362970
customer_note:
currency: USD
locale: en
@@ -6592,7 +7042,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status:
payment_status:
- completed_at: '2026-05-13T22:26:07.015Z'
+ completed_at: '2026-05-17T22:58:08.595Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -6607,9 +7057,9 @@ paths:
display_payment_total: "$0.00"
metadata: {}
canceled_at:
- approved_at: '2026-05-13T22:26:07.310Z'
- created_at: '2026-05-13T22:26:06.956Z'
- updated_at: '2026-05-13T22:26:07.015Z'
+ approved_at: '2026-05-17T22:58:08.896Z'
+ created_at: '2026-05-17T22:58:08.517Z'
+ updated_at: '2026-05-17T22:58:08.595Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6668,8 +7118,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R227402664
+ number: R862448919
customer_note:
currency: USD
locale: en
@@ -6696,7 +7146,7 @@ paths:
display_delivery_total: "$10.00"
fulfillment_status: canceled
payment_status: void
- completed_at: '2026-05-13T22:26:07.654Z'
+ completed_at: '2026-05-17T22:58:09.237Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -6710,10 +7160,10 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
metadata: {}
- canceled_at: '2026-05-13T22:26:07.935Z'
+ canceled_at: '2026-05-17T22:58:09.515Z'
approved_at:
- created_at: '2026-05-13T22:26:07.597Z'
- updated_at: '2026-05-13T22:26:08.032Z'
+ created_at: '2026-05-17T22:58:09.182Z'
+ updated_at: '2026-05-17T22:58:09.601Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6772,8 +7222,8 @@ paths:
id: or_UkLWZg9DAJ
market_id:
channel_id: ch_UkLWZg9DAJ
- number: R123649899
+ number: R636920706
customer_note:
currency: USD
locale: en
@@ -6800,7 +7250,7 @@ paths:
display_delivery_total: "$100.00"
fulfillment_status:
payment_status:
- completed_at: '2026-05-13T22:26:08.377Z'
+ completed_at: '2026-05-17T22:58:09.934Z'
store_credit_total: '0.0'
display_store_credit_total: "$0.00"
covered_by_store_credit: false
@@ -6816,8 +7266,8 @@ paths:
metadata: {}
canceled_at:
approved_at:
- created_at: '2026-05-13T22:26:08.319Z'
- updated_at: '2026-05-13T22:26:08.377Z'
+ created_at: '2026-05-17T22:58:09.880Z'
+ updated_at: '2026-05-17T22:58:09.934Z'
preferred_stock_location_id:
tags: []
internal_note:
@@ -6890,10 +7340,10 @@ paths:
metadata: {}
active: true
auto_capture:
- display_on: both
+ storefront_visible: true
position: 1
- created_at: '2026-05-13T22:26:08.689Z'
- updated_at: '2026-05-13T22:26:08.690Z'
+ created_at: '2026-05-17T22:58:10.232Z'
+ updated_at: '2026-05-17T22:58:10.233Z'
preferences: {}
preference_schema: []
meta:
@@ -6952,12 +7402,12 @@ paths:
label: Bogus
description:
preference_schema:
- - key: dummy_secret_key
- type: password
- default: SECRETKEY123
- key: dummy_key
type: string
default: PUBLICKEY123
+ - key: dummy_secret_key
+ type: password
+ default:
- type: custom_payment_source_method
label: Custom Payment Source Method
description:
@@ -7031,10 +7481,10 @@ paths:
metadata: {}
active: true
auto_capture:
- display_on: both
+ storefront_visible: true
position: 1
- created_at: '2026-05-13T22:26:09.275Z'
- updated_at: '2026-05-13T22:26:09.276Z'
+ created_at: '2026-05-17T22:58:10.803Z'
+ updated_at: '2026-05-17T22:58:10.805Z'
preferences: {}
preference_schema: []
"/api/v3/admin/products/{product_id}/custom_fields":
@@ -7104,8 +7554,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-05-13T22:26:09.595Z'
- updated_at: '2026-05-13T22:26:09.595Z'
+ created_at: '2026-05-17T22:58:11.118Z'
+ updated_at: '2026-05-17T22:58:11.118Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
meta:
@@ -7172,8 +7622,8 @@ paths:
field_type: long_text
key: custom.description
value: A longer description
- created_at: '2026-05-13T22:26:10.222Z'
- updated_at: '2026-05-13T22:26:10.222Z'
+ created_at: '2026-05-17T22:58:11.733Z'
+ updated_at: '2026-05-17T22:58:11.733Z'
storefront_visible: true
custom_field_definition_id: cfdef_gbHJdmfrXB
'422':
@@ -7257,8 +7707,8 @@ paths:
field_type: short_text
key: custom.title
value: wool
- created_at: '2026-05-13T22:26:10.593Z'
- updated_at: '2026-05-13T22:26:10.593Z'
+ created_at: '2026-05-17T22:58:12.085Z'
+ updated_at: '2026-05-17T22:58:12.085Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
patch:
@@ -7305,8 +7755,8 @@ paths:
field_type: short_text
key: custom.title
value: cotton
- created_at: '2026-05-13T22:26:10.912Z'
- updated_at: '2026-05-13T22:26:11.193Z'
+ created_at: '2026-05-17T22:58:12.401Z'
+ updated_at: '2026-05-17T22:58:12.680Z'
storefront_visible: true
custom_field_definition_id: cfdef_UkLWZg9DAJ
requestBody:
@@ -7444,36 +7894,33 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 39261
- slug: product-39261
+ name: Product 398974
+ slug: product-398974
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-13T22:26:11.525Z'
+ available_on: '2025-05-17T22:58:13.003Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Officia architecto quod fugiat saepe nam sint quo.
- Aut est provident exercitationem deleniti placeat officia. Odit
- necessitatibus culpa ipsa perspiciatis mollitia. Asperiores dolore
- consectetur veritatis quos eum sunt vel aspernatur. Illo vitae
- quaerat unde voluptatibus qui maxime soluta quasi. Nesciunt doloribus
- eveniet in temporibus accusantium. Eos dicta debitis repudiandae
- odio repellat laudantium. Delectus aliquam minus voluptatem rem
- vero nobis. Eligendi est voluptates odio nesciunt eaque alias.
- Adipisci doloribus delectus optio ipsum error sit. Iste cum quisquam
- sunt fugit consequatur architecto dolorem nihil. Commodi reiciendis
- earum esse omnis tenetur. In ullam maxime vero praesentium ipsum
- dolore at. Illo non voluptatem nobis ut id totam placeat. Repellendus
- numquam natus velit exercitationem mollitia possimus reprehenderit
- cumque. Vitae nihil dicta aut magni iste.
+ description: Officiis magnam distinctio voluptatibus dolores provident.
+ Quae neque corrupti natus id voluptatem occaecati. Eos commodi
+ deserunt quas voluptatibus occaecati ut minus impedit. Molestias
+ tempora quaerat fuga animi occaecati autem voluptatem. Ad error
+ reiciendis odit architecto asperiores quaerat laborum a. Quisquam
+ voluptas cupiditate saepe corporis. Rerum quibusdam odio recusandae
+ minima. Rerum reprehenderit magnam qui exercitationem. Debitis
+ ex optio rem facere officia maiores. Assumenda amet deserunt omnis
+ reiciendis repellendus. Facere cupiditate tempore vel itaque minus.
+ Possimus quisquam error atque recusandae vel. Pariatur repudiandae
+ nam consequuntur fuga voluptates blanditiis dolores beatae. Temporibus
+ vitae nam odio velit voluptatibus.
description_html: |-
- Officia architecto quod fugiat saepe nam sint quo. Aut est provident exercitationem deleniti placeat officia. Odit necessitatibus culpa ipsa perspiciatis mollitia. Asperiores dolore consectetur veritatis quos eum sunt vel aspernatur. Illo vitae quaerat unde voluptatibus qui maxime soluta quasi.
- Nesciunt doloribus eveniet in temporibus accusantium. Eos dicta debitis repudiandae odio repellat laudantium. Delectus aliquam minus voluptatem rem vero nobis.
- Eligendi est voluptates odio nesciunt eaque alias. Adipisci doloribus delectus optio ipsum error sit. Iste cum quisquam sunt fugit consequatur architecto dolorem nihil.
- Commodi reiciendis earum esse omnis tenetur. In ullam maxime vero praesentium ipsum dolore at. Illo non voluptatem nobis ut id totam placeat. Repellendus numquam natus velit exercitationem mollitia possimus reprehenderit cumque. Vitae nihil dicta aut magni iste.
+ Officiis magnam distinctio voluptatibus dolores provident. Quae neque corrupti natus id voluptatem occaecati. Eos commodi deserunt quas voluptatibus occaecati ut minus impedit. Molestias tempora quaerat fuga animi occaecati autem voluptatem.
+ Ad error reiciendis odit architecto asperiores quaerat laborum a. Quisquam voluptas cupiditate saepe corporis. Rerum quibusdam odio recusandae minima. Rerum reprehenderit magnam qui exercitationem. Debitis ex optio rem facere officia maiores.
+ Assumenda amet deserunt omnis reiciendis repellendus. Facere cupiditate tempore vel itaque minus. Possimus quisquam error atque recusandae vel. Pariatur repudiandae nam consequuntur fuga voluptates blanditiis dolores beatae. Temporibus vitae nam odio velit voluptatibus.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -7488,16 +7935,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:11.550Z'
- updated_at: '2026-05-13T22:26:11.550Z'
+ created_at: '2026-05-17T22:58:13.027Z'
+ updated_at: '2026-05-17T22:58:13.027Z'
original_price:
status: active
- make_active_at: '2025-05-13T22:26:11.525Z'
+ make_active_at: '2025-05-17T22:58:13.003Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-13T22:26:11.537Z'
- updated_at: '2026-05-13T22:26:11.551Z'
+ created_at: '2026-05-17T22:58:13.014Z'
+ updated_at: '2026-05-17T22:58:13.028Z'
tax_category_id: taxcat_UkLWZg9DAJ
meta:
page: 1
@@ -7631,8 +8078,8 @@ paths:
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-13T22:26:12.242Z'
- updated_at: '2026-05-13T22:26:12.245Z'
+ created_at: '2026-05-17T22:58:13.688Z'
+ updated_at: '2026-05-17T22:58:13.691Z'
tax_category_id:
schema:
"$ref": "#/components/schemas/Product"
@@ -7812,26 +8259,25 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 434707
- slug: product-434707
+ name: Product 438556
+ slug: product-438556
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-13T22:26:12.599Z'
+ available_on: '2025-05-17T22:58:14.064Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Sapiente enim praesentium facere minima laboriosam repellat
- similique omnis. Unde nostrum temporibus dolores ducimus laborum.
- Magnam ipsa esse vel aliquam nesciunt tempore. Eveniet facilis consectetur
- perferendis asperiores. Corporis consectetur voluptates occaecati
- aliquid quos. Atque ratione voluptatibus repellendus ea provident
- expedita exercitationem.
- description_html: |-
- Sapiente enim praesentium facere minima laboriosam repellat similique omnis. Unde nostrum temporibus dolores ducimus laborum. Magnam ipsa esse vel aliquam nesciunt tempore.
- Eveniet facilis consectetur perferendis asperiores. Corporis consectetur voluptates occaecati aliquid quos. Atque ratione voluptatibus repellendus ea provident expedita exercitationem.
+ description: Voluptatem magni libero quam officia earum esse inventore
+ assumenda. Dolores impedit aliquam eum voluptatem. Ducimus ullam
+ consequuntur nam perspiciatis deleniti aut. Vero necessitatibus
+ magnam et fugiat perspiciatis. Sunt eos repellendus odit incidunt.
+ description_html: Voluptatem magni libero quam officia earum esse
+ inventore assumenda. Dolores impedit aliquam eum voluptatem. Ducimus
+ ullam consequuntur nam perspiciatis deleniti aut. Vero necessitatibus
+ magnam et fugiat perspiciatis. Sunt eos repellendus odit incidunt.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -7846,16 +8292,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:12.624Z'
- updated_at: '2026-05-13T22:26:12.624Z'
+ created_at: '2026-05-17T22:58:14.092Z'
+ updated_at: '2026-05-17T22:58:14.092Z'
original_price:
status: active
- make_active_at: '2025-05-13T22:26:12.600Z'
+ make_active_at: '2025-05-17T22:58:14.064Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-13T22:26:12.611Z'
- updated_at: '2026-05-13T22:26:12.625Z'
+ created_at: '2026-05-17T22:58:14.078Z'
+ updated_at: '2026-05-17T22:58:14.093Z'
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -7922,29 +8368,29 @@ paths:
example:
id: prod_UkLWZg9DAJ
name: Updated Name
- slug: product-451333
+ slug: product-452799
meta_title:
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-05-13T22:26:13.263Z'
+ available_on: '2025-05-17T22:58:14.706Z'
purchasable: true
in_stock: false
backorderable: true
available: true
- description: Facilis ut aliquid voluptates possimus optio. Neque voluptatem
- minus consequatur at tenetur amet. Dolorum minus necessitatibus
- quisquam laboriosam dignissimos omnis aspernatur accusamus. Modi
- adipisci libero laudantium ea animi. Dicta ipsam aliquid doloribus
- nam optio. Reprehenderit cumque aliquid totam consequatur labore.
- Commodi molestias laboriosam sunt sed. Porro illum exercitationem
- ad accusantium deserunt possimus. Omnis temporibus ipsam similique
- dignissimos mollitia. Adipisci earum rem quis voluptatem hic reprehenderit
- id. Fuga mollitia at quod in laboriosam aliquid quis.
+ description: Facilis error earum consequuntur in. Ut sint dolor exercitationem
+ cupiditate tenetur cum. Eos earum accusantium repellendus fugiat
+ eum non. Explicabo molestiae eligendi eaque aperiam. Quaerat enim
+ unde impedit expedita iure omnis vel. Ut dicta autem omnis quas
+ ipsam unde. Delectus quo ad nihil dignissimos. Dicta tenetur eius
+ provident veritatis ut error quia ullam. Labore neque atque ipsam
+ qui voluptatum eligendi. Id laborum magni est deserunt natus consequuntur.
+ Quibusdam ab modi officia tempore facilis omnis. Et nemo consequatur
+ dolorum labore.
description_html: |-
- Facilis ut aliquid voluptates possimus optio. Neque voluptatem minus consequatur at tenetur amet. Dolorum minus necessitatibus quisquam laboriosam dignissimos omnis aspernatur accusamus.
- Modi adipisci libero laudantium ea animi. Dicta ipsam aliquid doloribus nam optio. Reprehenderit cumque aliquid totam consequatur labore.
- Commodi molestias laboriosam sunt sed. Porro illum exercitationem ad accusantium deserunt possimus. Omnis temporibus ipsam similique dignissimos mollitia. Adipisci earum rem quis voluptatem hic reprehenderit id. Fuga mollitia at quod in laboriosam aliquid quis.
+ Facilis error earum consequuntur in. Ut sint dolor exercitationem cupiditate tenetur cum. Eos earum accusantium repellendus fugiat eum non. Explicabo molestiae eligendi eaque aperiam.
+ Quaerat enim unde impedit expedita iure omnis vel. Ut dicta autem omnis quas ipsam unde. Delectus quo ad nihil dignissimos. Dicta tenetur eius provident veritatis ut error quia ullam. Labore neque atque ipsam qui voluptatum eligendi.
+ Id laborum magni est deserunt natus consequuntur. Quibusdam ab modi officia tempore facilis omnis. Et nemo consequatur dolorum labore.
default_variant_id: variant_UkLWZg9DAJ
thumbnail_url:
tags: []
@@ -7959,16 +8405,16 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:13.291Z'
- updated_at: '2026-05-13T22:26:13.291Z'
+ created_at: '2026-05-17T22:58:14.732Z'
+ updated_at: '2026-05-17T22:58:14.732Z'
original_price:
status: active
- make_active_at: '2025-05-13T22:26:13.263Z'
+ make_active_at: '2025-05-17T22:58:14.706Z'
discontinue_on:
metadata: {}
deleted_at:
- created_at: '2026-05-13T22:26:13.277Z'
- updated_at: '2026-05-13T22:26:13.581Z'
+ created_at: '2026-05-17T22:58:14.720Z'
+ updated_at: '2026-05-17T22:58:15.016Z'
tax_category_id: taxcat_UkLWZg9DAJ
schema:
"$ref": "#/components/schemas/Product"
@@ -8171,8 +8617,8 @@ paths:
example:
data:
- id: pact_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:14.435Z'
- updated_at: '2026-05-13T22:26:14.435Z'
+ created_at: '2026-05-17T22:58:15.703Z'
+ updated_at: '2026-05-17T22:58:15.703Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -8233,8 +8679,8 @@ paths:
application/json:
example:
id: pact_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:15.021Z'
- updated_at: '2026-05-13T22:26:15.021Z'
+ created_at: '2026-05-17T22:58:16.273Z'
+ updated_at: '2026-05-17T22:58:16.273Z'
type: free_shipping
promotion_id: promo_UkLWZg9DAJ
preferences: {}
@@ -8344,8 +8790,8 @@ paths:
example:
data:
- id: prorule_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:15.612Z'
- updated_at: '2026-05-13T22:26:15.612Z'
+ created_at: '2026-05-17T22:58:16.871Z'
+ updated_at: '2026-05-17T22:58:16.871Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -8412,8 +8858,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:16.188Z'
- updated_at: '2026-05-13T22:26:16.188Z'
+ created_at: '2026-05-17T22:58:17.455Z'
+ updated_at: '2026-05-17T22:58:17.455Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -8486,8 +8932,8 @@ paths:
application/json:
example:
id: prorule_UkLWZg9DAJ
- created_at: '2026-05-13T22:26:16.482Z'
- updated_at: '2026-05-13T22:26:16.761Z'
+ created_at: '2026-05-17T22:58:17.744Z'
+ updated_at: '2026-05-17T22:58:18.021Z'
type: currency
promotion_id: promo_UkLWZg9DAJ
preferences:
@@ -8577,7 +9023,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-13T22:26:17.057Z'
+ starts_at: '2026-05-17T22:58:18.315Z'
expires_at:
usage_limit:
match_policy: all
@@ -8588,8 +9034,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-13T22:26:17.059Z'
- updated_at: '2026-05-13T22:26:17.060Z'
+ created_at: '2026-05-17T22:58:18.316Z'
+ updated_at: '2026-05-17T22:58:18.317Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -8695,7 +9141,7 @@ paths:
name: Black Friday
description:
code: blackfriday-os
- starts_at: '2026-05-13T22:26:18.001Z'
+ starts_at: '2026-05-17T22:58:19.244Z'
expires_at:
usage_limit:
match_policy: all
@@ -8706,8 +9152,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-13T22:26:18.002Z'
- updated_at: '2026-05-13T22:26:18.024Z'
+ created_at: '2026-05-17T22:58:19.245Z'
+ updated_at: '2026-05-17T22:58:19.266Z'
store_ids:
- store_UkLWZg9DAJ
action_ids:
@@ -8860,7 +9306,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-13T22:26:18.322Z'
+ starts_at: '2026-05-17T22:58:19.562Z'
expires_at:
usage_limit:
match_policy: all
@@ -8871,8 +9317,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-13T22:26:18.323Z'
- updated_at: '2026-05-13T22:26:18.324Z'
+ created_at: '2026-05-17T22:58:19.563Z'
+ updated_at: '2026-05-17T22:58:19.564Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -8968,7 +9414,7 @@ paths:
name: Summer Sale
description:
code: summer
- starts_at: '2026-05-13T22:26:19.230Z'
+ starts_at: '2026-05-17T22:58:20.443Z'
expires_at:
usage_limit:
match_policy: all
@@ -8979,8 +9425,8 @@ paths:
code_prefix:
promotion_category_id:
metadata: {}
- created_at: '2026-05-13T22:26:19.231Z'
- updated_at: '2026-05-13T22:26:19.595Z'
+ created_at: '2026-05-17T22:58:20.443Z'
+ updated_at: '2026-05-17T22:58:20.736Z'
store_ids:
- store_UkLWZg9DAJ
action_ids: []
@@ -9216,15 +9662,15 @@ paths:
label: Country
description:
preference_schema:
- - key: country_iso
- type: string
- default:
- key: country_isos
type: array
default: []
- key: country_id
type: integer
default:
+ - key: country_iso
+ type: string
+ default:
- type: currency
label: Currency
description:
@@ -9251,9 +9697,6 @@ paths:
label: Item total
description:
preference_schema:
- - key: operator_max
- type: string
- default: "<"
- key: amount_min
type: decimal
default: 100.0
@@ -9263,6 +9706,9 @@ paths:
- key: amount_max
type: decimal
default:
+ - key: operator_max
+ type: string
+ default: "<"
- type: one_use_per_user
label: One Use Per User
description:
@@ -9332,8 +9778,8 @@ paths:
data:
- id: role_UkLWZg9DAJ
name: admin
- created_at: '2026-05-13T22:26:20.479Z'
- updated_at: '2026-05-13T22:26:20.479Z'
+ created_at: '2026-05-17T22:58:21.622Z'
+ updated_at: '2026-05-17T22:58:21.622Z'
meta:
page: 1
limit: 25
@@ -9468,8 +9914,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-05-13T22:26:20.773Z'
- updated_at: '2026-05-13T22:26:20.773Z'
+ created_at: '2026-05-17T22:58:21.908Z'
+ updated_at: '2026-05-17T22:58:21.908Z'
meta:
page: 1
limit: 25
@@ -9580,8 +10026,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 30
pickup_instructions:
- created_at: '2026-05-13T22:26:21.360Z'
- updated_at: '2026-05-13T22:26:21.360Z'
+ created_at: '2026-05-17T22:58:22.489Z'
+ updated_at: '2026-05-17T22:58:22.489Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -9755,8 +10201,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes:
pickup_instructions:
- created_at: '2026-05-13T22:26:21.653Z'
- updated_at: '2026-05-13T22:26:21.653Z'
+ created_at: '2026-05-17T22:58:22.779Z'
+ updated_at: '2026-05-17T22:58:22.779Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'404':
@@ -9841,8 +10287,8 @@ paths:
pickup_stock_policy: local
pickup_ready_in_minutes: 45
pickup_instructions:
- created_at: '2026-05-13T22:26:22.223Z'
- updated_at: '2026-05-13T22:26:22.502Z'
+ created_at: '2026-05-17T22:58:23.346Z'
+ updated_at: '2026-05-17T22:58:23.623Z'
schema:
"$ref": "#/components/schemas/StockLocation"
'422':
@@ -10045,8 +10491,8 @@ paths:
data:
- id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-05-13T22:26:23.085Z'
- updated_at: '2026-05-13T22:26:23.085Z'
+ created_at: '2026-05-17T22:58:24.197Z'
+ updated_at: '2026-05-17T22:58:24.197Z'
non_expiring: false
meta:
page: 1
@@ -10137,8 +10583,8 @@ paths:
example:
id: sccat_UkLWZg9DAJ
name: Goodwill
- created_at: '2026-05-13T22:26:23.384Z'
- updated_at: '2026-05-13T22:26:23.384Z'
+ created_at: '2026-05-17T22:58:24.493Z'
+ updated_at: '2026-05-17T22:58:24.493Z'
non_expiring: false
schema:
"$ref": "#/components/schemas/StoreCreditCategory"
@@ -10203,8 +10649,8 @@ paths:
preferred_timezone: UTC
preferred_weight_unit: lb
preferred_unit_system: imperial
- created_at: '2026-05-13T22:25:22.039Z'
- updated_at: '2026-05-13T22:26:23.969Z'
+ created_at: '2026-05-17T22:57:20.918Z'
+ updated_at: '2026-05-17T22:58:25.097Z'
url: http://www.example.com:3000
supported_currencies:
- USD
@@ -10275,8 +10721,8 @@ paths:
preferred_timezone: UTC
preferred_weight_unit: lb
preferred_unit_system: imperial
- created_at: '2026-05-13T22:25:22.039Z'
- updated_at: '2026-05-13T22:26:24.576Z'
+ created_at: '2026-05-17T22:57:20.918Z'
+ updated_at: '2026-05-17T22:58:25.709Z'
url: http://www.example.com:3000
supported_currencies:
- USD
@@ -10496,13 +10942,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-13T22:26:26.013Z'
- updated_at: '2026-05-13T22:26:26.027Z'
+ created_at: '2026-05-17T22:58:27.121Z'
+ updated_at: '2026-05-17T22:58:27.134Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 505125
+ product_name: Product 509759
- id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
sku: SKU-57
@@ -10513,10 +10959,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 198.37
- height: 116.6
- width: 27.2
- depth: 112.62
+ weight: 80.73
+ height: 2.44
+ width: 113.51
+ depth: 190.29
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -10539,8 +10985,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:26:26.038Z'
- updated_at: '2026-05-13T22:26:26.038Z'
+ created_at: '2026-05-17T22:58:27.144Z'
+ updated_at: '2026-05-17T22:58:27.144Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -10549,13 +10995,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-13T22:26:26.035Z'
- updated_at: '2026-05-13T22:26:26.050Z'
+ created_at: '2026-05-17T22:58:27.141Z'
+ updated_at: '2026-05-17T22:58:27.155Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 505125
+ product_name: Product 509759
meta:
page: 1
limit: 25
@@ -10666,8 +11112,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:26:26.714Z'
- updated_at: '2026-05-13T22:26:26.714Z'
+ created_at: '2026-05-17T22:58:27.805Z'
+ updated_at: '2026-05-17T22:58:27.805Z'
metadata: {}
position: 3
cost_price:
@@ -10676,13 +11122,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-13T22:26:26.719Z'
- updated_at: '2026-05-13T22:26:26.720Z'
+ created_at: '2026-05-17T22:58:27.808Z'
+ updated_at: '2026-05-17T22:58:27.810Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 513260
+ product_name: Product 512942
'422':
description: validation error
content:
@@ -10869,10 +11315,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 189.87
- height: 112.17
- width: 34.12
- depth: 130.29
+ weight: 110.63
+ height: 3.38
+ width: 79.16
+ depth: 28.31
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -10895,8 +11341,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:26:27.126Z'
- updated_at: '2026-05-13T22:26:27.126Z'
+ created_at: '2026-05-17T22:58:28.233Z'
+ updated_at: '2026-05-17T22:58:28.233Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -10905,13 +11351,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-13T22:26:27.124Z'
- updated_at: '2026-05-13T22:26:27.138Z'
+ created_at: '2026-05-17T22:58:28.231Z'
+ updated_at: '2026-05-17T22:58:28.246Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 536897
+ product_name: Product 535621
'404':
description: variant not found
content:
@@ -10990,10 +11436,10 @@ paths:
purchasable: true
in_stock: false
backorderable: true
- weight: 91.32
- height: 135.81
- width: 9.48
- depth: 143.5
+ weight: 24.88
+ height: 167.5
+ width: 121.98
+ depth: 156.64
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -11016,8 +11462,8 @@ paths:
option_type_label: Size
image_url:
metadata: {}
- created_at: '2026-05-13T22:26:27.823Z'
- updated_at: '2026-05-13T22:26:27.823Z'
+ created_at: '2026-05-17T22:58:28.920Z'
+ updated_at: '2026-05-17T22:58:28.920Z'
metadata: {}
position: 2
cost_price: '17.0'
@@ -11026,13 +11472,13 @@ paths:
weight_unit: lb
dimensions_unit:
deleted_at:
- created_at: '2026-05-13T22:26:27.821Z'
- updated_at: '2026-05-13T22:26:28.119Z'
+ created_at: '2026-05-17T22:58:28.917Z'
+ updated_at: '2026-05-17T22:58:29.223Z'
tax_category_id: taxcat_UkLWZg9DAJ
available_stock: 0
reserved_quantity: 0
total_on_hand: 0
- product_name: Product 552228
+ product_name: Product 552946
requestBody:
content:
application/json:
@@ -12023,16 +12469,24 @@ components:
type: string
name:
type: string
- users_count:
+ description:
+ type: string
+ nullable: true
+ customers_count:
type: number
created_at:
type: string
updated_at:
type: string
+ customers:
+ type: array
+ items:
+ "$ref": "#/components/schemas/Customer"
required:
- id
- name
- - users_count
+ - description
+ - customers_count
- created_at
- updated_at
x-typelizer: true
@@ -12809,6 +13263,8 @@ components:
type: string
metadata:
type: object
+ filterable:
+ type: boolean
created_at:
type: string
updated_at:
@@ -12824,9 +13280,9 @@ components:
- position
- kind
- metadata
+ - filterable
- created_at
- updated_at
- - option_values
x-typelizer: true
OptionValue:
type: object
@@ -13143,8 +13599,8 @@ components:
auto_capture:
type: boolean
nullable: true
- display_on:
- type: string
+ storefront_visible:
+ type: boolean
position:
type: number
created_at:
@@ -13165,7 +13621,7 @@ components:
- metadata
- active
- auto_capture
- - display_on
+ - storefront_visible
- position
- created_at
- updated_at
diff --git a/packages/admin-sdk/examples/customer-groups/create.ts b/packages/admin-sdk/examples/customer-groups/create.ts
new file mode 100644
index 0000000000..ea31832d6f
--- /dev/null
+++ b/packages/admin-sdk/examples/customer-groups/create.ts
@@ -0,0 +1,16 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const group = await client.customerGroups.create({
+ name: 'VIP customers',
+ description: 'Top spenders, eligible for early access',
+ customer_ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
+})
+// endregion:example
+
+export { group }
diff --git a/packages/admin-sdk/examples/customer-groups/delete.ts b/packages/admin-sdk/examples/customer-groups/delete.ts
new file mode 100644
index 0000000000..a39a8d3d79
--- /dev/null
+++ b/packages/admin-sdk/examples/customer-groups/delete.ts
@@ -0,0 +1,10 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+await client.customerGroups.delete('cg_UkLWZg9DAJ')
+// endregion:example
diff --git a/packages/admin-sdk/examples/customer-groups/get.ts b/packages/admin-sdk/examples/customer-groups/get.ts
new file mode 100644
index 0000000000..22539f4579
--- /dev/null
+++ b/packages/admin-sdk/examples/customer-groups/get.ts
@@ -0,0 +1,14 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+// Pass `expand: ['customers']` to embed the group's customers in the response
+// — omit it for the much smaller index-payload shape.
+const group = await client.customerGroups.get('cg_UkLWZg9DAJ', { expand: ['customers'] })
+// endregion:example
+
+export { group }
diff --git a/packages/admin-sdk/examples/customer-groups/list.ts b/packages/admin-sdk/examples/customer-groups/list.ts
new file mode 100644
index 0000000000..ee6431d402
--- /dev/null
+++ b/packages/admin-sdk/examples/customer-groups/list.ts
@@ -0,0 +1,12 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const { data: groups } = await client.customerGroups.list({ page: 1, limit: 25 })
+// endregion:example
+
+export { groups }
diff --git a/packages/admin-sdk/examples/customer-groups/update.ts b/packages/admin-sdk/examples/customer-groups/update.ts
new file mode 100644
index 0000000000..cf99fbb25f
--- /dev/null
+++ b/packages/admin-sdk/examples/customer-groups/update.ts
@@ -0,0 +1,17 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+// `customer_ids` is a full-set update — the model reconciles the membership
+// to match the array (adds new IDs, removes ones not present).
+const group = await client.customerGroups.update('cg_UkLWZg9DAJ', {
+ name: 'VIP customers (Q1)',
+ customer_ids: ['cus_UkLWZg9DAJ'],
+})
+// endregion:example
+
+export { group }
diff --git a/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts b/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts
new file mode 100644
index 0000000000..092e73812d
--- /dev/null
+++ b/packages/admin-sdk/examples/customers/bulk-add-to-groups.ts
@@ -0,0 +1,15 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const result = await client.customers.bulkAddToGroups({
+ ids: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'],
+ customer_group_ids: ['cg_UkLWZg9DAJ'],
+})
+// endregion:example
+
+export { result }
diff --git a/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts b/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts
new file mode 100644
index 0000000000..d595b2d75f
--- /dev/null
+++ b/packages/admin-sdk/examples/customers/bulk-remove-from-groups.ts
@@ -0,0 +1,15 @@
+import { createAdminClient } from '@spree/admin-sdk'
+
+const client = createAdminClient({
+ baseUrl: 'https://your-store.com',
+ secretKey: 'sk_xxx',
+})
+
+// region:example
+const result = await client.customers.bulkRemoveFromGroups({
+ ids: ['cus_UkLWZg9DAJ'],
+ customer_group_ids: ['cg_UkLWZg9DAJ'],
+})
+// endregion:example
+
+export { result }
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index beabc6a0bb..2f068ecd6e 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -93,6 +93,8 @@ import type {
ApiKeyUpdateParams,
CustomerAddressParams,
CustomerCreateParams,
+ CustomerGroupCreateParams,
+ CustomerGroupUpdateParams,
CustomerStoreCreditCreateParams,
CustomerStoreCreditUpdateParams,
CustomerUpdateParams,
@@ -1121,8 +1123,31 @@ export class AdminClient {
params: params ? transformListParams(params) : undefined,
}),
- get: (id: string, options?: RequestOptions): Promise<CustomerGroup> =>
- this.request<CustomerGroup>('GET', `/customer_groups/${id}`, options),
+ get: (
+ id: string,
+ params?: { expand?: string[] },
+ options?: RequestOptions,
+ ): Promise<CustomerGroup> =>
+ this.request<CustomerGroup>('GET', `/customer_groups/${id}`, {
+ ...options,
+ params: getParams(params),
+ }),
+
+ create: (params: CustomerGroupCreateParams, options?: RequestOptions): Promise<CustomerGroup> =>
+ this.request<CustomerGroup>('POST', '/customer_groups', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: CustomerGroupUpdateParams,
+ options?: RequestOptions,
+ ): Promise<CustomerGroup> =>
+ this.request<CustomerGroup>('PATCH', `/customer_groups/${id}`, {
+ ...options,
+ body: params,
+ }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/customer_groups/${id}`, options),
}
// ============================================
@@ -1223,6 +1248,26 @@ export class AdminClient {
delete: (id: string, options?: RequestOptions): Promise<void> =>
this.request<void>('DELETE', `/customers/${id}`, options),
+ /**
+ * Bulk-attach a set of customers to a set of groups. Both arrays carry
+ * prefixed IDs; the server decodes them. Idempotent.
+ */
+ bulkAddToGroups: (
+ params: { ids: string[]; customer_group_ids: string[] },
+ options?: RequestOptions,
+ ): Promise<{ customer_count: number; customer_group_count: number }> =>
+ this.request('POST', '/customers/bulk_add_to_groups', { ...options, body: params }),
+
+ /**
+ * Bulk-detach a set of customers from a set of groups. No-op for
+ * non-members. Same shape as `bulkAddToGroups`.
+ */
+ bulkRemoveFromGroups: (
+ params: { ids: string[]; customer_group_ids: string[] },
+ options?: RequestOptions,
+ ): Promise<{ customer_count: number; customer_group_count: number }> =>
+ this.request('POST', '/customers/bulk_remove_from_groups', { ...options, body: params }),
+
addresses: {
list: (
customerId: string,
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index 1238a445a8..b1c1a83e60 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -490,6 +490,18 @@ export interface TaxCategoryUpdateParams {
is_default?: boolean
}
+export interface CustomerGroupCreateParams {
+ name: string
+ description?: string | null
+ customer_ids?: string[]
+}
+
+export interface CustomerGroupUpdateParams {
+ name?: string
+ description?: string | null
+ customer_ids?: string[]
+}
+
/**
* One entry in `preference_schema`, describing a single tunable knob on
* a STI subclass (payment provider, promotion action, promotion rule).
diff --git a/packages/admin-sdk/src/types/generated/Customer.ts b/packages/admin-sdk/src/types/generated/Customer.ts
index e1aee66394..a8759bf41a 100644
--- a/packages/admin-sdk/src/types/generated/Customer.ts
+++ b/packages/admin-sdk/src/types/generated/Customer.ts
@@ -1,7 +1,7 @@
-// Typelizer digest 2a77c7f4b9fa96a9a727312b874fcc5f
+// Typelizer digest 49ab32637fba419585a209c07a92a8c5
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
-import type {Address, Order, StoreCredit} from '@/types'
+import type {Address, Order, StoreCredit, CustomerGroup} from '@/types'
interface Customer {
id: string;
@@ -36,6 +36,7 @@ interface Customer {
last_order_completed_at: string | null;
orders?: Array<Order>;
store_credits?: Array<StoreCredit>;
+ customer_groups?: Array<CustomerGroup>;
}
export default Customer;
diff --git a/packages/admin-sdk/src/types/generated/CustomerGroup.ts b/packages/admin-sdk/src/types/generated/CustomerGroup.ts
index 5ac6ec5479..258ac44048 100644
--- a/packages/admin-sdk/src/types/generated/CustomerGroup.ts
+++ b/packages/admin-sdk/src/types/generated/CustomerGroup.ts
@@ -1,13 +1,16 @@
-// Typelizer digest 1e9340b059025e03642d5f847ac24ec6
+// Typelizer digest 025973c77ff5850bed4adf860d24722d
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
+import type {Customer} from '@/types'
interface CustomerGroup {
id: string;
name: string;
- users_count: number;
+ description: string | null;
+ customers_count: number;
created_at: string;
updated_at: string;
+ customers?: Array<Customer>;
}
export default CustomerGroup;
diff --git a/packages/admin/e2e/customer-groups.spec.ts b/packages/admin/e2e/customer-groups.spec.ts
new file mode 100644
index 0000000000..30c4cd02c4
--- /dev/null
+++ b/packages/admin/e2e/customer-groups.spec.ts
@@ -0,0 +1,93 @@
+import { expect, type Page, test } from '@playwright/test'
+import { gotoIndex, login, rowButton } from './helpers'
+
+const CUSTOMER_GROUPS_PATH = (storeId: string) => `/${storeId}/customers/groups`
+const CTA = /add customer group/i
+
+async function createCustomerGroup(page: Page, attrs: { name: string; description?: string }) {
+ await page.getByRole('button', { name: /add customer group/i }).click()
+ await expect(page.getByRole('heading', { name: /add customer group/i })).toBeVisible()
+
+ await page.locator('#name').fill(attrs.name)
+ if (attrs.description) await page.locator('#description').fill(attrs.description)
+
+ await page.getByRole('button', { name: /create customer group/i }).click()
+}
+
+test.describe('customer groups', () => {
+ test('lists customer groups', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMER_GROUPS_PATH(creds.store_id), CTA)
+ })
+
+ test('creates a new customer group', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMER_GROUPS_PATH(creds.store_id), CTA)
+
+ const name = `E2E Group ${Date.now()}`
+ await createCustomerGroup(page, { name, description: 'For E2E test.' })
+
+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })
+ })
+
+ test('edits a group name and description', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMER_GROUPS_PATH(creds.store_id), CTA)
+
+ const original = `E2E Edit Group ${Date.now()}`
+ const updated = `${original} (updated)`
+
+ await createCustomerGroup(page, { name: original })
+ await expect(rowButton(page, original)).toBeVisible({ timeout: 15_000 })
+
+ await rowButton(page, original).click()
+ await expect(page.getByRole('heading', { name: original })).toBeVisible({ timeout: 15_000 })
+ await expect(page.locator('#name')).toHaveValue(original)
+
+ await page.locator('#name').fill(updated)
+ await page.locator('#description').fill('Updated description')
+ await page.getByRole('button', { name: /^save$/i }).click()
+
+ await expect(rowButton(page, updated)).toBeVisible({ timeout: 15_000 })
+ })
+
+ test('edit sheet links to the filtered customers view', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMER_GROUPS_PATH(creds.store_id), CTA)
+
+ const name = `E2E Members Link ${Date.now()}`
+ await createCustomerGroup(page, { name })
+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })
+
+ await rowButton(page, name).click()
+ await expect(page.getByRole('heading', { name })).toBeVisible({ timeout: 15_000 })
+
+ // Members summary shows "0 customers in this group" (empty by default) +
+ // a View members link that deep-links to the customers index with a
+ // Ransack filter on `customer_groups_id_in`.
+ await expect(page.getByText(/0 customers in this group/i)).toBeVisible()
+ const link = page.getByRole('link', { name: /view members/i })
+ await expect(link).toHaveAttribute('href', /customer_groups_id/)
+ })
+
+ test('deletes a customer group', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMER_GROUPS_PATH(creds.store_id), CTA)
+
+ const name = `E2E Delete Group ${Date.now()}`
+ await createCustomerGroup(page, { name })
+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })
+
+ await rowButton(page, name).click()
+ await expect(page.getByRole('heading', { name })).toBeVisible({ timeout: 15_000 })
+
+ await page.getByRole('button', { name: /^delete$/i }).click()
+ await expect(page.getByRole('heading', { name: /delete customer group\?/i })).toBeVisible()
+ await page
+ .getByRole('dialog')
+ .getByRole('button', { name: /^delete$/i })
+ .click()
+
+ await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })
+ })
+})
diff --git a/packages/admin/e2e/customers.spec.ts b/packages/admin/e2e/customers.spec.ts
index 02200f67a4..4849c4421a 100644
--- a/packages/admin/e2e/customers.spec.ts
+++ b/packages/admin/e2e/customers.spec.ts
@@ -1,5 +1,5 @@
import { expect, type Page, test } from '@playwright/test'
-import { fillAddressForm, gotoIndex, login } from './helpers'
+import { FIXTURE_PROMO_CUSTOMER_GROUP, fillAddressForm, gotoIndex, login } from './helpers'
const CUSTOMERS_PATH = (storeId: string) => `/${storeId}/customers`
const CTA = /new customer/i
@@ -100,6 +100,63 @@ test.describe('customers', () => {
await expect(page.getByText(/25\.00/).first()).toBeVisible({ timeout: 15_000 })
})
+ test('bulk-assigns selected customers to a group', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)
+
+ const suffix = Date.now()
+ const emailA = `e2e-bulk-a-${suffix}@example.com`
+ const emailB = `e2e-bulk-b-${suffix}@example.com`
+ await createCustomer(page, emailA)
+ await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)
+ await createCustomer(page, emailB)
+ await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)
+
+ // Locate the two rows we just created and tick their checkboxes. The row
+ // selection markup is `<input type="checkbox" aria-label="Select row">`
+ // scoped to the row whose cell text contains the email.
+ for (const email of [emailA, emailB]) {
+ await page
+ .locator('tr')
+ .filter({ hasText: email })
+ .getByRole('checkbox', { name: /select row/i })
+ .check()
+ }
+
+ // The bulk action bar appears once any row is selected.
+ await expect(page.getByText(/2 selected/i)).toBeVisible()
+ await page.getByRole('button', { name: /add to group/i }).click()
+
+ // Picker sheet opens — pick the seeded group, then confirm.
+ await expect(page.getByRole('heading', { name: /add 2 customers to groups/i })).toBeVisible()
+ await page
+ .getByRole('dialog')
+ .getByPlaceholder(/search customer groups/i)
+ .fill(FIXTURE_PROMO_CUSTOMER_GROUP)
+ await page
+ .getByRole('option', { name: new RegExp(FIXTURE_PROMO_CUSTOMER_GROUP, 'i') })
+ .first()
+ .click()
+ await page.getByRole('dialog').getByRole('button', { name: /^add$/i }).click()
+
+ // After success, the toast confirms the count and the row chips render
+ // the group name once the table refetches.
+ await expect(page.getByText(/added 2 customers to groups/i)).toBeVisible({ timeout: 15_000 })
+
+ // Visit /customers/groups WITHIN the QueryClient's staleTime window (60s).
+ // If the bulk action didn't invalidate the groups cache, the stale
+ // snapshot (showing 0 customers in the seeded group) would render here.
+ // Regression guard for the TanStack Query cross-resource invalidation bug.
+ await page.goto(`/${creds.store_id}/customers/groups`)
+ const groupRow = page.locator('tr').filter({ hasText: FIXTURE_PROMO_CUSTOMER_GROUP })
+ // The count is the last <td> in the row. Poll until it reads ≥ 2.
+ await expect
+ .poll(async () => Number((await groupRow.locator('td').last().innerText()).trim()), {
+ timeout: 15_000,
+ })
+ .toBeGreaterThanOrEqual(2)
+ })
+
test('deletes a customer', async ({ page }) => {
const creds = await login(page)
await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)
diff --git a/packages/admin/src/components/spree/promotion-editors/rule-customer-group.tsx b/packages/admin/src/components/spree/promotion-editors/rule-customer-group.tsx
index a46208c84f..c1d9a644a1 100644
--- a/packages/admin/src/components/spree/promotion-editors/rule-customer-group.tsx
+++ b/packages/admin/src/components/spree/promotion-editors/rule-customer-group.tsx
@@ -1,8 +1,8 @@
import type { CustomerGroup } from '@spree/admin-sdk'
import { useState } from 'react'
-import { adminClient } from '@/client'
import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-autocomplete'
import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
+import { customerGroupAutocompleteProps } from '@/hooks/use-customer-groups'
import { EditorShell } from './editor-shell'
import type { PromotionRuleEditorContext } from './types'
@@ -27,17 +27,10 @@ export function CustomerGroupRuleEditor({ draft, onSave, onClose }: PromotionRul
<Field>
<FieldLabel>Customer groups</FieldLabel>
<ResourceMultiAutocomplete
- queryKey="promotion-rule-customer-groups"
+ {...customerGroupAutocompleteProps('promotion-rule-customer-groups')}
value={groupIds}
onChange={setGroupIds}
onResolvedOptionsChange={setCustomerGroups}
- search={(q) =>
- adminClient.customerGroups.list({ name_cont: q, limit: 20, sort: 'name' })
- }
- hydrate={(ids) => adminClient.customerGroups.list({ id_in: ids, limit: ids.length })}
- getOptionLabel={(g) => g.name ?? g.id}
- placeholder="Search customer groups…"
- emptyText="No customer groups match"
/>
</Field>
</FieldGroup>
diff --git a/packages/admin/src/components/spree/resource-table.tsx b/packages/admin/src/components/spree/resource-table.tsx
index 1f87ef05eb..b7322e7e49 100644
--- a/packages/admin/src/components/spree/resource-table.tsx
+++ b/packages/admin/src/components/spree/resource-table.tsx
@@ -15,7 +15,7 @@ import {
verticalListSortingStrategy,
} from '@dnd-kit/sortable'
import { CSS } from '@dnd-kit/utilities'
-import { useQuery } from '@tanstack/react-query'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import {
type CSSProperties,
@@ -23,13 +23,16 @@ import {
useCallback,
useDeferredValue,
useEffect,
+ useMemo,
useState,
} from 'react'
import { z } from 'zod/v4'
+import { type BulkAction, BulkActionBar } from '@/components/spree/bulk-action-bar'
import { DragHandle } from '@/components/spree/drag-handle'
import { EmptyState } from '@/components/spree/empty-state'
import { TableToolbar } from '@/components/spree/table-toolbar'
import { Card, CardContent } from '@/components/ui/card'
+import { Checkbox } from '@/components/ui/checkbox'
import {
Table,
TableBody,
@@ -140,6 +143,14 @@ interface ResourceTableProps<T> {
* (default: `position`) — otherwise reordering would be meaningless.
*/
reorder?: ReorderConfig<T>
+ /**
+ * Bulk operations available against selected rows. When present, the
+ * table renders a leading checkbox column and a sticky action bar
+ * appears once any row is selected. Mutually exclusive with `reorder`
+ * — the leading column is already taken by the drag handle.
+ */
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ bulkActions?: BulkAction<any>[]
}
export interface ReorderConfig<T> {
@@ -161,10 +172,15 @@ export function ResourceTable<T extends Record<string, any>>({
defaultParams,
actions,
reorder,
+ bulkActions,
}: ResourceTableProps<T>) {
const table = getTable<T>(tableKey)
const { token } = useAuth()
const navigate = useNavigate()
+ const queryClient = useQueryClient()
+
+ const selectionEnabled = !!bulkActions?.length && !reorder
+ const [selectedIds, setSelectedIds] = useState<Set<string>>(() => new Set())
const {
page,
@@ -228,16 +244,28 @@ export function ResourceTable<T extends Record<string, any>>({
const fetchedRows = data?.data ?? []
const meta = data?.meta
+ // Selection is per-page and ephemeral. Wipe it whenever the user pages,
+ // re-sorts, filters, or searches — keeping IDs from prior pages would let
+ // them silently apply a bulk op to rows the user can no longer see.
+ // biome-ignore lint/correctness/useExhaustiveDependencies: intentional reset on visible-set change
+ useEffect(() => {
+ if (selectionEnabled) {
+ setSelectedIds((prev) => (prev.size === 0 ? prev : new Set()))
+ }
+ }, [page, sortString, deferredSearch, filters, selectionEnabled])
+
+ const reorderActive = !!reorder
+
// Mirror the fetched rows in local state while reordering so we can swap
- // them optimistically on drop. The mirror tracks the upstream cache by
- // identity — TanStack returns a new array reference on every refetch, so
- // this useEffect runs whenever the server data updates.
+ // them optimistically on drop. Only allocated when reorder is active —
+ // otherwise the table reads `fetchedRows` straight through. The mirror
+ // tracks the upstream cache by identity; TanStack returns a new array
+ // reference on every refetch, so this useEffect runs whenever data updates.
const [localRows, setLocalRows] = useState<T[]>(fetchedRows)
useEffect(() => {
- setLocalRows(fetchedRows)
- }, [fetchedRows])
+ if (reorderActive) setLocalRows(fetchedRows)
+ }, [fetchedRows, reorderActive])
- const reorderActive = !!reorder
const rows = reorderActive ? localRows : fetchedRows
// dnd-kit sensors: pointer for mouse/touch (5px activation distance keeps
@@ -300,6 +328,32 @@ export function ResourceTable<T extends Record<string, any>>({
updateSearch({ columns: isDefault ? undefined : cols.join(',') })
}
+ const pageIds = useMemo(() => (data?.data ?? []).map((r) => String((r as any).id)), [data])
+ const allPageSelected = pageIds.length > 0 && pageIds.every((id) => selectedIds.has(id))
+ const somePageSelected = pageIds.some((id) => selectedIds.has(id)) && !allPageSelected
+
+ function toggleRow(id: string) {
+ setSelectedIds((prev) => {
+ const next = new Set(prev)
+ if (next.has(id)) next.delete(id)
+ else next.add(id)
+ return next
+ })
+ }
+
+ function togglePage() {
+ setSelectedIds((prev) => {
+ if (allPageSelected) {
+ const next = new Set(prev)
+ for (const id of pageIds) next.delete(id)
+ return next
+ }
+ const next = new Set(prev)
+ for (const id of pageIds) next.add(id)
+ return next
+ })
+ }
+
// Header columns for price-like right-aligned columns
const headerColumns = visibleColumns.map((col) => {
const isRightAligned = col.className?.includes('text-right')
@@ -389,6 +443,16 @@ export function ResourceTable<T extends Record<string, any>>({
<Table>
<TableHeader>
<tr>
+ {selectionEnabled && (
+ <TableHead className="w-8">
+ <Checkbox
+ checked={allPageSelected}
+ indeterminate={somePageSelected}
+ onCheckedChange={togglePage}
+ aria-label="Select all rows on this page"
+ />
+ </TableHead>
+ )}
{headerColumns.map((col) => (
<TableHead key={col.key} className={col.headerClassName}>
{col.label}
@@ -398,9 +462,11 @@ export function ResourceTable<T extends Record<string, any>>({
</TableHeader>
<TableBody>
{isLoading ? (
- <TableEmpty colSpan={visibleColumns.length}>Loading...</TableEmpty>
+ <TableEmpty colSpan={visibleColumns.length + (selectionEnabled ? 1 : 0)}>
+ Loading...
+ </TableEmpty>
) : rows.length === 0 ? (
- <TableEmpty colSpan={visibleColumns.length}>
+ <TableEmpty colSpan={visibleColumns.length + (selectionEnabled ? 1 : 0)}>
<EmptyState
compact
icon={table.emptyIcon}
@@ -413,15 +479,31 @@ export function ResourceTable<T extends Record<string, any>>({
/>
</TableEmpty>
) : (
- rows.map((row, i) => (
- <TableRow key={(row as any).id ?? i}>
- {visibleColumns.map((col) => (
- <TableCell key={col.key} className={col.className}>
- {col.render ? col.render(row) : String((row as any)[col.key] ?? '—')}
- </TableCell>
- ))}
- </TableRow>
- ))
+ rows.map((row, i) => {
+ const rowId = String((row as any).id ?? i)
+ const isSelected = selectionEnabled && selectedIds.has(rowId)
+ return (
+ <TableRow
+ key={(row as any).id ?? i}
+ className={isSelected ? 'bg-muted/40' : undefined}
+ >
+ {selectionEnabled && (
+ <TableCell className="w-8">
+ <Checkbox
+ checked={isSelected}
+ onCheckedChange={() => toggleRow(rowId)}
+ aria-label="Select row"
+ />
+ </TableCell>
+ )}
+ {visibleColumns.map((col) => (
+ <TableCell key={col.key} className={col.className}>
+ {col.render ? col.render(row) : String((row as any)[col.key] ?? '—')}
+ </TableCell>
+ ))}
+ </TableRow>
+ )
+ })
)}
</TableBody>
</Table>
@@ -433,6 +515,17 @@ export function ResourceTable<T extends Record<string, any>>({
onPageSizeChange={(size) => updateSearch({ limit: size, page: 1 })}
/>
)}
+ {selectionEnabled && (
+ <BulkActionBar
+ selectedIds={Array.from(selectedIds)}
+ actions={bulkActions!}
+ onClear={() => setSelectedIds(new Set())}
+ onDone={() => {
+ setSelectedIds(new Set())
+ queryClient.invalidateQueries({ queryKey: [queryKey] })
+ }}
+ />
+ )}
</CardContent>
</Card>
)
diff --git a/packages/admin/src/components/spree/table-toolbar.tsx b/packages/admin/src/components/spree/table-toolbar.tsx
index 18e23d7b98..259f4bdb83 100644
--- a/packages/admin/src/components/spree/table-toolbar.tsx
+++ b/packages/admin/src/components/spree/table-toolbar.tsx
@@ -1,3 +1,4 @@
+import { useQuery } from '@tanstack/react-query'
import {
ArrowUpDownIcon,
Columns3Icon,
@@ -8,6 +9,7 @@ import {
XIcon,
} from 'lucide-react'
import { useCallback, useMemo, useRef, useState } from 'react'
+import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-autocomplete'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { CardTitle } from '@/components/ui/card'
@@ -31,7 +33,12 @@ import {
SelectValue,
} from '@/components/ui/select'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
-import type { ColumnDef, FilterRule, SortOption } from '@/lib/table-registry'
+import {
+ type ColumnDef,
+ type FilterRule,
+ parseFilterIds,
+ type SortOption,
+} from '@/lib/table-registry'
interface TableToolbarProps {
/** Displayable columns (for column selector and table headers) */
@@ -89,6 +96,10 @@ const operatorsByType: Record<string, { value: string; label: string }[]> = {
{ value: 'gteq', label: 'on or after' },
{ value: 'lteq', label: 'on or before' },
],
+ resource: [
+ { value: 'in', label: 'is any of' },
+ { value: 'not_in', label: 'is none of' },
+ ],
}
function getOperators(type: string) {
@@ -135,7 +146,7 @@ export function TableToolbar({
return (
<>
- <div className="flex flex-col lg:flex-row gap-3 items-start lg:items-center justify-between p-3 border-b border-border">
+ <div className="flex flex-col lg:flex-row gap-2 items-start lg:items-center justify-between p-3 border-b border-border">
{title && <CardTitle>{title}</CardTitle>}
<div className="flex gap-2 items-center flex-wrap ml-auto">
{/* Search */}
@@ -215,27 +226,14 @@ export function TableToolbar({
{/* Active filter badges */}
{filters.length > 0 && (
<div className="flex gap-2 flex-wrap px-3 py-2 border-b border-border">
- {filters.map((filter) => {
- const col = allCols.find((c) => c.key === filter.field)
- const ops = getOperators(col?.filterType ?? 'string')
- const opLabel = ops.find((o) => o.value === filter.operator)?.label ?? filter.operator
- return (
- <Badge key={filter.id} variant="outline" className="gap-1.5 pr-0.5">
- <span className="font-medium">{col?.label ?? filter.field}</span>
- <span className="text-muted-foreground">{opLabel}</span>
- {!noValueOperators.includes(filter.operator) && (
- <span className="font-medium">{filter.value}</span>
- )}
- <button
- type="button"
- className="ml-0.5 p-0.5 rounded-full hover:bg-accent"
- onClick={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
- >
- <XIcon className="size-3" />
- </button>
- </Badge>
- )
- })}
+ {filters.map((filter) => (
+ <FilterChip
+ key={filter.id}
+ filter={filter}
+ col={allCols.find((c) => c.key === filter.field)}
+ onRemove={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
+ />
+ ))}
<button
type="button"
className="text-xs text-muted-foreground hover:text-foreground"
@@ -249,6 +247,75 @@ export function TableToolbar({
)
}
+// ============================================================================
+// Filter Chip
+// ============================================================================
+
+function FilterChip({
+ filter,
+ col,
+ onRemove,
+}: {
+ filter: FilterRule
+ col: ColumnDef | undefined
+ onRemove: () => void
+}) {
+ const ops = getOperators(col?.filterType ?? 'string')
+ const opLabel = ops.find((o) => o.value === filter.operator)?.label ?? filter.operator
+ const showValue = !noValueOperators.includes(filter.operator)
+
+ return (
+ <Badge variant="outline" className="gap-1.5 pr-0.5">
+ <span className="font-medium">{col?.label ?? filter.field}</span>
+ <span className="text-muted-foreground">{opLabel}</span>
+ {showValue &&
+ (col?.filterType === 'resource' && col.filterResource ? (
+ <ResourceFilterValue value={filter.value} config={col.filterResource} />
+ ) : (
+ <span className="font-medium">{filter.value}</span>
+ ))}
+ <button
+ type="button"
+ className="ml-0.5 p-0.5 rounded-full hover:bg-accent"
+ onClick={onRemove}
+ >
+ <XIcon className="size-3" />
+ </button>
+ </Badge>
+ )
+}
+
+/**
+ * Hydrates the CSV id list in a resource filter into human labels. Reuses
+ * the resource's `hydrate` callback so each chip benefits from React Query's
+ * cache (the picker inside the panel populates the same `queryKey`).
+ */
+function ResourceFilterValue({
+ value,
+ config,
+}: {
+ value: string
+ config: NonNullable<ColumnDef['filterResource']>
+}) {
+ const ids = useMemo(() => parseFilterIds(value), [value])
+
+ const { data } = useQuery({
+ queryKey: ['filter-chip', config.queryKey, ids],
+ queryFn: () => config.hydrate(ids),
+ enabled: ids.length > 0,
+ staleTime: 60_000,
+ })
+
+ if (ids.length === 0) return null
+
+ const labels = ids.map((id) => {
+ const record = data?.data.find((r) => r.id === id)
+ return record ? config.getOptionLabel(record) : id
+ })
+
+ return <span className="font-medium">{labels.join(', ')}</span>
+}
+
// ============================================================================
// Sort Dropdown
// ============================================================================
@@ -486,7 +553,20 @@ function FilterPanel({
</Select>
{!noValueOperators.includes(filter.operator) &&
- (col?.filterType === 'enum' && col.filterOptions ? (
+ (col?.filterType === 'resource' && col.filterResource ? (
+ <div className="flex-1 min-w-0">
+ <ResourceMultiAutocomplete
+ queryKey={col.filterResource.queryKey}
+ value={parseFilterIds(filter.value)}
+ onChange={(ids) => updateFilter(filter.id, { value: ids.join(',') })}
+ search={col.filterResource.search}
+ hydrate={col.filterResource.hydrate}
+ getOptionLabel={col.filterResource.getOptionLabel}
+ placeholder={col.filterResource.placeholder}
+ emptyText={col.filterResource.emptyText}
+ />
+ </div>
+ ) : col?.filterType === 'enum' && col.filterOptions ? (
<Select
items={col.filterOptions}
value={filter.value || undefined}
diff --git a/packages/admin/src/hooks/use-customer-groups.ts b/packages/admin/src/hooks/use-customer-groups.ts
new file mode 100644
index 0000000000..1fef186a75
--- /dev/null
+++ b/packages/admin/src/hooks/use-customer-groups.ts
@@ -0,0 +1,73 @@
+import type {
+ CustomerGroup,
+ CustomerGroupCreateParams,
+ CustomerGroupUpdateParams,
+} from '@spree/admin-sdk'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
+import { adminClient } from '@/client'
+import { useResourceMutation } from '@/hooks/use-resource-mutation'
+
+/**
+ * Shared config for any `<ResourceMultiAutocomplete>` picking customer
+ * groups (table filter, bulk-action sheet, promotion-rule editor). Pass
+ * a unique `queryKey` per instance so independent caches don't collide.
+ */
+export function customerGroupAutocompleteProps(queryKey: string) {
+ return {
+ queryKey,
+ search: (q: string) =>
+ adminClient.customerGroups.list({ name_cont: q, limit: 20, sort: 'name' }),
+ hydrate: (ids: string[]) => adminClient.customerGroups.list({ id_in: ids, limit: ids.length }),
+ getOptionLabel: (g: CustomerGroup) => g.name ?? g.id,
+ placeholder: 'Search customer groups…',
+ emptyText: 'No customer groups match',
+ }
+}
+
+export const customerGroupsQueryKey = ['customer-groups'] as const
+
+export function customerGroupQueryKey(id: string, expand?: string[]) {
+ return expand?.length
+ ? (['customer-groups', id, { expand }] as const)
+ : (['customer-groups', id] as const)
+}
+
+export function useCustomerGroup(id: string | undefined, expand?: string[]) {
+ return useQuery({
+ queryKey: id ? customerGroupQueryKey(id, expand) : ['customer-groups', 'noop'],
+ queryFn: () => adminClient.customerGroups.get(id as string, { expand }),
+ enabled: !!id,
+ })
+}
+
+export function useCreateCustomerGroup() {
+ return useResourceMutation<CustomerGroup, Error, CustomerGroupCreateParams>({
+ mutationFn: (params) => adminClient.customerGroups.create(params),
+ invalidate: [customerGroupsQueryKey],
+ successMessage: 'Customer group created',
+ errorMessage: 'Failed to create customer group',
+ })
+}
+
+export function useUpdateCustomerGroup(id: string) {
+ return useResourceMutation<CustomerGroup, Error, CustomerGroupUpdateParams>({
+ mutationFn: (params) => adminClient.customerGroups.update(id, params),
+ invalidate: [customerGroupsQueryKey, customerGroupQueryKey(id)],
+ successMessage: 'Customer group updated',
+ errorMessage: 'Failed to update customer group',
+ })
+}
+
+export function useDeleteCustomerGroup() {
+ const queryClient = useQueryClient()
+
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (id) => adminClient.customerGroups.delete(id),
+ invalidate: [customerGroupsQueryKey],
+ successMessage: 'Customer group deleted',
+ errorMessage: 'Failed to delete customer group',
+ onSuccess: (_data, id) => {
+ queryClient.removeQueries({ queryKey: customerGroupQueryKey(id) })
+ },
+ })
+}
diff --git a/packages/admin/src/lib/filters-to-ransack.ts b/packages/admin/src/lib/filters-to-ransack.ts
index b5fe4eb11b..d544de8e2c 100644
--- a/packages/admin/src/lib/filters-to-ransack.ts
+++ b/packages/admin/src/lib/filters-to-ransack.ts
@@ -1,4 +1,4 @@
-import type { ColumnDef, FilterRule } from '@/lib/table-registry'
+import { type ColumnDef, type FilterRule, parseFilterIds } from '@/lib/table-registry'
/**
* Convert toolbar `FilterRule[]` state into a flat Ransack predicate hash:
@@ -16,15 +16,27 @@ import type { ColumnDef, FilterRule } from '@/lib/table-registry'
* `transformListParams` wraps each key in `q[...]`) and the export endpoint
* (which stores the hash as `search_params`) expect.
*/
+// Array-valued operators get a `[]` suffix so `transformListParams` emits
+// `q[xxx_in][]=...` for each item. The chip stores the IDs as a CSV string
+// in `FilterRule.value` so the URL serializer (which already JSON-stringifies
+// FilterRule[]) stays simple.
+const ARRAY_OPERATORS = new Set(['in', 'not_in'])
+
export function filtersToRansack(
filters: FilterRule[],
columns: ColumnDef[],
-): Record<string, string> {
- const out: Record<string, string> = {}
+): Record<string, string | string[]> {
+ const out: Record<string, string | string[]> = {}
for (const filter of filters) {
const col = columns.find((c) => c.key === filter.field)
const ransackKey = col?.ransackAttribute ?? filter.field
- out[`${ransackKey}_${filter.operator}`] = filter.value
+ const key = `${ransackKey}_${filter.operator}`
+ if (ARRAY_OPERATORS.has(filter.operator)) {
+ const ids = parseFilterIds(filter.value)
+ if (ids.length > 0) out[key] = ids
+ } else {
+ out[key] = filter.value
+ }
}
return out
}
diff --git a/packages/admin/src/lib/permissions.ts b/packages/admin/src/lib/permissions.ts
index fad98cb4df..75cde7d282 100644
--- a/packages/admin/src/lib/permissions.ts
+++ b/packages/admin/src/lib/permissions.ts
@@ -10,6 +10,7 @@ export const Subject = {
Variant: 'Spree::Variant',
Order: 'Spree::Order',
Customer: 'Spree::User',
+ CustomerGroup: 'Spree::CustomerGroup',
AdminUser: 'Spree::AdminUser',
ApiKey: 'Spree::ApiKey',
Store: 'Spree::Store',
diff --git a/packages/admin/src/lib/table-registry.ts b/packages/admin/src/lib/table-registry.ts
index b3fcd9c345..cb6488b1fe 100644
--- a/packages/admin/src/lib/table-registry.ts
+++ b/packages/admin/src/lib/table-registry.ts
@@ -22,27 +22,65 @@ interface ColumnDefBase<T = any> {
}
/**
- * Column definition. Discriminated union on `filterType`: when `filterType` is
- * `'enum'`, `filterOptions` is **required**; for the other types it must be
- * omitted (those filters render their own input widget).
+ * Config for `filterType: 'resource'` — drives a `<ResourceMultiAutocomplete>`
+ * inside the filter panel and hydrates labels in the active-filter chip.
+ *
+ * `search` is called as the user types. `hydrate` resolves currently-selected
+ * IDs (deep-link reload, navigating back to the page) to records so the chip
+ * can show human-readable names instead of raw prefixed IDs.
+ */
+export interface ResourceFilterConfig<R extends { id: string } = { id: string }> {
+ queryKey: string
+ search: (query: string) => Promise<{ data: R[] }>
+ hydrate: (ids: string[]) => Promise<{ data: R[] }>
+ getOptionLabel: (option: R) => string
+ placeholder?: string
+ emptyText?: string
+}
+
+/**
+ * Column definition. Discriminated union on `filterType`:
+ * - `'enum'` → `filterOptions` is **required**
+ * - `'resource'` → `filterResource` is **required** (multi-select picker)
+ * - other types → both must be omitted
*/
export type ColumnDef<T = any> =
| (ColumnDefBase<T> & {
filterType?: 'string' | 'boolean' | 'number' | 'date'
filterOptions?: never
+ filterResource?: never
})
| (ColumnDefBase<T> & {
filterType: 'enum'
filterOptions: { value: string; label: string }[]
+ filterResource?: never
+ })
+ | (ColumnDefBase<T> & {
+ filterType: 'resource'
+ filterOptions?: never
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ filterResource: ResourceFilterConfig<any>
})
export interface FilterRule {
id: string
field: string
operator: string
+ /**
+ * For array-valued operators (`in`, `not_in`) and the `'resource'` filter
+ * type, the IDs are encoded as a trimmed CSV string. Use `parseFilterIds`
+ * to decode and `ids.join(',')` to encode — keeps URL serialization simple.
+ */
value: string
}
+export function parseFilterIds(value: string): string[] {
+ return value
+ .split(',')
+ .map((s) => s.trim())
+ .filter(Boolean)
+}
+
export interface SortOption {
field: string
direction: 'asc' | 'desc'
diff --git a/packages/admin/src/nav/default.ts b/packages/admin/src/nav/default.ts
index 00e5619cb7..29f57f91e0 100644
--- a/packages/admin/src/nav/default.ts
+++ b/packages/admin/src/nav/default.ts
@@ -82,6 +82,15 @@ nav.add({
icon: UsersIcon,
subject: Subject.Customer,
position: 400,
+ children: [
+ {
+ key: 'customers.groups',
+ label: 'Groups',
+ path: '/customers/groups',
+ subject: Subject.CustomerGroup,
+ position: 100,
+ },
+ ],
})
nav.add({
diff --git a/packages/admin/src/routeTree.gen.ts b/packages/admin/src/routeTree.gen.ts
index 120ca8dbe3..85a9e0f5c3 100644
--- a/packages/admin/src/routeTree.gen.ts
+++ b/packages/admin/src/routeTree.gen.ts
@@ -35,6 +35,7 @@ import { Route as AuthenticatedStoreIdProductsProductIdRouteImport } from './rou
import { Route as AuthenticatedStoreIdOrdersNewRouteImport } from './routes/_authenticated/$storeId/orders/new'
import { Route as AuthenticatedStoreIdOrdersDraftsRouteImport } from './routes/_authenticated/$storeId/orders/drafts'
import { Route as AuthenticatedStoreIdOrdersOrderIdRouteImport } from './routes/_authenticated/$storeId/orders/$orderId'
+import { Route as AuthenticatedStoreIdCustomersGroupsRouteImport } from './routes/_authenticated/$storeId/customers/groups'
import { Route as AuthenticatedStoreIdCustomersCustomerIdRouteImport } from './routes/_authenticated/$storeId/customers/$customerId'
const LoginRoute = LoginRouteImport.update({
@@ -188,6 +189,12 @@ const AuthenticatedStoreIdOrdersOrderIdRoute =
path: '/orders/$orderId',
getParentRoute: () => AuthenticatedStoreIdRoute,
} as any)
+const AuthenticatedStoreIdCustomersGroupsRoute =
+ AuthenticatedStoreIdCustomersGroupsRouteImport.update({
+ id: '/customers/groups',
+ path: '/customers/groups',
+ getParentRoute: () => AuthenticatedStoreIdRoute,
+ } as any)
const AuthenticatedStoreIdCustomersCustomerIdRoute =
AuthenticatedStoreIdCustomersCustomerIdRouteImport.update({
id: '/customers/$customerId',
@@ -203,6 +210,7 @@ export interface FileRoutesByFullPath {
'/$storeId/settings': typeof AuthenticatedStoreIdSettingsRouteWithChildren
'/$storeId/': typeof AuthenticatedStoreIdIndexRoute
'/$storeId/customers/$customerId': typeof AuthenticatedStoreIdCustomersCustomerIdRoute
+ '/$storeId/customers/groups': typeof AuthenticatedStoreIdCustomersGroupsRoute
'/$storeId/orders/$orderId': typeof AuthenticatedStoreIdOrdersOrderIdRoute
'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute
'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute
@@ -229,6 +237,7 @@ export interface FileRoutesByTo {
'/': typeof AuthenticatedIndexRoute
'/$storeId': typeof AuthenticatedStoreIdIndexRoute
'/$storeId/customers/$customerId': typeof AuthenticatedStoreIdCustomersCustomerIdRoute
+ '/$storeId/customers/groups': typeof AuthenticatedStoreIdCustomersGroupsRoute
'/$storeId/orders/$orderId': typeof AuthenticatedStoreIdOrdersOrderIdRoute
'/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute
'/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute
@@ -259,6 +268,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings': typeof AuthenticatedStoreIdSettingsRouteWithChildren
'/_authenticated/$storeId/': typeof AuthenticatedStoreIdIndexRoute
'/_authenticated/$storeId/customers/$customerId': typeof AuthenticatedStoreIdCustomersCustomerIdRoute
+ '/_authenticated/$storeId/customers/groups': typeof AuthenticatedStoreIdCustomersGroupsRoute
'/_authenticated/$storeId/orders/$orderId': typeof AuthenticatedStoreIdOrdersOrderIdRoute
'/_authenticated/$storeId/orders/drafts': typeof AuthenticatedStoreIdOrdersDraftsRoute
'/_authenticated/$storeId/orders/new': typeof AuthenticatedStoreIdOrdersNewRoute
@@ -289,6 +299,7 @@ export interface FileRouteTypes {
| '/$storeId/settings'
| '/$storeId/'
| '/$storeId/customers/$customerId'
+ | '/$storeId/customers/groups'
| '/$storeId/orders/$orderId'
| '/$storeId/orders/drafts'
| '/$storeId/orders/new'
@@ -315,6 +326,7 @@ export interface FileRouteTypes {
| '/'
| '/$storeId'
| '/$storeId/customers/$customerId'
+ | '/$storeId/customers/groups'
| '/$storeId/orders/$orderId'
| '/$storeId/orders/drafts'
| '/$storeId/orders/new'
@@ -344,6 +356,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings'
| '/_authenticated/$storeId/'
| '/_authenticated/$storeId/customers/$customerId'
+ | '/_authenticated/$storeId/customers/groups'
| '/_authenticated/$storeId/orders/$orderId'
| '/_authenticated/$storeId/orders/drafts'
| '/_authenticated/$storeId/orders/new'
@@ -555,6 +568,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthenticatedStoreIdOrdersOrderIdRouteImport
parentRoute: typeof AuthenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/customers/groups': {
+ id: '/_authenticated/$storeId/customers/groups'
+ path: '/customers/groups'
+ fullPath: '/$storeId/customers/groups'
+ preLoaderRoute: typeof AuthenticatedStoreIdCustomersGroupsRouteImport
+ parentRoute: typeof AuthenticatedStoreIdRoute
+ }
'/_authenticated/$storeId/customers/$customerId': {
id: '/_authenticated/$storeId/customers/$customerId'
path: '/customers/$customerId'
@@ -602,6 +622,7 @@ interface AuthenticatedStoreIdRouteChildren {
AuthenticatedStoreIdSettingsRoute: typeof AuthenticatedStoreIdSettingsRouteWithChildren
AuthenticatedStoreIdIndexRoute: typeof AuthenticatedStoreIdIndexRoute
AuthenticatedStoreIdCustomersCustomerIdRoute: typeof AuthenticatedStoreIdCustomersCustomerIdRoute
+ AuthenticatedStoreIdCustomersGroupsRoute: typeof AuthenticatedStoreIdCustomersGroupsRoute
AuthenticatedStoreIdOrdersOrderIdRoute: typeof AuthenticatedStoreIdOrdersOrderIdRoute
AuthenticatedStoreIdOrdersDraftsRoute: typeof AuthenticatedStoreIdOrdersDraftsRoute
AuthenticatedStoreIdOrdersNewRoute: typeof AuthenticatedStoreIdOrdersNewRoute
@@ -622,6 +643,8 @@ const AuthenticatedStoreIdRouteChildren: AuthenticatedStoreIdRouteChildren = {
AuthenticatedStoreIdIndexRoute: AuthenticatedStoreIdIndexRoute,
AuthenticatedStoreIdCustomersCustomerIdRoute:
AuthenticatedStoreIdCustomersCustomerIdRoute,
+ AuthenticatedStoreIdCustomersGroupsRoute:
+ AuthenticatedStoreIdCustomersGroupsRoute,
AuthenticatedStoreIdOrdersOrderIdRoute:
AuthenticatedStoreIdOrdersOrderIdRoute,
AuthenticatedStoreIdOrdersDraftsRoute: AuthenticatedStoreIdOrdersDraftsRoute,
diff --git a/packages/admin/src/routes/_authenticated/$storeId/customers/groups.tsx b/packages/admin/src/routes/_authenticated/$storeId/customers/groups.tsx
new file mode 100644
index 0000000000..b473dfcebe
--- /dev/null
+++ b/packages/admin/src/routes/_authenticated/$storeId/customers/groups.tsx
@@ -0,0 +1,331 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import type {
+ CustomerGroup,
+ CustomerGroupCreateParams,
+ CustomerGroupUpdateParams,
+} from '@spree/admin-sdk'
+import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
+import { PlusIcon, UsersIcon } from 'lucide-react'
+import { useEffect } from 'react'
+import { useForm } from 'react-hook-form'
+import { z } from 'zod/v4'
+import { adminClient } from '@/client'
+import { Can } from '@/components/spree/can'
+import { useConfirm } from '@/components/spree/confirm-dialog'
+import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'
+import { useRowClickBridge } from '@/components/spree/row-click-bridge'
+import { Button } from '@/components/ui/button'
+import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
+import { Input } from '@/components/ui/input'
+import {
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+} from '@/components/ui/sheet'
+import { Textarea } from '@/components/ui/textarea'
+import {
+ useCreateCustomerGroup,
+ useCustomerGroup,
+ useDeleteCustomerGroup,
+ useUpdateCustomerGroup,
+} from '@/hooks/use-customer-groups'
+import { Subject } from '@/lib/permissions'
+import '@/tables/customer-groups'
+
+const customerGroupsSearchSchema = resourceSearchSchema.extend({
+ edit: z.string().optional(),
+ new: z.coerce.boolean().optional(),
+})
+
+export const Route = createFileRoute('/_authenticated/$storeId/customers/groups')({
+ validateSearch: customerGroupsSearchSchema,
+ component: CustomerGroupsPage,
+})
+
+function CustomerGroupsPage() {
+ const search = Route.useSearch() as z.infer<typeof customerGroupsSearchSchema>
+ const navigate = useNavigate()
+
+ const editId = search.edit
+ const isCreating = !!search.new
+
+ const closeSheet = () =>
+ navigate({
+ search: (prev: Record<string, unknown>) => {
+ const { edit: _e, new: _n, ...rest } = prev
+ return rest as never
+ },
+ })
+
+ const openCreate = () =>
+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })
+
+ const openEdit = (id: string) =>
+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, edit: id }) as never })
+
+ useRowClickBridge('data-customer-group-id', openEdit)
+
+ return (
+ <>
+ <ResourceTable<CustomerGroup>
+ tableKey="customer-groups"
+ queryKey="customer-groups"
+ queryFn={(params) => adminClient.customerGroups.list(params)}
+ searchParams={search}
+ actions={
+ <Can I="create" a={Subject.CustomerGroup}>
+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>
+ <PlusIcon className="size-4" />
+ Add customer group
+ </Button>
+ </Can>
+ }
+ />
+
+ {isCreating && <CreateCustomerGroupSheet open onOpenChange={(o) => !o && closeSheet()} />}
+ {editId && (
+ <EditCustomerGroupSheet id={editId} open onOpenChange={(o) => !o && closeSheet()} />
+ )}
+ </>
+ )
+}
+
+const formSchema = z.object({
+ name: z.string().min(1, 'Name is required'),
+ description: z.string().optional(),
+})
+
+type FormValues = z.infer<typeof formSchema>
+
+const DEFAULT_VALUES: FormValues = { name: '', description: '' }
+
+function valuesToParams(v: FormValues): CustomerGroupCreateParams & CustomerGroupUpdateParams {
+ return {
+ name: v.name,
+ description: v.description && v.description.length > 0 ? v.description : null,
+ }
+}
+
+function CreateCustomerGroupSheet({
+ open,
+ onOpenChange,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const createMutation = useCreateCustomerGroup()
+ const form = useForm<FormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(formSchema) as any,
+ defaultValues: DEFAULT_VALUES,
+ })
+
+ async function onSubmit(values: FormValues) {
+ await createMutation.mutateAsync(valuesToParams(values) as CustomerGroupCreateParams)
+ form.reset(DEFAULT_VALUES)
+ onOpenChange(false)
+ }
+
+ return (
+ <Sheet
+ open={open}
+ onOpenChange={(next) => {
+ if (!next) form.reset(DEFAULT_VALUES)
+ onOpenChange(next)
+ }}
+ >
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>Add customer group</SheetTitle>
+ <SheetDescription>
+ Groups segment customers for targeted promotions and reporting. After creating, assign
+ customers from the Customers screen using bulk actions.
+ </SheetDescription>
+ </SheetHeader>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <NameDescriptionFields form={form} />
+ </div>
+ <SheetFooter>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ Cancel
+ </Button>
+ <Button type="submit" size="sm" disabled={form.formState.isSubmitting}>
+ {form.formState.isSubmitting ? 'Creating…' : 'Create customer group'}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function EditCustomerGroupSheet({
+ id,
+ open,
+ onOpenChange,
+}: {
+ id: string
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { storeId } = Route.useParams()
+ const { data: group, isLoading } = useCustomerGroup(id)
+ const updateMutation = useUpdateCustomerGroup(id)
+ const deleteMutation = useDeleteCustomerGroup()
+ const confirm = useConfirm()
+
+ const form = useForm<FormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(formSchema) as any,
+ defaultValues: DEFAULT_VALUES,
+ })
+
+ useEffect(() => {
+ if (group) {
+ form.reset({
+ name: group.name,
+ description: group.description ?? '',
+ })
+ }
+ }, [group, form])
+
+ async function onSubmit(values: FormValues) {
+ await updateMutation.mutateAsync(valuesToParams(values))
+ form.reset(values)
+ onOpenChange(false)
+ }
+
+ async function onDelete() {
+ const ok = await confirm({
+ title: 'Delete customer group?',
+ message: `${group?.name ?? 'This group'} will be removed. Customers in it will not be deleted.`,
+ variant: 'destructive',
+ confirmLabel: 'Delete',
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(id)
+ onOpenChange(false)
+ }
+
+ // Filter the /customers index by this group's id. Ransack join filter on the
+ // `customer_groups` association — server uses `customer_groups_id_in`.
+ const membersFilter = JSON.stringify([
+ { id: 'group', field: 'customer_groups_id', operator: 'in', value: id },
+ ])
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{group?.name ?? 'Edit customer group'}</SheetTitle>
+ <SheetDescription>Update the name or description.</SheetDescription>
+ </SheetHeader>
+ {isLoading ? (
+ <div className="p-4 text-sm text-muted-foreground">Loading…</div>
+ ) : (
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <NameDescriptionFields form={form} />
+ <MembersSummary
+ count={group?.customers_count ?? 0}
+ href={`/${storeId}/customers?filters=${encodeURIComponent(membersFilter)}`}
+ />
+ </div>
+ <SheetFooter>
+ <Can I="destroy" a={Subject.CustomerGroup}>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={onDelete}
+ disabled={form.formState.isSubmitting || deleteMutation.isPending}
+ className="mr-auto text-destructive hover:bg-destructive/10 hover:text-destructive"
+ >
+ Delete
+ </Button>
+ </Can>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ size="sm"
+ disabled={form.formState.isSubmitting || !form.formState.isDirty}
+ >
+ {form.formState.isSubmitting ? 'Saving…' : 'Save'}
+ </Button>
+ </SheetFooter>
+ </form>
+ )}
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function NameDescriptionFields({
+ form,
+}: {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ form: any
+}) {
+ return (
+ <FieldGroup>
+ <Field>
+ <FieldLabel htmlFor="name">Name</FieldLabel>
+ <Input
+ id="name"
+ autoFocus
+ placeholder="e.g. VIP customers"
+ {...form.register('name')}
+ aria-invalid={!!form.formState.errors.name}
+ />
+ {form.formState.errors.name && (
+ <p className="text-sm text-destructive">{form.formState.errors.name.message}</p>
+ )}
+ </Field>
+
+ <Field>
+ <FieldLabel htmlFor="description">Description</FieldLabel>
+ <Textarea
+ id="description"
+ rows={3}
+ placeholder="Optional internal description"
+ {...form.register('description')}
+ />
+ </Field>
+ </FieldGroup>
+ )
+}
+
+function MembersSummary({ count, href }: { count: number; href: string }) {
+ return (
+ <div className="flex items-center justify-between rounded-md border bg-muted/40 px-3 py-2">
+ <div className="flex items-center gap-2 text-sm">
+ <UsersIcon className="size-4 text-muted-foreground" />
+ <span>
+ <span className="font-medium">{count}</span> {count === 1 ? 'customer' : 'customers'} in
+ this group
+ </span>
+ </div>
+ <Link to={href as never} className="text-sm font-medium text-primary hover:underline">
+ View members
+ </Link>
+ </div>
+ )
+}
diff --git a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
index 8db77a3645..945c3b1c27 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
@@ -1,13 +1,16 @@
import { useMutation } from '@tanstack/react-query'
import { createFileRoute, useNavigate } from '@tanstack/react-router'
-import { PlusIcon } from 'lucide-react'
+import { PlusIcon, UserMinusIcon, UserPlusIcon } from 'lucide-react'
import { type FormEvent, useState } from 'react'
import { z } from 'zod/v4'
import { adminClient } from '@/client'
+import type { BulkAction, BulkActionFormProps } from '@/components/spree/bulk-action-bar'
import { ExportButton } from '@/components/spree/export-button'
+import { ResourceMultiAutocomplete } from '@/components/spree/resource-multi-autocomplete'
import { ResourceTable, resourceSearchSchema } from '@/components/spree/resource-table'
import { TagCombobox } from '@/components/spree/tag-combobox'
import { Button } from '@/components/ui/button'
+import { Checkbox } from '@/components/ui/checkbox'
import { Field, FieldGroup, FieldLabel } from '@/components/ui/field'
import { Input } from '@/components/ui/input'
import {
@@ -19,6 +22,8 @@ import {
SheetTitle,
} from '@/components/ui/sheet'
import { Textarea } from '@/components/ui/textarea'
+import { customerGroupAutocompleteProps } from '@/hooks/use-customer-groups'
+import { Subject } from '@/lib/permissions'
import '@/tables/customers'
// Adds `?new=1` on top of the standard table search schema so the create sheet
@@ -32,6 +37,45 @@ export const Route = createFileRoute('/_authenticated/$storeId/customers/')({
component: CustomersPage,
})
+type GroupFormValues = { customer_group_ids: string[] }
+
+// Bulk-mutating customers shifts `customers_count` on every affected group, so
+// drop the groups cache to force a refetch when the user navigates back.
+const GROUP_INVALIDATIONS = [['customer-groups']]
+
+const BULK_ACTIONS: BulkAction<GroupFormValues>[] = [
+ {
+ key: 'add-to-groups',
+ label: 'Add to group…',
+ icon: <UserPlusIcon className="size-4" />,
+ subject: Subject.Customer,
+ form: (props) => <GroupPickerSheet {...props} mode="add" />,
+ run: ({ ids, formValues }) =>
+ adminClient.customers.bulkAddToGroups({
+ ids,
+ customer_group_ids: formValues?.customer_group_ids ?? [],
+ }),
+ invalidate: GROUP_INVALIDATIONS,
+ successMessage: 'Added {n} customers to groups',
+ errorMessage: 'Failed to add customers to groups',
+ },
+ {
+ key: 'remove-from-groups',
+ label: 'Remove from group…',
+ icon: <UserMinusIcon className="size-4" />,
+ subject: Subject.Customer,
+ form: (props) => <GroupPickerSheet {...props} mode="remove" />,
+ run: ({ ids, formValues }) =>
+ adminClient.customers.bulkRemoveFromGroups({
+ ids,
+ customer_group_ids: formValues?.customer_group_ids ?? [],
+ }),
+ invalidate: GROUP_INVALIDATIONS,
+ successMessage: 'Removed {n} customers from groups',
+ errorMessage: 'Failed to remove customers from groups',
+ },
+]
+
function CustomersPage() {
const search = Route.useSearch() as z.infer<typeof customersSearchSchema>
const navigate = useNavigate()
@@ -58,6 +102,8 @@ function CustomersPage() {
queryKey="customers"
queryFn={(params) => adminClient.customers.list(params)}
searchParams={search}
+ defaultParams={{ expand: ['customer_groups'] }}
+ bulkActions={BULK_ACTIONS}
actions={(ctx) => (
<>
<ExportButton type="Spree::Exports::Customers" {...ctx} />
@@ -73,6 +119,62 @@ function CustomersPage() {
)
}
+/**
+ * Multi-select group picker used by the bulk add/remove actions. Resolves
+ * with `{ customer_group_ids }` so the same component drives both verbs.
+ */
+function GroupPickerSheet({
+ ids,
+ onSubmit,
+ onCancel,
+ mode,
+}: BulkActionFormProps<GroupFormValues> & { mode: 'add' | 'remove' }) {
+ const [groupIds, setGroupIds] = useState<string[]>([])
+ const verb = mode === 'add' ? 'Add' : 'Remove'
+
+ return (
+ <Sheet open onOpenChange={(o) => !o && onCancel()}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>
+ {verb} {ids.length} customers to groups
+ </SheetTitle>
+ <SheetDescription>
+ {mode === 'add'
+ ? 'Selected customers will be added to every group you pick. Already-members are skipped.'
+ : 'Selected customers will be removed from every group you pick. Non-members are skipped.'}
+ </SheetDescription>
+ </SheetHeader>
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <FieldGroup>
+ <Field>
+ <FieldLabel>Customer groups</FieldLabel>
+ <ResourceMultiAutocomplete
+ {...customerGroupAutocompleteProps('customer-groups-picker')}
+ value={groupIds}
+ onChange={setGroupIds}
+ />
+ </Field>
+ </FieldGroup>
+ </div>
+ <SheetFooter>
+ <Button type="button" variant="outline" size="sm" onClick={onCancel}>
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ size="sm"
+ disabled={groupIds.length === 0}
+ onClick={() => onSubmit({ customer_group_ids: groupIds })}
+ >
+ {verb}
+ </Button>
+ </SheetFooter>
+ </SheetContent>
+ </Sheet>
+ )
+}
+
// ============================================================================
// Create Sheet
// ============================================================================
@@ -160,12 +262,15 @@ function NewCustomerSheet({
<TagCombobox taggableType="Spree::User" value={tags} onChange={setTags} />
</Field>
<Field>
- <label className="flex items-center gap-2 text-sm">
- <input
- type="checkbox"
+ <label
+ htmlFor="accepts_email_marketing"
+ className="flex items-center gap-2 text-sm"
+ >
+ <Checkbox
+ id="accepts_email_marketing"
name="accepts_email_marketing"
checked={acceptsMarketing}
- onChange={(e) => setAcceptsMarketing(e.target.checked)}
+ onCheckedChange={setAcceptsMarketing}
/>
Subscribed to marketing
</label>
diff --git a/packages/admin/src/tables/customer-groups.tsx b/packages/admin/src/tables/customer-groups.tsx
new file mode 100644
index 0000000000..7f1a13ded1
--- /dev/null
+++ b/packages/admin/src/tables/customer-groups.tsx
@@ -0,0 +1,37 @@
+import type { CustomerGroup } from '@spree/admin-sdk'
+import { UsersRoundIcon } from 'lucide-react'
+import { ResourceNameCell } from '@/components/spree/resource-name-cell'
+import { defineTable } from '@/lib/table-registry'
+
+defineTable<CustomerGroup>('customer-groups', {
+ title: 'Customer Groups',
+ searchParam: 'name_cont',
+ searchPlaceholder: 'Search by name…',
+ defaultSort: { field: 'name', direction: 'asc' },
+ emptyIcon: <UsersRoundIcon className="size-8 text-muted-foreground/50" />,
+ emptyMessage: 'No customer groups yet',
+ columns: [
+ {
+ key: 'name',
+ label: 'Name',
+ sortable: true,
+ filterable: true,
+ default: true,
+ render: (g) => (
+ <ResourceNameCell
+ id={g.id}
+ dataAttr="data-customer-group-id"
+ name={g.name}
+ secondary={g.description ?? undefined}
+ />
+ ),
+ },
+ {
+ key: 'customers_count',
+ label: 'Customers',
+ sortable: true,
+ default: true,
+ render: (g) => g.customers_count,
+ },
+ ],
+})
diff --git a/packages/admin/src/tables/customers.tsx b/packages/admin/src/tables/customers.tsx
index a2ed5787c9..b54564f007 100644
--- a/packages/admin/src/tables/customers.tsx
+++ b/packages/admin/src/tables/customers.tsx
@@ -1,7 +1,8 @@
import { Link } from '@tanstack/react-router'
import { UsersIcon } from 'lucide-react'
import { RelativeTime } from '@/components/spree/relative-time'
-import { ActiveBadge } from '@/components/ui/badge'
+import { ActiveBadge, Badge } from '@/components/ui/badge'
+import { customerGroupAutocompleteProps } from '@/hooks/use-customer-groups'
import { defineTable } from '@/lib/table-registry'
defineTable('customers', {
@@ -68,6 +69,30 @@ defineTable('customers', {
className: 'text-sm text-muted-foreground whitespace-nowrap',
render: (c) => <RelativeTime iso={c.last_order_completed_at} />,
},
+ {
+ key: 'customer_groups',
+ label: 'Groups',
+ default: false,
+ filterable: true,
+ filterType: 'resource',
+ // `users.customer_groups.id` join — backed by the
+ // `customer_groups` whitelisted_ransackable_association on User.
+ ransackAttribute: 'customer_groups_id',
+ filterResource: customerGroupAutocompleteProps('customer-groups-picker'),
+ render: (c) => {
+ const groups = c.customer_groups ?? []
+ if (groups.length === 0) return '—'
+ return (
+ <div className="flex flex-wrap gap-1">
+ {groups.map((g: { id: string; name: string }) => (
+ <Badge key={g.id} variant="secondary">
+ {g.name}
+ </Badge>
+ ))}
+ </div>
+ )
+ },
+ },
{
key: 'accepts_email_marketing',
label: 'Newsletter',
diff --git a/spree/api/app/controllers/spree/api/v3/admin/customer_groups_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/customer_groups_controller.rb
index 3bb2fcaf5e..32f4706730 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/customer_groups_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/customer_groups_controller.rb
@@ -5,6 +5,8 @@ module Spree
# Admin CRUD for `Spree::CustomerGroup`. Scoped to the current
# store so groups from sibling stores don't leak into pickers.
class CustomerGroupsController < ResourceController
+ scoped_resource :customers
+
protected
def model_class
@@ -20,7 +22,7 @@ module Spree
end
def permitted_params
- params.permit(:name)
+ params.permit(:name, :description, customer_ids: [])
end
end
end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/customers_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/customers_controller.rb
index e116578953..b498411e8b 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/customers_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/customers_controller.rb
@@ -45,6 +45,17 @@ module Spree
)
end
+ # Bulk add the given customers to the given groups. Idempotent —
+ # customers already in a group are skipped at the model layer.
+ def bulk_add_to_groups
+ apply_groups(:add_customers)
+ end
+
+ # Bulk remove the given customers from the given groups.
+ def bulk_remove_from_groups
+ apply_groups(:remove_customers)
+ end
+
protected
def model_class
@@ -73,6 +84,29 @@ module Spree
metadata: {}, tags: []
)
end
+
+ # Authorises bulk group mutation, decodes prefixed IDs, then dispatches
+ # to `add_customers` / `remove_customers` per group. Returns the
+ # counts of records actually affected so the UI can show a toast.
+ def apply_groups(method)
+ authorize! :update, model_class
+
+ user_ids = decode_ids(params[:ids], model_class)
+ group_ids = decode_ids(params[:customer_group_ids], Spree::CustomerGroup)
+
+ scoped_user_ids = scope.where(id: user_ids).pluck(:id)
+ scoped_groups = Spree::CustomerGroup.for_store(current_store).where(id: group_ids)
+
+ scoped_groups.find_each { |group| group.public_send(method, scoped_user_ids) }
+
+ render json: { customer_count: scoped_user_ids.size, customer_group_count: scoped_groups.size }
+ end
+
+ def decode_ids(ids, klass)
+ Array(ids).map do |id|
+ Spree::PrefixedId.prefixed_id?(id) ? klass.find_by_param!(id).id : id
+ end
+ end
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/customer_group_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/customer_group_serializer.rb
index 2140c7100f..3ac9dfa338 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/customer_group_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/customer_group_serializer.rb
@@ -7,10 +7,19 @@ module Spree
# what the admin UI needs to display + select rows.
class CustomerGroupSerializer < V3::BaseSerializer
typelize name: :string,
- users_count: :number
+ description: 'string | null',
+ customers_count: :number
- attributes :name, :users_count,
+ attributes :name, :description, :customers_count,
created_at: :iso8601, updated_at: :iso8601
+
+ # Members are paginated separately via `/customers?customer_group_id_in=…`
+ # because a group can hold tens of thousands of users — embedding the
+ # whole list on every group fetch would explode the index payload.
+ # Pass `expand=customers` when you need them inline (single-record reads only).
+ many :customers,
+ resource: Spree.api.admin_customer_serializer,
+ if: proc { expand?('customers') }
end
end
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/customer_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/customer_serializer.rb
index aef729f52e..47a5b44b75 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/customer_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/customer_serializer.rb
@@ -91,6 +91,10 @@ module Spree
many :store_credits,
resource: Spree.api.admin_store_credit_serializer,
if: proc { expand?('store_credits') }
+
+ many :customer_groups,
+ resource: Spree.api.admin_customer_group_serializer,
+ if: proc { expand?('customer_groups') }
end
end
end
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 315727a9a8..204ab71ef9 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -219,6 +219,11 @@ Spree::Core::Engine.add_routes do
resources :addresses, controller: 'customers/addresses'
resources :credit_cards, controller: 'customers/credit_cards', only: [:index, :show, :destroy]
resources :store_credits, controller: 'customers/store_credits'
+
+ collection do
+ post :bulk_add_to_groups
+ post :bulk_remove_from_groups
+ end
end
# Customer groups (segmentation; used by promotion rules + bulk customer ops)
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/customer_groups_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/customer_groups_controller_spec.rb
new file mode 100644
index 0000000000..a04a7d1bc6
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/customer_groups_controller_spec.rb
@@ -0,0 +1,166 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::CustomerGroupsController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:customer_group) { create(:customer_group, store: store, name: 'VIPs', description: 'Top spenders') }
+
+ before { request.headers.merge!(headers) }
+
+ describe 'GET #index' do
+ subject { get :index, as: :json }
+
+ it 'returns customer groups in the current store' do
+ subject
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data']).to be_an(Array)
+ expect(json_response['data'].map { |g| g['id'] }).to include(customer_group.prefixed_id)
+ expect(json_response['data'].first['customers_count']).to eq(0)
+ end
+
+ it 'excludes groups from other stores' do
+ other_store = create(:store)
+ other_group = create(:customer_group, store: other_store, name: 'Other')
+
+ subject
+ ids = json_response['data'].map { |g| g['id'] }
+ expect(ids).to include(customer_group.prefixed_id)
+ expect(ids).not_to include(other_group.prefixed_id)
+ end
+
+ it 'does not embed customers in the list payload' do
+ create(:user).then { |u| customer_group.customers << u }
+
+ subject
+ entry = json_response['data'].find { |g| g['id'] == customer_group.prefixed_id }
+ expect(entry).not_to have_key('customers')
+ expect(entry['customers_count']).to eq(1)
+ end
+ end
+
+ describe 'GET #show' do
+ subject { get :show, params: { id: customer_group.prefixed_id }, as: :json }
+
+ it 'returns the group without customers by default' do
+ subject
+ expect(response).to have_http_status(:ok)
+ expect(json_response['id']).to eq(customer_group.prefixed_id)
+ expect(json_response['name']).to eq('VIPs')
+ expect(json_response['description']).to eq('Top spenders')
+ expect(json_response).not_to have_key('customers')
+ end
+
+ it 'embeds customers when expand=customers is passed' do
+ user = create(:user, email: '[email protected]')
+ customer_group.customers << user
+
+ get :show, params: { id: customer_group.prefixed_id, expand: 'customers' }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['customers']).to be_an(Array)
+ expect(json_response['customers'].map { |c| c['email'] }).to include('[email protected]')
+ end
+
+ it 'returns 404 for a group from another store' do
+ other_group = create(:customer_group, store: create(:store))
+
+ get :show, params: { id: other_group.prefixed_id }, as: :json
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+
+ describe 'POST #create' do
+ let(:create_params) { { name: 'Wholesale', description: 'B2B accounts' } }
+
+ it 'creates a group scoped to the current store' do
+ expect { post :create, params: create_params, as: :json }.to change(Spree::CustomerGroup, :count).by(1)
+
+ expect(response).to have_http_status(:created)
+ expect(json_response['name']).to eq('Wholesale')
+ expect(json_response['description']).to eq('B2B accounts')
+ expect(json_response['customers_count']).to eq(0)
+ expect(Spree::CustomerGroup.last.store).to eq(store)
+ end
+
+ it 'attaches customers when customer_ids is given (decodes prefixed IDs)' do
+ alice = create(:user, email: '[email protected]')
+ bob = create(:user, email: '[email protected]')
+
+ post :create, params: create_params.merge(customer_ids: [alice.prefixed_id, bob.prefixed_id]), as: :json
+
+ expect(response).to have_http_status(:created)
+ group = Spree::CustomerGroup.find(Spree::PrefixedId.decode_prefixed_id(json_response['id']))
+ expect(group.customers).to match_array([alice, bob])
+ end
+
+ it 'returns 422 when name is missing' do
+ post :create, params: { description: 'no name' }, as: :json
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+
+ it 'returns 422 when name is duplicated within the same store' do
+ post :create, params: { name: 'VIPs' }, as: :json
+ expect(response).to have_http_status(:unprocessable_content)
+ end
+ end
+
+ describe 'PATCH #update' do
+ it 'updates name and description' do
+ patch :update, params: { id: customer_group.prefixed_id, name: 'Updated', description: 'New desc' }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ customer_group.reload
+ expect(customer_group.name).to eq('Updated')
+ expect(customer_group.description).to eq('New desc')
+ end
+
+ it 'reconciles customer_ids on update (adds + removes)' do
+ alice = create(:user)
+ bob = create(:user)
+ carol = create(:user)
+ customer_group.customers << [alice, bob]
+
+ patch :update, params: { id: customer_group.prefixed_id, customer_ids: [bob.prefixed_id, carol.prefixed_id] }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(customer_group.reload.customers).to match_array([bob, carol])
+ end
+
+ it 'clears membership when an empty array is sent' do
+ customer_group.customers << create(:user)
+
+ patch :update, params: { id: customer_group.prefixed_id, customer_ids: [] }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(customer_group.reload.customers).to be_empty
+ end
+
+ it 'returns 404 for a group from another store' do
+ other_group = create(:customer_group, store: create(:store))
+
+ patch :update, params: { id: other_group.prefixed_id, name: 'Hacked' }, as: :json
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'soft-deletes the customer group' do
+ target = create(:customer_group, store: store)
+
+ expect { delete :destroy, params: { id: target.prefixed_id }, as: :json }.
+ to change { Spree::CustomerGroup.where(id: target.id).count }.by(-1)
+
+ expect(response).to have_http_status(:no_content)
+ expect(Spree::CustomerGroup.with_deleted.exists?(id: target.id)).to be true
+ end
+
+ it 'returns 404 for a group from another store' do
+ other_group = create(:customer_group, store: create(:store))
+
+ delete :destroy, params: { id: other_group.prefixed_id }, as: :json
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/customers_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/customers_controller_spec.rb
index 2b27310ad3..d9c2ded545 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/customers_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/customers_controller_spec.rb
@@ -170,4 +170,74 @@ RSpec.describe Spree::Api::V3::Admin::CustomersController, type: :controller do
end
end
end
+
+ describe 'POST #bulk_add_to_groups' do
+ let(:alice) { create(:user, email: '[email protected]') }
+ let(:bob) { create(:user, email: '[email protected]') }
+ let(:vip) { create(:customer_group, store: store, name: 'VIPs') }
+ let(:wholesale) { create(:customer_group, store: store, name: 'Wholesale') }
+
+ it 'adds the listed customers to every listed group' do
+ post :bulk_add_to_groups, params: {
+ ids: [alice.prefixed_id, bob.prefixed_id],
+ customer_group_ids: [vip.prefixed_id, wholesale.prefixed_id]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(vip.reload.customers).to match_array([alice, bob])
+ expect(wholesale.reload.customers).to match_array([alice, bob])
+ expect(json_response).to eq('customer_count' => 2, 'customer_group_count' => 2)
+ end
+
+ it 'is idempotent — re-adding existing members is a no-op' do
+ vip.customers << alice
+
+ post :bulk_add_to_groups, params: {
+ ids: [alice.prefixed_id], customer_group_ids: [vip.prefixed_id]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(vip.reload.customers.size).to eq(1)
+ end
+
+ it 'ignores customer groups from other stores' do
+ other_group = create(:customer_group, store: create(:store))
+
+ post :bulk_add_to_groups, params: {
+ ids: [alice.prefixed_id], customer_group_ids: [other_group.prefixed_id]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(other_group.reload.customers).to be_empty
+ expect(json_response['customer_group_count']).to eq(0)
+ end
+ end
+
+ describe 'POST #bulk_remove_from_groups' do
+ let(:alice) { create(:user, email: '[email protected]') }
+ let(:bob) { create(:user, email: '[email protected]') }
+ let(:vip) { create(:customer_group, store: store, name: 'VIPs') }
+
+ before { vip.customers << [alice, bob] }
+
+ it 'removes the listed customers from every listed group' do
+ post :bulk_remove_from_groups, params: {
+ ids: [alice.prefixed_id], customer_group_ids: [vip.prefixed_id]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(vip.reload.customers).to eq([bob])
+ end
+
+ it 'is a no-op for non-members' do
+ stranger = create(:user)
+
+ post :bulk_remove_from_groups, params: {
+ ids: [stranger.prefixed_id], customer_group_ids: [vip.prefixed_id]
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(vip.reload.customers).to match_array([alice, bob])
+ end
+ end
end
diff --git a/spree/api/spec/integration/spree/api/v3/admin/customer_groups_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/customer_groups_spec.rb
new file mode 100644
index 0000000000..450d566dce
--- /dev/null
+++ b/spree/api/spec/integration/spree/api/v3/admin/customer_groups_spec.rb
@@ -0,0 +1,253 @@
+# frozen_string_literal: true
+
+require 'swagger_helper'
+
+RSpec.describe 'Admin Customer Groups API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
+ include_context 'API v3 Admin'
+
+ let(:Authorization) { "Bearer #{admin_jwt_token}" }
+ let!(:customer_group) { create(:customer_group, store: store, name: 'VIPs', description: 'Top spenders') }
+ let!(:other_group) { create(:customer_group, store: store, name: 'Wholesale') }
+
+ path '/api/v3/admin/customer_groups' do
+ get 'List customer groups' do
+ tags 'Customers'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Returns the customer groups configured for the current store. Groups
+ segment customers for targeted promotions (see the `customer_group`
+ promotion rule) and reporting. The list endpoint never embeds the
+ member list — fetch a single group with `?expand=customers` if you
+ need them inline, or query `/admin/customers?customer_group_id_in=…`
+ for paginated membership.
+ DESC
+ admin_scope :read, :customers
+
+ admin_sdk_example 'customer-groups/list'
+
+ 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: :'q[name_cont]', in: :query, type: :string, required: false,
+ description: 'Filter by name (contains)'
+ parameter name: :sort, in: :query, type: :string, required: false,
+ description: 'Sort by field. Prefix with `-` for descending (e.g., `-created_at`).'
+ parameter name: :fields, in: :query, type: :string, required: false,
+ description: 'Comma-separated list of fields to include. id is always included.'
+
+ response '200', 'customer groups found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+
+ schema SwaggerSchemaHelpers.paginated('CustomerGroup')
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['data']).to be_an(Array)
+ ids = data['data'].pluck('id')
+ expect(ids).to include(customer_group.prefixed_id, other_group.prefixed_id)
+ # Index payload never embeds customers, even for non-empty groups.
+ expect(data['data'].first).not_to have_key('customers')
+ end
+ end
+
+ response '401', 'unauthorized' do
+ let(:'x-spree-api-key') { 'invalid' }
+ let(:Authorization) { 'Bearer invalid' }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+
+ post 'Create a customer group' do
+ tags 'Customers'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Creates a customer group in the current store. `customer_ids` is
+ optional; when present, customers are attached at create time.
+ Pass prefixed IDs (e.g. `cus_…`) — the server decodes them
+ automatically.
+ DESC
+ admin_scope :write, :customers
+
+ admin_sdk_example 'customer-groups/create'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[name],
+ properties: {
+ name: { type: :string, example: 'Wholesale' },
+ description: { type: :string, example: 'B2B accounts', nullable: true },
+ customer_ids: { type: :array, items: { type: :string }, example: ['cus_UkLWZg9DAJ'] }
+ }
+ }
+
+ response '201', 'customer group created' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:alice) { create(:user) }
+ let(:body) { { name: 'Wholesale 2', description: 'B2B accounts', customer_ids: [alice.prefixed_id] } }
+
+ schema '$ref' => '#/components/schemas/CustomerGroup'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['name']).to eq('Wholesale 2')
+ expect(data['description']).to eq('B2B accounts')
+ expect(data['customers_count']).to eq(1)
+ end
+ end
+
+ response '422', 'validation error' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:body) { { name: '' } }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+ end
+
+ path '/api/v3/admin/customer_groups/{id}' do
+ parameter name: :id, in: :path, type: :string, required: true, description: 'Customer group prefixed ID'
+
+ get 'Get a customer group' do
+ tags 'Customers'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Returns a single customer group. Pass `?expand=customers` to embed
+ the full member list inline (recommended only for single-record
+ reads — embed cost scales with membership size).
+ DESC
+ admin_scope :read, :customers
+
+ admin_sdk_example 'customer-groups/get'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :expand, in: :query, type: :string, required: false,
+ description: 'Comma-separated associations to embed. Supported: `customers`.'
+ parameter name: :fields, in: :query, type: :string, required: false,
+ description: 'Comma-separated list of fields to include. id is always included.'
+
+ response '200', 'customer group found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { customer_group.prefixed_id }
+
+ schema '$ref' => '#/components/schemas/CustomerGroup'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['id']).to eq(customer_group.prefixed_id)
+ expect(data['name']).to eq('VIPs')
+ expect(data['description']).to eq('Top spenders')
+ expect(data).not_to have_key('customers')
+ end
+ end
+
+ response '200', 'customer group with embedded customers' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { customer_group.prefixed_id }
+ let(:expand) { 'customers' }
+ let(:alice) { create(:user) }
+
+ before { customer_group.customers << alice }
+
+ schema '$ref' => '#/components/schemas/CustomerGroup'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['customers']).to be_an(Array)
+ expect(data['customers'].pluck('id')).to include(alice.prefixed_id)
+ end
+ end
+
+ response '404', 'customer group not found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { 'cg_nonexistent' }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+
+ patch 'Update a customer group' do
+ tags 'Customers'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Updates name, description, or membership. `customer_ids` is a
+ full-set replacement — the server reconciles the membership to
+ match the array, adding new IDs and removing ones not present.
+ Send `customer_ids: []` to clear all members.
+ DESC
+ admin_scope :write, :customers
+
+ admin_sdk_example 'customer-groups/update'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ properties: {
+ name: { type: :string, example: 'VIP customers (Q1)' },
+ description: { type: :string, example: 'Updated description', nullable: true },
+ customer_ids: { type: :array, items: { type: :string }, example: ['cus_UkLWZg9DAJ'] }
+ }
+ }
+
+ response '200', 'customer group updated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { customer_group.prefixed_id }
+ let(:body) { { name: 'VIP customers (Q1)' } }
+
+ schema '$ref' => '#/components/schemas/CustomerGroup'
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['name']).to eq('VIP customers (Q1)')
+ end
+ end
+
+ response '422', 'validation error' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { customer_group.prefixed_id }
+ let(:body) { { name: '' } }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+
+ delete 'Delete a customer group' do
+ tags 'Customers'
+ security [api_key: [], bearer_auth: []]
+ description 'Soft-deletes the group. Member users are not deleted; their `customer_group_users` rows are dropped.'
+ admin_scope :write, :customers
+
+ admin_sdk_example 'customer-groups/delete'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+
+ response '204', 'customer group deleted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:id) { customer_group.prefixed_id }
+
+ run_test!
+ end
+ end
+ end
+end
diff --git a/spree/api/spec/integration/spree/api/v3/admin/customers_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/customers_spec.rb
index 3c3257c049..23d9087737 100644
--- a/spree/api/spec/integration/spree/api/v3/admin/customers_spec.rb
+++ b/spree/api/spec/integration/spree/api/v3/admin/customers_spec.rb
@@ -168,4 +168,96 @@ RSpec.describe 'Admin Customers API', type: :request, swagger_doc: 'api-referenc
end
end
end
+
+ path '/api/v3/admin/customers/bulk_add_to_groups' do
+ post 'Bulk-add customers to groups' do
+ tags 'Customers'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Attaches each customer in `ids` to every group in `customer_group_ids`.
+ Idempotent — customers already in a group are skipped server-side.
+ Groups from sibling stores are silently ignored. Returns counts of
+ customers and groups that were processed (post store-scoping).
+ DESC
+ admin_scope :write, :customers
+
+ admin_sdk_example 'customers/bulk-add-to-groups'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[ids customer_group_ids],
+ properties: {
+ ids: { type: :array, items: { type: :string }, example: ['cus_UkLWZg9DAJ', 'cus_QrLWXg9CAJ'] },
+ customer_group_ids: { type: :array, items: { type: :string }, example: ['cg_UkLWZg9DAJ'] }
+ }
+ }
+
+ response '200', 'customers added to groups' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:alice) { create(:user) }
+ let(:vip_group) { create(:customer_group, store: store, name: 'VIPs') }
+ let(:body) { { ids: [alice.prefixed_id], customer_group_ids: [vip_group.prefixed_id] } }
+
+ schema type: :object, properties: {
+ customer_count: { type: :integer },
+ customer_group_count: { type: :integer }
+ }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data).to eq('customer_count' => 1, 'customer_group_count' => 1)
+ end
+ end
+ end
+ end
+
+ path '/api/v3/admin/customers/bulk_remove_from_groups' do
+ post 'Bulk-remove customers from groups' do
+ tags 'Customers'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description <<~DESC
+ Detaches each customer in `ids` from every group in `customer_group_ids`.
+ No-op for non-members. Groups from sibling stores are silently ignored.
+ DESC
+ admin_scope :write, :customers
+
+ admin_sdk_example 'customers/bulk-remove-from-groups'
+
+ parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
+ parameter name: :Authorization, in: :header, type: :string, required: true
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ required: %w[ids customer_group_ids],
+ properties: {
+ ids: { type: :array, items: { type: :string }, example: ['cus_UkLWZg9DAJ'] },
+ customer_group_ids: { type: :array, items: { type: :string }, example: ['cg_UkLWZg9DAJ'] }
+ }
+ }
+
+ response '200', 'customers removed from groups' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:alice) { create(:user) }
+ let(:vip_group) { create(:customer_group, store: store, name: 'VIPs') }
+ let(:body) { { ids: [alice.prefixed_id], customer_group_ids: [vip_group.prefixed_id] } }
+
+ before { vip_group.customers << alice }
+
+ schema type: :object, properties: {
+ customer_count: { type: :integer },
+ customer_group_count: { type: :integer }
+ }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data).to eq('customer_count' => 1, 'customer_group_count' => 1)
+ end
+ end
+ end
+ end
end
diff --git a/spree/core/app/models/concerns/spree/user_methods.rb b/spree/core/app/models/concerns/spree/user_methods.rb
index dfd7d99c09..0fe93db6b2 100644
--- a/spree/core/app/models/concerns/spree/user_methods.rb
+++ b/spree/core/app/models/concerns/spree/user_methods.rb
@@ -126,7 +126,7 @@ module Spree
# Backward compatibility alias — remove in Spree 6.0
def self.multi_search(query) = search(query)
- self.whitelisted_ransackable_associations = %w[bill_address ship_address addresses tags spree_roles orders]
+ self.whitelisted_ransackable_associations = %w[bill_address ship_address addresses tags spree_roles orders customer_groups]
self.whitelisted_ransackable_attributes = %w[id email first_name last_name phone accepts_email_marketing
created_at updated_at last_sign_in_at]
self.whitelisted_ransackable_scopes = %w[search multi_search with_min_total_spent]
diff --git a/spree/core/app/models/spree/customer_group.rb b/spree/core/app/models/spree/customer_group.rb
index 00e855e52a..62dea31ce1 100644
--- a/spree/core/app/models/spree/customer_group.rb
+++ b/spree/core/app/models/spree/customer_group.rb
@@ -10,6 +10,11 @@ module Spree
belongs_to :store, class_name: 'Spree::Store', inverse_of: :customer_groups
has_many :customer_group_users, class_name: 'Spree::CustomerGroupUser', dependent: :destroy
has_many :users, through: :customer_group_users, source: :user, source_type: Spree.user_class.to_s
+ # `customers` is the public name across the v3 API; declaring it as its
+ # own association (rather than `alias_method`) is what lets `customer_ids=`
+ # exist and what makes the `PrefixedId` auto-decoder in `assign_attributes`
+ # recognise the key — that lookup keys off `reflect_on_association(:customers)`.
+ has_many :customers, through: :customer_group_users, source: :user, source_type: Spree.user_class.to_s
#
# Validations
@@ -25,9 +30,10 @@ module Spree
#
# Instance Methods
#
- def users_count
- customer_group_users.count
+ def customers_count
+ customer_group_users.size
end
+ alias_method :users_count, :customers_count
# Bulk add customers to the group
# @param user_ids [Array] array of user IDs to add