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.

Improve Asset management in Admin API

Damian Legawieccb0eb151fdf2
diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yaml
index 8e38752326..a5e759a51d 100644
--- a/docs/api-reference/admin.yaml
+++ b/docs/api-reference/admin.yaml
@@ -38,226 +38,6 @@ info:
```
version: v3
paths:
- "/api/v3/admin/products/{product_id}/assets":
- get:
- summary: List product assets
- tags:
- - Assets
- security:
- - api_key: []
- bearer_auth: []
- description: Returns a paginated list of assets (images) for a product.
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: Authorization
- in: header
- required: true
- description: Bearer token for admin authentication
- schema:
- type: string
- - name: product_id
- in: path
- required: true
- description: Product prefixed ID
- schema:
- type: string
- - name: page
- in: query
- required: false
- description: Page number
- schema:
- type: integer
- - name: limit
- in: query
- required: false
- description: Number of records per page
- schema:
- type: integer
- responses:
- '200':
- description: assets found
- content:
- application/json:
- example:
- data:
- - id: asset_UkLWZg9DAJ
- viewable_id: variant_UkLWZg9DAJ
- type:
- viewable_type: Spree::Variant
- position: 1
- alt:
- created_at: '2026-03-07T09:48:52.536Z'
- updated_at: '2026-03-07T09:48:52.543Z'
- meta:
- page: 1
- limit: 25
- count: 1
- pages: 1
- from: 1
- to: 1
- in: 1
- previous:
- next:
- post:
- summary: Create an asset
- tags:
- - Assets
- security:
- - api_key: []
- bearer_auth: []
- description: Creates a new asset (image) for a product.
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: Authorization
- in: header
- required: true
- description: Bearer token for admin authentication
- schema:
- type: string
- - name: product_id
- in: path
- required: true
- description: Product prefixed ID
- schema:
- type: string
- responses:
- '422':
- description: validation error (attachment required)
- content:
- application/json:
- example:
- error:
- code: validation_error
- message: Attachment can't be blank
- details:
- attachment:
- - can't be blank
- schema:
- "$ref": "#/components/schemas/ErrorResponse"
- requestBody:
- content:
- application/json:
- schema:
- type: object
- properties:
- alt:
- type: string
- example: Product front view
- position:
- type: integer
- example: 1
- type:
- type: string
- example: Spree::Image
- description: Asset type (defaults to Spree::Image)
- viewable_type:
- type: string
- description: Polymorphic viewable type
- viewable_id:
- type: string
- description: Polymorphic viewable ID
- "/api/v3/admin/products/{product_id}/assets/{id}":
- patch:
- summary: Update an asset
- tags:
- - Assets
- security:
- - api_key: []
- bearer_auth: []
- description: Updates an asset. Only provided fields are updated.
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: Authorization
- in: header
- required: true
- description: Bearer token for admin authentication
- schema:
- type: string
- - name: product_id
- in: path
- required: true
- description: Product prefixed ID
- schema:
- type: string
- - name: id
- in: path
- required: true
- description: Asset prefixed ID
- schema:
- type: string
- responses:
- '200':
- description: asset updated
- content:
- application/json:
- example:
- id: asset_UkLWZg9DAJ
- viewable_id: variant_UkLWZg9DAJ
- type:
- viewable_type: Spree::Variant
- position: 1
- alt: Updated alt text
- created_at: '2026-03-07T09:48:53.343Z'
- updated_at: '2026-03-07T09:48:53.644Z'
- requestBody:
- content:
- application/json:
- schema:
- type: object
- properties:
- alt:
- type: string
- example: Updated alt text
- position:
- type: integer
- example: 2
- delete:
- summary: Delete an asset
- tags:
- - Assets
- security:
- - api_key: []
- bearer_auth: []
- description: Deletes an asset from a product.
- parameters:
- - name: x-spree-api-key
- in: header
- required: true
- schema:
- type: string
- - name: Authorization
- in: header
- required: true
- description: Bearer token for admin authentication
- schema:
- type: string
- - name: product_id
- in: path
- required: true
- description: Product prefixed ID
- schema:
- type: string
- - name: id
- in: path
- required: true
- description: Asset prefixed ID
- schema:
- type: string
- responses:
- '204':
- description: asset deleted
"/api/v3/admin/auth/login":
post:
summary: Login
@@ -294,14 +74,14 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjE1OGE1YzExLWE2NzktNDQyMi05ZDc5LTQ0NThkM2U5Yjk2ZiIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzcyODgwNTM0fQ.BN4XFSIuQQwCrQ_FIPVcGps5xgYLNiws_tuwIJxawBA
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjljM2IxZmJjLWM3YWEtNDAzZC1iNGY1LWYxYTgwNjk1ZTM1YSIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzcyODg2NzAyfQ.L9_GL_zuCQgjAwALcEHR0eAAYlVpAxdzb2p2wxjIe4c
user:
id: admin_UkLWZg9DAJ
- first_name: Sook
- last_name: Heathcote
- created_at: '2026-03-07T09:48:54.263Z'
- updated_at: '2026-03-07T09:48:54.263Z'
+ first_name: Aurora
+ last_name: Volkman
+ created_at: '2026-03-07T11:31:42.311Z'
+ updated_at: '2026-03-07T11:31:42.311Z'
schema:
"$ref": "#/components/schemas/AdminAuthResponse"
'401':
@@ -375,14 +155,14 @@ paths:
content:
application/json:
example:
- token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6IjdhZDczMmY4LWJiMTktNDU2MS04MWUxLTEwZDRhZjIxN2IyYSIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzcyODgwNTM1fQ.yR3s9n89lASSQ1OOBW2bBFF3eH-8xelkVq_ymUiAGfQ
+ token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJhZG1pbiIsImp0aSI6ImNlMzU1MWQxLTY1YmUtNDY4Yy05YTA3LTNmNDExZmJkMWM4YyIsImlzcyI6InNwcmVlIiwiYXVkIjoiYWRtaW5fYXBpIiwiZXhwIjoxNzcyODg2NzA0fQ.zEb7pVHJXhL5DQg0xvZQonix73zbAl0FQMNpiW-rb08
user:
id: admin_UkLWZg9DAJ
- first_name: Alena
- last_name: Schaden
- created_at: '2026-03-07T09:48:55.946Z'
- updated_at: '2026-03-07T09:48:55.946Z'
+ first_name: Gabriel
+ last_name: Cole
+ created_at: '2026-03-07T11:31:44.251Z'
+ updated_at: '2026-03-07T11:31:44.251Z'
schema:
"$ref": "#/components/schemas/AdminAuthResponse"
'401':
@@ -446,8 +226,8 @@ paths:
presentation: Size
position: 1
filterable: true
- created_at: '2026-03-07T09:48:55.974Z'
- updated_at: '2026-03-07T09:48:55.974Z'
+ created_at: '2026-03-07T11:31:44.363Z'
+ updated_at: '2026-03-07T11:31:44.363Z'
option_values: []
meta:
page: 1
@@ -515,8 +295,8 @@ paths:
presentation: Material
position: 2
filterable: true
- created_at: '2026-03-07T09:48:56.832Z'
- updated_at: '2026-03-07T09:48:56.832Z'
+ created_at: '2026-03-07T11:31:45.295Z'
+ updated_at: '2026-03-07T11:31:45.295Z'
option_values: []
schema:
"$ref": "#/components/schemas/AdminOptionType"
@@ -608,8 +388,8 @@ paths:
presentation: Size
position: 1
filterable: true
- created_at: '2026-03-07T09:48:57.122Z'
- updated_at: '2026-03-07T09:48:57.122Z'
+ created_at: '2026-03-07T11:31:45.591Z'
+ updated_at: '2026-03-07T11:31:45.591Z'
option_values: []
schema:
"$ref": "#/components/schemas/AdminOptionType"
@@ -660,8 +440,8 @@ paths:
presentation: Updated Presentation
position: 1
filterable: true
- created_at: '2026-03-07T09:48:57.694Z'
- updated_at: '2026-03-07T09:48:57.977Z'
+ created_at: '2026-03-07T11:31:46.171Z'
+ updated_at: '2026-03-07T11:31:46.463Z'
option_values: []
schema:
"$ref": "#/components/schemas/AdminOptionType"
@@ -782,8 +562,8 @@ paths:
state: open
included: false
mandatory:
- created_at: '2026-03-07T09:48:58.916Z'
- updated_at: '2026-03-07T09:48:58.922Z'
+ created_at: '2026-03-07T11:31:47.628Z'
+ updated_at: '2026-03-07T11:31:47.635Z'
source_type: Spree::TaxRate
source_id: tax_UkLWZg9DAJ
adjustable_type: Spree::Order
@@ -839,8 +619,8 @@ paths:
state: open
included: false
mandatory:
- created_at: '2026-03-07T09:48:59.778Z'
- updated_at: '2026-03-07T09:48:59.778Z'
+ created_at: '2026-03-07T11:31:48.608Z'
+ updated_at: '2026-03-07T11:31:48.608Z'
source_type:
source_id:
adjustable_type: Spree::Order
@@ -908,8 +688,8 @@ paths:
state: open
included: false
mandatory:
- created_at: '2026-03-07T09:49:00.142Z'
- updated_at: '2026-03-07T09:49:00.145Z'
+ created_at: '2026-03-07T11:31:48.905Z'
+ updated_at: '2026-03-07T11:31:48.907Z'
source_type: Spree::TaxRate
source_id: tax_UkLWZg9DAJ
adjustable_type: Spree::Order
@@ -960,8 +740,8 @@ paths:
state: open
included: false
mandatory:
- created_at: '2026-03-07T09:49:00.708Z'
- updated_at: '2026-03-07T09:49:00.994Z'
+ created_at: '2026-03-07T11:31:49.583Z'
+ updated_at: '2026-03-07T11:31:49.898Z'
source_type: Spree::TaxRate
source_id: tax_UkLWZg9DAJ
adjustable_type: Spree::Order
@@ -1052,8 +832,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 54277
- slug: product-54277
+ name: Product 13567
+ slug: product-13567
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -1072,8 +852,8 @@ paths:
discounted_amount: '20.0'
display_discounted_amount: "$20.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:01.917Z'
- updated_at: '2026-03-07T09:49:01.917Z'
+ created_at: '2026-03-07T11:31:51.526Z'
+ updated_at: '2026-03-07T11:31:51.526Z'
compare_at_amount:
thumbnail_url:
option_values:
@@ -1135,8 +915,8 @@ paths:
variant_id: variant_VqXmZF31wY
quantity: 3
currency: USD
- name: Product 74079
- slug: product-74079
+ name: Product 35964
+ slug: product-35964
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -1155,8 +935,8 @@ paths:
discounted_amount: '59.97'
display_discounted_amount: "$59.97"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:02.880Z'
- updated_at: '2026-03-07T09:49:02.880Z'
+ created_at: '2026-03-07T11:31:52.624Z'
+ updated_at: '2026-03-07T11:31:52.624Z'
compare_at_amount:
thumbnail_url:
option_values:
@@ -1229,8 +1009,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 2
currency: USD
- name: Product 83056
- slug: product-83056
+ name: Product 45612
+ slug: product-45612
options_text: 'Size: S'
price: '10.0'
display_price: "$10.00"
@@ -1249,8 +1029,8 @@ paths:
discounted_amount: '20.0'
display_discounted_amount: "$20.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:03.230Z'
- updated_at: '2026-03-07T09:49:03.230Z'
+ created_at: '2026-03-07T11:31:52.999Z'
+ updated_at: '2026-03-07T11:31:52.999Z'
compare_at_amount:
thumbnail_url:
option_values:
@@ -1308,8 +1088,8 @@ paths:
variant_id: variant_gbHJdmfrXB
quantity: 5
currency: USD
- name: Product 97809
- slug: product-97809
+ name: Product 54848
+ slug: product-54848
options_text: 'Size: S'
price: '19.99'
display_price: "$19.99"
@@ -1328,8 +1108,8 @@ paths:
discounted_amount: '99.95'
display_discounted_amount: "$99.95"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:03.877Z'
- updated_at: '2026-03-07T09:49:04.178Z'
+ created_at: '2026-03-07T11:31:53.645Z'
+ updated_at: '2026-03-07T11:31:53.981Z'
compare_at_amount:
thumbnail_url:
option_values:
@@ -1426,11 +1206,11 @@ paths:
payment_method_id: pm_UkLWZg9DAJ
state: completed
response_code: '12345'
- number: P5NANKE0
+ number: PE5Y1CQ6
amount: '110.0'
display_amount: "$110.00"
- created_at: '2026-03-07T09:49:05.222Z'
- updated_at: '2026-03-07T09:49:05.222Z'
+ created_at: '2026-03-07T11:31:55.026Z'
+ updated_at: '2026-03-07T11:31:55.026Z'
source_type: credit_card
source_id: card_UkLWZg9DAJ
source:
@@ -1500,11 +1280,11 @@ paths:
payment_method_id: pm_EfhxLZ9ck8
state: checkout
response_code:
- number: P3KGU7F5
+ number: P4W7JK5J
amount: '110.0'
display_amount: "$110.00"
- created_at: '2026-03-07T09:49:06.611Z'
- updated_at: '2026-03-07T09:49:06.611Z'
+ created_at: '2026-03-07T11:31:56.451Z'
+ updated_at: '2026-03-07T11:31:56.451Z'
source_type:
source_id:
source:
@@ -1580,11 +1360,11 @@ paths:
payment_method_id: pm_UkLWZg9DAJ
state: completed
response_code: '12345'
- number: PYESX0KG
+ number: PEBBI073
amount: '110.0'
display_amount: "$110.00"
- created_at: '2026-03-07T09:49:06.982Z'
- updated_at: '2026-03-07T09:49:06.982Z'
+ created_at: '2026-03-07T11:31:56.836Z'
+ updated_at: '2026-03-07T11:31:56.836Z'
source_type: credit_card
source_id: card_UkLWZg9DAJ
source:
@@ -1651,11 +1431,11 @@ paths:
payment_method_id: pm_UkLWZg9DAJ
state: completed
response_code: '12345'
- number: PSA3QJH1
+ number: PDYBX5M9
amount: '110.0'
display_amount: "$110.00"
- created_at: '2026-03-07T09:49:07.630Z'
- updated_at: '2026-03-07T09:49:07.954Z'
+ created_at: '2026-03-07T11:31:57.512Z'
+ updated_at: '2026-03-07T11:31:57.860Z'
source_type: credit_card
source_id: card_UkLWZg9DAJ
source:
@@ -1722,11 +1502,11 @@ paths:
payment_method_id: pm_UkLWZg9DAJ
state: void
response_code: void-12345
- number: PKCSF9MY
+ number: P689ZF08
amount: '110.0'
display_amount: "$110.00"
- created_at: '2026-03-07T09:49:08.341Z'
- updated_at: '2026-03-07T09:49:08.651Z'
+ created_at: '2026-03-07T11:31:58.237Z'
+ updated_at: '2026-03-07T11:31:58.544Z'
source_type: credit_card
source_id: card_UkLWZg9DAJ
source:
@@ -1829,8 +1609,8 @@ paths:
example:
id: re_UkLWZg9DAJ
transaction_id: '12345'
- created_at: '2026-03-07T09:49:09.979Z'
- updated_at: '2026-03-07T09:49:09.979Z'
+ created_at: '2026-03-07T11:31:59.923Z'
+ updated_at: '2026-03-07T11:31:59.923Z'
amount: '5.0'
payment_id: py_UkLWZg9DAJ
refund_reason_id: rr_UkLWZg9DAJ
@@ -1889,29 +1669,29 @@ paths:
example:
data:
- id: ship_UkLWZg9DAJ
- number: H17811757638
+ number: H63961999053
state: ready
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:10.322Z'
- updated_at: '2026-03-07T09:49:10.381Z'
+ created_at: '2026-03-07T11:32:00.284Z'
+ updated_at: '2026-03-07T11:32:00.345Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_36
- name: Marcos Tremblay
+ state_abbr: STATE_ABBR_32
+ name: Kina Bernhard
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_36
+ state_text: STATE_ABBR_32
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -1981,29 +1761,29 @@ paths:
application/json:
example:
id: ship_UkLWZg9DAJ
- number: H83204287660
+ number: H97411524064
state: ready
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:10.982Z'
- updated_at: '2026-03-07T09:49:11.047Z'
+ created_at: '2026-03-07T11:32:00.960Z'
+ updated_at: '2026-03-07T11:32:01.021Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_38
- name: Dolores Kertzmann
+ state_abbr: STATE_ABBR_34
+ name: Edna Medhurst
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_38
+ state_text: STATE_ABBR_34
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2062,29 +1842,29 @@ paths:
application/json:
example:
id: ship_UkLWZg9DAJ
- number: H43240020259
+ number: H73575509694
state: ready
tracking: 1Z999AA10123456784
tracking_url: https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1Z999AA10123456784
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:11.724Z'
- updated_at: '2026-03-07T09:49:12.080Z'
+ created_at: '2026-03-07T11:32:01.618Z'
+ updated_at: '2026-03-07T11:32:01.961Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_40
- name: Enoch Eichmann
+ state_abbr: STATE_ABBR_36
+ name: Tomiko Roob
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_40
+ state_text: STATE_ABBR_36
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2155,29 +1935,29 @@ paths:
application/json:
example:
id: ship_UkLWZg9DAJ
- number: H30742910700
+ number: H93306462242
state: shipped
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
- shipped_at: '2026-03-07T09:49:12.733Z'
- created_at: '2026-03-07T09:49:12.391Z'
- updated_at: '2026-03-07T09:49:12.733Z'
+ shipped_at: '2026-03-07T11:32:02.646Z'
+ created_at: '2026-03-07T11:32:02.289Z'
+ updated_at: '2026-03-07T11:32:02.646Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_42
- name: Jacquelyne Feeney
+ state_abbr: STATE_ABBR_38
+ name: Frida Kub
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_42
+ state_text: STATE_ABBR_38
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2237,29 +2017,29 @@ paths:
application/json:
example:
id: ship_UkLWZg9DAJ
- number: H78231356128
+ number: H08656001130
state: canceled
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:13.041Z'
- updated_at: '2026-03-07T09:49:13.371Z'
+ created_at: '2026-03-07T11:32:02.966Z'
+ updated_at: '2026-03-07T11:32:03.318Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_44
- name: Sandie Kreiger
+ state_abbr: STATE_ABBR_40
+ name: Ezequiel Steuber
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_44
+ state_text: STATE_ABBR_40
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2319,29 +2099,29 @@ paths:
application/json:
example:
id: ship_UkLWZg9DAJ
- number: H23636611052
+ number: H02364330432
state: pending
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:13.691Z'
- updated_at: '2026-03-07T09:49:14.062Z'
+ created_at: '2026-03-07T11:32:03.668Z'
+ updated_at: '2026-03-07T11:32:04.079Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_46
- name: Saturnina Turner
+ state_abbr: STATE_ABBR_42
+ name: Marita Graham
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_46
+ state_text: STATE_ABBR_42
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2403,29 +2183,29 @@ paths:
example:
data:
- id: ship_gbHJdmfrXB
- number: H17061029092
+ number: H21664429230
state: ready
tracking:
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:14.808Z'
- updated_at: '2026-03-07T09:49:14.858Z'
+ created_at: '2026-03-07T11:32:04.766Z'
+ updated_at: '2026-03-07T11:32:04.810Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_gbHJdmfrXB
- state_abbr: STATE_ABBR_48
+ state_abbr: STATE_ABBR_44
name: Warehouse 2
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_48
+ state_text: STATE_ABBR_44
shipping_rates:
- id: shpr_uw2YK1rnl0
shipping_method_id: shpm_UkLWZg9DAJ
@@ -2535,14 +2315,14 @@ paths:
example:
data:
- id: or_UkLWZg9DAJ
- number: R794806176
+ number: R113959961
state: cart
checkout_steps:
- address
- delivery
- complete
- token: RJ25AtGi6tnVKG6bfwh8pmyn497Rthwr5fu
+ token: 72C8TYgVLCYFrZr1s3AkdriwQgVdk7E36t3
special_instructions:
currency: USD
locale: en
@@ -2567,8 +2347,8 @@ paths:
total: '0.0'
display_total: "$0.00"
completed_at:
- created_at: '2026-03-07T09:49:15.137Z'
- updated_at: '2026-03-07T09:49:15.137Z'
+ created_at: '2026-03-07T11:32:05.092Z'
+ updated_at: '2026-03-07T11:32:05.092Z'
order_promotions: []
line_items: []
shipments: []
@@ -2586,10 +2366,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_50
- state_abbr: STATE_ABBR_50
+ state_text: STATE_ABBR_46
+ state_abbr: STATE_ABBR_46
quick_checkout: false
- state_name: STATE_NAME_50
+ state_name: STATE_NAME_46
ship_address:
payment_methods: []
channel: spree
@@ -2663,13 +2443,13 @@ paths:
application/json:
example:
id: or_gbHJdmfrXB
- number: R877641266
+ number: R594081781
state: cart
checkout_steps:
- address
- delivery
- complete
- token: ljpkaGh8h1KxYK_6BJGH8A1772876956532
+ token: Dr2-m36jKm3IYEpuywubNQ1772883126491
special_instructions:
currency: USD
@@ -2695,8 +2475,8 @@ paths:
total: '0.0'
display_total: "$0.00"
completed_at:
- created_at: '2026-03-07T09:49:16.534Z'
- updated_at: '2026-03-07T09:49:16.534Z'
+ created_at: '2026-03-07T11:32:06.492Z'
+ updated_at: '2026-03-07T11:32:06.492Z'
order_promotions: []
line_items: []
shipments: []
@@ -2787,14 +2567,14 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R396350911
+ number: R337788873
state: cart
checkout_steps:
- address
- delivery
- complete
- token: b1SWfXoFfG9k8PcytUamj5kJjNcfPred3hs
+ token: 96PRA6YRFjpYjzRMkpfdjZog8ZfmV5MqwyS
special_instructions:
currency: USD
locale: en
@@ -2819,8 +2599,8 @@ paths:
total: '0.0'
display_total: "$0.00"
completed_at:
- created_at: '2026-03-07T09:49:16.808Z'
- updated_at: '2026-03-07T09:49:16.808Z'
+ created_at: '2026-03-07T11:32:06.766Z'
+ updated_at: '2026-03-07T11:32:06.766Z'
order_promotions: []
line_items: []
shipments: []
@@ -2838,10 +2618,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_53
- state_abbr: STATE_ABBR_53
+ state_text: STATE_ABBR_49
+ state_abbr: STATE_ABBR_49
quick_checkout: false
- state_name: STATE_NAME_53
+ state_name: STATE_NAME_49
ship_address:
payment_methods: []
channel: spree
@@ -2912,13 +2692,13 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R394325023
+ number: R077527935
state: cart
checkout_steps:
- address
- delivery
- complete
- token: YwSvAv32FSSfzUvAKvzbkrv21Z2ie5yVtgH
+ token: Ky8anMN786JtzXwk8DbMTKmGbu3QKH2Xysf
special_instructions:
currency: USD
@@ -2944,8 +2724,8 @@ paths:
total: '0.0'
display_total: "$0.00"
completed_at:
- created_at: '2026-03-07T09:49:17.934Z'
- updated_at: '2026-03-07T09:49:18.265Z'
+ created_at: '2026-03-07T11:32:07.903Z'
+ updated_at: '2026-03-07T11:32:08.192Z'
order_promotions: []
line_items: []
shipments: []
@@ -2963,10 +2743,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_55
- state_abbr: STATE_ABBR_55
+ state_text: STATE_ABBR_51
+ state_abbr: STATE_ABBR_51
quick_checkout: false
- state_name: STATE_NAME_55
+ state_name: STATE_NAME_51
ship_address:
payment_methods: []
channel: spree
@@ -3116,15 +2896,15 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R613805461
+ number: R233851919
state: canceled
checkout_steps:
- address
- delivery
- payment
- complete
- token: 9Pg1D7pyZUHktpuPwnLn9ytGGxiDGSD4LkR
+ token: 8ecmPZ2xEtaYkfA7ZAPYcqLwZXTNavs92gJ
special_instructions:
currency: USD
locale: en
@@ -3148,17 +2928,17 @@ paths:
display_additional_tax_total: "$0.00"
total: '20.0'
display_total: "$20.00"
- completed_at: '2026-03-07T09:49:19.172Z'
- created_at: '2026-03-07T09:49:19.121Z'
- updated_at: '2026-03-07T09:49:19.501Z'
+ completed_at: '2026-03-07T11:32:09.111Z'
+ created_at: '2026-03-07T11:32:09.052Z'
+ updated_at: '2026-03-07T11:32:09.443Z'
order_promotions: []
line_items:
- id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
quantity: 1
currency: USD
- name: Product 264282
- slug: product-264282
+ name: Product 222802
+ slug: product-222802
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3177,8 +2957,8 @@ paths:
discounted_amount: '10.0'
display_discounted_amount: "$10.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:19.150Z'
- updated_at: '2026-03-07T09:49:19.150Z'
+ created_at: '2026-03-07T11:32:09.088Z'
+ updated_at: '2026-03-07T11:32:09.088Z'
compare_at_amount:
thumbnail_url:
option_values: []
@@ -3189,29 +2969,29 @@ paths:
order_id: or_UkLWZg9DAJ
shipments:
- id: ship_UkLWZg9DAJ
- number: H90495361070
+ number: H12260130427
state: canceled
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:19.156Z'
- updated_at: '2026-03-07T09:49:19.498Z'
+ created_at: '2026-03-07T11:32:09.094Z'
+ updated_at: '2026-03-07T11:32:09.441Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_57
- name: Pattie Ritchie
+ state_abbr: STATE_ABBR_53
+ name: Noreen Donnelly
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_57
+ state_text: STATE_ABBR_53
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -3245,10 +3025,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_57
- state_abbr: STATE_ABBR_57
+ state_text: STATE_ABBR_53
+ state_abbr: STATE_ABBR_53
quick_checkout: false
- state_name: STATE_NAME_57
+ state_name: STATE_NAME_53
ship_address:
id: addr_gbHJdmfrXB
firstname: John
@@ -3262,10 +3042,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_58
- state_abbr: STATE_ABBR_58
+ state_text: STATE_ABBR_54
+ state_abbr: STATE_ABBR_54
quick_checkout: false
- state_name: STATE_NAME_58
+ state_name: STATE_NAME_54
payment_methods: []
channel: spree
last_ip_address:
@@ -3283,7 +3063,7 @@ paths:
locale: en
payment_total: '0.0'
display_payment_total: "$0.00"
- canceled_at: '2026-03-07T09:49:19.463Z'
+ canceled_at: '2026-03-07T11:32:09.407Z'
approved_at:
metadata:
approver_id:
@@ -3324,15 +3104,15 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R314260374
+ number: R217948365
state: complete
checkout_steps:
- address
- delivery
- payment
- complete
- token: CkCEY5aSoa6uHikCHNV5T7uEuWsForvjXzQ
+ token: FspY8H6zJ8tJnkQo1v6arHRM2Ndy5o8PjAV
special_instructions:
currency: USD
locale: en
@@ -3356,17 +3136,17 @@ paths:
display_additional_tax_total: "$0.00"
total: '110.0'
display_total: "$110.00"
- completed_at: '2026-03-07T09:49:19.839Z'
- created_at: '2026-03-07T09:49:19.788Z'
- updated_at: '2026-03-07T09:49:19.839Z'
+ completed_at: '2026-03-07T11:32:09.791Z'
+ created_at: '2026-03-07T11:32:09.737Z'
+ updated_at: '2026-03-07T11:32:09.791Z'
order_promotions: []
line_items:
- id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
quantity: 1
currency: USD
- name: Product 278932
- slug: product-278932
+ name: Product 237239
+ slug: product-237239
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3385,8 +3165,8 @@ paths:
discounted_amount: '10.0'
display_discounted_amount: "$10.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:19.816Z'
- updated_at: '2026-03-07T09:49:19.816Z'
+ created_at: '2026-03-07T11:32:09.769Z'
+ updated_at: '2026-03-07T11:32:09.769Z'
compare_at_amount:
thumbnail_url:
option_values: []
@@ -3397,29 +3177,29 @@ paths:
order_id: or_UkLWZg9DAJ
shipments:
- id: ship_UkLWZg9DAJ
- number: H45895641344
+ number: H15691854339
state: pending
tracking: U10000
tracking_url:
cost: '100.0'
display_cost: "$100.00"
shipped_at:
- created_at: '2026-03-07T09:49:19.822Z'
- updated_at: '2026-03-07T09:49:19.836Z'
+ created_at: '2026-03-07T11:32:09.774Z'
+ updated_at: '2026-03-07T11:32:09.788Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_59
- name: Kyoko Jaskolski
+ state_abbr: STATE_ABBR_55
+ name: Terisa Klocko
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_59
+ state_text: STATE_ABBR_55
shipping_rates:
- id: shpr_gbHJdmfrXB
shipping_method_id: shpm_UkLWZg9DAJ
@@ -3453,10 +3233,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_59
- state_abbr: STATE_ABBR_59
+ state_text: STATE_ABBR_55
+ state_abbr: STATE_ABBR_55
quick_checkout: false
- state_name: STATE_NAME_59
+ state_name: STATE_NAME_55
ship_address:
id: addr_gbHJdmfrXB
firstname: John
@@ -3470,10 +3250,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_60
- state_abbr: STATE_ABBR_60
+ state_text: STATE_ABBR_56
+ state_abbr: STATE_ABBR_56
quick_checkout: false
- state_name: STATE_NAME_60
+ state_name: STATE_NAME_56
payment_methods: []
channel: spree
last_ip_address:
@@ -3492,7 +3272,7 @@ paths:
payment_total: '0.0'
display_payment_total: "$0.00"
canceled_at:
- approved_at: '2026-03-07T09:49:20.133Z'
+ approved_at: '2026-03-07T11:32:10.092Z'
metadata:
approver_id: admin_UkLWZg9DAJ
canceler_id:
@@ -3532,15 +3312,15 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R044624105
+ number: R352612523
state: resumed
checkout_steps:
- address
- delivery
- payment
- complete
- token: GS1ErpET5WiD4FAVmiyXym3gUFT8P8nnwhY
+ token: dpdnvdo4KMBoHDJNbjHqb6d49Cr18UbxBqh
special_instructions:
currency: USD
locale: en
@@ -3564,17 +3344,17 @@ paths:
display_additional_tax_total: "$0.00"
total: '20.0'
display_total: "$20.00"
- completed_at: '2026-03-07T09:49:20.485Z'
- created_at: '2026-03-07T09:49:20.422Z'
- updated_at: '2026-03-07T09:49:20.832Z'
+ completed_at: '2026-03-07T11:32:10.442Z'
+ created_at: '2026-03-07T11:32:10.384Z'
+ updated_at: '2026-03-07T11:32:10.789Z'
order_promotions: []
line_items:
- id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
quantity: 1
currency: USD
- name: Product 282673
- slug: product-282673
+ name: Product 245952
+ slug: product-245952
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3593,8 +3373,8 @@ paths:
discounted_amount: '10.0'
display_discounted_amount: "$10.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:20.458Z'
- updated_at: '2026-03-07T09:49:20.804Z'
+ created_at: '2026-03-07T11:32:10.417Z'
+ updated_at: '2026-03-07T11:32:10.760Z'
compare_at_amount:
thumbnail_url:
option_values: []
@@ -3605,29 +3385,29 @@ paths:
order_id: or_UkLWZg9DAJ
shipments:
- id: ship_UkLWZg9DAJ
- number: H28345271880
+ number: H66819641422
state: pending
tracking: U10000
tracking_url:
cost: '10.0'
display_cost: "$10.00"
shipped_at:
- created_at: '2026-03-07T09:49:20.464Z'
- updated_at: '2026-03-07T09:49:20.824Z'
+ created_at: '2026-03-07T11:32:10.423Z'
+ updated_at: '2026-03-07T11:32:10.781Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_61
- name: Jeff Spencer
+ state_abbr: STATE_ABBR_57
+ name: Lucilla Kemmer
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_61
+ state_text: STATE_ABBR_57
shipping_rates:
- id: shpr_EfhxLZ9ck8
shipping_method_id: shpm_UkLWZg9DAJ
@@ -3661,10 +3441,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_61
- state_abbr: STATE_ABBR_61
+ state_text: STATE_ABBR_57
+ state_abbr: STATE_ABBR_57
quick_checkout: false
- state_name: STATE_NAME_61
+ state_name: STATE_NAME_57
ship_address:
id: addr_gbHJdmfrXB
firstname: John
@@ -3678,10 +3458,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_62
- state_abbr: STATE_ABBR_62
+ state_text: STATE_ABBR_58
+ state_abbr: STATE_ABBR_58
quick_checkout: false
- state_name: STATE_NAME_62
+ state_name: STATE_NAME_58
payment_methods: []
channel: spree
last_ip_address:
@@ -3699,7 +3479,7 @@ paths:
locale: en
payment_total: '0.0'
display_payment_total: "$0.00"
- canceled_at: '2026-03-07T09:49:20.769Z'
+ canceled_at: '2026-03-07T11:32:10.729Z'
approved_at:
metadata:
approver_id:
@@ -3741,15 +3521,15 @@ paths:
application/json:
example:
id: or_UkLWZg9DAJ
- number: R003420680
+ number: R157765926
state: complete
checkout_steps:
- address
- delivery
- payment
- complete
- token: AmbpLGfsFGZuggwhJmPx9YDdXW9Jk3HfqFg
+ token: mmWKYkWQY5zF9uw3A3KRG5NGidk4rkx1DSU
special_instructions:
currency: USD
locale: en
@@ -3773,17 +3553,17 @@ paths:
display_additional_tax_total: "$0.00"
total: '110.0'
display_total: "$110.00"
- completed_at: '2026-03-07T09:49:21.165Z'
- created_at: '2026-03-07T09:49:21.119Z'
- updated_at: '2026-03-07T09:49:21.165Z'
+ completed_at: '2026-03-07T11:32:11.156Z'
+ created_at: '2026-03-07T11:32:11.090Z'
+ updated_at: '2026-03-07T11:32:11.156Z'
order_promotions: []
line_items:
- id: li_UkLWZg9DAJ
variant_id: variant_UkLWZg9DAJ
quantity: 1
currency: USD
- name: Product 295302
- slug: product-295302
+ name: Product 256333
+ slug: product-256333
options_text: ''
price: '10.0'
display_price: "$10.00"
@@ -3802,8 +3582,8 @@ paths:
discounted_amount: '10.0'
display_discounted_amount: "$10.00"
display_compare_at_amount: "$0.00"
- created_at: '2026-03-07T09:49:21.146Z'
- updated_at: '2026-03-07T09:49:21.146Z'
+ created_at: '2026-03-07T11:32:11.128Z'
+ updated_at: '2026-03-07T11:32:11.128Z'
compare_at_amount:
thumbnail_url:
option_values: []
@@ -3814,29 +3594,29 @@ paths:
order_id: or_UkLWZg9DAJ
shipments:
- id: ship_UkLWZg9DAJ
- number: H70934335043
+ number: H48503041679
state: pending
tracking: U10000
tracking_url:
cost: '100.0'
display_cost: "$100.00"
shipped_at:
- created_at: '2026-03-07T09:49:21.150Z'
- updated_at: '2026-03-07T09:49:21.163Z'
+ created_at: '2026-03-07T11:32:11.135Z'
+ updated_at: '2026-03-07T11:32:11.153Z'
shipping_method:
id: shpm_UkLWZg9DAJ
name: UPS Ground
code: UPS_GROUND
stock_location:
id: sloc_UkLWZg9DAJ
- state_abbr: STATE_ABBR_63
- name: Deb Stehr
+ state_abbr: STATE_ABBR_59
+ name: Jerri Huels
address1: 1600 Pennsylvania Ave NW
city: Washington
zipcode: '20500'
country_iso: US
country_name: United States of America
- state_text: STATE_ABBR_63
+ state_text: STATE_ABBR_59
shipping_rates:
- id: shpr_gbHJdmfrXB
shipping_method_id: shpm_UkLWZg9DAJ
@@ -3870,10 +3650,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_63
- state_abbr: STATE_ABBR_63
+ state_text: STATE_ABBR_59
+ state_abbr: STATE_ABBR_59
quick_checkout: false
- state_name: STATE_NAME_63
+ state_name: STATE_NAME_59
ship_address:
id: addr_gbHJdmfrXB
firstname: John
@@ -3887,10 +3667,10 @@ paths:
company: Company
country_name: United States of America
country_iso: US
- state_text: STATE_ABBR_64
- state_abbr: STATE_ABBR_64
+ state_text: STATE_ABBR_60
+ state_abbr: STATE_ABBR_60
quick_checkout: false
- state_name: STATE_NAME_64
+ state_name: STATE_NAME_60
payment_methods: []
channel: spree
last_ip_address:
@@ -3915,6 +3695,227 @@ paths:
canceler_id:
created_by_id:
user_id: cus_UkLWZg9DAJ
+ "/api/v3/admin/products/{product_id}/assets":
+ get:
+ summary: List product assets
+ tags:
+ - Product Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Returns a paginated list of assets (images) for a product.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ description: Page number
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ description: Number of records per page
+ schema:
+ type: integer
+ responses:
+ '200':
+ description: assets found
+ content:
+ application/json:
+ example:
+ data:
+ - id: asset_UkLWZg9DAJ
+ viewable_id: variant_UkLWZg9DAJ
+ type:
+ viewable_type: Spree::Variant
+ position: 1
+ alt:
+ created_at: '2026-03-07T11:32:11.511Z'
+ updated_at: '2026-03-07T11:32:11.513Z'
+ meta:
+ page: 1
+ limit: 25
+ count: 1
+ pages: 1
+ from: 1
+ to: 1
+ in: 1
+ previous:
+ next:
+ post:
+ summary: Create a product asset
+ tags:
+ - Product Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Creates a new asset (image) for a product.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ responses:
+ '202':
+ description: asset import from URL enqueued
+ '422':
+ description: validation error (attachment required)
+ content:
+ application/json:
+ example:
+ error:
+ code: validation_error
+ message: Attachment can't be blank
+ details:
+ attachment:
+ - can't be blank
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ alt:
+ type: string
+ example: Product front view
+ position:
+ type: integer
+ example: 1
+ type:
+ type: string
+ example: Spree::Image
+ description: Asset type (defaults to Spree::Image)
+ url:
+ type: string
+ example: https://example.com/image.jpg
+ description: External URL to import image from (async). Returns
+ 202 Accepted.
+ "/api/v3/admin/products/{product_id}/assets/{id}":
+ patch:
+ summary: Update a product asset
+ tags:
+ - Product Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Updates a product asset. Only provided fields are updated.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ description: Asset prefixed ID
+ schema:
+ type: string
+ responses:
+ '200':
+ description: asset updated
+ content:
+ application/json:
+ example:
+ id: asset_UkLWZg9DAJ
+ viewable_id: variant_UkLWZg9DAJ
+ type:
+ viewable_type: Spree::Variant
+ position: 1
+ alt: Updated alt text
+ created_at: '2026-03-07T11:32:12.512Z'
+ updated_at: '2026-03-07T11:32:12.804Z'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ alt:
+ type: string
+ example: Updated alt text
+ position:
+ type: integer
+ example: 2
+ delete:
+ summary: Delete a product asset
+ tags:
+ - Product Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Deletes an asset from a product.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ description: Asset prefixed ID
+ schema:
+ type: string
+ responses:
+ '204':
+ description: asset deleted
"/api/v3/admin/products":
get:
summary: List products
@@ -3980,19 +3981,19 @@ paths:
example:
data:
- id: prod_UkLWZg9DAJ
- name: Product 309987
+ name: Product 316023
description: |-
- Expedita accusantium ipsa itaque asperiores ducimus eius. Natus officiis perspiciatis occaecati repudiandae quos. Repellat distinctio quam placeat nobis.
- Quia ullam similique quasi recusandae ratione. Quaerat minima ipsa atque rerum sed. Iusto in rerum incidunt doloribus consequuntur.
- Accusamus molestias voluptas nostrum debitis. Magni ratione placeat aspernatur omnis error sed hic deleniti. Aliquid tempore aliquam porro dolorem perferendis. Voluptatibus corporis facere dolorum perspiciatis sequi ipsum rem sint.
- Libero rem ducimus reiciendis placeat quasi natus quidem sit. Nostrum repellat illo commodi ex debitis mollitia corrupti corporis. Enim aliquid rem eaque vero. Minima facere ipsum dolorum ut assumenda earum. Voluptatem quis similique maxime labore earum id magnam.
- slug: product-309987
+ Assumenda nihil debitis nulla temporibus ratione. Eius at expedita nam perferendis quos ad. Magni ducimus itaque eius dolorum.
+ Doloremque fugiat nam consequuntur vel mollitia iusto amet voluptate. Harum sed eos sequi assumenda maiores beatae omnis. Numquam vero fugiat quis rem neque natus beatae eligendi. Fuga mollitia molestiae consequatur quidem. Id provident nemo amet explicabo tempora.
+ Consectetur mollitia soluta facere sed. Ab eligendi dicta consequatur aut nam voluptatem iure delectus. Sapiente voluptatibus quidem perferendis ullam quae. Sint impedit dolor tenetur ipsam maiores ratione. Veritatis dolorum impedit mollitia dolores deleniti laudantium recusandae.
+ Voluptatum iusto sequi excepturi laborum quasi delectus. Aliquam sint libero laboriosam error est vel quasi ex. Dolor nesciunt voluptate dolorem facilis necessitatibus excepturi. Ipsa vitae consequuntur totam debitis labore temporibus.
+ slug: product-316023
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-03-07T09:49:21.501Z'
- created_at: '2026-03-07T09:49:21.524Z'
- updated_at: '2026-03-07T09:49:21.546Z'
+ available_on: '2025-03-07T11:32:13.145Z'
+ created_at: '2026-03-07T11:32:13.158Z'
+ updated_at: '2026-03-07T11:32:13.169Z'
purchasable: true
in_stock: false
backorderable: true
@@ -4011,11 +4012,11 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-03-07T09:49:21.528Z'
- updated_at: '2026-03-07T09:49:21.528Z'
+ created_at: '2026-03-07T11:32:13.159Z'
+ updated_at: '2026-03-07T11:32:13.159Z'
original_price:
status: active
- make_active_at: '2025-03-07T09:49:21.502Z'
+ make_active_at: '2025-03-07T11:32:13.145Z'
discontinue_on:
meta_title:
promotionable: true
@@ -4094,8 +4095,8 @@ paths:
meta_keywords:
variant_count: 0
available_on:
- created_at: '2026-03-07T09:49:22.549Z'
- updated_at: '2026-03-07T09:49:22.552Z'
+ created_at: '2026-03-07T11:32:14.115Z'
+ updated_at: '2026-03-07T11:32:14.119Z'
purchasable: false
in_stock: false
backorderable: false
@@ -4114,8 +4115,8 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_gbHJdmfrXB
- created_at: '2026-03-07T09:49:22.551Z'
- updated_at: '2026-03-07T09:49:22.551Z'
+ created_at: '2026-03-07T11:32:14.117Z'
+ updated_at: '2026-03-07T11:32:14.117Z'
original_price:
status: draft
make_active_at:
@@ -4262,17 +4263,18 @@ paths:
application/json:
example:
id: prod_UkLWZg9DAJ
- name: Product 343825
+ name: Product 358866
description: |-
- Numquam in officiis ex cum neque. Dolor error neque eaque repellat minus. Necessitatibus corporis beatae dolores iusto. Unde itaque est quas exercitationem tempora.
- Quisquam impedit harum enim sequi. Reiciendis rem doloremque nam expedita. Incidunt fugit sint odio adipisci perferendis.
- slug: product-343825
+ Dolor suscipit debitis dolorum fugiat dicta assumenda ratione ab. Quis ea eveniet debitis dolorem animi sed earum qui. Fuga ad at tempora voluptate nihil labore velit quos. Doloremque est vero labore quam doloribus.
+ Earum sed dolore nostrum facere commodi eligendi ad. Vel in necessitatibus occaecati neque laboriosam facere asperiores sint. Nemo aperiam occaecati autem ducimus consequatur numquam nostrum.
+ Suscipit enim beatae repudiandae ex sed sunt aliquid. Deserunt explicabo corporis quo omnis aspernatur. Beatae accusantium recusandae doloribus enim quo quis tempora. Voluptates similique accusamus quos laudantium nesciunt laboriosam commodi eligendi. Facilis tempore temporibus sit illo.
+ slug: product-358866
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-03-07T09:49:22.902Z'
- created_at: '2026-03-07T09:49:22.914Z'
- updated_at: '2026-03-07T09:49:22.924Z'
+ available_on: '2025-03-07T11:32:14.487Z'
+ created_at: '2026-03-07T11:32:14.502Z'
+ updated_at: '2026-03-07T11:32:14.516Z'
purchasable: true
in_stock: false
backorderable: true
@@ -4291,11 +4293,11 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-03-07T09:49:22.916Z'
- updated_at: '2026-03-07T09:49:22.916Z'
+ created_at: '2026-03-07T11:32:14.504Z'
+ updated_at: '2026-03-07T11:32:14.504Z'
original_price:
status: active
- make_active_at: '2025-03-07T09:49:22.902Z'
+ make_active_at: '2025-03-07T11:32:14.487Z'
discontinue_on:
meta_title:
promotionable: true
@@ -4353,15 +4355,17 @@ paths:
id: prod_UkLWZg9DAJ
name: Updated Name
description: |-
- Consequatur illum sint quidem amet labore incidunt minus. A perspiciatis deleniti non voluptate. Perspiciatis vitae laboriosam dolor id perferendis dignissimos quas. Similique vero delectus iste minima. Error assumenda laudantium nostrum aliquid.
- Doloribus corrupti atque quidem necessitatibus saepe esse odio. Laboriosam repellendus quas qui nihil velit delectus. Minima atque vitae nam hic accusamus. Exercitationem voluptatibus beatae qui officiis hic veniam.
- slug: product-365151
+ Quibusdam veritatis aperiam officiis vero debitis. Assumenda impedit amet occaecati qui. Repellat amet facere quam vitae nisi. Recusandae quam minima similique minus doloremque nihil id.
+ Mollitia voluptates sit asperiores soluta dolore quibusdam sequi officia. Sit repellendus commodi beatae laudantium temporibus quia ipsam. Doloremque at eum earum enim numquam quas nemo. Impedit voluptas dolor est illo. Fugit iste expedita placeat sapiente neque nostrum.
+ Aspernatur quis saepe tempore dolores magnam. Numquam nisi voluptate optio quisquam. Dolores quae nobis amet ea alias.
+ Voluptatem debitis necessitatibus nobis voluptas et facilis minus. Maiores rem fuga officia mollitia. Similique veritatis aliquid voluptate debitis doloribus ea animi. Perferendis exercitationem eum consequuntur quae expedita.
+ slug: product-374144
meta_description:
meta_keywords:
variant_count: 0
- available_on: '2025-03-07T09:49:23.540Z'
- created_at: '2026-03-07T09:49:23.552Z'
- updated_at: '2026-03-07T09:49:23.856Z'
+ available_on: '2025-03-07T11:32:15.139Z'
+ created_at: '2026-03-07T11:32:15.152Z'
+ updated_at: '2026-03-07T11:32:15.480Z'
purchasable: true
in_stock: false
backorderable: true
@@ -4380,11 +4384,11 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_UkLWZg9DAJ
- created_at: '2026-03-07T09:49:23.554Z'
- updated_at: '2026-03-07T09:49:23.554Z'
+ created_at: '2026-03-07T11:32:15.154Z'
+ updated_at: '2026-03-07T11:32:15.154Z'
original_price:
status: active
- make_active_at: '2025-03-07T09:49:23.540Z'
+ make_active_at: '2025-03-07T11:32:15.139Z'
discontinue_on:
meta_title:
promotionable: true
@@ -4556,29 +4560,29 @@ paths:
- id: txnmy_UkLWZg9DAJ
name: Categories
position: 1
- created_at: '2026-03-07T09:48:52.290Z'
- updated_at: '2026-03-07T09:48:52.310Z'
+ created_at: '2026-03-07T11:31:41.908Z'
+ updated_at: '2026-03-07T11:31:41.929Z'
root_id: txn_UkLWZg9DAJ
store_id: store_UkLWZg9DAJ
- id: txnmy_gbHJdmfrXB
name: Brands
position: 2
- created_at: '2026-03-07T09:48:52.311Z'
- updated_at: '2026-03-07T09:48:52.319Z'
+ created_at: '2026-03-07T11:31:41.931Z'
+ updated_at: '2026-03-07T11:31:41.940Z'
root_id: txn_gbHJdmfrXB
store_id: store_UkLWZg9DAJ
- id: txnmy_EfhxLZ9ck8
name: Collections
position: 3
- created_at: '2026-03-07T09:48:52.321Z'
- updated_at: '2026-03-07T09:48:52.387Z'
+ created_at: '2026-03-07T11:31:41.942Z'
+ updated_at: '2026-03-07T11:31:41.999Z'
root_id: txn_EfhxLZ9ck8
store_id: store_UkLWZg9DAJ
- id: txnmy_VqXmZF31wY
name: taxonomy_1
position: 4
- created_at: '2026-03-07T09:49:24.550Z'
- updated_at: '2026-03-07T09:49:24.559Z'
+ created_at: '2026-03-07T11:32:16.258Z'
+ updated_at: '2026-03-07T11:32:16.268Z'
root_id: txn_OIJLhNcSbf
store_id: store_UkLWZg9DAJ
meta:
@@ -4642,8 +4646,8 @@ paths:
id: txnmy_uw2YK1rnl0
name: New Taxonomy
position: 5
- created_at: '2026-03-07T09:49:25.419Z'
- updated_at: '2026-03-07T09:49:25.428Z'
+ created_at: '2026-03-07T11:32:17.147Z'
+ updated_at: '2026-03-07T11:32:17.156Z'
root_id: txn_AXs1igzRC6
store_id: store_UkLWZg9DAJ
schema:
@@ -4717,8 +4721,8 @@ paths:
id: txnmy_VqXmZF31wY
name: taxonomy_5
position: 4
- created_at: '2026-03-07T09:49:25.732Z'
- updated_at: '2026-03-07T09:49:25.740Z'
+ created_at: '2026-03-07T11:32:17.459Z'
+ updated_at: '2026-03-07T11:32:17.466Z'
root_id: txn_OIJLhNcSbf
store_id: store_UkLWZg9DAJ
schema:
@@ -4769,8 +4773,8 @@ paths:
id: txnmy_VqXmZF31wY
name: Updated Taxonomy
position: 4
- created_at: '2026-03-07T09:49:26.309Z'
- updated_at: '2026-03-07T09:49:26.603Z'
+ created_at: '2026-03-07T11:32:18.050Z'
+ updated_at: '2026-03-07T11:32:18.346Z'
root_id: txn_OIJLhNcSbf
store_id: store_UkLWZg9DAJ
schema:
@@ -4884,8 +4888,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:48:52.301Z'
- updated_at: '2026-03-07T09:48:52.309Z'
+ created_at: '2026-03-07T11:31:41.919Z'
+ updated_at: '2026-03-07T11:31:41.927Z'
parent_id:
taxonomy_id: txnmy_UkLWZg9DAJ
description: ''
@@ -4910,8 +4914,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:48:52.314Z'
- updated_at: '2026-03-07T09:48:52.318Z'
+ created_at: '2026-03-07T11:31:41.934Z'
+ updated_at: '2026-03-07T11:31:41.939Z'
parent_id:
taxonomy_id: txnmy_gbHJdmfrXB
description: ''
@@ -4936,8 +4940,8 @@ paths:
meta_description:
meta_keywords:
children_count: 2
- created_at: '2026-03-07T09:48:52.325Z'
- updated_at: '2026-03-07T09:48:52.387Z'
+ created_at: '2026-03-07T11:31:41.944Z'
+ updated_at: '2026-03-07T11:31:41.999Z'
parent_id:
taxonomy_id: txnmy_EfhxLZ9ck8
description: ''
@@ -4962,8 +4966,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:48:52.339Z'
- updated_at: '2026-03-07T09:48:52.342Z'
+ created_at: '2026-03-07T11:31:41.956Z'
+ updated_at: '2026-03-07T11:31:41.958Z'
parent_id: txn_EfhxLZ9ck8
taxonomy_id: txnmy_EfhxLZ9ck8
description: ''
@@ -4988,8 +4992,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:48:52.353Z'
- updated_at: '2026-03-07T09:48:52.354Z'
+ created_at: '2026-03-07T11:31:41.968Z'
+ updated_at: '2026-03-07T11:31:41.970Z'
parent_id: txn_EfhxLZ9ck8
taxonomy_id: txnmy_EfhxLZ9ck8
description: ''
@@ -5014,8 +5018,8 @@ paths:
meta_description:
meta_keywords:
children_count: 1
- created_at: '2026-03-07T09:49:27.237Z'
- updated_at: '2026-03-07T09:49:27.252Z'
+ created_at: '2026-03-07T11:32:18.961Z'
+ updated_at: '2026-03-07T11:32:18.984Z'
parent_id:
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5040,8 +5044,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:27.245Z'
- updated_at: '2026-03-07T09:49:27.250Z'
+ created_at: '2026-03-07T11:32:18.970Z'
+ updated_at: '2026-03-07T11:32:18.982Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5138,8 +5142,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:27.868Z'
- updated_at: '2026-03-07T09:49:27.874Z'
+ created_at: '2026-03-07T11:32:19.607Z'
+ updated_at: '2026-03-07T11:32:19.613Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5223,8 +5227,8 @@ paths:
meta_description:
meta_keywords:
children_count: 1
- created_at: '2026-03-07T09:49:28.464Z'
- updated_at: '2026-03-07T09:49:28.478Z'
+ created_at: '2026-03-07T11:32:20.215Z'
+ updated_at: '2026-03-07T11:32:20.230Z'
parent_id:
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5249,8 +5253,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:28.471Z'
- updated_at: '2026-03-07T09:49:28.477Z'
+ created_at: '2026-03-07T11:32:20.223Z'
+ updated_at: '2026-03-07T11:32:20.229Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5329,8 +5333,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:29.076Z'
- updated_at: '2026-03-07T09:49:29.089Z'
+ created_at: '2026-03-07T11:32:20.825Z'
+ updated_at: '2026-03-07T11:32:20.832Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5450,8 +5454,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:29.424Z'
- updated_at: '2026-03-07T09:49:29.430Z'
+ created_at: '2026-03-07T11:32:21.154Z'
+ updated_at: '2026-03-07T11:32:21.159Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5527,8 +5531,8 @@ paths:
meta_description:
meta_keywords:
children_count: 0
- created_at: '2026-03-07T09:49:30.176Z'
- updated_at: '2026-03-07T09:49:30.465Z'
+ created_at: '2026-03-07T11:32:21.782Z'
+ updated_at: '2026-03-07T11:32:22.074Z'
parent_id: txn_OIJLhNcSbf
taxonomy_id: txnmy_VqXmZF31wY
description: ''
@@ -5623,6 +5627,251 @@ paths:
responses:
'204':
description: taxon deleted
+ "/api/v3/admin/products/{product_id}/variants/{variant_id}/assets":
+ get:
+ summary: List variant assets
+ tags:
+ - Variant Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Returns a paginated list of assets (images) for a variant.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: variant_id
+ in: path
+ required: true
+ description: Variant prefixed ID
+ schema:
+ type: string
+ - name: page
+ in: query
+ required: false
+ description: Page number
+ schema:
+ type: integer
+ - name: limit
+ in: query
+ required: false
+ description: Number of records per page
+ schema:
+ type: integer
+ responses:
+ '200':
+ description: variant assets found
+ content:
+ application/json:
+ example:
+ data:
+ - id: asset_UkLWZg9DAJ
+ viewable_id: variant_gbHJdmfrXB
+ type:
+ viewable_type: Spree::Variant
+ position: 1
+ alt:
+ created_at: '2026-03-07T11:32:22.752Z'
+ updated_at: '2026-03-07T11:32:22.755Z'
+ meta:
+ page: 1
+ limit: 25
+ count: 1
+ pages: 1
+ from: 1
+ to: 1
+ in: 1
+ previous:
+ next:
+ post:
+ summary: Create a variant asset
+ tags:
+ - Variant Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Creates a new asset (image) for a variant.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: variant_id
+ in: path
+ required: true
+ description: Variant prefixed ID
+ schema:
+ type: string
+ responses:
+ '202':
+ description: variant asset import from URL enqueued
+ '422':
+ description: validation error (attachment required)
+ content:
+ application/json:
+ example:
+ error:
+ code: validation_error
+ message: Attachment can't be blank
+ details:
+ attachment:
+ - can't be blank
+ schema:
+ "$ref": "#/components/schemas/ErrorResponse"
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ alt:
+ type: string
+ example: Variant image
+ position:
+ type: integer
+ example: 1
+ type:
+ type: string
+ example: Spree::Image
+ description: Asset type (defaults to Spree::Image)
+ url:
+ type: string
+ example: https://example.com/image.jpg
+ description: External URL to import image from (async). Returns
+ 202 Accepted.
+ "/api/v3/admin/products/{product_id}/variants/{variant_id}/assets/{id}":
+ patch:
+ summary: Update a variant asset
+ tags:
+ - Variant Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Updates a variant asset. Only provided fields are updated.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: variant_id
+ in: path
+ required: true
+ description: Variant prefixed ID
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ description: Asset prefixed ID
+ schema:
+ type: string
+ responses:
+ '200':
+ description: variant asset updated
+ content:
+ application/json:
+ example:
+ id: asset_UkLWZg9DAJ
+ viewable_id: variant_gbHJdmfrXB
+ type:
+ viewable_type: Spree::Variant
+ position: 1
+ alt: Updated variant image
+ created_at: '2026-03-07T11:32:23.817Z'
+ updated_at: '2026-03-07T11:32:24.112Z'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ alt:
+ type: string
+ example: Updated variant image
+ position:
+ type: integer
+ example: 2
+ delete:
+ summary: Delete a variant asset
+ tags:
+ - Variant Assets
+ security:
+ - api_key: []
+ bearer_auth: []
+ description: Deletes an asset from a variant.
+ parameters:
+ - name: x-spree-api-key
+ in: header
+ required: true
+ schema:
+ type: string
+ - name: Authorization
+ in: header
+ required: true
+ description: Bearer token for admin authentication
+ schema:
+ type: string
+ - name: product_id
+ in: path
+ required: true
+ description: Product prefixed ID
+ schema:
+ type: string
+ - name: variant_id
+ in: path
+ required: true
+ description: Variant prefixed ID
+ schema:
+ type: string
+ - name: id
+ in: path
+ required: true
+ description: Asset prefixed ID
+ schema:
+ type: string
+ responses:
+ '204':
+ description: variant asset deleted
"/api/v3/admin/products/{product_id}/variants":
get:
summary: List product variants
@@ -5679,13 +5928,13 @@ paths:
data:
- id: variant_UkLWZg9DAJ
product_id: prod_UkLWZg9DAJ
- sku: SKU-45
+ sku: SKU-56
is_master: true
options_text: ''
track_inventory: true
image_count: 0
- created_at: '2026-03-07T09:49:31.204Z'
- updated_at: '2026-03-07T09:49:31.218Z'
+ created_at: '2026-03-07T11:32:24.497Z'
+ updated_at: '2026-03-07T11:32:24.517Z'
thumbnail:
purchasable: false
in_stock: false
@@ -5721,21 +5970,21 @@ paths:
total_on_hand: 0
- id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
- sku: SKU-46
+ sku: SKU-57
is_master: false
options_text: 'Size: S'
track_inventory: true
image_count: 0
- created_at: '2026-03-07T09:49:31.230Z'
- updated_at: '2026-03-07T09:49:31.246Z'
+ created_at: '2026-03-07T11:32:24.534Z'
+ updated_at: '2026-03-07T11:32:24.553Z'
thumbnail:
purchasable: true
in_stock: false
backorderable: true
- weight: 99.54
- height: 43.63
- width: 184.31
- depth: 123.69
+ weight: 150.88
+ height: 30.39
+ width: 128.66
+ depth: 67.13
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -5747,19 +5996,19 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_gbHJdmfrXB
- created_at: '2026-03-07T09:49:31.232Z'
- updated_at: '2026-03-07T09:49:31.232Z'
+ created_at: '2026-03-07T11:32:24.535Z'
+ updated_at: '2026-03-07T11:32:24.535Z'
original_price:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-7
+ name: size-12
presentation: S
position: 1
- option_type_name: foo-size-16
+ option_type_name: foo-size-21
option_type_presentation: Size
- created_at: '2026-03-07T09:49:31.236Z'
- updated_at: '2026-03-07T09:49:31.236Z'
+ created_at: '2026-03-07T11:32:24.540Z'
+ updated_at: '2026-03-07T11:32:24.540Z'
position: 2
tax_category_id: 1
cost_price: '17.0'
@@ -5823,8 +6072,8 @@ paths:
options_text: 'Size: XL'
track_inventory: true
image_count: 0
- created_at: '2026-03-07T09:49:31.940Z'
- updated_at: '2026-03-07T09:49:31.942Z'
+ created_at: '2026-03-07T11:32:25.277Z'
+ updated_at: '2026-03-07T11:32:25.280Z'
thumbnail:
purchasable: false
in_stock: false
@@ -5844,8 +6093,8 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_EfhxLZ9ck8
- created_at: '2026-03-07T09:49:31.941Z'
- updated_at: '2026-03-07T09:49:31.941Z'
+ created_at: '2026-03-07T11:32:25.279Z'
+ updated_at: '2026-03-07T11:32:25.279Z'
original_price:
option_values:
- id: optval_gbHJdmfrXB
@@ -5855,8 +6104,8 @@ paths:
position: 1
option_type_name: size
option_type_presentation: Size
- created_at: '2026-03-07T09:49:31.936Z'
- updated_at: '2026-03-07T09:49:31.936Z'
+ created_at: '2026-03-07T11:32:25.273Z'
+ updated_at: '2026-03-07T11:32:25.273Z'
position: 3
tax_category_id: 1
cost_price:
@@ -6008,21 +6257,21 @@ paths:
example:
id: variant_gbHJdmfrXB
product_id: prod_UkLWZg9DAJ
- sku: SKU-52
+ sku: SKU-63
is_master: false
options_text: 'Size: S'
track_inventory: true
image_count: 0
- created_at: '2026-03-07T09:49:32.412Z'
- updated_at: '2026-03-07T09:49:32.423Z'
+ created_at: '2026-03-07T11:32:25.683Z'
+ updated_at: '2026-03-07T11:32:25.693Z'
thumbnail:
purchasable: true
in_stock: false
backorderable: true
- weight: 28.96
- height: 55.66
- width: 97.34
- depth: 133.49
+ weight: 43.27
+ height: 73.76
+ width: 121.26
+ depth: 148.3
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -6034,19 +6283,19 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_gbHJdmfrXB
- created_at: '2026-03-07T09:49:32.413Z'
- updated_at: '2026-03-07T09:49:32.413Z'
+ created_at: '2026-03-07T11:32:25.684Z'
+ updated_at: '2026-03-07T11:32:25.684Z'
original_price:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-10
+ name: size-15
presentation: S
position: 1
- option_type_name: foo-size-19
+ option_type_name: foo-size-24
option_type_presentation: Size
- created_at: '2026-03-07T09:49:32.416Z'
- updated_at: '2026-03-07T09:49:32.416Z'
+ created_at: '2026-03-07T11:32:25.687Z'
+ updated_at: '2026-03-07T11:32:25.687Z'
position: 2
tax_category_id: 1
cost_price: '17.0'
@@ -6114,16 +6363,16 @@ paths:
options_text: 'Size: S'
track_inventory: true
image_count: 0
- created_at: '2026-03-07T09:49:33.130Z'
- updated_at: '2026-03-07T09:49:33.506Z'
+ created_at: '2026-03-07T11:32:26.385Z'
+ updated_at: '2026-03-07T11:32:26.697Z'
thumbnail:
purchasable: true
in_stock: false
backorderable: true
- weight: 164.39
- height: 7.16
- width: 13.85
- depth: 84.33
+ weight: 51.81
+ height: 38.57
+ width: 136.5
+ depth: 87.66
price:
id: price_gbHJdmfrXB
amount: '19.99'
@@ -6135,19 +6384,19 @@ paths:
display_compare_at_amount:
price_list_id:
variant_id: variant_gbHJdmfrXB
- created_at: '2026-03-07T09:49:33.131Z'
- updated_at: '2026-03-07T09:49:33.131Z'
+ created_at: '2026-03-07T11:32:26.386Z'
+ updated_at: '2026-03-07T11:32:26.386Z'
original_price:
option_values:
- id: optval_UkLWZg9DAJ
option_type_id: opt_UkLWZg9DAJ
- name: size-12
+ name: size-17
presentation: S
position: 1
- option_type_name: foo-size-21
+ option_type_name: foo-size-26
option_type_presentation: Size
- created_at: '2026-03-07T09:49:33.133Z'
- updated_at: '2026-03-07T09:49:33.133Z'
+ created_at: '2026-03-07T11:32:26.388Z'
+ updated_at: '2026-03-07T11:32:26.388Z'
position: 2
tax_category_id: 1
cost_price: '17.0'
diff --git a/packages/sdk-core/src/request.ts b/packages/sdk-core/src/request.ts
index 515227d284..8d502cc072 100644
--- a/packages/sdk-core/src/request.ts
+++ b/packages/sdk-core/src/request.ts
@@ -193,8 +193,8 @@ export function createRequestFn(
throw new SpreeError(errorBody, response.status);
}
- // Handle 204 No Content
- if (response.status === 204) {
+ // Handle 202 Accepted / 204 No Content (empty body)
+ if (response.status === 202 || response.status === 204) {
return undefined as T;
}
diff --git a/packages/sdk/scripts/generate-admin-client.ts b/packages/sdk/scripts/generate-admin-client.ts
index 07b2d6321f..482a0be8f2 100644
--- a/packages/sdk/scripts/generate-admin-client.ts
+++ b/packages/sdk/scripts/generate-admin-client.ts
@@ -199,6 +199,10 @@ interface Resource {
parentName?: string;
/** Parent path param, e.g. 'product_id' */
parentParam?: string;
+ /** Grandparent resource name for deeply nested, e.g. 'products' for variant assets */
+ grandparentName?: string;
+ /** Grandparent path param, e.g. 'product_id' for variant assets */
+ grandparentParam?: string;
endpoints: ResourceEndpoint[];
}
@@ -247,15 +251,45 @@ function analyzeResources(spec: OpenApiSpec): Resource[] {
// /products → resource=products
// /products/{id} → resource=products
// /products/{product_id}/variants → resource=variants, parent=products
- // /products/{product_id}/variants/{id} → resource=variants, parent=products
+ // /products/{product_id}/variants/{variant_id}/assets → resource=assets, parent=variants, grandparent=products
const segments = apiPath.split('/').filter(Boolean);
let resourceName: string;
let basePath: string;
let parentName: string | undefined;
let parentParam: string | undefined;
+ let grandparentName: string | undefined;
+ let grandparentParam: string | undefined;
+
+ if (segments.length >= 5 && segments[1].startsWith('{') && segments[3].startsWith('{')) {
+ // 5+ segments: /parent/{id}/child/{id}/something
+ // If the 5th segment is a resource name (has collection/member endpoints), it's deeply nested.
+ // If it's a custom action name (no sub-paths with /{id}), it's a member action on the child resource.
+ const fifthSegment = segments[4];
+ const potentialDeepBasePath = `${API_PREFIX}/${segments[0]}/${segments[1]}/${segments[2]}/${segments[3]}/${fifthSegment}`;
+ const hasDeepCollection = Object.keys(spec.paths).some(
+ (p) => p === potentialDeepBasePath && (spec.paths[p]?.get || spec.paths[p]?.post)
+ );
+ const hasDeepMember = Object.keys(spec.paths).some(
+ (p) => p.startsWith(potentialDeepBasePath + '/{')
+ );
- if (segments.length >= 3 && segments[1].startsWith('{') && segments[1].endsWith('}')) {
+ if (hasDeepCollection || hasDeepMember) {
+ // Deeply nested resource: /products/{product_id}/variants/{variant_id}/assets
+ grandparentName = segments[0];
+ grandparentParam = segments[1].slice(1, -1);
+ parentName = segments[2];
+ parentParam = segments[3].slice(1, -1);
+ resourceName = segments[4];
+ basePath = potentialDeepBasePath;
+ } else {
+ // Custom member action on nested resource: /orders/{order_id}/payments/{id}/capture
+ parentName = segments[0];
+ parentParam = segments[1].slice(1, -1);
+ resourceName = segments[2];
+ basePath = `${API_PREFIX}/${segments[0]}/${segments[1]}/${segments[2]}`;
+ }
+ } else if (segments.length >= 3 && segments[1].startsWith('{') && segments[1].endsWith('}')) {
// Check if this is a member action (e.g., /orders/{id}/cancel) vs a nested resource
// Member actions: only have /parent/{id}/action (no further /{id})
// Nested resources: have /parent/{id}/resource and /parent/{id}/resource/{id}
@@ -288,7 +322,9 @@ function analyzeResources(spec: OpenApiSpec): Resource[] {
basePath = `${API_PREFIX}/${segments[0]}`;
}
- const resourceKey = parentName ? `${parentName}.${resourceName}` : resourceName;
+ const resourceKey = grandparentName
+ ? `${grandparentName}.${parentName}.${resourceName}`
+ : parentName ? `${parentName}.${resourceName}` : resourceName;
const { action, customAction } = classifyAction(httpMethod, fullPath, basePath);
if (!resourceMap.has(resourceKey)) {
@@ -298,6 +334,8 @@ function analyzeResources(spec: OpenApiSpec): Resource[] {
basePath,
parentName,
parentParam,
+ grandparentName,
+ grandparentParam,
endpoints: [],
});
}
@@ -408,8 +446,37 @@ function generateRequestParamType(
function generateResourceMethods(resource: Resource, paramTypes: Map<string, string>): string {
const lines: string[] = [];
const responseType = getResponseType(resource);
- const hasParent = !!resource.parentName;
- const parentParamName = resource.parentParam ? camelCase(resource.parentParam) : '';
+
+ // Build parent param declarations and URL prefix
+ const parentParams: { name: string; camel: string }[] = [];
+ if (resource.grandparentParam) {
+ parentParams.push({ name: resource.grandparentParam, camel: camelCase(resource.grandparentParam) });
+ }
+ if (resource.parentParam) {
+ parentParams.push({ name: resource.parentParam, camel: camelCase(resource.parentParam) });
+ }
+
+ // Build URL prefix: e.g. `/products/${productId}/variants/${variantId}/assets`
+ let urlPrefix: string;
+ if (resource.grandparentName && resource.parentName) {
+ urlPrefix = `/${resource.grandparentName}/\${${parentParams[0].camel}}/${resource.parentName}/\${${parentParams[1].camel}}/${resource.name}`;
+ } else if (resource.parentName) {
+ urlPrefix = `/${resource.parentName}/\${${parentParams[0].camel}}/${resource.name}`;
+ } else {
+ urlPrefix = `/${resource.name}`;
+ }
+ const hasParent = parentParams.length > 0;
+ const useBacktick = hasParent;
+
+ const parentParamDecls = parentParams.map((p) => ` ${p.camel}: string,`);
+
+ // Build path string for generated code. Always uses backtick template literal.
+ function collectionPath() {
+ return `\`${urlPrefix}\``;
+ }
+ function memberPath(suffix = '') {
+ return `\`${urlPrefix}/\${id}${suffix}\``;
+ }
for (const endpoint of resource.endpoints) {
const { action, method, operation, customAction } = endpoint;
@@ -420,53 +487,30 @@ function generateResourceMethods(resource: Resource, paramTypes: Map<string, str
switch (action) {
case 'list': {
if (jsdoc) lines.push(jsdoc);
- if (hasParent) {
- lines.push(` list: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` params?: ListParams,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<PaginatedResponse<${responseType}>> =>`);
- lines.push(` this.request<PaginatedResponse<${responseType}>>('GET', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}\`, {`);
- lines.push(` ...options,`);
- lines.push(` params: transformListParams({ ...params }),`);
- lines.push(` }),`);
- } else {
- lines.push(` list: (`);
- lines.push(` params?: ListParams,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<PaginatedResponse<${responseType}>> =>`);
- lines.push(` this.request<PaginatedResponse<${responseType}>>('GET', '/${resource.name}', {`);
- lines.push(` ...options,`);
- lines.push(` params: transformListParams({ ...params }),`);
- lines.push(` }),`);
- }
+ lines.push(` list: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` params?: ListParams,`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<PaginatedResponse<${responseType}>> =>`);
+ lines.push(` this.request<PaginatedResponse<${responseType}>>('GET', ${collectionPath()}, {`);
+ lines.push(` ...options,`);
+ lines.push(` params: transformListParams({ ...params }),`);
+ lines.push(` }),`);
break;
}
case 'get': {
if (jsdoc) lines.push(jsdoc);
- if (hasParent) {
- lines.push(` get: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` id: string,`);
- lines.push(` params?: { expand?: string[] },`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('GET', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}/\${id}\`, {`);
- lines.push(` ...options,`);
- lines.push(` params: getParams(params),`);
- lines.push(` }),`);
- } else {
- lines.push(` get: (`);
- lines.push(` id: string,`);
- lines.push(` params?: { expand?: string[] },`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('GET', \`/${resource.name}/\${id}\`, {`);
- lines.push(` ...options,`);
- lines.push(` params: getParams(params),`);
- lines.push(` }),`);
- }
+ lines.push(` get: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` id: string,`);
+ lines.push(` params?: { expand?: string[] },`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<${responseType}> =>`);
+ lines.push(` this.request<${responseType}>('GET', ${memberPath()}, {`);
+ lines.push(` ...options,`);
+ lines.push(` params: getParams(params),`);
+ lines.push(` }),`);
break;
}
@@ -474,26 +518,15 @@ function generateResourceMethods(resource: Resource, paramTypes: Map<string, str
const createTypeName = `Admin${singularPascal(resource.name)}CreateParams`;
const paramType = paramTypes.has(createTypeName) ? createTypeName : 'Record<string, unknown>';
if (jsdoc) lines.push(jsdoc);
- if (hasParent) {
- lines.push(` create: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` params: ${paramType},`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('POST', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}\`, {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- } else {
- lines.push(` create: (`);
- lines.push(` params: ${paramType},`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('POST', '/${resource.name}', {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- }
+ lines.push(` create: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` params: ${paramType},`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<${responseType}> =>`);
+ lines.push(` this.request<${responseType}>('POST', ${collectionPath()}, {`);
+ lines.push(` ...options,`);
+ lines.push(` body: params,`);
+ lines.push(` }),`);
break;
}
@@ -501,47 +534,27 @@ function generateResourceMethods(resource: Resource, paramTypes: Map<string, str
const updateTypeName = `Admin${singularPascal(resource.name)}UpdateParams`;
const paramType = paramTypes.has(updateTypeName) ? updateTypeName : 'Record<string, unknown>';
if (jsdoc) lines.push(jsdoc);
- if (hasParent) {
- lines.push(` update: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` id: string,`);
- lines.push(` params: ${paramType},`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('PATCH', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}/\${id}\`, {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- } else {
- lines.push(` update: (`);
- lines.push(` id: string,`);
- lines.push(` params: ${paramType},`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('PATCH', \`/${resource.name}/\${id}\`, {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- }
+ lines.push(` update: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` id: string,`);
+ lines.push(` params: ${paramType},`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<${responseType}> =>`);
+ lines.push(` this.request<${responseType}>('PATCH', ${memberPath()}, {`);
+ lines.push(` ...options,`);
+ lines.push(` body: params,`);
+ lines.push(` }),`);
break;
}
case 'delete': {
if (jsdoc) lines.push(jsdoc);
- if (hasParent) {
- lines.push(` delete: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` id: string,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<void> =>`);
- lines.push(` this.request<void>('DELETE', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}/\${id}\`, options),`);
- } else {
- lines.push(` delete: (`);
- lines.push(` id: string,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<void> =>`);
- lines.push(` this.request<void>('DELETE', \`/${resource.name}/\${id}\`, options),`);
- }
+ lines.push(` delete: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` id: string,`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<void> =>`);
+ lines.push(` this.request<void>('DELETE', ${memberPath()}, options),`);
break;
}
@@ -549,30 +562,17 @@ function generateResourceMethods(resource: Resource, paramTypes: Map<string, str
if (!customAction) break;
const fnName = camelCase(customAction);
if (jsdoc) lines.push(jsdoc);
- // Custom actions are always on a member (POST /resources/{id}/action)
if (method === 'POST' || method === 'PATCH') {
- if (hasParent) {
- lines.push(` ${fnName}: (`);
- lines.push(` ${parentParamName}: string,`);
- lines.push(` id: string,`);
- lines.push(` params?: Record<string, unknown>,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('${method}', \`/${resource.parentName}/\${${parentParamName}}/${resource.name}/\${id}/${customAction}\`, {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- } else {
- lines.push(` ${fnName}: (`);
- lines.push(` id: string,`);
- lines.push(` params?: Record<string, unknown>,`);
- lines.push(` options?: RequestOptions`);
- lines.push(` ): Promise<${responseType}> =>`);
- lines.push(` this.request<${responseType}>('${method}', \`/${resource.name}/\${id}/${customAction}\`, {`);
- lines.push(` ...options,`);
- lines.push(` body: params,`);
- lines.push(` }),`);
- }
+ lines.push(` ${fnName}: (`);
+ lines.push(...parentParamDecls);
+ lines.push(` id: string,`);
+ lines.push(` params?: Record<string, unknown>,`);
+ lines.push(` options?: RequestOptions`);
+ lines.push(` ): Promise<${responseType}> =>`);
+ lines.push(` this.request<${responseType}>('${method}', ${memberPath(`/${customAction}`)}, {`);
+ lines.push(` ...options,`);
+ lines.push(` body: params,`);
+ lines.push(` }),`);
}
break;
}
@@ -623,9 +623,10 @@ function generateClient(spec: OpenApiSpec): { client: string; params: string } {
responseTypes.add(getResponseType(resource));
}
- // Group resources: top-level vs nested
+ // Group resources: top-level, 1-level nested, deeply nested (2-level)
const topLevel = resources.filter((r) => !r.parentName);
- const nested = resources.filter((r) => r.parentName);
+ const nested = resources.filter((r) => r.parentName && !r.grandparentName);
+ const deeplyNested = resources.filter((r) => r.grandparentName);
// Build imports
const importedTypes = [...responseTypes].sort();
@@ -716,6 +717,11 @@ function generateClient(spec: OpenApiSpec): { client: string; params: string } {
// Add nested resources as sub-objects
for (const nestedResource of nestedResources) {
const nestedPropName = camelCase(nestedResource.name);
+ // Find deeply nested resources under this nested resource
+ const deepChildren = deeplyNested.filter(
+ (d) => d.grandparentName === resource.name && d.parentName === nestedResource.name
+ );
+
out.push(` /** Nested: ${resource.name}/{id}/${nestedResource.name} */`);
out.push(` ${nestedPropName}: {`);
// Indent nested methods by 2 more spaces
@@ -724,6 +730,21 @@ function generateClient(spec: OpenApiSpec): { client: string; params: string } {
.map((line) => (line.trim() ? ` ${line}` : line))
.join('\n');
out.push(nestedMethods);
+
+ // Add deeply nested resources as sub-sub-objects
+ for (const deepResource of deepChildren) {
+ const deepPropName = camelCase(deepResource.name);
+ out.push(` /** Nested: ${resource.name}/{id}/${nestedResource.name}/{id}/${deepResource.name} */`);
+ out.push(` ${deepPropName}: {`);
+ const deepMethods = generateResourceMethods(deepResource, paramTypes)
+ .split('\n')
+ .map((line) => (line.trim() ? ` ${line}` : line))
+ .join('\n');
+ out.push(deepMethods);
+ out.push(` },`);
+ out.push(``);
+ }
+
out.push(` },`);
out.push(``);
}
diff --git a/packages/sdk/src/admin-client.ts b/packages/sdk/src/admin-client.ts
index 743a1feb99..c78efb576b 100644
--- a/packages/sdk/src/admin-client.ts
+++ b/packages/sdk/src/admin-client.ts
@@ -106,7 +106,7 @@ export class AdminClient {
params?: ListParams,
options?: RequestOptions
): Promise<PaginatedResponse<AdminOptionType>> =>
- this.request<PaginatedResponse<AdminOptionType>>('GET', '/option_types', {
+ this.request<PaginatedResponse<AdminOptionType>>('GET', `/option_types`, {
...options,
params: transformListParams({ ...params }),
}),
@@ -116,7 +116,7 @@ export class AdminClient {
params: AdminOptionTypeCreateParams,
options?: RequestOptions
): Promise<AdminOptionType> =>
- this.request<AdminOptionType>('POST', '/option_types', {
+ this.request<AdminOptionType>('POST', `/option_types`, {
...options,
body: params,
}),
@@ -162,7 +162,7 @@ export class AdminClient {
params?: ListParams,
options?: RequestOptions
): Promise<PaginatedResponse<AdminOrder>> =>
- this.request<PaginatedResponse<AdminOrder>>('GET', '/orders', {
+ this.request<PaginatedResponse<AdminOrder>>('GET', `/orders`, {
...options,
params: transformListParams({ ...params }),
}),
@@ -172,7 +172,7 @@ export class AdminClient {
params: AdminOrderCreateParams,
options?: RequestOptions
): Promise<AdminOrder> =>
- this.request<AdminOrder>('POST', '/orders', {
+ this.request<AdminOrder>('POST', `/orders`, {
...options,
body: params,
}),
@@ -553,7 +553,7 @@ export class AdminClient {
params?: ListParams,
options?: RequestOptions
): Promise<PaginatedResponse<AdminProduct>> =>
- this.request<PaginatedResponse<AdminProduct>>('GET', '/products', {
+ this.request<PaginatedResponse<AdminProduct>>('GET', `/products`, {
...options,
params: transformListParams({ ...params }),
}),
@@ -563,7 +563,7 @@ export class AdminClient {
params: AdminProductCreateParams,
options?: RequestOptions
): Promise<AdminProduct> =>
- this.request<AdminProduct>('POST', '/products', {
+ this.request<AdminProduct>('POST', `/products`, {
...options,
body: params,
}),
@@ -610,7 +610,7 @@ export class AdminClient {
params: transformListParams({ ...params }),
}),
- /** Create an asset */
+ /** Create a product asset */
create: (
productId: string,
params: AdminAssetCreateParams,
@@ -621,7 +621,7 @@ export class AdminClient {
body: params,
}),
- /** Update an asset */
+ /** Update a product asset */
update: (
productId: string,
id: string,
@@ -633,7 +633,7 @@ export class AdminClient {
body: params,
}),
- /** Delete an asset */
+ /** Delete a product asset */
delete: (
productId: string,
id: string,
@@ -699,6 +699,56 @@ export class AdminClient {
): Promise<void> =>
this.request<void>('DELETE', `/products/${productId}/variants/${id}`, options),
+ /** Nested: products/{id}/variants/{id}/assets */
+ assets: {
+ /** List variant assets */
+ list: (
+ productId: string,
+ variantId: string,
+ params?: ListParams,
+ options?: RequestOptions
+ ): Promise<PaginatedResponse<AdminAsset>> =>
+ this.request<PaginatedResponse<AdminAsset>>('GET', `/products/${productId}/variants/${variantId}/assets`, {
+ ...options,
+ params: transformListParams({ ...params }),
+ }),
+
+ /** Create a variant asset */
+ create: (
+ productId: string,
+ variantId: string,
+ params: AdminAssetCreateParams,
+ options?: RequestOptions
+ ): Promise<AdminAsset> =>
+ this.request<AdminAsset>('POST', `/products/${productId}/variants/${variantId}/assets`, {
+ ...options,
+ body: params,
+ }),
+
+ /** Update a variant asset */
+ update: (
+ productId: string,
+ variantId: string,
+ id: string,
+ params: AdminAssetUpdateParams,
+ options?: RequestOptions
+ ): Promise<AdminAsset> =>
+ this.request<AdminAsset>('PATCH', `/products/${productId}/variants/${variantId}/assets/${id}`, {
+ ...options,
+ body: params,
+ }),
+
+ /** Delete a variant asset */
+ delete: (
+ productId: string,
+ variantId: string,
+ id: string,
+ options?: RequestOptions
+ ): Promise<void> =>
+ this.request<void>('DELETE', `/products/${productId}/variants/${variantId}/assets/${id}`, options),
+
+ },
+
},
};
@@ -713,7 +763,7 @@ export class AdminClient {
params?: ListParams,
options?: RequestOptions
): Promise<PaginatedResponse<AdminTaxonomy>> =>
- this.request<PaginatedResponse<AdminTaxonomy>>('GET', '/taxonomies', {
+ this.request<PaginatedResponse<AdminTaxonomy>>('GET', `/taxonomies`, {
...options,
params: transformListParams({ ...params }),
}),
@@ -723,7 +773,7 @@ export class AdminClient {
params: AdminTaxonomyCreateParams,
options?: RequestOptions
): Promise<AdminTaxonomy> =>
- this.request<AdminTaxonomy>('POST', '/taxonomies', {
+ this.request<AdminTaxonomy>('POST', `/taxonomies`, {
...options,
body: params,
}),
@@ -827,7 +877,7 @@ export class AdminClient {
params?: ListParams,
options?: RequestOptions
): Promise<PaginatedResponse<AdminTaxon>> =>
- this.request<PaginatedResponse<AdminTaxon>>('GET', '/taxons', {
+ this.request<PaginatedResponse<AdminTaxon>>('GET', `/taxons`, {
...options,
params: transformListParams({ ...params }),
}),
diff --git a/packages/sdk/src/admin-params.ts b/packages/sdk/src/admin-params.ts
index 3eff2e7df9..e6514ee174 100644
--- a/packages/sdk/src/admin-params.ts
+++ b/packages/sdk/src/admin-params.ts
@@ -3,19 +3,6 @@
// Request parameter types (generated from OpenAPI request bodies)
-export interface AdminAssetCreateParams {
- alt?: string;
- position?: number;
- type?: string;
- viewable_type?: string;
- viewable_id?: string;
-}
-
-export interface AdminAssetUpdateParams {
- alt?: string;
- position?: number;
-}
-
export interface AdminOptionTypeCreateParams {
name: string;
presentation: string;
@@ -117,6 +104,18 @@ export interface AdminOrderUpdateParams {
}>;
}
+export interface AdminAssetCreateParams {
+ alt?: string;
+ position?: number;
+ type?: string;
+ url?: string;
+}
+
+export interface AdminAssetUpdateParams {
+ alt?: string;
+ position?: number;
+}
+
export interface AdminProductCreateParams {
name: string;
price: number;
diff --git a/packages/sdk/tests/admin/products.test.ts b/packages/sdk/tests/admin/products.test.ts
index 86cfdf4dd4..aab74a74e8 100644
--- a/packages/sdk/tests/admin/products.test.ts
+++ b/packages/sdk/tests/admin/products.test.ts
@@ -72,6 +72,15 @@ describe('admin / products', () => {
expect(result.alt).toBe(adminFixtures.asset.alt);
});
+ it('creates an asset from URL (returns 202)', async () => {
+ await expect(
+ client.admin.products.assets.create('prod_1', {
+ url: 'https://example.com/image.jpg',
+ position: 1,
+ })
+ ).resolves.toBeFalsy();
+ });
+
it('updates an asset', async () => {
const result = await client.admin.products.assets.update('prod_1', 'asset_1', {
alt: 'Updated alt',
@@ -123,5 +132,44 @@ describe('admin / products', () => {
client.admin.products.variants.delete('prod_1', 'var_1')
).resolves.toBeUndefined();
});
+
+ describe('assets', () => {
+ it('lists variant assets', async () => {
+ const result = await client.admin.products.variants.assets.list('prod_1', 'var_1');
+
+ expect(result.data).toHaveLength(1);
+ expect(result.data[0].alt).toBe('Product image');
+ });
+
+ it('creates a variant asset', async () => {
+ const result = await client.admin.products.variants.assets.create('prod_1', 'var_1', {
+ alt: 'Variant image',
+ });
+
+ expect(result.alt).toBe(adminFixtures.asset.alt);
+ });
+
+ it('creates a variant asset from URL (returns 202)', async () => {
+ await expect(
+ client.admin.products.variants.assets.create('prod_1', 'var_1', {
+ url: 'https://example.com/variant.jpg',
+ })
+ ).resolves.toBeFalsy();
+ });
+
+ it('updates a variant asset', async () => {
+ const result = await client.admin.products.variants.assets.update('prod_1', 'var_1', 'asset_1', {
+ alt: 'Updated variant alt',
+ });
+
+ expect(result.alt).toBe('Updated variant alt');
+ });
+
+ it('deletes a variant asset', async () => {
+ await expect(
+ client.admin.products.variants.assets.delete('prod_1', 'var_1', 'asset_1')
+ ).resolves.toBeUndefined();
+ });
+ });
});
});
diff --git a/packages/sdk/tests/mocks/admin-handlers.ts b/packages/sdk/tests/mocks/admin-handlers.ts
index 412386d341..0cec261459 100644
--- a/packages/sdk/tests/mocks/admin-handlers.ts
+++ b/packages/sdk/tests/mocks/admin-handlers.ts
@@ -260,9 +260,13 @@ export const adminHandlers = [
HttpResponse.json({ data: [adminFixtures.asset], meta: paginationMeta })
),
- http.post(`${API_PREFIX}/products/:productId/assets`, () =>
- HttpResponse.json(adminFixtures.asset, { status: 201 })
- ),
+ http.post(`${API_PREFIX}/products/:productId/assets`, async ({ request }) => {
+ const body = await request.json() as Record<string, unknown>;
+ if (body.url) {
+ return new HttpResponse(null, { status: 202 });
+ }
+ return HttpResponse.json(adminFixtures.asset, { status: 201 });
+ }),
http.patch(`${API_PREFIX}/products/:productId/assets/:id`, () =>
HttpResponse.json({ ...adminFixtures.asset, alt: 'Updated alt' })
@@ -272,6 +276,29 @@ export const adminHandlers = [
new HttpResponse(null, { status: 204 })
),
+ // ============================================
+ // Variant Assets
+ // ============================================
+ http.get(`${API_PREFIX}/products/:productId/variants/:variantId/assets`, () =>
+ HttpResponse.json({ data: [adminFixtures.asset], meta: paginationMeta })
+ ),
+
+ http.post(`${API_PREFIX}/products/:productId/variants/:variantId/assets`, async ({ request }) => {
+ const body = await request.json() as Record<string, unknown>;
+ if (body.url) {
+ return new HttpResponse(null, { status: 202 });
+ }
+ return HttpResponse.json(adminFixtures.asset, { status: 201 });
+ }),
+
+ http.patch(`${API_PREFIX}/products/:productId/variants/:variantId/assets/:id`, () =>
+ HttpResponse.json({ ...adminFixtures.asset, alt: 'Updated variant alt' })
+ ),
+
+ http.delete(`${API_PREFIX}/products/:productId/variants/:variantId/assets/:id`, () =>
+ new HttpResponse(null, { status: 204 })
+ ),
+
// ============================================
// Product Variants
// ============================================
diff --git a/spree/api/app/controllers/spree/api/v3/admin/assets_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/assets_controller.rb
new file mode 100644
index 0000000000..176a7b739c
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/assets_controller.rb
@@ -0,0 +1,85 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class AssetsController < ResourceController
+ def create
+ if permitted_params[:url].present?
+ create_from_url
+ else
+ @resource = build_resource
+ authorize_resource!(@resource, :create)
+
+ if @resource.save
+ render json: serialize_resource(@resource), status: :created
+ else
+ render_validation_error(@resource.errors)
+ end
+ end
+ end
+
+ protected
+
+ def model_class
+ Spree::Asset
+ end
+
+ def serializer_class
+ Spree.api.admin_asset_serializer
+ end
+
+ def set_parent
+ @product = current_store.products.find_by_prefix_id!(params[:product_id])
+ authorize!(:show, @product)
+
+ @parent = if params[:variant_id].present?
+ @product.variants_including_master.find_by_prefix_id!(params[:variant_id])
+ else
+ @product.master
+ end
+ end
+
+ def parent_association
+ :images
+ end
+
+ ALLOWED_ASSET_TYPES = -> { [Spree::Asset, *Spree::Asset.descendants].map(&:name).to_set.freeze }
+
+ def build_resource
+ asset_type = permitted_params[:type] || 'Spree::Image'
+
+ unless ALLOWED_ASSET_TYPES.call.include?(asset_type)
+ raise ArgumentError, "Invalid asset type: #{asset_type}"
+ end
+
+ asset = @parent.images.build(permitted_params.except(:type, :url))
+ asset.type = asset_type
+
+ asset
+ end
+
+ def permitted_params
+ params.permit(*Spree::PermittedAttributes.asset_attributes)
+ end
+
+ def create_from_url
+ authorize!(:create, Spree::Asset)
+
+ url = permitted_params[:url]
+ position = permitted_params[:position]
+
+ Spree::Images::SaveFromUrlJob.perform_later(
+ @parent.id,
+ @parent.class.name,
+ url,
+ nil,
+ position
+ )
+
+ head :accepted
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/products/assets_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/products/assets_controller.rb
deleted file mode 100644
index 4dd4f29940..0000000000
--- a/spree/api/app/controllers/spree/api/v3/admin/products/assets_controller.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-module Spree
- module Api
- module V3
- module Admin
- module Products
- class AssetsController < ResourceController
- def create
- @resource = build_resource
- authorize_resource!(@resource, :create)
-
- if @resource.save
- render json: serialize_resource(@resource), status: :created
- else
- render_validation_error(@resource.errors)
- end
- end
-
- protected
-
- def model_class
- Spree::Asset
- end
-
- def serializer_class
- Spree.api.admin_asset_serializer
- end
-
- def set_parent
- @product = current_store.products.find_by_prefix_id!(params[:product_id])
- authorize!(:show, @product)
- @parent = @product.master
- end
-
- def parent_association
- :images
- end
-
- ALLOWED_ASSET_TYPES = -> { [Spree::Asset, *Spree::Asset.descendants].map(&:name).to_set.freeze }
-
- def build_resource
- asset_type = permitted_params[:type] || 'Spree::Image'
-
- unless ALLOWED_ASSET_TYPES.call.include?(asset_type)
- raise ArgumentError, "Invalid asset type: #{asset_type}"
- end
-
- asset = @parent.images.build(permitted_params.except(:type, :variant_ids))
- asset.type = asset_type
-
- asset
- end
-
- def permitted_params
- params.permit(*Spree::PermittedAttributes.asset_attributes, variant_ids: [])
- end
- end
- end
- end
- end
- end
-end
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 0d041d69a2..69e128a62e 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -100,8 +100,10 @@ Spree::Core::Engine.add_routes do
member do
post :clone
end
- resources :variants, controller: 'products/variants'
- resources :assets, controller: 'products/assets', only: [:index, :create, :update, :destroy]
+ resources :variants, controller: 'products/variants' do
+ resources :assets, controller: 'assets', only: [:index, :create, :update, :destroy]
+ end
+ resources :assets, controller: 'assets', only: [:index, :create, :update, :destroy]
end
# Taxonomies > Taxons
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb
index d8af2a8359..3c42bdae92 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/products/assets_controller_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-RSpec.describe Spree::Api::V3::Admin::Products::AssetsController, type: :controller do
+RSpec.describe Spree::Api::V3::Admin::AssetsController, type: :controller do
render_views
include_context 'API v3 Admin authenticated'
@@ -10,74 +10,158 @@ RSpec.describe Spree::Api::V3::Admin::Products::AssetsController, type: :control
before { request.headers.merge!(headers) }
- describe 'GET #index' do
- it 'returns assets for the product' do
- get :index, params: { product_id: product.prefixed_id }, as: :json
+ describe 'product assets' do
+ describe 'GET #index' do
+ it 'returns assets for the product' do
+ get :index, params: { product_id: product.prefixed_id }, as: :json
- expect(response).to have_http_status(:ok)
- expect(json_response['data']).to be_an(Array)
- ids = json_response['data'].map { |a| a['id'] }
- expect(ids).to include(image.prefixed_id)
- end
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data']).to be_an(Array)
+ ids = json_response['data'].map { |a| a['id'] }
+ expect(ids).to include(image.prefixed_id)
+ end
- context 'with product from another store' do
- let(:other_store) { create(:store) }
- let(:other_product) { create(:product, stores: [other_store]) }
+ context 'with product from another store' do
+ let(:other_store) { create(:store) }
+ let(:other_product) { create(:product, stores: [other_store]) }
- it 'returns 404' do
- get :index, params: { product_id: other_product.prefixed_id }, as: :json
- expect(response).to have_http_status(:not_found)
+ it 'returns 404' do
+ get :index, params: { product_id: other_product.prefixed_id }, as: :json
+ expect(response).to have_http_status(:not_found)
+ end
end
end
- end
- describe 'POST #create' do
- it 'returns validation error without attachment' do
- post :create, params: {
- product_id: product.prefixed_id,
- alt: 'New image',
- position: 1
- }, as: :json
+ describe 'POST #create' do
+ it 'returns validation error without attachment' do
+ post :create, params: {
+ product_id: product.prefixed_id,
+ alt: 'New image',
+ position: 1
+ }, as: :json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ end
- expect(response).to have_http_status(:unprocessable_content)
+ it 'enqueues SaveFromUrlJob when url is provided' do
+ expect {
+ post :create, params: {
+ product_id: product.prefixed_id,
+ url: 'https://example.com/image.jpg',
+ position: 2
+ }, as: :json
+ }.to have_enqueued_job(Spree::Images::SaveFromUrlJob).with(
+ product.master.id,
+ 'Spree::Variant',
+ 'https://example.com/image.jpg',
+ nil,
+ 2
+ )
+
+ expect(response).to have_http_status(:accepted)
+ end
end
- end
- describe 'PATCH #update' do
- it 'updates the asset alt text' do
- patch :update, params: {
- product_id: product.prefixed_id,
- id: image.prefixed_id,
- alt: 'Updated alt text'
- }, as: :json
-
- expect(response).to have_http_status(:ok)
- expect(json_response['alt']).to eq('Updated alt text')
- expect(image.reload.alt).to eq('Updated alt text')
+ describe 'PATCH #update' do
+ it 'updates the asset alt text' do
+ patch :update, params: {
+ product_id: product.prefixed_id,
+ id: image.prefixed_id,
+ alt: 'Updated alt text'
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['alt']).to eq('Updated alt text')
+ expect(image.reload.alt).to eq('Updated alt text')
+ end
+
+ it 'updates the asset position' do
+ patch :update, params: {
+ product_id: product.prefixed_id,
+ id: image.prefixed_id,
+ position: 5
+ }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(image.reload.position).to eq(5)
+ end
end
- it 'updates the asset position' do
- patch :update, params: {
- product_id: product.prefixed_id,
- id: image.prefixed_id,
- position: 5
- }, as: :json
+ describe 'DELETE #destroy' do
+ it 'deletes the asset' do
+ expect {
+ delete :destroy, params: {
+ product_id: product.prefixed_id,
+ id: image.prefixed_id
+ }, as: :json
+ }.to change(product.master.images, :count).by(-1)
- expect(response).to have_http_status(:ok)
- expect(image.reload.position).to eq(5)
+ expect(response).to have_http_status(:no_content)
+ end
end
end
- describe 'DELETE #destroy' do
- it 'deletes the asset' do
- expect {
- delete :destroy, params: {
+ describe 'variant assets' do
+ let!(:variant) { create(:variant, product: product) }
+ let!(:variant_image) { create(:image, viewable: variant) }
+
+ describe 'GET #index' do
+ it 'returns assets for the variant' do
+ get :index, params: { product_id: product.prefixed_id, variant_id: variant.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ ids = json_response['data'].map { |a| a['id'] }
+ expect(ids).to include(variant_image.prefixed_id)
+ expect(ids).not_to include(image.prefixed_id)
+ end
+ end
+
+ describe 'POST #create' do
+ it 'enqueues SaveFromUrlJob for variant when url is provided' do
+ expect {
+ post :create, params: {
+ product_id: product.prefixed_id,
+ variant_id: variant.prefixed_id,
+ url: 'https://example.com/variant.jpg'
+ }, as: :json
+ }.to have_enqueued_job(Spree::Images::SaveFromUrlJob).with(
+ variant.id,
+ 'Spree::Variant',
+ 'https://example.com/variant.jpg',
+ nil,
+ nil
+ )
+
+ expect(response).to have_http_status(:accepted)
+ end
+ end
+
+ describe 'PATCH #update' do
+ it 'updates the variant asset' do
+ patch :update, params: {
product_id: product.prefixed_id,
- id: image.prefixed_id
+ variant_id: variant.prefixed_id,
+ id: variant_image.prefixed_id,
+ alt: 'Variant image'
}, as: :json
- }.to change(product.master.images, :count).by(-1)
- expect(response).to have_http_status(:no_content)
+ expect(response).to have_http_status(:ok)
+ expect(variant_image.reload.alt).to eq('Variant image')
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'deletes the variant asset' do
+ expect {
+ delete :destroy, params: {
+ product_id: product.prefixed_id,
+ variant_id: variant.prefixed_id,
+ id: variant_image.prefixed_id
+ }, as: :json
+ }.to change(variant.images, :count).by(-1)
+
+ expect(response).to have_http_status(:no_content)
+ end
end
end
end
diff --git a/spree/api/spec/integration/spree/api/v3/admin/assets_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/product_assets_spec.rb
similarity index 84%
rename from spree/api/spec/integration/spree/api/v3/admin/assets_spec.rb
rename to spree/api/spec/integration/spree/api/v3/admin/product_assets_spec.rb
index d8338e9aa0..e04bbb90c4 100644
--- a/spree/api/spec/integration/spree/api/v3/admin/assets_spec.rb
+++ b/spree/api/spec/integration/spree/api/v3/admin/product_assets_spec.rb
@@ -2,7 +2,7 @@
require 'swagger_helper'
-RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
+RSpec.describe 'Admin Product Assets API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
include_context 'API v3 Admin'
let!(:product) { create(:product, stores: [store]) }
@@ -11,7 +11,7 @@ RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/a
path '/api/v3/admin/products/{product_id}/assets' do
get 'List product assets' do
- tags 'Assets'
+ tags 'Product Assets'
produces 'application/json'
security [api_key: [], bearer_auth: []]
description 'Returns a paginated list of assets (images) for a product.'
@@ -34,8 +34,8 @@ RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/a
end
end
- post 'Create an asset' do
- tags 'Assets'
+ post 'Create a product asset' do
+ tags 'Product Assets'
consumes 'application/json'
produces 'application/json'
security [api_key: [], bearer_auth: []]
@@ -51,11 +51,18 @@ RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/a
alt: { type: :string, example: 'Product front view' },
position: { type: :integer, example: 1 },
type: { type: :string, example: 'Spree::Image', description: 'Asset type (defaults to Spree::Image)' },
- viewable_type: { type: :string, description: 'Polymorphic viewable type' },
- viewable_id: { type: :string, description: 'Polymorphic viewable ID' }
+ url: { type: :string, example: 'https://example.com/image.jpg', description: 'External URL to import image from (async). Returns 202 Accepted.' }
}
}
+ response '202', 'asset import from URL enqueued' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:body) { { url: 'https://example.com/image.jpg', position: 1 } }
+
+ run_test!
+ end
+
response '422', 'validation error (attachment required)' do
let(:'x-spree-api-key') { secret_api_key.plaintext_token }
let(:product_id) { product.prefixed_id }
@@ -69,12 +76,12 @@ RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/a
end
path '/api/v3/admin/products/{product_id}/assets/{id}' do
- patch 'Update an asset' do
- tags 'Assets'
+ patch 'Update a product asset' do
+ tags 'Product Assets'
consumes 'application/json'
produces 'application/json'
security [api_key: [], bearer_auth: []]
- description 'Updates an asset. Only provided fields are updated.'
+ description 'Updates a product asset. Only provided fields are updated.'
parameter name: 'x-spree-api-key', in: :header, type: :string, required: true
parameter name: :Authorization, in: :header, type: :string, required: true,
@@ -102,8 +109,8 @@ RSpec.describe 'Admin Assets API', type: :request, swagger_doc: 'api-reference/a
end
end
- delete 'Delete an asset' do
- tags 'Assets'
+ delete 'Delete a product asset' do
+ tags 'Product Assets'
security [api_key: [], bearer_auth: []]
description 'Deletes an asset from a product.'
diff --git a/spree/api/spec/integration/spree/api/v3/admin/variant_assets_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/variant_assets_spec.rb
new file mode 100644
index 0000000000..7ab07c4a90
--- /dev/null
+++ b/spree/api/spec/integration/spree/api/v3/admin/variant_assets_spec.rb
@@ -0,0 +1,144 @@
+# frozen_string_literal: true
+
+require 'swagger_helper'
+
+RSpec.describe 'Admin Variant Assets API', type: :request, swagger_doc: 'api-reference/admin.yaml' do
+ include_context 'API v3 Admin'
+
+ let!(:product) { create(:product, stores: [store]) }
+ let!(:variant) { create(:variant, product: product) }
+ let!(:variant_image) { create(:image, viewable: variant) }
+ let(:Authorization) { "Bearer #{admin_jwt_token}" }
+
+ path '/api/v3/admin/products/{product_id}/variants/{variant_id}/assets' do
+ get 'List variant assets' do
+ tags 'Variant Assets'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Returns a paginated list of assets (images) for a variant.'
+
+ 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: :product_id, in: :path, type: :string, required: true, description: 'Product prefixed ID'
+ parameter name: :variant_id, in: :path, type: :string, required: true, description: 'Variant prefixed ID'
+ 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'
+
+ response '200', 'variant assets found' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:variant_id) { variant.prefixed_id }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['data']).to be_an(Array)
+ ids = data['data'].map { |a| a['id'] }
+ expect(ids).to include(variant_image.prefixed_id)
+ end
+ end
+ end
+
+ post 'Create a variant asset' do
+ tags 'Variant Assets'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Creates a new asset (image) for a variant.'
+
+ 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: :product_id, in: :path, type: :string, required: true, description: 'Product prefixed ID'
+ parameter name: :variant_id, in: :path, type: :string, required: true, description: 'Variant prefixed ID'
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ properties: {
+ alt: { type: :string, example: 'Variant image' },
+ position: { type: :integer, example: 1 },
+ type: { type: :string, example: 'Spree::Image', description: 'Asset type (defaults to Spree::Image)' },
+ url: { type: :string, example: 'https://example.com/image.jpg', description: 'External URL to import image from (async). Returns 202 Accepted.' }
+ }
+ }
+
+ response '202', 'variant asset import from URL enqueued' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:variant_id) { variant.prefixed_id }
+ let(:body) { { url: 'https://example.com/variant.jpg', position: 1 } }
+
+ run_test!
+ end
+
+ response '422', 'validation error (attachment required)' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:variant_id) { variant.prefixed_id }
+ let(:body) { { alt: 'New variant image', position: 1 } }
+
+ schema '$ref' => '#/components/schemas/ErrorResponse'
+
+ run_test!
+ end
+ end
+ end
+
+ path '/api/v3/admin/products/{product_id}/variants/{variant_id}/assets/{id}' do
+ patch 'Update a variant asset' do
+ tags 'Variant Assets'
+ consumes 'application/json'
+ produces 'application/json'
+ security [api_key: [], bearer_auth: []]
+ description 'Updates a variant asset. Only provided fields are updated.'
+
+ 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: :product_id, in: :path, type: :string, required: true, description: 'Product prefixed ID'
+ parameter name: :variant_id, in: :path, type: :string, required: true, description: 'Variant prefixed ID'
+ parameter name: :id, in: :path, type: :string, required: true, description: 'Asset prefixed ID'
+ parameter name: :body, in: :body, schema: {
+ type: :object,
+ properties: {
+ alt: { type: :string, example: 'Updated variant image' },
+ position: { type: :integer, example: 2 }
+ }
+ }
+
+ response '200', 'variant asset updated' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:variant_id) { variant.prefixed_id }
+ let(:id) { variant_image.prefixed_id }
+ let(:body) { { alt: 'Updated variant image' } }
+
+ run_test! do |response|
+ data = JSON.parse(response.body)
+ expect(data['alt']).to eq('Updated variant image')
+ end
+ end
+ end
+
+ delete 'Delete a variant asset' do
+ tags 'Variant Assets'
+ security [api_key: [], bearer_auth: []]
+ description 'Deletes an asset from a variant.'
+
+ 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: :product_id, in: :path, type: :string, required: true, description: 'Product prefixed ID'
+ parameter name: :variant_id, in: :path, type: :string, required: true, description: 'Variant prefixed ID'
+ parameter name: :id, in: :path, type: :string, required: true, description: 'Asset prefixed ID'
+
+ response '204', 'variant asset deleted' do
+ let(:'x-spree-api-key') { secret_api_key.plaintext_token }
+ let(:product_id) { product.prefixed_id }
+ let(:variant_id) { variant.prefixed_id }
+ let(:id) { variant_image.prefixed_id }
+
+ run_test!
+ end
+ end
+ end
+end
diff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rb
index 02f438242b..a41e75a0d8 100644
--- a/spree/core/lib/spree/permitted_attributes.rb
+++ b/spree/core/lib/spree/permitted_attributes.rb
@@ -92,8 +92,7 @@ module Spree
@@api_key_attributes = [:name, :key_type]
- @@asset_attributes = [:type, :viewable_id, :viewable_type, :attachment, :alt, :position,
- :media_type, :focal_point_x, :focal_point_y, :external_video_url]
+ @@asset_attributes = [:type, :viewable_id, :viewable_type, :attachment, :alt, :position, :url]
@@checkout_attributes = [
:coupon_code, :email, :shipping_method_id, :special_instructions, :use_billing, :use_shipping,