@spree/docs 0.1.94 → 0.1.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ The `spree api` command group turns the CLI into a first-class Admin API client:
9
9
  ```bash
10
10
  spree api get /products -q status_eq=active --sort -created_at --limit 10
11
11
  spree api get /orders/ord_x8k2J9aQ --expand items,payments
12
- spree api post /products -d '{"name":"Classic Tee"}'
12
+ spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
13
13
  spree api patch /orders/ord_x8k2J9aQ/cancel
14
14
  spree api endpoints --resource orders
15
15
  spree api schema "POST /orders/{id}/refunds"
@@ -93,7 +93,7 @@ spree api get /products --limit 5 | jq '.data[].name'
93
93
  Request bodies are flat JSON (no root wrapping), inline, from a file, or from stdin:
94
94
 
95
95
  ```bash
96
- spree api post /products -d '{"name":"Classic Tee","price":29.99}'
96
+ spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
97
97
  spree api post /orders/ord_x8k2J9aQ/refunds -d @refund.json
98
98
  cat prices.json | spree api post /prices/bulk_upsert -d -
99
99
  spree api delete /products/prod_86Rf07xd
@@ -101,6 +101,28 @@ spree api delete /products/prod_86Rf07xd
101
101
 
102
102
  Mutations automatically carry an `Idempotency-Key`, so retries are safe.
103
103
 
104
+ ### Creating products
105
+
106
+ A product is a catalog grouping; everything purchasable — SKU, price, stock, weight — lives on its variants. For a **simple product** with no options, ship a top-level `prices` array and Spree creates the single backing variant for you:
107
+
108
+ ```bash
109
+ spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
110
+ ```
111
+
112
+ For a product with options, send the `variants` array, each with its own `options` and `prices` (and optionally `stock_items`):
113
+
114
+ ```bash
115
+ spree api post /products -d '{
116
+ "name": "Classic Tee",
117
+ "variants": [
118
+ { "sku": "TEE-S", "options": [{"name":"size","value":"Small"}], "prices": [{"currency":"USD","amount":"29.99"}] },
119
+ { "sku": "TEE-M", "options": [{"name":"size","value":"Medium"}], "prices": [{"currency":"USD","amount":"29.99"}] }
120
+ ]
121
+ }'
122
+ ```
123
+
124
+ Run `spree api schema "POST /products"` for the full request body.
125
+
104
126
  ## Discovering endpoints and schemas
105
127
 
106
128
  The CLI bundles a snapshot of the Admin API OpenAPI spec, so discovery works offline:
@@ -12,7 +12,7 @@ The Spree CLI (`@spree/cli`) does two things from your terminal:
12
12
  ```bash
13
13
  spree dev # boot the project
14
14
  spree api get /orders -q status_eq=complete --limit 10 # query the Admin API
15
- spree api post /products -d '{"name":"Classic Tee"}' # create a resource
15
+ spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}' # create a resource
16
16
  spree api endpoints --search refund # discover endpoints, offline
17
17
  ```
18
18
 
@@ -192,7 +192,7 @@ Call the Admin API with generic `get`/`post`/`patch`/`delete` commands — zero-
192
192
 
193
193
  ```bash
194
194
  spree api get /products -q status_eq=active --limit 10
195
- spree api post /products -d '{"name":"Classic Tee"}'
195
+ spree api post /products -d '{"name":"Classic Tee","prices":[{"currency":"USD","amount":"29.99"}]}'
196
196
  spree api endpoints --resource orders # endpoints + required scopes, offline
197
197
  spree api schema "POST /orders" # request/response schema, offline
198
198
  spree api status
@@ -355,12 +355,12 @@ Capture or void an authorized payment, and issue refunds, through the nested ord
355
355
  ```typescript Admin SDK
356
356
  await client.orders.payments.capture('or_xxx', 'pay_xxx')
357
357
  await client.orders.payments.void('or_xxx', 'pay_xxx')
358
- await client.orders.refunds.create('or_xxx', { payment_id: 'pay_xxx', amount: 19.99 })
358
+ await client.orders.refunds.create('or_xxx', { payment_id: 'pay_xxx', amount: '19.99' })
359
359
  ```
360
360
 
361
361
  ```bash CLI
362
362
  spree api patch /orders/or_xxx/payments/pay_xxx/capture
363
- spree api post /orders/or_xxx/refunds -d '{"payment_id": "pay_xxx", "amount": 19.99}'
363
+ spree api post /orders/or_xxx/refunds -d '{"payment_id": "pay_xxx", "amount": "19.99"}'
364
364
  ```
365
365
 
366
366
 
@@ -15,8 +15,8 @@ Each variant has one or more `Price` records — one per currency. The API autom
15
15
 
16
16
  | Attribute | Description | Example |
17
17
  |-----------|-------------|---------|
18
- | `amount` | Current selling price | `99.90` |
19
- | `compare_at_amount` | Original/compare price for strikethrough display | `129.90` |
18
+ | `amount` | Current selling price | `"99.90"` |
19
+ | `compare_at_amount` | Original/compare price for strikethrough display | `"129.90"` |
20
20
  | `currency` | ISO 4217 currency code | `USD` |
21
21
 
22
22
  > **WARNING:** If a product doesn't have a price in the selected currency, it won't appear in Store API responses by default.
@@ -73,13 +73,13 @@ const client = createAdminClient({
73
73
  })
74
74
 
75
75
  // Set / change one variant's price in a currency
76
- await client.prices.create({ variant_id: 'variant_xxx', currency: 'USD', amount: 15.99 })
76
+ await client.prices.create({ variant_id: 'variant_xxx', currency: 'USD', amount: '15.99' })
77
77
 
78
78
  // Upsert many at once
79
79
  await client.prices.bulkUpsert({
80
80
  prices: [
81
- { variant_id: 'variant_xxx', currency: 'USD', amount: 15.99 },
82
- { variant_id: 'variant_xxx', currency: 'EUR', amount: 14.99 },
81
+ { variant_id: 'variant_xxx', currency: 'USD', amount: '15.99' },
82
+ { variant_id: 'variant_xxx', currency: 'EUR', amount: '14.99' },
83
83
  ],
84
84
  })
85
85
  ```
@@ -87,8 +87,8 @@ await client.prices.bulkUpsert({
87
87
  ```bash CLI
88
88
  spree api post /prices/bulk_upsert -d '{
89
89
  "prices": [
90
- { "variant_id": "variant_xxx", "currency": "USD", "amount": 15.99 },
91
- { "variant_id": "variant_xxx", "currency": "EUR", "amount": 14.99 }
90
+ { "variant_id": "variant_xxx", "currency": "USD", "amount": "15.99" },
91
+ { "variant_id": "variant_xxx", "currency": "EUR", "amount": "14.99" }
92
92
  ]
93
93
  }'
94
94
  ```
@@ -183,7 +183,7 @@ const product = await client.products.create({
183
183
  { name: 'size', value: 'Small' },
184
184
  { name: 'color', value: 'navy' },
185
185
  ],
186
- prices: [{ currency: 'USD', amount: 29.99 }],
186
+ prices: [{ currency: 'USD', amount: '29.99' }],
187
187
  stock_items: [{ stock_location_id: 'sloc_xxx', count_on_hand: 50 }],
188
188
  },
189
189
  ],
@@ -197,7 +197,7 @@ spree api post /products -d '{
197
197
  "variants": [{
198
198
  "sku": "TSHIRT-S-NAVY",
199
199
  "options": [{ "name": "size", "value": "Small" }],
200
- "prices": [{ "currency": "USD", "amount": 29.99 }]
200
+ "prices": [{ "currency": "USD", "amount": "29.99" }]
201
201
  }]
202
202
  }'
203
203
  ```
@@ -302,7 +302,7 @@ const variant = await client.products.variants.create('prod_xxx', {
302
302
  { name: 'size', value: 'Large' },
303
303
  { name: 'color', value: 'Red' },
304
304
  ],
305
- prices: [{ currency: 'USD', amount: 24.99 }],
305
+ prices: [{ currency: 'USD', amount: '24.99' }],
306
306
  stock_items: [{ stock_location_id: 'sloc_xxx', count_on_hand: 30 }],
307
307
  })
308
308
  ```
@@ -311,7 +311,7 @@ const variant = await client.products.variants.create('prod_xxx', {
311
311
  spree api post /products/prod_xxx/variants -d '{
312
312
  "sku": "TEE-L-R",
313
313
  "options": [{ "name": "size", "value": "Large" }],
314
- "prices": [{ "currency": "USD", "amount": 24.99 }]
314
+ "prices": [{ "currency": "USD", "amount": "24.99" }]
315
315
  }'
316
316
  ```
317
317
 
@@ -133,7 +133,7 @@ const client = createAdminClient({
133
133
  })
134
134
 
135
135
  const credit = await client.customers.storeCredits.create('cus_xxx', {
136
- amount: 25.0,
136
+ amount: '25.00',
137
137
  currency: 'USD',
138
138
  category_id: 'sccat_xxx',
139
139
  memo: 'Goodwill credit for delayed shipment',
@@ -142,7 +142,7 @@ const credit = await client.customers.storeCredits.create('cus_xxx', {
142
142
 
143
143
  ```bash CLI
144
144
  spree api post /customers/cus_xxx/store_credits -d '{
145
- "amount": 25.0,
145
+ "amount": "25.00",
146
146
  "currency": "USD",
147
147
  "category_id": "sccat_xxx",
148
148
  "memo": "Goodwill credit"
@@ -258,7 +258,7 @@ const client = createAdminClient({
258
258
  })
259
259
 
260
260
  const giftCard = await client.giftCards.create({
261
- amount: 50,
261
+ amount: '50.00',
262
262
  currency: 'USD',
263
263
  expires_at: '2026-12-31',
264
264
  })
@@ -268,7 +268,7 @@ console.log(giftCard.code) // share this with the recipient
268
268
 
269
269
  ```bash CLI
270
270
  spree api post /gift_cards -d '{
271
- "amount": 50,
271
+ "amount": "50.00",
272
272
  "currency": "USD",
273
273
  "expires_at": "2026-12-31"
274
274
  }'
@@ -295,7 +295,7 @@ Batches can also be created via the Admin API:
295
295
  const batch = await client.giftCardBatches.create({
296
296
  prefix: 'HOLIDAY',
297
297
  codes_count: 1000,
298
- amount: 25,
298
+ amount: '25.00',
299
299
  currency: 'USD',
300
300
  expires_at: '2026-12-31',
301
301
  })
@@ -305,7 +305,7 @@ const batch = await client.giftCardBatches.create({
305
305
  spree api post /gift_card_batches -d '{
306
306
  "prefix": "HOLIDAY",
307
307
  "codes_count": 1000,
308
- "amount": 25,
308
+ "amount": "25.00",
309
309
  "currency": "USD",
310
310
  "expires_at": "2026-12-31"
311
311
  }'
@@ -73,6 +73,26 @@ Upon successful authentication, you should see the admin screen:
73
73
 
74
74
  <img src="/images/spree_admin_dashboard.png" />
75
75
 
76
+ ## Using the Spree CLI
77
+
78
+ Projects scaffolded with `create-spree-app` include [`@spree/cli`](../cli/quickstart.md) for managing the backend and calling the Admin API. Because it's a project dependency, run it with `npx` (or any package-manager script):
79
+
80
+ ```bash
81
+ npx spree dev # boot the Docker stack
82
+ npx spree api get products # query the Admin API (read-only key preconfigured)
83
+ ```
84
+
85
+ Project setup mints a read-only Admin API key into `.spree/credentials.json` (and `spree api` mints it on first use if you skipped setup), so `spree api` works without any extra configuration.
86
+
87
+ To call `spree` directly without the `npx` prefix, install the CLI globally:
88
+
89
+ ```bash
90
+ npm install -g @spree/cli
91
+ spree api get products
92
+ ```
93
+
94
+ See the [Spree CLI guide](../cli/quickstart.md) for all commands and the [Admin API from the CLI](../cli/admin-api.md) for querying your store's data.
95
+
76
96
  ## Next Steps
77
97
 
78
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.94",
3
+ "version": "0.1.96",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",