Raw
Large file — syntax highlighting disabled.
1 openapi: 3.0.0
2 info:
3 version: 2.21.2
4 title: Medusa Storefront API
5 license:
6 name: MIT
7 url: https://github.com/medusajs/medusa/blob/master/LICENSE
8 servers:
9 - url: http://localhost:9000
10 - url: https://api.medusajs.com
11 tags:
12 - name: Auth
13 description: |
14 Auth API routes allow you to manage a customer's authentication.
15 - name: Carts
16 description: |
17 A cart is a virtual shopping bag that customers can use to add items they want to purchase.
18
19 A cart is then used to checkout and place an order.
20
21 These API routes allow customers to create and manage their cart, and place an order.
22 externalDocs:
23 description: How to implement cart functionality in a storefront.
24 url: https://docs.medusajs.com/resources/storefront-development/cart
25 x-associatedSchema:
26 $ref: '#/components/schemas/StoreCart'
27 - name: Collections
28 description: |
29 A product collection organizes products into a collection for marketing purposes. For example, a summer collection.
30
31 These API routes allow customers to browse collections and their products.
32 externalDocs:
33 description: How to list product collections in a storefront.
34 url: https://docs.medusajs.com/resources/storefront-development/products/collections/list
35 x-associatedSchema:
36 $ref: '#/components/schemas/StoreCollection'
37 - name: Currencies
38 description: |
39 A store has multiple currencies, and product prices can be different for each currency.
40
41 When retrieving product variant prices, you specify either the ID of a region or a currency that the customer selected.
42
43 These API routes allow customers to browse currencies.
44 externalDocs:
45 description: How to retrieve product variant prices in a storefront.
46 url: https://docs.medusajs.com/resources/storefront-development/products/price
47 x-associatedSchema:
48 $ref: '#/components/schemas/StoreCurrency'
49 - name: Customers
50 description: |
51 Customers can place orders as guest customers or register.
52
53 When a customer registers, they can manage their profile, save addresses for later usage, and more.
54
55 These API routes allow customers to create and manage their accounts.
56 externalDocs:
57 description: How to implement customer account functionalities in a storefront.
58 url: https://docs.medusajs.com/resources/storefront-development/customers
59 x-associatedSchema:
60 $ref: '#/components/schemas/StoreCustomer'
61 - name: Gift Cards
62 description: |
63 A gift card is a prepaid card that customers can use to purchase products in the store.
64 Customers can purchase gift cards for themselves or others, and then use them to pay for their orders.
65 These API routes allow logged-in customers to create and manage their gift cards.
66 <Note>
67 Gift Cards are available through the [Loyalty Plugin](https://docs.medusajs.com/resources/commerce-modules/loyalty).
68 </Note>
69 x-associatedSchema:
70 $ref: '#/components/schemas/StoreGiftCard'
71 - name: Locales
72 description: |
73 A locale is a language that content is translated into for customers to view in a storefront.
74 Medusa installs locales by default. These API routes allow you to retrieve supported locales in the store.
75 externalDocs:
76 description: Learn more about locales and translations.
77 url: https://docs.medusajs.com/resources/commerce-modules/translation/concepts
78 x-associatedSchema:
79 $ref: '#/components/schemas/StoreLocale'
80 - name: Multi-Factor Authentication (MFA) Factors
81 description: |
82 Multi-factor authentication (MFA) factors are additional ways to verify a customer's identity during login, in addition to their password. Examples of MFA factors include authenticator apps, SMS messages, and email.
83 These API routes allow customers to manage their MFA factors, such as enabling an authenticator app or generating recovery codes.
84 externalDocs:
85 description: Learn more about MFA in Medusa
86 url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
87 - name: Orders
88 description: |
89 Guest and registered customers can view orders they placed.
90
91 These API routes allow customers to view their orders.
92 x-associatedSchema:
93 $ref: '#/components/schemas/StoreOrder'
94 - name: Payment Collections
95 description: |
96 A cart must have a payment collection with an authorized payment session.
97
98 Use these API routes during checkout to set the cart's payment provider and authorize its payment session.
99 externalDocs:
100 description: How to implement payment during checkout.
101 url: https://docs.medusajs.com/resources/storefront-development/checkout/payment
102 x-associatedSchema:
103 $ref: '#/components/schemas/StorePaymentCollection'
104 - name: Payment Providers
105 description: |
106 Each region has a set of payment providers enabled.
107
108 During checkout, you retrieve the available payment providers in the customer's region to show them to the customer. Customers then choose their preferred provider to authorize their payment and place their order.
109
110 These API routes allow customers to view available payment providers in their region.
111 externalDocs:
112 description: How to implement payment during checkout.
113 url: https://docs.medusajs.com/resources/storefront-development/checkout/payment
114 x-associatedSchema:
115 $ref: '#/components/schemas/StorePaymentProvider'
116 - name: Product Categories
117 description: |
118 Products can be categorized into categories.
119
120 These API routes allow customers to browse categories and their products.
121 externalDocs:
122 description: How to list product categories in a storefront.
123 url: https://docs.medusajs.com/resources/storefront-development/products/categories/list
124 x-associatedSchema:
125 $ref: '#/components/schemas/StoreProductCategory'
126 - name: Product Options
127 x-associatedSchema:
128 $ref: '#/components/schemas/StoreProductOption'
129 description: |
130 A product option is a way to define different options for a product, such as "Size" or "Color". Product options can be created globally and used by multiple products, or they can be exclusive to a specific product.
131 These API routes allow customers to view product options.
132 externalDocs:
133 description: Use Product Options in a Storefront
134 url: https://docs.medusajs.com/resources/storefront-development/products/options
135 - name: Product Tags
136 x-associatedSchema:
137 $ref: '#/components/schemas/StoreProductTag'
138 - name: Product Types
139 x-associatedSchema:
140 $ref: '#/components/schemas/StoreProductType'
141 - name: Product Variants
142 x-associatedSchema:
143 $ref: '#/components/schemas/StoreProductVariant'
144 - name: Products
145 description: |
146 Customers browse products for their purchase.
147
148 A product has variants for different option values. The customer chooses from these variants before adding it to the cart.
149
150 These API routes allow customers to browse products.
151 externalDocs:
152 description: How to list products, get their prices, and more in a storefront.
153 url: https://docs.medusajs.com/resources/storefront-development/products
154 x-associatedSchema:
155 $ref: '#/components/schemas/StoreProduct'
156 - name: Regions
157 description: |
158 Regions are different countries or geographical regions that the commerce store serves customers in.
159
160 Customers can choose what region they're in to view prices of that region's currency.
161
162 Use these API routes to retrieve available regions in the store.
163 externalDocs:
164 description: How to retrieve and store selected region in a storefront.
165 url: https://docs.medusajs.com/resources/storefront-development/regions
166 x-associatedSchema:
167 $ref: '#/components/schemas/StoreRegion'
168 - name: Return Reasons
169 description: |
170 A return reason is a possible reason a customer wants to return an item.
171
172 Use these API routes when implementing return creation flow in your storefront to allow customers to select their return reason.
173 x-associatedSchema:
174 $ref: '#/components/schemas/StoreReturnReason'
175 - name: Returns
176 description: |
177 Customers can request to return items in their order. The admin user then receives and handles the return.
178
179 These API routes allows customers to create a return.
180 x-associatedSchema:
181 $ref: '#/components/schemas/StoreReturn'
182 - name: Search
183 description: |
184 Search the indexes that your application exposes to the storefront.
185
186 An index is only searchable through these API routes once it's allowed with the `configureStoreSearch` middleware.
187 - name: Shipping Options
188 description: |
189 A shipping option is a way of shipping an item to or from the customer.
190
191 During the checkout flow, the customer selects their preferred shipping option to receive their order.
192
193 These API routes allow customers to retrieve available shipping options for their context.
194 externalDocs:
195 description: How to implement shipping during checkout.
196 url: https://docs.medusajs.com/resources/storefront-development/checkout/shipping
197 x-associatedSchema:
198 $ref: '#/components/schemas/StoreShippingOption'
199 - name: Store Credit Accounts
200 x-associatedSchema:
201 description: |
202 A store credit account is a way for customers to manage their store credit balance. Customers can use their store credit to pay for orders, and view their store credit balance.
203 These API routes allow customers to view their store credit accounts.
204 <Note>
205 Store Credit Accounts are only available through the [Loyalty Plugin](https://docs.medusajs.com/resources/commerce-modules/loyalty).
206 </Note>
207 $ref: '#/components/schemas/StoreStoreCreditAccount'
208 paths:
209 /auth/customer/emailpass/verification/confirm:
210 post:
211 operationId: PostActor_typeAuth_providerVerificationConfirm
212 summary: Verify the Customer's Email
213 description: Verifies the customer's email using a token that is typically sent to their email address. This is used to confirm the customer's email during registration or authentication when [email verification is required](https://docs.medusajs.com/resources/commerce-modules/auth/auth-providers/emailpass). You can listen to the `auth.verification_requested` event in a subscriber and send an email to the customer with the verification token.
214 x-authenticated: false
215 requestBody:
216 content:
217 application/json:
218 schema:
219 type: object
220 description: The details required to verify the customer's email.
221 required:
222 - token
223 properties:
224 token:
225 type: string
226 title: token
227 description: The verification token sent to the customer's email address.
228 x-codeSamples:
229 - lang: Shell
230 label: cURL
231 source: |-
232 curl -X POST '{backend_url}/auth/customer/emailpass/verification/confirm' \
233 -H 'Content-Type: application/json' \
234 --data-raw '{
235 "token": "{value}"
236 }'
237 tags:
238 - Auth
239 responses:
240 '200':
241 description: OK
242 '400':
243 $ref: '#/components/responses/400_error'
244 '401':
245 $ref: '#/components/responses/unauthorized'
246 '404':
247 $ref: '#/components/responses/not_found_error'
248 '409':
249 $ref: '#/components/responses/invalid_state_error'
250 '422':
251 $ref: '#/components/responses/invalid_request_error'
252 '500':
253 $ref: '#/components/responses/500_error'
254 /auth/customer/providers:
255 get:
256 operationId: GetCustomerProviders
257 x-sidebar-summary: List Providers
258 summary: List Auth Providers for Customers
259 description: Retrieve a list of auth providers for the customer actor type. This is useful to show the authentication option for the available providers.
260 x-authenticated: false
261 x-codeSamples:
262 - lang: JavaScript
263 label: JS SDK
264 source: |-
265 import Medusa from "@medusajs/js-sdk"
266
267 export const sdk = new Medusa({
268 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
269 debug: import.meta.env.DEV,
270 auth: {
271 type: "session",
272 },
273 })
274
275 const { providers } = await sdk.auth.listProviders("customer")
276 - lang: Shell
277 label: cURL
278 source: curl '{backend_url}/auth/customer/providers'
279 tags:
280 - Auth
281 responses:
282 '200':
283 description: OK
284 content:
285 application/json:
286 schema:
287 $ref: '#/components/schemas/AuthProvidersListResponse'
288 '400':
289 $ref: '#/components/responses/400_error'
290 '401':
291 $ref: '#/components/responses/unauthorized'
292 '404':
293 $ref: '#/components/responses/not_found_error'
294 '409':
295 $ref: '#/components/responses/invalid_state_error'
296 '422':
297 $ref: '#/components/responses/invalid_request_error'
298 '500':
299 $ref: '#/components/responses/500_error'
300 /auth/customer/{auth_provider}:
301 post:
302 operationId: PostActor_typeAuth_provider
303 summary: Authenticate Customer
304 description: |
305 Authenticate a customer and receive the JWT token to be used in the header of subsequent requests.
306
307 When used with a third-party provider, such as Google, the request returns a `location` property. You redirect to the specified URL in your storefront to continue authentication with the third-party service.
308 externalDocs:
309 url: https://docs.medusajs.com/resources/storefront-development/customers/login#1-using-a-jwt-token
310 description: 'Storefront development: How to login as a customer'
311 x-authenticated: false
312 parameters:
313 - name: auth_provider
314 in: path
315 description: The provider used for authentication.
316 required: true
317 schema:
318 type: string
319 example: emailpass
320 requestBody:
321 content:
322 application/json:
323 schema:
324 type: object
325 title: input
326 description: |
327 The input data necessary for authentication.
328 For example, for email-pass authentication, pass `email` and `password` properties.
329 For the Google and GitHub authentication providers, you can pass `callback_url` to indicate the URL in the frontend that the customer should be redirected to after completing their authentication. This will override the provider's `callbackUrl` configurations in `medusa-config.ts`.
330 x-codeSamples:
331 - lang: JavaScript
332 label: JS SDK
333 source: |-
334 import Medusa from "@medusajs/js-sdk"
335
336 let MEDUSA_BACKEND_URL = "http://localhost:9000"
337
338 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
339 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
340 }
341
342 export const sdk = new Medusa({
343 baseUrl: MEDUSA_BACKEND_URL,
344 debug: process.env.NODE_ENV === "development",
345 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
346 })
347
348 const result = await sdk.auth.login(
349 "customer",
350 "emailpass",
351 {
352 email: "customer@gmail.com",
353 password: "supersecret"
354 }
355 )
356
357 if (typeof result !== "string") {
358 alert("Authentication requires additional steps")
359 // replace with the redirect logic of your application
360 window.location.href = result.location
361 return
362 }
363
364 // customer is now authenticated
365 // all subsequent requests will use the token in the header
366 const { customer } = await sdk.store.customer.retrieve()
367 - lang: Bash
368 label: Google Provider
369 source: curl -X POST '{backend_url}/auth/customer/google'
370 tags:
371 - Auth
372 responses:
373 '200':
374 description: OK
375 content:
376 application/json:
377 schema:
378 oneOf:
379 - $ref: '#/components/schemas/AuthResponse'
380 - $ref: '#/components/schemas/AuthCallbackResponse'
381 '400':
382 $ref: '#/components/responses/400_error'
383 '401':
384 $ref: '#/components/responses/unauthorized'
385 '404':
386 $ref: '#/components/responses/not_found_error'
387 '409':
388 $ref: '#/components/responses/invalid_state_error'
389 '422':
390 $ref: '#/components/responses/invalid_request_error'
391 '500':
392 $ref: '#/components/responses/500_error'
393 /auth/customer/{auth_provider}/callback:
394 post:
395 operationId: PostActor_typeAuth_providerCallback
396 summary: Validate Authentication Callback
397 description: |
398 This API route is used by your storefront or frontend application when a third-party provider redirects to it after authentication. It validates the authentication with the third-party provider and, if successful, returns an authentication token. All query parameters received from the third-party provider, such as `code`, `state`, and `error`, must be passed as query parameters to this route.
399 You can decode the JWT token using libraries like [react-jwt](https://www.npmjs.com/package/react-jwt) in the storefront. If the decoded data doesn't have an `actor_id` property, then you must register the customer using the Create Customer API route passing the token in the request's Authorization header.
400 externalDocs:
401 url: https://docs.medusajs.com/resources/storefront-development/customers/third-party-login
402 description: 'Storefront development: Implement third-party (social) login.'
403 x-authenticated: false
404 parameters:
405 - name: auth_provider
406 in: path
407 description: The provider used for authentication.
408 required: true
409 schema:
410 type: string
411 example: google
412 x-codeSamples:
413 - lang: JavaScript
414 label: Google Provider
415 source: |-
416 import Medusa from "@medusajs/js-sdk"
417 import { decodeToken } from "react-jwt"
418
419 let MEDUSA_BACKEND_URL = "http://localhost:9000"
420
421 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
422 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
423 }
424
425 export const sdk = new Medusa({
426 baseUrl: MEDUSA_BACKEND_URL,
427 debug: process.env.NODE_ENV === "development",
428 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
429 })
430
431 const token = await sdk.auth.callback(
432 "customer",
433 "google",
434 {
435 code: "123",
436 state: "456"
437 }
438 )
439 // all subsequent requests will use the token in the header
440
441 const decodedToken = decodeToken(token) as { actor_id: string, user_metadata: Record<string, unknown> }
442
443 const shouldCreateCustomer = decodedToken.actor_id === ""
444
445 if (shouldCreateCustomer) {
446 const { customer } = await sdk.store.customer.create({
447 email: decodedToken.user_metadata.email as string,
448 })
449
450 // refresh auth token
451 await sdk.auth.refresh()
452 // all subsequent requests will use the new token in the header
453 } else {
454 // Customer already exists and is authenticated
455 }
456 - lang: TypeScript
457 label: GitHub Provider
458 source: |-
459 import Medusa from "@medusajs/js-sdk"
460 import { decodeToken } from "react-jwt"
461
462 let MEDUSA_BACKEND_URL = "http://localhost:9000"
463
464 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
465 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
466 }
467
468 export const sdk = new Medusa({
469 baseUrl: MEDUSA_BACKEND_URL,
470 debug: process.env.NODE_ENV === "development",
471 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
472 })
473
474 const token = await sdk.auth.callback(
475 "customer",
476 "github",
477 {
478 code: "123",
479 state: "456"
480 }
481 )
482 // all subsequent requests will use the token in the header
483
484 const decodedToken = decodeToken(token) as { actor_id: string, user_metadata: Record<string, unknown> }
485
486 const shouldCreateCustomer = decodedToken.actor_id === ""
487
488 if (shouldCreateCustomer) {
489 const { customer } = await sdk.store.customer.create({
490 email: decodedToken.user_metadata.email as string,
491 })
492
493 // refresh auth token
494 await sdk.auth.refresh()
495 // all subsequent requests will use the new token in the header
496 } else {
497 // Customer already exists and is authenticated
498 }
499 tags:
500 - Auth
501 responses:
502 '200':
503 description: OK
504 content:
505 application/json:
506 schema:
507 $ref: '#/components/schemas/AuthResponse'
508 '400':
509 $ref: '#/components/responses/400_error'
510 '401':
511 $ref: '#/components/responses/unauthorized'
512 '404':
513 $ref: '#/components/responses/not_found_error'
514 '409':
515 $ref: '#/components/responses/invalid_state_error'
516 '422':
517 $ref: '#/components/responses/invalid_request_error'
518 '500':
519 $ref: '#/components/responses/500_error'
520 /auth/customer/{auth_provider}/register:
521 post:
522 operationId: PostActor_typeAuth_provider_register
523 summary: Retrieve Registration JWT Token
524 description: This API route retrieves a registration JWT token of a customer that hasn't been registered yet. The token is used in the header of requests that create a customer.
525 externalDocs:
526 url: https://docs.medusajs.com/resources/storefront-development/customers/register
527 description: 'Storefront development: How to register a customer'
528 x-authenticated: false
529 parameters:
530 - name: auth_provider
531 in: path
532 description: The provider used for authentication.
533 required: true
534 schema:
535 type: string
536 example: emailpass
537 requestBody:
538 content:
539 application/json:
540 schema:
541 type: object
542 title: input
543 description: The input data necessary for authentication. For example, for email-pass authentication, pass `email` and `password` properties.
544 example:
545 email: customer@gmail.com
546 password: supersecret
547 x-codeSamples:
548 - lang: JavaScript
549 label: JS SDK
550 source: |-
551 import Medusa from "@medusajs/js-sdk"
552
553 let MEDUSA_BACKEND_URL = "http://localhost:9000"
554
555 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
556 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
557 }
558
559 export const sdk = new Medusa({
560 baseUrl: MEDUSA_BACKEND_URL,
561 debug: process.env.NODE_ENV === "development",
562 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
563 })
564
565 await sdk.auth.register(
566 "customer",
567 "emailpass",
568 {
569 email: "customer@gmail.com",
570 password: "supersecret"
571 }
572 )
573
574 // all subsequent requests will use the token in the header
575 const { customer } = await sdk.store.customer.create({
576 email: "customer@gmail.com",
577 password: "supersecret"
578 })
579 - lang: Shell
580 label: cURL
581 source: |-
582 curl -X POST '{backend_url}/auth/customer/emailpass/register' \
583 -H 'Content-Type: application/json' \
584 --data-raw '{
585 "email": "customer@gmail.com",
586 "password": "supersecret"
587 }'
588 tags:
589 - Auth
590 responses:
591 '200':
592 description: OK
593 content:
594 application/json:
595 schema:
596 $ref: '#/components/schemas/AuthResponse'
597 '400':
598 $ref: '#/components/responses/400_error'
599 '401':
600 $ref: '#/components/responses/unauthorized'
601 '404':
602 $ref: '#/components/responses/not_found_error'
603 '409':
604 $ref: '#/components/responses/invalid_state_error'
605 '422':
606 $ref: '#/components/responses/invalid_request_error'
607 '500':
608 $ref: '#/components/responses/500_error'
609 /auth/customer/{auth_provider}/reset-password:
610 post:
611 operationId: PostActor_typeAuth_providerResetPassword
612 summary: Generate Reset Password Token for Customer
613 x-sidebar-summary: Generate Reset Password Token
614 description: |
615 Generate a reset password token for a customer. This API route doesn't reset the customer password or send them the reset instructions in a notification.
616
617 Instead, This API route emits the `auth.password_reset` event, passing it the token as a payload. You can listen to that event in a subscriber as explained in [this guide](https://docs.medusajs.com/resources/commerce-modules/auth/reset-password), then send the customer a notification. The notification is sent using a [Notification Module Provider](https://docs.medusajs.com/resources/infrastructure-modules/notification), and it should have a URL that accepts a `token` query parameter, allowing the customer to reset their password from the storefront.
618
619
620 Use the generated token to update the customer's password using the [Reset Password API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_providerupdate).
621 externalDocs:
622 url: https://docs.medusajs.com/resources/storefront-development/customers/reset-password#1-request-reset-password-page
623 description: 'Storefront development: How to create the request reset password page.'
624 x-authenticated: false
625 parameters:
626 - name: auth_provider
627 in: path
628 description: The provider used for authentication.
629 required: true
630 schema:
631 type: string
632 example: emailpass
633 requestBody:
634 content:
635 application/json:
636 schema:
637 type: object
638 description: The input data necessary to generate a reset password token.
639 required:
640 - identifier
641 properties:
642 identifier:
643 type: string
644 description: The customer's identifier for the selected auth provider. For example, for the `emailpass` auth provider, the value is the customer's email.
645 example: customer@gmail.com
646 metadata:
647 type: object
648 description: Optional metadata to include with the reset password token generation request.
649 x-codeSamples:
650 - lang: JavaScript
651 label: JS SDK
652 source: |-
653 import Medusa from "@medusajs/js-sdk"
654
655 let MEDUSA_BACKEND_URL = "http://localhost:9000"
656
657 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
658 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
659 }
660
661 export const sdk = new Medusa({
662 baseUrl: MEDUSA_BACKEND_URL,
663 debug: process.env.NODE_ENV === "development",
664 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
665 })
666
667 sdk.auth.resetPassword(
668 "customer",
669 "emailpass",
670 {
671 identifier: "customer@gmail.com"
672 }
673 )
674 .then(() => {
675 // user receives token
676 })
677 - lang: Shell
678 label: cURL
679 source: |-
680 curl -X POST '{backend_url}/auth/customer/emailpass/reset-password' \
681 -H 'Content-Type: application/json' \
682 --data-raw '{
683 "identifier": "customer@gmail.com"
684 }'
685 tags:
686 - Auth
687 responses:
688 '201':
689 description: OK
690 content:
691 text/plain:
692 schema:
693 type: string
694 title: message
695 description: The 201 status code's message.
696 example: Created
697 '400':
698 $ref: '#/components/responses/400_error'
699 '401':
700 $ref: '#/components/responses/unauthorized'
701 '404':
702 $ref: '#/components/responses/not_found_error'
703 '409':
704 $ref: '#/components/responses/invalid_state_error'
705 '422':
706 $ref: '#/components/responses/invalid_request_error'
707 '500':
708 $ref: '#/components/responses/500_error'
709 x-workflow: generateResetPasswordTokenWorkflow
710 x-events:
711 - name: auth.password_reset
712 payload: |-
713 ```ts
714 {
715 entity_id, // The identifier of the user or customer. For example, an email address.
716 actor_type, // The type of actor. For example, "customer", "user", or custom.
717 token, // The generated token.
718 metadata, // Optional custom metadata passed from the request.
719 }
720 ```
721 description: |-
722 Emitted when a reset password token is generated. You can listen to this event
723 to send a reset password email to the user or customer, for example.
724 deprecated: false
725 /auth/customer/{auth_provider}/update:
726 post:
727 operationId: PostActor_typeAuth_providerUpdate
728 summary: Reset a Customer's Password
729 x-sidebar-summary: Reset Password
730 description: Reset a customer's password using a reset-password token generated with the [Generate Reset Password Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_providerresetpassword). You pass the token as a bearer token in the request's Authorization header.
731 externalDocs:
732 url: https://docs.medusajs.com/resources/storefront-development/customers/reset-password#2-reset-password-page
733 description: 'Storefront development: How to create the reset password page.'
734 x-authenticated: true
735 parameters:
736 - name: auth_provider
737 in: path
738 description: The provider used for authentication.
739 required: true
740 schema:
741 type: string
742 example: emailpass
743 requestBody:
744 content:
745 application/json:
746 schema:
747 type: object
748 title: input
749 description: The input data necessary for authentication with the specified auth provider. For example, for email-pass authentication, pass `email` and `password` properties.
750 example:
751 email: customer@gmail.com
752 password: supersecret
753 x-codeSamples:
754 - lang: JavaScript
755 label: JS SDK
756 source: |-
757 import Medusa from "@medusajs/js-sdk"
758
759 let MEDUSA_BACKEND_URL = "http://localhost:9000"
760
761 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
762 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
763 }
764
765 export const sdk = new Medusa({
766 baseUrl: MEDUSA_BACKEND_URL,
767 debug: process.env.NODE_ENV === "development",
768 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
769 })
770
771 sdk.auth.updateProvider(
772 "customer",
773 "emailpass",
774 {
775 password: "supersecret"
776 },
777 token
778 )
779 .then(() => {
780 // password updated
781 })
782 - lang: Shell
783 label: cURL
784 source: |-
785 curl -X POST '{backend_url}/auth/customer/emailpass/update' \
786 -H 'Content-Type: application/json' \
787 -H 'Authorization: Bearer {token}' \
788 --data-raw '{
789 "email": "customer@gmail.com",
790 "password": "supersecret"
791 }'
792 security:
793 - reset_password: []
794 tags:
795 - Auth
796 responses:
797 '200':
798 description: OK
799 content:
800 application/json:
801 schema:
802 type: object
803 required:
804 - success
805 description: Details on the reset password's status.
806 properties:
807 success:
808 type: boolean
809 title: success
810 description: Whether the password was reset successfully.
811 '400':
812 $ref: '#/components/responses/400_error'
813 '401':
814 $ref: '#/components/responses/unauthorized'
815 '404':
816 $ref: '#/components/responses/not_found_error'
817 '409':
818 $ref: '#/components/responses/invalid_state_error'
819 '422':
820 $ref: '#/components/responses/invalid_request_error'
821 '500':
822 $ref: '#/components/responses/500_error'
823 /auth/mfa/challenges/{id}/verify:
824 post:
825 operationId: PostMfaChallengesIdVerify
826 summary: Verify a Multi-Factor Authentication (MFA) Challenge
827 x-sidebar-summary: Verify MFA Challenge
828 description: |
829 Verify a multi-factor authentication (MFA) challenge issued during login. On success, this
830 completes the authentication flow and returns a JWT token that can be used to authenticate
831 subsequent requests.
832 x-authenticated: false
833 externalDocs:
834 description: Learn more about MFA in Medusa
835 url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
836 parameters:
837 - name: id
838 in: path
839 description: The MFA challenge's ID.
840 required: true
841 schema:
842 type: string
843 requestBody:
844 content:
845 application/json:
846 schema:
847 type: object
848 description: The details required to verify the MFA challenge.
849 required:
850 - method
851 - code
852 properties:
853 method:
854 type: string
855 title: method
856 description: The MFA method used to verify the challenge (for example, `totp` or `recovery-code`).
857 code:
858 type: string
859 title: code
860 description: The verification code generated by the chosen MFA method.
861 x-codeSamples:
862 - lang: JavaScript
863 label: JS SDK
864 source: |-
865 import Medusa from "@medusajs/js-sdk"
866
867 export const sdk = new Medusa({
868 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
869 debug: import.meta.env.DEV,
870 auth: {
871 type: "session",
872 },
873 })
874
875 const result = await sdk.auth.login("user", "emailpass", {
876 email: "user@example.com",
877 password: "secret"
878 })
879
880 if (typeof result === "object" && "mfa_challenge" in result) {
881 await sdk.auth.mfa.verifyChallenge(result.mfa_challenge.id, {
882 method: "totp",
883 code: "123456"
884 })
885 }
886 - lang: Shell
887 label: cURL
888 source: |-
889 curl -X POST '{backend_url}/auth/mfa/challenges/{id}/verify' \
890 -H 'Content-Type: application/json' \
891 --data-raw '{
892 "method": "{value}",
893 "code": "{value}"
894 }'
895 tags:
896 - Multi-Factor Authentication (MFA) Factors
897 responses:
898 '200':
899 description: OK
900 '400':
901 $ref: '#/components/responses/400_error'
902 '401':
903 $ref: '#/components/responses/unauthorized'
904 '404':
905 $ref: '#/components/responses/not_found_error'
906 '409':
907 $ref: '#/components/responses/invalid_state_error'
908 '422':
909 $ref: '#/components/responses/invalid_request_error'
910 '500':
911 $ref: '#/components/responses/500_error'
912 x-since: 2.15.3
913 /auth/mfa/factors:
914 get:
915 operationId: GetMfaFactors
916 summary: List Multifactor Authentication (MFA) Factors
917 x-sidebar-summary: List MFA Factors
918 description: |
919 Retrieve the list of multi-factor authentication (MFA) factors registered for the authenticated user,
920 including both pending (not yet verified) and enabled factors.
921 x-authenticated: true
922 parameters: []
923 x-codeSamples:
924 - lang: JavaScript
925 label: JS SDK
926 source: |-
927 import Medusa from "@medusajs/js-sdk"
928
929 export const sdk = new Medusa({
930 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
931 debug: import.meta.env.DEV,
932 auth: {
933 type: "session",
934 },
935 })
936
937 const { mfa_factors } = await sdk.auth.mfa.list()
938 - lang: Shell
939 label: cURL
940 source: curl '{backend_url}/auth/mfa/factors'
941 tags:
942 - Multi-Factor Authentication (MFA) Factors
943 responses:
944 '200':
945 description: OK
946 '400':
947 $ref: '#/components/responses/400_error'
948 '401':
949 $ref: '#/components/responses/unauthorized'
950 '404':
951 $ref: '#/components/responses/not_found_error'
952 '409':
953 $ref: '#/components/responses/invalid_state_error'
954 '422':
955 $ref: '#/components/responses/invalid_request_error'
956 '500':
957 $ref: '#/components/responses/500_error'
958 x-since: 2.15.3
959 post:
960 operationId: PostMfaFactors
961 summary: Start Multi-Factor Authentication (MFA) Factor Enrollment
962 x-sidebar-summary: Start MFA Factor Enrollment
963 description: |
964 Start the enrollment of a new multi-factor authentication (MFA) factor for the authenticated
965 user. The response contains the factor along with provider-specific setup data (such as a
966 secret and an `otpauth_url` for TOTP) that can be used to display a QR code. The factor must
967 then be verified via the verify endpoint before it can be used.
968 x-authenticated: true
969 externalDocs:
970 description: Learn more about MFA in Medusa
971 url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
972 parameters: []
973 requestBody:
974 content:
975 application/json:
976 schema:
977 type: object
978 description: The details of the MFA factor to enroll.
979 required:
980 - provider
981 properties:
982 provider:
983 type: string
984 title: provider
985 description: The ID of the MFA provider to enroll the factor with (for example, `totp`).
986 label:
987 type: string
988 title: label
989 description: A human-readable label to identify the factor (for example, the name of the authenticator app or device).
990 issuer:
991 type: string
992 title: issuer
993 description: The issuer name shown in authenticator apps for this factor. Defaults to the application name when omitted.
994 metadata:
995 type: object
996 description: Additional provider-specific data to associate with the factor.
997 x-codeSamples:
998 - lang: JavaScript
999 label: JS SDK
1000 source: |-
1001 import Medusa from "@medusajs/js-sdk"
1002
1003 export const sdk = new Medusa({
1004 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
1005 debug: import.meta.env.DEV,
1006 auth: {
1007 type: "session",
1008 },
1009 })
1010
1011 const setup = await sdk.auth.mfa.start({
1012 provider: "totp",
1013 label: "Authenticator app"
1014 })
1015
1016 // Render setup.otpauth_url as a QR code or show setup.secret manually.
1017 - lang: Shell
1018 label: cURL
1019 source: |-
1020 curl -X POST '{backend_url}/auth/mfa/factors' \
1021 -H 'Content-Type: application/json' \
1022 --data-raw '{
1023 "provider": "{value}"
1024 }'
1025 tags:
1026 - Multi-Factor Authentication (MFA) Factors
1027 responses:
1028 '200':
1029 description: OK
1030 '400':
1031 $ref: '#/components/responses/400_error'
1032 '401':
1033 $ref: '#/components/responses/unauthorized'
1034 '404':
1035 $ref: '#/components/responses/not_found_error'
1036 '409':
1037 $ref: '#/components/responses/invalid_state_error'
1038 '422':
1039 $ref: '#/components/responses/invalid_request_error'
1040 '500':
1041 $ref: '#/components/responses/500_error'
1042 x-since: 2.15.3
1043 /auth/mfa/factors/{id}:
1044 delete:
1045 operationId: DeleteMfaFactorsId
1046 summary: Disable a Multi-Factor Authentication (MFA) Factor
1047 x-sidebar-summary: Disable MFA Factor
1048 description: |
1049 Disable a multi-factor authentication (MFA) factor for the authenticated user. Once disabled,
1050 the factor can no longer be used to verify MFA challenges. When disabling a recovery-code
1051 factor, a valid recovery code must be provided in the request body.
1052 x-authenticated: true
1053 parameters:
1054 - name: id
1055 in: path
1056 description: The MFA factor's ID.
1057 required: true
1058 schema:
1059 type: string
1060 requestBody:
1061 content:
1062 application/json:
1063 schema:
1064 type: object
1065 description: The details required to disable the MFA factor.
1066 properties:
1067 method:
1068 type: string
1069 title: method
1070 description: The MFA method used to authorize disabling the factor (for example, `recovery-code`).
1071 code:
1072 type: string
1073 title: code
1074 description: The verification code associated with the provided `method`, used to confirm the disable action.
1075 x-codeSamples:
1076 - lang: JavaScript
1077 label: JS SDK
1078 source: |-
1079 import Medusa from "@medusajs/js-sdk"
1080
1081 export const sdk = new Medusa({
1082 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
1083 debug: import.meta.env.DEV,
1084 auth: {
1085 type: "session",
1086 },
1087 })
1088
1089 const { mfa_factor } = await sdk.auth.mfa.disable("authmfa_123")
1090 - lang: Shell
1091 label: cURL
1092 source: curl -X DELETE '{backend_url}/auth/mfa/factors/{id}'
1093 tags:
1094 - Multi-Factor Authentication (MFA) Factors
1095 responses:
1096 '200':
1097 description: OK
1098 '400':
1099 $ref: '#/components/responses/400_error'
1100 '401':
1101 $ref: '#/components/responses/unauthorized'
1102 '404':
1103 $ref: '#/components/responses/not_found_error'
1104 '409':
1105 $ref: '#/components/responses/invalid_state_error'
1106 '422':
1107 $ref: '#/components/responses/invalid_request_error'
1108 '500':
1109 $ref: '#/components/responses/500_error'
1110 x-since: 2.15.3
1111 /auth/mfa/factors/{id}/verify:
1112 post:
1113 operationId: PostMfaFactorsIdVerify
1114 summary: Verify and Enable a Multi-Factor Authentication (MFA) Factor
1115 x-sidebar-summary: Verify and Enable MFA Factor
1116 description: |
1117 Verify a pending multi-factor authentication (MFA) factor by submitting a code generated from
1118 it. A successful verification enables the factor, after which it can be used to verify MFA
1119 challenges during login.
1120 x-authenticated: true
1121 externalDocs:
1122 description: Learn more about MFA in Medusa
1123 url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
1124 parameters:
1125 - name: id
1126 in: path
1127 description: The MFA factor's ID.
1128 required: true
1129 schema:
1130 type: string
1131 requestBody:
1132 content:
1133 application/json:
1134 schema:
1135 type: object
1136 description: The details required to verify and enable the MFA factor.
1137 required:
1138 - code
1139 properties:
1140 code:
1141 type: string
1142 title: code
1143 description: The verification code generated by the MFA factor (for example, the current TOTP code from the authenticator app).
1144 x-codeSamples:
1145 - lang: JavaScript
1146 label: JS SDK
1147 source: |-
1148 import Medusa from "@medusajs/js-sdk"
1149
1150 export const sdk = new Medusa({
1151 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
1152 debug: import.meta.env.DEV,
1153 auth: {
1154 type: "session",
1155 },
1156 })
1157
1158 const { mfa_factor } = await sdk.auth.mfa.verify("authmfa_123", {
1159 code: "123456"
1160 })
1161 - lang: Shell
1162 label: cURL
1163 source: |-
1164 curl -X POST '{backend_url}/auth/mfa/factors/{id}/verify' \
1165 -H 'Content-Type: application/json' \
1166 --data-raw '{
1167 "code": "{value}"
1168 }'
1169 tags:
1170 - Multi-Factor Authentication (MFA) Factors
1171 responses:
1172 '200':
1173 description: OK
1174 '400':
1175 $ref: '#/components/responses/400_error'
1176 '401':
1177 $ref: '#/components/responses/unauthorized'
1178 '404':
1179 $ref: '#/components/responses/not_found_error'
1180 '409':
1181 $ref: '#/components/responses/invalid_state_error'
1182 '422':
1183 $ref: '#/components/responses/invalid_request_error'
1184 '500':
1185 $ref: '#/components/responses/500_error'
1186 x-since: 2.15.3
1187 /auth/mfa/recovery-codes:
1188 post:
1189 operationId: PostMfaRecoveryCodes
1190 summary: Generate Multi-Factor Authentication (MFA) Recovery Codes
1191 x-sidebar-summary: Generate MFA Recovery Codes
1192 description: |
1193 Generate a new set of single-use recovery codes for the authenticated user. Recovery codes can
1194 be used to verify MFA challenges when the user does not have access to their primary MFA
1195 factor. Generating new codes replaces any previously issued codes, so they should be stored in
1196 a safe place. At least one enabled MFA factor is required to generate recovery codes.
1197 x-authenticated: true
1198 externalDocs:
1199 description: Learn more about MFA in Medusa
1200 url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
1201 parameters: []
1202 requestBody:
1203 content:
1204 application/json:
1205 schema:
1206 type: object
1207 description: The options to use when generating recovery codes.
1208 properties:
1209 count:
1210 type: number
1211 title: count
1212 description: The number of recovery codes to generate. Must be between 1 and 50. Defaults to the provider's configured value when omitted.
1213 x-codeSamples:
1214 - lang: JavaScript
1215 label: JS SDK
1216 source: |-
1217 import Medusa from "@medusajs/js-sdk"
1218
1219 export const sdk = new Medusa({
1220 baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
1221 debug: import.meta.env.DEV,
1222 auth: {
1223 type: "session",
1224 },
1225 })
1226
1227 const { recovery_codes } = await sdk.auth.mfa.generateRecoveryCodes()
1228 - lang: Shell
1229 label: cURL
1230 source: curl -X POST '{backend_url}/auth/mfa/recovery-codes'
1231 tags:
1232 - Multi-Factor Authentication (MFA) Factors
1233 responses:
1234 '200':
1235 description: OK
1236 '400':
1237 $ref: '#/components/responses/400_error'
1238 '401':
1239 $ref: '#/components/responses/unauthorized'
1240 '404':
1241 $ref: '#/components/responses/not_found_error'
1242 '409':
1243 $ref: '#/components/responses/invalid_state_error'
1244 '422':
1245 $ref: '#/components/responses/invalid_request_error'
1246 '500':
1247 $ref: '#/components/responses/500_error'
1248 x-since: 2.15.3
1249 /auth/session:
1250 post:
1251 operationId: PostSession
1252 summary: Set Authentication Session
1253 description: Set the cookie session ID of a customer. The customer must be previously authenticated with the `/auth/customer/{provider}` API route first, as the JWT token is required in the header of the request.
1254 externalDocs:
1255 url: https://docs.medusajs.com/resources/storefront-development/customers/login#2-using-a-cookie-session
1256 description: 'Storefront development: How to login as a customer'
1257 x-authenticated: true
1258 x-codeSamples:
1259 - lang: Shell
1260 label: cURL
1261 source: |-
1262 curl -X POST '{backend_url}/auth/session' \
1263 -H 'Authorization: Bearer {jwt_token}'
1264 tags:
1265 - Auth
1266 responses:
1267 '200':
1268 description: OK
1269 content:
1270 application/json:
1271 schema:
1272 $ref: '#/components/schemas/AuthStoreSessionResponse'
1273 '400':
1274 $ref: '#/components/responses/400_error'
1275 '401':
1276 $ref: '#/components/responses/unauthorized'
1277 '404':
1278 $ref: '#/components/responses/not_found_error'
1279 '409':
1280 $ref: '#/components/responses/invalid_state_error'
1281 '422':
1282 $ref: '#/components/responses/invalid_request_error'
1283 '500':
1284 $ref: '#/components/responses/500_error'
1285 delete:
1286 operationId: DeleteSession
1287 summary: Delete Authentication Session
1288 description: Deletes the cookie session ID previously set for authentication.
1289 x-authenticated: true
1290 x-codeSamples:
1291 - lang: JavaScript
1292 label: JS SDK
1293 source: |-
1294 import Medusa from "@medusajs/js-sdk"
1295
1296 let MEDUSA_BACKEND_URL = "http://localhost:9000"
1297
1298 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
1299 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
1300 }
1301
1302 export const sdk = new Medusa({
1303 baseUrl: MEDUSA_BACKEND_URL,
1304 debug: process.env.NODE_ENV === "development",
1305 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
1306 })
1307
1308 await sdk.auth.logout()
1309
1310 // customer is now logged out
1311 // you can't send any requests that require authentication
1312 - lang: Shell
1313 label: cURL
1314 source: |-
1315 curl -X DELETE '{backend_url}/auth/session' \
1316 -H 'Cookie: connect.sid={sid}'
1317 tags:
1318 - Auth
1319 responses:
1320 '200':
1321 description: OK
1322 content:
1323 application/json:
1324 schema:
1325 type: object
1326 description: The deletion's details.
1327 required:
1328 - success
1329 properties:
1330 success:
1331 type: boolean
1332 title: success
1333 description: Whether the session was deleted successfully.
1334 '400':
1335 $ref: '#/components/responses/400_error'
1336 '401':
1337 $ref: '#/components/responses/unauthorized'
1338 '404':
1339 $ref: '#/components/responses/not_found_error'
1340 '409':
1341 $ref: '#/components/responses/invalid_state_error'
1342 '422':
1343 $ref: '#/components/responses/invalid_request_error'
1344 '500':
1345 $ref: '#/components/responses/500_error'
1346 /auth/token/refresh:
1347 post:
1348 operationId: PostAdminAuthTokenRefresh
1349 summary: Refresh Authentication Token
1350 description: Refresh the authentication token of a customer. This is useful after authenticating a customer with a third-party service to ensure the token holds the new user's details, or when you don't want customers to re-login every day.
1351 externalDocs:
1352 url: https://docs.medusajs.com/resources/storefront-development/customers/third-party-login
1353 description: 'Storefront development: Implement third-party (social) login.'
1354 x-authenticated: true
1355 x-codeSamples:
1356 - lang: JavaScript
1357 label: JS SDK
1358 source: |-
1359 import Medusa from "@medusajs/js-sdk"
1360
1361 let MEDUSA_BACKEND_URL = "http://localhost:9000"
1362
1363 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
1364 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
1365 }
1366
1367 export const sdk = new Medusa({
1368 baseUrl: MEDUSA_BACKEND_URL,
1369 debug: process.env.NODE_ENV === "development",
1370 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
1371 })
1372
1373 const token = await sdk.auth.refresh()
1374
1375 // all subsequent requests will use the token in the header
1376 const { customer } = await sdk.store.customer.retrieve()
1377 - lang: Shell
1378 label: cURL
1379 source: |-
1380 curl -X POST '{backend_url}/auth/token/refresh' \
1381 -H 'Authorization: Bearer {token}'
1382 tags:
1383 - Auth
1384 responses:
1385 '200':
1386 description: OK
1387 content:
1388 application/json:
1389 schema:
1390 $ref: '#/components/schemas/AuthResponse'
1391 '400':
1392 $ref: '#/components/responses/400_error'
1393 '401':
1394 $ref: '#/components/responses/unauthorized'
1395 '404':
1396 $ref: '#/components/responses/not_found_error'
1397 '409':
1398 $ref: '#/components/responses/invalid_state_error'
1399 '422':
1400 $ref: '#/components/responses/invalid_request_error'
1401 '500':
1402 $ref: '#/components/responses/500_error'
1403 /auth/verification/confirm:
1404 post:
1405 operationId: PostVerificationConfirm
1406 summary: Confirm Customer Verification
1407 x-sidebar-summary: Confirm Verification
1408 description: Confirm a verification token of the customer. This API route is used as the last step part of the email verification flow. It can also be used for custom flows, such as phone number verification. Once successfully verified, a customer can complete their registration and log into their account.
1409 externalDocs:
1410 url: https://docs.medusajs.com/resources/storefront-development/customers/verify-account
1411 description: 'Storefront guide: Register Customer with Email Verification.'
1412 x-authenticated: false
1413 requestBody:
1414 content:
1415 application/json:
1416 schema:
1417 type: object
1418 description: The verification details
1419 required:
1420 - code
1421 properties:
1422 code:
1423 type: string
1424 title: code
1425 description: The token, OTP, or any other code that was sent to the customer for verification.
1426 code_provider:
1427 type: string
1428 title: code_provider
1429 description: The provider to use for verification. This is optional. When not provided, the default `token` provider is used.
1430 x-codeSamples:
1431 - lang: Shell
1432 label: cURL
1433 source: |-
1434 curl -X POST '{backend_url}/auth/verification/confirm' \
1435 -H 'Content-Type: application/json' \
1436 --data-raw '{
1437 "code": "{value}"
1438 }'
1439 tags:
1440 - Auth
1441 responses:
1442 '200':
1443 description: OK
1444 '400':
1445 $ref: '#/components/responses/400_error'
1446 '401':
1447 $ref: '#/components/responses/unauthorized'
1448 '404':
1449 $ref: '#/components/responses/not_found_error'
1450 '409':
1451 $ref: '#/components/responses/invalid_state_error'
1452 '422':
1453 $ref: '#/components/responses/invalid_request_error'
1454 '500':
1455 $ref: '#/components/responses/500_error'
1456 x-since: 2.16.0
1457 /auth/verification/request:
1458 post:
1459 operationId: PostVerificationRequest
1460 summary: Request Customer Verification
1461 x-sidebar-summary: Request Verification
1462 description: Create a verification request for a customer. This API route is used when a customer logs in, but their email requires verification. It can also be used for custom flows, such as phone number verification. Once successfully requested, a verification code will be generated and an `auth.verification_requested` event will be emitted. You can listen to this event and decide how to deliver the code to the customer.
1463 externalDocs:
1464 url: https://docs.medusajs.com/resources/storefront-development/customers/verify-account
1465 description: 'Storefront guide: Register Customer with Email Verification.'
1466 x-authenticated: false
1467 parameters: []
1468 requestBody:
1469 content:
1470 application/json:
1471 schema:
1472 type: object
1473 description: The verification request details
1474 required:
1475 - entity_id
1476 - entity_type
1477 - code_provider
1478 properties:
1479 entity_id:
1480 type: string
1481 title: entity_id
1482 description: The identifier of the user or customer. For example, an email address.
1483 entity_type:
1484 type: string
1485 title: entity_type
1486 description: The type of identity being verified. For example, "email" or "phone_number".
1487 code_provider:
1488 type: string
1489 title: code_provider
1490 description: The provider to use to create the verification token or code. By default, Medusa provides a `token` provider that generates a random token. You can also implement your own provider to generate a code or OTP.
1491 metadata:
1492 type: object
1493 description: Custom key-value pairs that can be passed to the verification request. This is optional and can be used to store additional information related to the verification request.
1494 x-codeSamples:
1495 - lang: Shell
1496 label: cURL
1497 source: |-
1498 curl -X POST '{backend_url}/auth/verification/request' \
1499 -H 'Content-Type: application/json' \
1500 --data-raw '{
1501 "entity_id": "customer@example.com",
1502 "entity_type": "email",
1503 "code_provider": "token"
1504 }'
1505 tags:
1506 - Auth
1507 responses:
1508 '201':
1509 description: OK
1510 '400':
1511 $ref: '#/components/responses/400_error'
1512 '401':
1513 $ref: '#/components/responses/unauthorized'
1514 '404':
1515 $ref: '#/components/responses/not_found_error'
1516 '409':
1517 $ref: '#/components/responses/invalid_state_error'
1518 '422':
1519 $ref: '#/components/responses/invalid_request_error'
1520 '500':
1521 $ref: '#/components/responses/500_error'
1522 x-workflow: requestVerificationWorkflow
1523 x-events:
1524 - name: auth.verification_requested
1525 payload: |-
1526 ```ts
1527 {
1528 entity_id, // The identifier of the entity being verified. For example, an email address.
1529 entity_type, // The kind of entity being verified. For example, "email".
1530 code_provider, // The verification provider that generated the code. For example, "token".
1531 auth_identity_id, // The ID of the auth identity being verified.
1532 code, // The generated verification code.
1533 expires_at, // (Date) The code expiry date.
1534 metadata, // (object) Optional custom metadata passed from the request.
1535 }
1536 ```
1537 description: |-
1538 Emitted when a verification code is generated. You can listen to
1539 this event and decide how to deliver the code to the user or customer.
1540 The payload changed in v2.17.0:
1541 `actor_type` and `provider_identity_id` were removed,
1542 `provider` was renamed to `code_provider`, and `entity_type` was added.
1543 Subscribers written before v2.17.0 must be updated to use the payload below.
1544 deprecated: false
1545 since: 2.15.5
1546 x-since: 2.16.0
1547 /store/carts:
1548 post:
1549 operationId: PostCarts
1550 summary: Create Cart
1551 description: Create a cart.
1552 x-authenticated: false
1553 parameters:
1554 - name: x-publishable-api-key
1555 in: header
1556 description: Publishable API Key created in the Medusa Admin.
1557 required: true
1558 schema:
1559 type: string
1560 externalDocs:
1561 url: https://docs.medusajs.com/api/store#publishable-api-key
1562 - name: x-medusa-locale
1563 in: header
1564 description: The locale in BCP 47 format to retrieve localized content.
1565 required: false
1566 schema:
1567 type: string
1568 example: en-US
1569 externalDocs:
1570 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
1571 description: Learn more in the Serve Translations in Storefront guide.
1572 - name: fields
1573 in: query
1574 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
1575 required: false
1576 schema:
1577 type: string
1578 title: fields
1579 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
1580 externalDocs:
1581 url: '#select-fields-and-relations'
1582 - name: locale
1583 in: query
1584 description: The locale in BCP 47 format to retrieve localized content.
1585 required: false
1586 schema:
1587 type: string
1588 example: en-US
1589 externalDocs:
1590 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
1591 description: Learn more in the Serve Translations in Storefront guide.
1592 requestBody:
1593 content:
1594 application/json:
1595 schema:
1596 allOf:
1597 - $ref: '#/components/schemas/StoreCreateCart'
1598 - type: object
1599 description: The cart's details.
1600 properties:
1601 additional_data:
1602 type: object
1603 description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
1604 description: The cart's details.
1605 x-codeSamples:
1606 - lang: JavaScript
1607 label: JS SDK
1608 source: |-
1609 import Medusa from "@medusajs/js-sdk"
1610
1611 let MEDUSA_BACKEND_URL = "http://localhost:9000"
1612
1613 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
1614 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
1615 }
1616
1617 export const sdk = new Medusa({
1618 baseUrl: MEDUSA_BACKEND_URL,
1619 debug: process.env.NODE_ENV === "development",
1620 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
1621 })
1622
1623 sdk.store.cart.create({
1624 region_id: "reg_123"
1625 })
1626 .then(({ cart }) => {
1627 console.log(cart)
1628 })
1629 - lang: Shell
1630 label: cURL
1631 source: |-
1632 curl -X POST '{backend_url}/store/carts' \
1633 -H 'Content-Type: application/json' \
1634 -H 'x-publishable-api-key: {your_publishable_api_key}' \
1635 --data-raw '{
1636 "region_id": "reg_123"
1637 }'
1638 tags:
1639 - Carts
1640 responses:
1641 '200':
1642 description: OK
1643 content:
1644 application/json:
1645 schema:
1646 $ref: '#/components/schemas/StoreCartResponse'
1647 '400':
1648 $ref: '#/components/responses/400_error'
1649 '401':
1650 $ref: '#/components/responses/unauthorized'
1651 '404':
1652 $ref: '#/components/responses/not_found_error'
1653 '409':
1654 $ref: '#/components/responses/invalid_state_error'
1655 '422':
1656 $ref: '#/components/responses/invalid_request_error'
1657 '500':
1658 $ref: '#/components/responses/500_error'
1659 x-workflow: createCartWorkflow
1660 x-events:
1661 - name: cart.created
1662 payload: |-
1663 ```ts
1664 {
1665 id, // The ID of the cart
1666 }
1667 ```
1668 description: Emitted when a cart is created.
1669 deprecated: false
1670 x-allowed:
1671 - id
1672 - currency_code
1673 - email
1674 - locale
1675 - region_id
1676 - created_at
1677 - updated_at
1678 - completed_at
1679 - total
1680 - subtotal
1681 - tax_total
1682 - discount_total
1683 - discount_subtotal
1684 - discount_tax_total
1685 - original_total
1686 - original_tax_total
1687 - item_total
1688 - item_subtotal
1689 - item_tax_total
1690 - item_discount_total
1691 - original_item_total
1692 - original_item_subtotal
1693 - original_item_tax_total
1694 - shipping_total
1695 - shipping_subtotal
1696 - shipping_tax_total
1697 - shipping_discount_total
1698 - original_shipping_tax_total
1699 - original_shipping_subtotal
1700 - original_shipping_total
1701 - credit_line_subtotal
1702 - credit_line_tax_total
1703 - credit_line_total
1704 - metadata
1705 - sales_channel_id
1706 - promotions.id
1707 - promotions.code
1708 - promotions.is_automatic
1709 - promotions.is_tax_inclusive
1710 - promotions.application_method.value
1711 - promotions.application_method.type
1712 - promotions.application_method.currency_code
1713 - items.id
1714 - items.thumbnail
1715 - items.product
1716 - items.product.id
1717 - items.variant
1718 - items.variant_id
1719 - items.product_id
1720 - items.is_giftcard
1721 - items.product.categories.id
1722 - items.product.tags.id
1723 - items.product.collection_id
1724 - items.product.type_id
1725 - items.product_type_id
1726 - items.product_title
1727 - items.product_description
1728 - items.product_subtitle
1729 - items.product_type
1730 - items.product_collection
1731 - items.product_handle
1732 - items.variant_sku
1733 - items.variant_barcode
1734 - items.variant_title
1735 - items.requires_shipping
1736 - items.metadata
1737 - items.created_at
1738 - items.updated_at
1739 - items.title
1740 - items.quantity
1741 - items.unit_price
1742 - items.compare_at_unit_price
1743 - items.is_tax_inclusive
1744 - items.tax_lines.id
1745 - items.tax_lines.description
1746 - items.tax_lines.code
1747 - items.tax_lines.rate
1748 - items.tax_lines.provider_id
1749 - items.tax_lines.data
1750 - items.tax_lines.metadata
1751 - items.adjustments.id
1752 - items.adjustments.code
1753 - items.adjustments.promotion_id
1754 - items.adjustments.amount
1755 - items.adjustments.is_tax_inclusive
1756 - customer.id
1757 - customer.email
1758 - customer.groups.id
1759 - shipping_methods.tax_lines.id
1760 - shipping_methods.tax_lines.description
1761 - shipping_methods.tax_lines.code
1762 - shipping_methods.tax_lines.rate
1763 - shipping_methods.tax_lines.provider_id
1764 - shipping_methods.tax_lines.data
1765 - shipping_methods.tax_lines.metadata
1766 - shipping_methods.amount
1767 - shipping_methods.is_tax_inclusive
1768 - shipping_methods.adjustments.id
1769 - shipping_methods.adjustments.code
1770 - shipping_methods.adjustments.amount
1771 - shipping_methods.shipping_option_id
1772 - shipping_address_id
1773 - shipping_address.id
1774 - shipping_address.first_name
1775 - shipping_address.last_name
1776 - shipping_address.company
1777 - shipping_address.address_1
1778 - shipping_address.address_2
1779 - shipping_address.city
1780 - shipping_address.postal_code
1781 - shipping_address.country_code
1782 - shipping_address.region_code
1783 - shipping_address.province
1784 - shipping_address.phone
1785 - billing_address_id
1786 - billing_address.id
1787 - billing_address.first_name
1788 - billing_address.last_name
1789 - billing_address.company
1790 - billing_address.address_1
1791 - billing_address.address_2
1792 - billing_address.city
1793 - billing_address.postal_code
1794 - billing_address.country_code
1795 - billing_address.region_code
1796 - billing_address.province
1797 - billing_address.phone
1798 - region.id
1799 - region.name
1800 - region.currency_code
1801 - region.automatic_taxes
1802 - region.countries
1803 - payment_collection
1804 - payment_collection.payment_sessions
1805 - credit_lines
1806 - items
1807 - region
1808 - promotions
1809 - customer
1810 - shipping_methods
1811 - shipping_address
1812 - billing_address
1813 - items.total
1814 - items.subtotal
1815 - items.tax_total
1816 - items.discount_total
1817 - items.discount_tax_total
1818 - items.original_total
1819 - items.original_subtotal
1820 - items.original_tax_total
1821 - items.item_total
1822 - items.item_subtotal
1823 - items.item_tax_total
1824 - shipping_methods.name
1825 - payment_collection.payment_sessions.data
1826 - original_subtotal
1827 - gift_card_total
1828 - gift_card_tax_total
1829 - items.cart_id
1830 - items.is_discountable
1831 - items.tax_lines
1832 - items.tax_lines.item_id
1833 - items.tax_lines.total
1834 - items.tax_lines.subtotal
1835 - items.tax_lines.tax_rate_id
1836 - items.tax_lines.created_at
1837 - items.tax_lines.updated_at
1838 - items.adjustments
1839 - items.adjustments.cart_id
1840 - items.adjustments.item_id
1841 - items.adjustments.description
1842 - items.adjustments.provider_id
1843 - items.adjustments.created_at
1844 - items.adjustments.updated_at
1845 - shipping_methods.id
1846 - shipping_methods.cart_id
1847 - shipping_methods.description
1848 - shipping_methods.data
1849 - shipping_methods.metadata
1850 - shipping_methods.original_total
1851 - shipping_methods.original_subtotal
1852 - shipping_methods.original_tax_total
1853 - shipping_methods.total
1854 - shipping_methods.subtotal
1855 - shipping_methods.tax_total
1856 - shipping_methods.discount_total
1857 - shipping_methods.discount_tax_total
1858 - shipping_methods.created_at
1859 - shipping_methods.updated_at
1860 - shipping_methods.tax_lines
1861 - shipping_methods.tax_lines.shipping_method_id
1862 - shipping_methods.tax_lines.total
1863 - shipping_methods.tax_lines.subtotal
1864 - shipping_methods.tax_lines.tax_rate_id
1865 - shipping_methods.tax_lines.created_at
1866 - shipping_methods.tax_lines.updated_at
1867 - shipping_methods.adjustments
1868 - shipping_methods.adjustments.cart_id
1869 - shipping_methods.adjustments.shipping_method_id
1870 - shipping_methods.adjustments.description
1871 - shipping_methods.adjustments.provider_id
1872 - shipping_methods.adjustments.promotion_id
1873 - shipping_methods.adjustments.created_at
1874 - shipping_methods.adjustments.updated_at
1875 - shipping_address.created_at
1876 - shipping_address.updated_at
1877 - billing_address.created_at
1878 - billing_address.updated_at
1879 - region.countries.id
1880 - payment_collection.id
1881 - payment_collection.currency_code
1882 - payment_collection.amount
1883 - payment_collection.status
1884 - payment_collection.payment_providers
1885 - payment_collection.payment_providers.id
1886 - payment_collection.payment_sessions.id
1887 - payment_collection.payment_sessions.amount
1888 - payment_collection.payment_sessions.currency_code
1889 - payment_collection.payment_sessions.provider_id
1890 - payment_collection.payment_sessions.status
1891 /store/carts/{id}:
1892 get:
1893 operationId: GetCartsId
1894 summary: Get a Cart
1895 description: Retrieve a cart by its ID. You can expand the cart's relations or select the fields that should be returned.
1896 x-authenticated: false
1897 parameters:
1898 - name: id
1899 in: path
1900 description: The cart's ID.
1901 required: true
1902 schema:
1903 type: string
1904 - name: x-publishable-api-key
1905 in: header
1906 description: Publishable API Key created in the Medusa Admin.
1907 required: true
1908 schema:
1909 type: string
1910 externalDocs:
1911 url: https://docs.medusajs.com/api/store#publishable-api-key
1912 - name: x-medusa-locale
1913 in: header
1914 description: The locale in BCP 47 format to retrieve localized content.
1915 required: false
1916 schema:
1917 type: string
1918 example: en-US
1919 externalDocs:
1920 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
1921 description: Learn more in the Serve Translations in Storefront guide.
1922 - name: fields
1923 in: query
1924 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
1925 required: false
1926 schema:
1927 type: string
1928 title: fields
1929 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
1930 externalDocs:
1931 url: '#select-fields-and-relations'
1932 - name: locale
1933 in: query
1934 description: The locale in BCP 47 format to retrieve localized content.
1935 required: false
1936 schema:
1937 type: string
1938 example: en-US
1939 externalDocs:
1940 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
1941 description: Learn more in the Serve Translations in Storefront guide.
1942 x-codeSamples:
1943 - lang: JavaScript
1944 label: JS SDK
1945 source: |-
1946 import Medusa from "@medusajs/js-sdk"
1947
1948 let MEDUSA_BACKEND_URL = "http://localhost:9000"
1949
1950 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
1951 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
1952 }
1953
1954 export const sdk = new Medusa({
1955 baseUrl: MEDUSA_BACKEND_URL,
1956 debug: process.env.NODE_ENV === "development",
1957 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
1958 })
1959
1960 sdk.store.cart.retrieve("cart_123")
1961 .then(({ cart }) => {
1962 console.log(cart)
1963 })
1964 - lang: Shell
1965 label: cURL
1966 source: |-
1967 curl '{backend_url}/store/carts/{id}' \
1968 -H 'x-publishable-api-key: {your_publishable_api_key}'
1969 tags:
1970 - Carts
1971 responses:
1972 '200':
1973 description: OK
1974 content:
1975 application/json:
1976 schema:
1977 $ref: '#/components/schemas/StoreCartResponse'
1978 '400':
1979 $ref: '#/components/responses/400_error'
1980 '401':
1981 $ref: '#/components/responses/unauthorized'
1982 '404':
1983 $ref: '#/components/responses/not_found_error'
1984 '409':
1985 $ref: '#/components/responses/invalid_state_error'
1986 '422':
1987 $ref: '#/components/responses/invalid_request_error'
1988 '500':
1989 $ref: '#/components/responses/500_error'
1990 x-allowed:
1991 - id
1992 - currency_code
1993 - email
1994 - locale
1995 - region_id
1996 - created_at
1997 - updated_at
1998 - completed_at
1999 - total
2000 - subtotal
2001 - tax_total
2002 - discount_total
2003 - discount_subtotal
2004 - discount_tax_total
2005 - original_total
2006 - original_tax_total
2007 - item_total
2008 - item_subtotal
2009 - item_tax_total
2010 - item_discount_total
2011 - original_item_total
2012 - original_item_subtotal
2013 - original_item_tax_total
2014 - shipping_total
2015 - shipping_subtotal
2016 - shipping_tax_total
2017 - shipping_discount_total
2018 - original_shipping_tax_total
2019 - original_shipping_subtotal
2020 - original_shipping_total
2021 - credit_line_subtotal
2022 - credit_line_tax_total
2023 - credit_line_total
2024 - metadata
2025 - sales_channel_id
2026 - promotions.id
2027 - promotions.code
2028 - promotions.is_automatic
2029 - promotions.is_tax_inclusive
2030 - promotions.application_method.value
2031 - promotions.application_method.type
2032 - promotions.application_method.currency_code
2033 - items.id
2034 - items.thumbnail
2035 - items.product
2036 - items.product.id
2037 - items.variant
2038 - items.variant_id
2039 - items.product_id
2040 - items.is_giftcard
2041 - items.product.categories.id
2042 - items.product.tags.id
2043 - items.product.collection_id
2044 - items.product.type_id
2045 - items.product_type_id
2046 - items.product_title
2047 - items.product_description
2048 - items.product_subtitle
2049 - items.product_type
2050 - items.product_collection
2051 - items.product_handle
2052 - items.variant_sku
2053 - items.variant_barcode
2054 - items.variant_title
2055 - items.requires_shipping
2056 - items.metadata
2057 - items.created_at
2058 - items.updated_at
2059 - items.title
2060 - items.quantity
2061 - items.unit_price
2062 - items.compare_at_unit_price
2063 - items.is_tax_inclusive
2064 - items.tax_lines.id
2065 - items.tax_lines.description
2066 - items.tax_lines.code
2067 - items.tax_lines.rate
2068 - items.tax_lines.provider_id
2069 - items.tax_lines.data
2070 - items.tax_lines.metadata
2071 - items.adjustments.id
2072 - items.adjustments.code
2073 - items.adjustments.promotion_id
2074 - items.adjustments.amount
2075 - items.adjustments.is_tax_inclusive
2076 - customer.id
2077 - customer.email
2078 - customer.groups.id
2079 - shipping_methods.tax_lines.id
2080 - shipping_methods.tax_lines.description
2081 - shipping_methods.tax_lines.code
2082 - shipping_methods.tax_lines.rate
2083 - shipping_methods.tax_lines.provider_id
2084 - shipping_methods.tax_lines.data
2085 - shipping_methods.tax_lines.metadata
2086 - shipping_methods.amount
2087 - shipping_methods.is_tax_inclusive
2088 - shipping_methods.adjustments.id
2089 - shipping_methods.adjustments.code
2090 - shipping_methods.adjustments.amount
2091 - shipping_methods.shipping_option_id
2092 - shipping_address_id
2093 - shipping_address.id
2094 - shipping_address.first_name
2095 - shipping_address.last_name
2096 - shipping_address.company
2097 - shipping_address.address_1
2098 - shipping_address.address_2
2099 - shipping_address.city
2100 - shipping_address.postal_code
2101 - shipping_address.country_code
2102 - shipping_address.region_code
2103 - shipping_address.province
2104 - shipping_address.phone
2105 - billing_address_id
2106 - billing_address.id
2107 - billing_address.first_name
2108 - billing_address.last_name
2109 - billing_address.company
2110 - billing_address.address_1
2111 - billing_address.address_2
2112 - billing_address.city
2113 - billing_address.postal_code
2114 - billing_address.country_code
2115 - billing_address.region_code
2116 - billing_address.province
2117 - billing_address.phone
2118 - region.id
2119 - region.name
2120 - region.currency_code
2121 - region.automatic_taxes
2122 - region.countries
2123 - payment_collection
2124 - payment_collection.payment_sessions
2125 - credit_lines
2126 - items
2127 - region
2128 - promotions
2129 - customer
2130 - shipping_methods
2131 - shipping_address
2132 - billing_address
2133 - items.total
2134 - items.subtotal
2135 - items.tax_total
2136 - items.discount_total
2137 - items.discount_tax_total
2138 - items.original_total
2139 - items.original_subtotal
2140 - items.original_tax_total
2141 - items.item_total
2142 - items.item_subtotal
2143 - items.item_tax_total
2144 - shipping_methods.name
2145 - payment_collection.payment_sessions.data
2146 - original_subtotal
2147 - gift_card_total
2148 - gift_card_tax_total
2149 - items.cart_id
2150 - items.is_discountable
2151 - items.tax_lines
2152 - items.tax_lines.item_id
2153 - items.tax_lines.total
2154 - items.tax_lines.subtotal
2155 - items.tax_lines.tax_rate_id
2156 - items.tax_lines.created_at
2157 - items.tax_lines.updated_at
2158 - items.adjustments
2159 - items.adjustments.cart_id
2160 - items.adjustments.item_id
2161 - items.adjustments.description
2162 - items.adjustments.provider_id
2163 - items.adjustments.created_at
2164 - items.adjustments.updated_at
2165 - shipping_methods.id
2166 - shipping_methods.cart_id
2167 - shipping_methods.description
2168 - shipping_methods.data
2169 - shipping_methods.metadata
2170 - shipping_methods.original_total
2171 - shipping_methods.original_subtotal
2172 - shipping_methods.original_tax_total
2173 - shipping_methods.total
2174 - shipping_methods.subtotal
2175 - shipping_methods.tax_total
2176 - shipping_methods.discount_total
2177 - shipping_methods.discount_tax_total
2178 - shipping_methods.created_at
2179 - shipping_methods.updated_at
2180 - shipping_methods.tax_lines
2181 - shipping_methods.tax_lines.shipping_method_id
2182 - shipping_methods.tax_lines.total
2183 - shipping_methods.tax_lines.subtotal
2184 - shipping_methods.tax_lines.tax_rate_id
2185 - shipping_methods.tax_lines.created_at
2186 - shipping_methods.tax_lines.updated_at
2187 - shipping_methods.adjustments
2188 - shipping_methods.adjustments.cart_id
2189 - shipping_methods.adjustments.shipping_method_id
2190 - shipping_methods.adjustments.description
2191 - shipping_methods.adjustments.provider_id
2192 - shipping_methods.adjustments.promotion_id
2193 - shipping_methods.adjustments.created_at
2194 - shipping_methods.adjustments.updated_at
2195 - shipping_address.created_at
2196 - shipping_address.updated_at
2197 - billing_address.created_at
2198 - billing_address.updated_at
2199 - region.countries.id
2200 - payment_collection.id
2201 - payment_collection.currency_code
2202 - payment_collection.amount
2203 - payment_collection.status
2204 - payment_collection.payment_providers
2205 - payment_collection.payment_providers.id
2206 - payment_collection.payment_sessions.id
2207 - payment_collection.payment_sessions.amount
2208 - payment_collection.payment_sessions.currency_code
2209 - payment_collection.payment_sessions.provider_id
2210 - payment_collection.payment_sessions.status
2211 post:
2212 operationId: PostCartsId
2213 summary: Update a Cart
2214 description: Update a cart's details. This unsets the payment methods chosen before, and the customer would have to choose them again. Also, if the customer has chosen a shipping method whose option isn't valid for the cart's shipping address anymore, the shipping method will be unset. For example, if the shipping option is valid only in the US geo zone, and the shipping address's country code is `DE`, the shipping method will be unset.
2215 x-authenticated: false
2216 parameters:
2217 - name: id
2218 in: path
2219 description: The cart's ID.
2220 required: true
2221 schema:
2222 type: string
2223 - name: x-publishable-api-key
2224 in: header
2225 description: Publishable API Key created in the Medusa Admin.
2226 required: true
2227 schema:
2228 type: string
2229 externalDocs:
2230 url: https://docs.medusajs.com/api/store#publishable-api-key
2231 - name: x-medusa-locale
2232 in: header
2233 description: The locale in BCP 47 format to retrieve localized content.
2234 required: false
2235 schema:
2236 type: string
2237 example: en-US
2238 externalDocs:
2239 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
2240 description: Learn more in the Serve Translations in Storefront guide.
2241 - name: fields
2242 in: query
2243 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
2244 required: false
2245 schema:
2246 type: string
2247 title: fields
2248 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
2249 externalDocs:
2250 url: '#select-fields-and-relations'
2251 - name: locale
2252 in: query
2253 description: The locale in BCP 47 format to retrieve localized content.
2254 required: false
2255 schema:
2256 type: string
2257 example: en-US
2258 externalDocs:
2259 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
2260 description: Learn more in the Serve Translations in Storefront guide.
2261 requestBody:
2262 content:
2263 application/json:
2264 schema:
2265 allOf:
2266 - $ref: '#/components/schemas/UpdateCartData'
2267 - type: object
2268 description: The properties to update in the cart item.
2269 properties:
2270 additional_data:
2271 type: object
2272 description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
2273 description: The properties to update in the cart item.
2274 x-codeSamples:
2275 - lang: JavaScript
2276 label: JS SDK
2277 source: |-
2278 import Medusa from "@medusajs/js-sdk"
2279
2280 let MEDUSA_BACKEND_URL = "http://localhost:9000"
2281
2282 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
2283 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
2284 }
2285
2286 export const sdk = new Medusa({
2287 baseUrl: MEDUSA_BACKEND_URL,
2288 debug: process.env.NODE_ENV === "development",
2289 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
2290 })
2291
2292 sdk.store.cart.update("cart_123", {
2293 region_id: "reg_123"
2294 })
2295 .then(({ cart }) => {
2296 console.log(cart)
2297 })
2298 - lang: Shell
2299 label: cURL
2300 source: |-
2301 curl -X POST '{backend_url}/store/carts/{id}' \
2302 -H 'x-publishable-api-key: {your_publishable_api_key}'
2303 tags:
2304 - Carts
2305 responses:
2306 '200':
2307 description: OK
2308 content:
2309 application/json:
2310 schema:
2311 type: object
2312 description: The updated cart's details.
2313 required:
2314 - cart
2315 properties:
2316 cart:
2317 $ref: '#/components/schemas/StoreCart'
2318 '400':
2319 $ref: '#/components/responses/400_error'
2320 '401':
2321 $ref: '#/components/responses/unauthorized'
2322 '404':
2323 $ref: '#/components/responses/not_found_error'
2324 '409':
2325 $ref: '#/components/responses/invalid_state_error'
2326 '422':
2327 $ref: '#/components/responses/invalid_request_error'
2328 '500':
2329 $ref: '#/components/responses/500_error'
2330 x-workflow: updateCartWorkflow
2331 x-events:
2332 - name: cart.updated
2333 payload: |-
2334 ```ts
2335 {
2336 id, // The ID of the cart
2337 }
2338 ```
2339 description: Emitted when a cart's details are updated.
2340 deprecated: false
2341 - name: cart.region_updated
2342 payload: |-
2343 ```ts
2344 {
2345 id, // The ID of the cart
2346 }
2347 ```
2348 description: |-
2349 Emitted when the cart's region is updated. This
2350 event is emitted alongside the `cart.updated` event.
2351 deprecated: false
2352 x-allowed:
2353 - id
2354 - currency_code
2355 - email
2356 - locale
2357 - region_id
2358 - created_at
2359 - updated_at
2360 - completed_at
2361 - total
2362 - subtotal
2363 - tax_total
2364 - discount_total
2365 - discount_subtotal
2366 - discount_tax_total
2367 - original_total
2368 - original_tax_total
2369 - item_total
2370 - item_subtotal
2371 - item_tax_total
2372 - item_discount_total
2373 - original_item_total
2374 - original_item_subtotal
2375 - original_item_tax_total
2376 - shipping_total
2377 - shipping_subtotal
2378 - shipping_tax_total
2379 - shipping_discount_total
2380 - original_shipping_tax_total
2381 - original_shipping_subtotal
2382 - original_shipping_total
2383 - credit_line_subtotal
2384 - credit_line_tax_total
2385 - credit_line_total
2386 - metadata
2387 - sales_channel_id
2388 - promotions.id
2389 - promotions.code
2390 - promotions.is_automatic
2391 - promotions.is_tax_inclusive
2392 - promotions.application_method.value
2393 - promotions.application_method.type
2394 - promotions.application_method.currency_code
2395 - items.id
2396 - items.thumbnail
2397 - items.product
2398 - items.product.id
2399 - items.variant
2400 - items.variant_id
2401 - items.product_id
2402 - items.is_giftcard
2403 - items.product.categories.id
2404 - items.product.tags.id
2405 - items.product.collection_id
2406 - items.product.type_id
2407 - items.product_type_id
2408 - items.product_title
2409 - items.product_description
2410 - items.product_subtitle
2411 - items.product_type
2412 - items.product_collection
2413 - items.product_handle
2414 - items.variant_sku
2415 - items.variant_barcode
2416 - items.variant_title
2417 - items.requires_shipping
2418 - items.metadata
2419 - items.created_at
2420 - items.updated_at
2421 - items.title
2422 - items.quantity
2423 - items.unit_price
2424 - items.compare_at_unit_price
2425 - items.is_tax_inclusive
2426 - items.tax_lines.id
2427 - items.tax_lines.description
2428 - items.tax_lines.code
2429 - items.tax_lines.rate
2430 - items.tax_lines.provider_id
2431 - items.tax_lines.data
2432 - items.tax_lines.metadata
2433 - items.adjustments.id
2434 - items.adjustments.code
2435 - items.adjustments.promotion_id
2436 - items.adjustments.amount
2437 - items.adjustments.is_tax_inclusive
2438 - customer.id
2439 - customer.email
2440 - customer.groups.id
2441 - shipping_methods.tax_lines.id
2442 - shipping_methods.tax_lines.description
2443 - shipping_methods.tax_lines.code
2444 - shipping_methods.tax_lines.rate
2445 - shipping_methods.tax_lines.provider_id
2446 - shipping_methods.tax_lines.data
2447 - shipping_methods.tax_lines.metadata
2448 - shipping_methods.amount
2449 - shipping_methods.is_tax_inclusive
2450 - shipping_methods.adjustments.id
2451 - shipping_methods.adjustments.code
2452 - shipping_methods.adjustments.amount
2453 - shipping_methods.shipping_option_id
2454 - shipping_address_id
2455 - shipping_address.id
2456 - shipping_address.first_name
2457 - shipping_address.last_name
2458 - shipping_address.company
2459 - shipping_address.address_1
2460 - shipping_address.address_2
2461 - shipping_address.city
2462 - shipping_address.postal_code
2463 - shipping_address.country_code
2464 - shipping_address.region_code
2465 - shipping_address.province
2466 - shipping_address.phone
2467 - billing_address_id
2468 - billing_address.id
2469 - billing_address.first_name
2470 - billing_address.last_name
2471 - billing_address.company
2472 - billing_address.address_1
2473 - billing_address.address_2
2474 - billing_address.city
2475 - billing_address.postal_code
2476 - billing_address.country_code
2477 - billing_address.region_code
2478 - billing_address.province
2479 - billing_address.phone
2480 - region.id
2481 - region.name
2482 - region.currency_code
2483 - region.automatic_taxes
2484 - region.countries
2485 - payment_collection
2486 - payment_collection.payment_sessions
2487 - credit_lines
2488 - items
2489 - region
2490 - promotions
2491 - customer
2492 - shipping_methods
2493 - shipping_address
2494 - billing_address
2495 - items.total
2496 - items.subtotal
2497 - items.tax_total
2498 - items.discount_total
2499 - items.discount_tax_total
2500 - items.original_total
2501 - items.original_subtotal
2502 - items.original_tax_total
2503 - items.item_total
2504 - items.item_subtotal
2505 - items.item_tax_total
2506 - shipping_methods.name
2507 - payment_collection.payment_sessions.data
2508 - original_subtotal
2509 - gift_card_total
2510 - gift_card_tax_total
2511 - items.cart_id
2512 - items.is_discountable
2513 - items.tax_lines
2514 - items.tax_lines.item_id
2515 - items.tax_lines.total
2516 - items.tax_lines.subtotal
2517 - items.tax_lines.tax_rate_id
2518 - items.tax_lines.created_at
2519 - items.tax_lines.updated_at
2520 - items.adjustments
2521 - items.adjustments.cart_id
2522 - items.adjustments.item_id
2523 - items.adjustments.description
2524 - items.adjustments.provider_id
2525 - items.adjustments.created_at
2526 - items.adjustments.updated_at
2527 - shipping_methods.id
2528 - shipping_methods.cart_id
2529 - shipping_methods.description
2530 - shipping_methods.data
2531 - shipping_methods.metadata
2532 - shipping_methods.original_total
2533 - shipping_methods.original_subtotal
2534 - shipping_methods.original_tax_total
2535 - shipping_methods.total
2536 - shipping_methods.subtotal
2537 - shipping_methods.tax_total
2538 - shipping_methods.discount_total
2539 - shipping_methods.discount_tax_total
2540 - shipping_methods.created_at
2541 - shipping_methods.updated_at
2542 - shipping_methods.tax_lines
2543 - shipping_methods.tax_lines.shipping_method_id
2544 - shipping_methods.tax_lines.total
2545 - shipping_methods.tax_lines.subtotal
2546 - shipping_methods.tax_lines.tax_rate_id
2547 - shipping_methods.tax_lines.created_at
2548 - shipping_methods.tax_lines.updated_at
2549 - shipping_methods.adjustments
2550 - shipping_methods.adjustments.cart_id
2551 - shipping_methods.adjustments.shipping_method_id
2552 - shipping_methods.adjustments.description
2553 - shipping_methods.adjustments.provider_id
2554 - shipping_methods.adjustments.promotion_id
2555 - shipping_methods.adjustments.created_at
2556 - shipping_methods.adjustments.updated_at
2557 - shipping_address.created_at
2558 - shipping_address.updated_at
2559 - billing_address.created_at
2560 - billing_address.updated_at
2561 - region.countries.id
2562 - payment_collection.id
2563 - payment_collection.currency_code
2564 - payment_collection.amount
2565 - payment_collection.status
2566 - payment_collection.payment_providers
2567 - payment_collection.payment_providers.id
2568 - payment_collection.payment_sessions.id
2569 - payment_collection.payment_sessions.amount
2570 - payment_collection.payment_sessions.currency_code
2571 - payment_collection.payment_sessions.provider_id
2572 - payment_collection.payment_sessions.status
2573 /store/carts/{id}/complete:
2574 post:
2575 operationId: PostCartsIdComplete
2576 summary: Complete Cart
2577 description: Complete a cart and place an order.
2578 x-authenticated: false
2579 externalDocs:
2580 url: https://docs.medusajs.com/resources/storefront-development/checkout/complete-cart
2581 description: 'Storefront guide: How to implement cart completion during checkout.'
2582 parameters:
2583 - name: id
2584 in: path
2585 description: The cart's ID.
2586 required: true
2587 schema:
2588 type: string
2589 - name: x-publishable-api-key
2590 in: header
2591 description: Publishable API Key created in the Medusa Admin.
2592 required: true
2593 schema:
2594 type: string
2595 externalDocs:
2596 url: https://docs.medusajs.com/api/store#publishable-api-key
2597 - name: x-medusa-locale
2598 in: header
2599 description: The locale in BCP 47 format to retrieve localized content.
2600 required: false
2601 schema:
2602 type: string
2603 example: en-US
2604 externalDocs:
2605 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
2606 description: Learn more in the Serve Translations in Storefront guide.
2607 - name: fields
2608 in: query
2609 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
2610 required: false
2611 schema:
2612 type: string
2613 title: fields
2614 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
2615 externalDocs:
2616 url: '#select-fields-and-relations'
2617 - name: locale
2618 in: query
2619 description: The locale in BCP 47 format to retrieve localized content.
2620 required: false
2621 schema:
2622 type: string
2623 example: en-US
2624 externalDocs:
2625 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
2626 description: Learn more in the Serve Translations in Storefront guide.
2627 x-codeSamples:
2628 - lang: JavaScript
2629 label: JS SDK
2630 source: |-
2631 import Medusa from "@medusajs/js-sdk"
2632
2633 let MEDUSA_BACKEND_URL = "http://localhost:9000"
2634
2635 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
2636 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
2637 }
2638
2639 export const sdk = new Medusa({
2640 baseUrl: MEDUSA_BACKEND_URL,
2641 debug: process.env.NODE_ENV === "development",
2642 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
2643 })
2644
2645 sdk.store.cart.complete("cart_123")
2646 .then((data) => {
2647 if(data.type === "cart") {
2648 // an error occurred
2649 console.log(data.error, data.cart)
2650 } else {
2651 // order placed successfully
2652 console.log(data.order)
2653 }
2654 })
2655 - lang: Shell
2656 label: cURL
2657 source: |-
2658 curl -X POST '{backend_url}/store/carts/{id}/complete' \
2659 -H 'x-publishable-api-key: {your_publishable_api_key}'
2660 tags:
2661 - Carts
2662 responses:
2663 '200':
2664 description: OK
2665 content:
2666 application/json:
2667 schema:
2668 oneOf:
2669 - type: object
2670 description: The created order's details.
2671 required:
2672 - type
2673 - order
2674 properties:
2675 type:
2676 type: string
2677 title: type
2678 description: The type of the returned object. In this case, the order is returned because the cart was completed successfully.
2679 default: order
2680 order:
2681 $ref: '#/components/schemas/StoreOrder'
2682 - type: object
2683 description: The details of why the cart completion failed.
2684 required:
2685 - type
2686 - cart
2687 - error
2688 properties:
2689 type:
2690 type: string
2691 title: type
2692 description: The type of the returned object. In this case, the cart is returned because an error has occurred.
2693 default: cart
2694 cart:
2695 $ref: '#/components/schemas/StoreCart'
2696 error:
2697 type: object
2698 description: The error's details.
2699 required:
2700 - message
2701 - name
2702 - type
2703 properties:
2704 message:
2705 type: string
2706 title: message
2707 description: The error's message.
2708 name:
2709 type: string
2710 title: name
2711 description: The error's name.
2712 type:
2713 type: string
2714 title: type
2715 description: |
2716 The error's type. Can be a [MedusaError type](https://docs.medusajs.com/learn/fundamentals/api-routes/errors#medusaerror-types) or `payment_authorization_error` or `payment_requires_more_error` for payment-related errors.
2717 '400':
2718 $ref: '#/components/responses/400_error'
2719 '401':
2720 $ref: '#/components/responses/unauthorized'
2721 '404':
2722 $ref: '#/components/responses/not_found_error'
2723 '409':
2724 $ref: '#/components/responses/invalid_state_error'
2725 '422':
2726 $ref: '#/components/responses/invalid_request_error'
2727 '500':
2728 $ref: '#/components/responses/500_error'
2729 x-workflow: completeCartWorkflow
2730 x-events:
2731 - name: order.placed
2732 payload: |-
2733 ```ts
2734 {
2735 id, // The ID of the order
2736 }
2737 ```
2738 description: |-
2739 Emitted when an order is placed, or when a draft order is converted to an
2740 order.
2741 deprecated: false
2742 - name: reservation-item.created
2743 payload: |-
2744 ```ts
2745 {
2746 id, // The ID of the reservation
2747 order_id, // (optional) The ID of the order, if the reservation was created by an order flow
2748 }
2749 ```
2750 description: Emitted when reservations are created.
2751 deprecated: false
2752 since: 2.18.0
2753 x-allowed:
2754 - id
2755 - status
2756 - summary
2757 - currency_code
2758 - display_id
2759 - custom_display_id
2760 - region_id
2761 - email
2762 - total
2763 - subtotal
2764 - tax_total
2765 - discount_total
2766 - discount_subtotal
2767 - discount_tax_total
2768 - original_total
2769 - original_subtotal
2770 - original_tax_total
2771 - item_total
2772 - item_subtotal
2773 - item_tax_total
2774 - original_item_total
2775 - original_item_subtotal
2776 - original_item_tax_total
2777 - shipping_total
2778 - shipping_subtotal
2779 - shipping_tax_total
2780 - original_shipping_tax_total
2781 - original_shipping_subtotal
2782 - original_shipping_total
2783 - credit_line_total
2784 - credit_line_subtotal
2785 - credit_line_tax_total
2786 - created_at
2787 - updated_at
2788 - credit_lines
2789 - items
2790 - items.tax_lines
2791 - items.adjustments
2792 - items.detail
2793 - items.variant
2794 - items.variant.product
2795 - shipping_address
2796 - billing_address
2797 - shipping_methods
2798 - shipping_methods.tax_lines
2799 - shipping_methods.adjustments
2800 - payment_collections
2801 - customer_id
2802 - sales_channel_id
2803 - payment_status
2804 - fulfillment_status
2805 - item_discount_total
2806 - gift_card_total
2807 - gift_card_tax_total
2808 - shipping_discount_total
2809 - customer.id
2810 - customer.email
2811 - cart.id
2812 - items.metadata
2813 - items.product
2814 - payment_collections.payments
2815 - payment_collections.payment_sessions
2816 - payment_collections.payment_providers
2817 - fulfillments
2818 - promotions
2819 - promotions.id
2820 - promotions.code
2821 - promotions.is_automatic
2822 - promotions.is_tax_inclusive
2823 - promotions.application_method.value
2824 - promotions.application_method.type
2825 - promotions.application_method.currency_code
2826 - items.id
2827 - items.title
2828 - items.subtitle
2829 - items.thumbnail
2830 - items.variant_id
2831 - items.product_id
2832 - items.product_title
2833 - items.product_description
2834 - items.product_subtitle
2835 - items.product_type_id
2836 - items.product_type
2837 - items.product_collection
2838 - items.product_handle
2839 - items.variant_sku
2840 - items.variant_barcode
2841 - items.variant_title
2842 - items.variant_option_values
2843 - items.requires_shipping
2844 - items.is_discountable
2845 - items.is_tax_inclusive
2846 - items.unit_price
2847 - items.quantity
2848 - items.created_at
2849 - items.updated_at
2850 - items.original_total
2851 - items.original_subtotal
2852 - items.original_tax_total
2853 - items.item_total
2854 - items.item_subtotal
2855 - items.item_tax_total
2856 - items.total
2857 - items.subtotal
2858 - items.tax_total
2859 - items.discount_total
2860 - items.discount_tax_total
2861 - items.refundable_total
2862 - items.refundable_total_per_unit
2863 - items.detail.id
2864 - items.detail.item_id
2865 - items.detail.quantity
2866 - items.detail.fulfilled_quantity
2867 - items.detail.delivered_quantity
2868 - items.detail.shipped_quantity
2869 - items.detail.return_requested_quantity
2870 - items.detail.return_received_quantity
2871 - items.detail.return_dismissed_quantity
2872 - items.detail.written_off_quantity
2873 - items.detail.metadata
2874 - items.detail.created_at
2875 - items.detail.updated_at
2876 - items.tax_lines.id
2877 - items.tax_lines.code
2878 - items.tax_lines.rate
2879 - items.tax_lines.created_at
2880 - items.tax_lines.updated_at
2881 - items.tax_lines.item_id
2882 - items.tax_lines.total
2883 - items.tax_lines.subtotal
2884 - items.adjustments.id
2885 - items.adjustments.amount
2886 - items.adjustments.order_id
2887 - items.adjustments.created_at
2888 - items.adjustments.updated_at
2889 - items.adjustments.item_id
2890 - items.variant.id
2891 - items.variant.title
2892 - items.variant.sku
2893 - items.variant.barcode
2894 - items.variant.ean
2895 - items.variant.upc
2896 - items.variant.thumbnail
2897 - items.variant.allow_backorder
2898 - items.variant.manage_inventory
2899 - items.variant.hs_code
2900 - items.variant.origin_country
2901 - items.variant.mid_code
2902 - items.variant.material
2903 - items.variant.weight
2904 - items.variant.length
2905 - items.variant.height
2906 - items.variant.width
2907 - items.variant.created_at
2908 - items.variant.updated_at
2909 - items.variant.deleted_at
2910 - items.variant.options
2911 - items.variant.product.id
2912 - items.variant.product.title
2913 - items.variant.product.handle
2914 - items.variant.product.subtitle
2915 - items.variant.product.description
2916 - items.variant.product.is_giftcard
2917 - items.variant.product.status
2918 - items.variant.product.thumbnail
2919 - items.variant.product.width
2920 - items.variant.product.weight
2921 - items.variant.product.length
2922 - items.variant.product.height
2923 - items.variant.product.origin_country
2924 - items.variant.product.hs_code
2925 - items.variant.product.mid_code
2926 - items.variant.product.material
2927 - items.variant.product.collection_id
2928 - items.variant.product.type_id
2929 - items.variant.product.discountable
2930 - items.variant.product.external_id
2931 - items.variant.product.created_at
2932 - items.variant.product.updated_at
2933 - items.variant.product.deleted_at
2934 - items.variant.product.variants
2935 - items.variant.product.options
2936 - items.variant.product.images
2937 - shipping_address.id
2938 - shipping_address.metadata
2939 - shipping_address.created_at
2940 - shipping_address.updated_at
2941 - billing_address.id
2942 - billing_address.metadata
2943 - billing_address.created_at
2944 - billing_address.updated_at
2945 - shipping_methods.id
2946 - shipping_methods.order_id
2947 - shipping_methods.name
2948 - shipping_methods.amount
2949 - shipping_methods.is_tax_inclusive
2950 - shipping_methods.shipping_option_id
2951 - shipping_methods.data
2952 - shipping_methods.metadata
2953 - shipping_methods.original_total
2954 - shipping_methods.original_subtotal
2955 - shipping_methods.original_tax_total
2956 - shipping_methods.total
2957 - shipping_methods.subtotal
2958 - shipping_methods.tax_total
2959 - shipping_methods.discount_total
2960 - shipping_methods.discount_tax_total
2961 - shipping_methods.created_at
2962 - shipping_methods.updated_at
2963 - shipping_methods.tax_lines.id
2964 - shipping_methods.tax_lines.code
2965 - shipping_methods.tax_lines.rate
2966 - shipping_methods.tax_lines.created_at
2967 - shipping_methods.tax_lines.updated_at
2968 - shipping_methods.tax_lines.shipping_method_id
2969 - shipping_methods.tax_lines.total
2970 - shipping_methods.tax_lines.subtotal
2971 - shipping_methods.adjustments.id
2972 - shipping_methods.adjustments.amount
2973 - shipping_methods.adjustments.order_id
2974 - shipping_methods.adjustments.created_at
2975 - shipping_methods.adjustments.updated_at
2976 - shipping_methods.adjustments.shipping_method_id
2977 - payment_collections.id
2978 - payment_collections.currency_code
2979 - payment_collections.amount
2980 - payment_collections.status
2981 /store/carts/{id}/customer:
2982 post:
2983 operationId: PostCartsIdCustomer
2984 summary: Change Cart's Customer to Logged-in Customer
2985 x-sidebar-summary: Change Customer
2986 description: Change the cart's customer to the currently logged-in customer. This is useful when you create the cart for a guest customer, then they log in with their account.
2987 externalDocs:
2988 url: https://docs.medusajs.com/resources/storefront-development/cart/update#set-carts-customer
2989 description: 'Storefront guide: How to set the cart''s customer.'
2990 x-authenticated: true
2991 parameters:
2992 - name: id
2993 in: path
2994 description: The cart's ID.
2995 required: true
2996 schema:
2997 type: string
2998 - name: x-publishable-api-key
2999 in: header
3000 description: Publishable API Key created in the Medusa Admin.
3001 required: true
3002 schema:
3003 type: string
3004 externalDocs:
3005 url: https://docs.medusajs.com/api/store#publishable-api-key
3006 - name: x-medusa-locale
3007 in: header
3008 description: The locale in BCP 47 format to retrieve localized content.
3009 required: false
3010 schema:
3011 type: string
3012 example: en-US
3013 externalDocs:
3014 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3015 description: Learn more in the Serve Translations in Storefront guide.
3016 - name: fields
3017 in: query
3018 description: |-
3019 Comma-separated fields that should be included in the returned data.
3020 if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.
3021 without prefix it will replace the entire default fields.
3022 required: false
3023 schema:
3024 type: string
3025 title: fields
3026 description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. Without prefix it will replace the entire default fields.
3027 externalDocs:
3028 url: '#select-fields-and-relations'
3029 - name: locale
3030 in: query
3031 description: The locale in BCP 47 format to retrieve localized content.
3032 required: false
3033 schema:
3034 type: string
3035 example: en-US
3036 externalDocs:
3037 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3038 description: Learn more in the Serve Translations in Storefront guide.
3039 security:
3040 - cookie_auth: []
3041 - jwt_token: []
3042 requestBody:
3043 content:
3044 application/json:
3045 schema:
3046 type: object
3047 description: Optional additional data to pass to the underlying workflow.
3048 properties:
3049 additional_data:
3050 type: object
3051 description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
3052 x-codeSamples:
3053 - lang: JavaScript
3054 label: JS SDK
3055 source: |-
3056 import Medusa from "@medusajs/js-sdk"
3057
3058 let MEDUSA_BACKEND_URL = "http://localhost:9000"
3059
3060 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
3061 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
3062 }
3063
3064 export const sdk = new Medusa({
3065 baseUrl: MEDUSA_BACKEND_URL,
3066 debug: process.env.NODE_ENV === "development",
3067 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
3068 })
3069
3070 // TODO must be authenticated as the customer to set the cart's customer
3071 sdk.store.cart.transferCart("cart_123")
3072 .then(({ cart }) => {
3073 console.log(cart)
3074 })
3075 - lang: Shell
3076 label: cURL
3077 source: |-
3078 curl -X POST '{backend_url}/store/carts/{id}/customer' \
3079 -H 'Authorization: Bearer {jwt_token}' \
3080 -H 'x-publishable-api-key: {your_publishable_api_key}'
3081 tags:
3082 - Carts
3083 responses:
3084 '200':
3085 description: OK
3086 content:
3087 application/json:
3088 schema:
3089 $ref: '#/components/schemas/StoreCartResponse'
3090 '400':
3091 $ref: '#/components/responses/400_error'
3092 '401':
3093 $ref: '#/components/responses/unauthorized'
3094 '404':
3095 $ref: '#/components/responses/not_found_error'
3096 '409':
3097 $ref: '#/components/responses/invalid_state_error'
3098 '422':
3099 $ref: '#/components/responses/invalid_request_error'
3100 '500':
3101 $ref: '#/components/responses/500_error'
3102 x-workflow: transferCartCustomerWorkflow
3103 x-events:
3104 - name: cart.customer_transferred
3105 payload: |-
3106 ```ts
3107 {
3108 id, // The ID of the cart
3109 customer_id, // The ID of the customer
3110 }
3111 ```
3112 description: Emitted when the customer in the cart is transferred.
3113 deprecated: false
3114 since: 2.8.0
3115 x-allowed:
3116 - id
3117 - currency_code
3118 - email
3119 - locale
3120 - region_id
3121 - created_at
3122 - updated_at
3123 - completed_at
3124 - total
3125 - subtotal
3126 - tax_total
3127 - discount_total
3128 - discount_subtotal
3129 - discount_tax_total
3130 - original_total
3131 - original_tax_total
3132 - item_total
3133 - item_subtotal
3134 - item_tax_total
3135 - item_discount_total
3136 - original_item_total
3137 - original_item_subtotal
3138 - original_item_tax_total
3139 - shipping_total
3140 - shipping_subtotal
3141 - shipping_tax_total
3142 - shipping_discount_total
3143 - original_shipping_tax_total
3144 - original_shipping_subtotal
3145 - original_shipping_total
3146 - credit_line_subtotal
3147 - credit_line_tax_total
3148 - credit_line_total
3149 - metadata
3150 - sales_channel_id
3151 - promotions.id
3152 - promotions.code
3153 - promotions.is_automatic
3154 - promotions.is_tax_inclusive
3155 - promotions.application_method.value
3156 - promotions.application_method.type
3157 - promotions.application_method.currency_code
3158 - items.id
3159 - items.thumbnail
3160 - items.product
3161 - items.product.id
3162 - items.variant
3163 - items.variant_id
3164 - items.product_id
3165 - items.is_giftcard
3166 - items.product.categories.id
3167 - items.product.tags.id
3168 - items.product.collection_id
3169 - items.product.type_id
3170 - items.product_type_id
3171 - items.product_title
3172 - items.product_description
3173 - items.product_subtitle
3174 - items.product_type
3175 - items.product_collection
3176 - items.product_handle
3177 - items.variant_sku
3178 - items.variant_barcode
3179 - items.variant_title
3180 - items.requires_shipping
3181 - items.metadata
3182 - items.created_at
3183 - items.updated_at
3184 - items.title
3185 - items.quantity
3186 - items.unit_price
3187 - items.compare_at_unit_price
3188 - items.is_tax_inclusive
3189 - items.tax_lines.id
3190 - items.tax_lines.description
3191 - items.tax_lines.code
3192 - items.tax_lines.rate
3193 - items.tax_lines.provider_id
3194 - items.tax_lines.data
3195 - items.tax_lines.metadata
3196 - items.adjustments.id
3197 - items.adjustments.code
3198 - items.adjustments.promotion_id
3199 - items.adjustments.amount
3200 - items.adjustments.is_tax_inclusive
3201 - customer.id
3202 - customer.email
3203 - customer.groups.id
3204 - shipping_methods.tax_lines.id
3205 - shipping_methods.tax_lines.description
3206 - shipping_methods.tax_lines.code
3207 - shipping_methods.tax_lines.rate
3208 - shipping_methods.tax_lines.provider_id
3209 - shipping_methods.tax_lines.data
3210 - shipping_methods.tax_lines.metadata
3211 - shipping_methods.amount
3212 - shipping_methods.is_tax_inclusive
3213 - shipping_methods.adjustments.id
3214 - shipping_methods.adjustments.code
3215 - shipping_methods.adjustments.amount
3216 - shipping_methods.shipping_option_id
3217 - shipping_address_id
3218 - shipping_address.id
3219 - shipping_address.first_name
3220 - shipping_address.last_name
3221 - shipping_address.company
3222 - shipping_address.address_1
3223 - shipping_address.address_2
3224 - shipping_address.city
3225 - shipping_address.postal_code
3226 - shipping_address.country_code
3227 - shipping_address.region_code
3228 - shipping_address.province
3229 - shipping_address.phone
3230 - billing_address_id
3231 - billing_address.id
3232 - billing_address.first_name
3233 - billing_address.last_name
3234 - billing_address.company
3235 - billing_address.address_1
3236 - billing_address.address_2
3237 - billing_address.city
3238 - billing_address.postal_code
3239 - billing_address.country_code
3240 - billing_address.region_code
3241 - billing_address.province
3242 - billing_address.phone
3243 - region.id
3244 - region.name
3245 - region.currency_code
3246 - region.automatic_taxes
3247 - region.countries
3248 - payment_collection
3249 - payment_collection.payment_sessions
3250 - credit_lines
3251 - items
3252 - region
3253 - promotions
3254 - customer
3255 - shipping_methods
3256 - shipping_address
3257 - billing_address
3258 - items.total
3259 - items.subtotal
3260 - items.tax_total
3261 - items.discount_total
3262 - items.discount_tax_total
3263 - items.original_total
3264 - items.original_subtotal
3265 - items.original_tax_total
3266 - items.item_total
3267 - items.item_subtotal
3268 - items.item_tax_total
3269 - shipping_methods.name
3270 - payment_collection.payment_sessions.data
3271 - original_subtotal
3272 - gift_card_total
3273 - gift_card_tax_total
3274 - items.cart_id
3275 - items.is_discountable
3276 - items.tax_lines
3277 - items.tax_lines.item_id
3278 - items.tax_lines.total
3279 - items.tax_lines.subtotal
3280 - items.tax_lines.tax_rate_id
3281 - items.tax_lines.created_at
3282 - items.tax_lines.updated_at
3283 - items.adjustments
3284 - items.adjustments.cart_id
3285 - items.adjustments.item_id
3286 - items.adjustments.description
3287 - items.adjustments.provider_id
3288 - items.adjustments.created_at
3289 - items.adjustments.updated_at
3290 - shipping_methods.id
3291 - shipping_methods.cart_id
3292 - shipping_methods.description
3293 - shipping_methods.data
3294 - shipping_methods.metadata
3295 - shipping_methods.original_total
3296 - shipping_methods.original_subtotal
3297 - shipping_methods.original_tax_total
3298 - shipping_methods.total
3299 - shipping_methods.subtotal
3300 - shipping_methods.tax_total
3301 - shipping_methods.discount_total
3302 - shipping_methods.discount_tax_total
3303 - shipping_methods.created_at
3304 - shipping_methods.updated_at
3305 - shipping_methods.tax_lines
3306 - shipping_methods.tax_lines.shipping_method_id
3307 - shipping_methods.tax_lines.total
3308 - shipping_methods.tax_lines.subtotal
3309 - shipping_methods.tax_lines.tax_rate_id
3310 - shipping_methods.tax_lines.created_at
3311 - shipping_methods.tax_lines.updated_at
3312 - shipping_methods.adjustments
3313 - shipping_methods.adjustments.cart_id
3314 - shipping_methods.adjustments.shipping_method_id
3315 - shipping_methods.adjustments.description
3316 - shipping_methods.adjustments.provider_id
3317 - shipping_methods.adjustments.promotion_id
3318 - shipping_methods.adjustments.created_at
3319 - shipping_methods.adjustments.updated_at
3320 - shipping_address.created_at
3321 - shipping_address.updated_at
3322 - billing_address.created_at
3323 - billing_address.updated_at
3324 - region.countries.id
3325 - payment_collection.id
3326 - payment_collection.currency_code
3327 - payment_collection.amount
3328 - payment_collection.status
3329 - payment_collection.payment_providers
3330 - payment_collection.payment_providers.id
3331 - payment_collection.payment_sessions.id
3332 - payment_collection.payment_sessions.amount
3333 - payment_collection.payment_sessions.currency_code
3334 - payment_collection.payment_sessions.provider_id
3335 - payment_collection.payment_sessions.status
3336 /store/carts/{id}/gift-cards:
3337 post:
3338 operationId: PostCartsIdGiftCards
3339 summary: Add Gift Card to Cart
3340 x-sidebar-summary: Add Gift Card
3341 description: Add a Gift Card to a cart
3342 x-authenticated: false
3343 x-ignoreCleanup: true
3344 parameters:
3345 - name: id
3346 in: path
3347 description: The cart's ID.
3348 required: true
3349 schema:
3350 type: string
3351 - name: x-publishable-api-key
3352 in: header
3353 description: Publishable API Key created in the Medusa Admin.
3354 required: true
3355 schema:
3356 type: string
3357 externalDocs:
3358 url: https://docs.medusajs.com/api/store#publishable-api-key
3359 - name: x-medusa-locale
3360 in: header
3361 description: The locale in BCP 47 format to retrieve localized content.
3362 required: false
3363 schema:
3364 type: string
3365 example: en-US
3366 externalDocs:
3367 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3368 description: Learn more in the Serve Translations in Storefront guide.
3369 - name: locale
3370 in: query
3371 description: The locale in BCP 47 format to retrieve localized content.
3372 required: false
3373 schema:
3374 type: string
3375 example: en-US
3376 externalDocs:
3377 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3378 description: Learn more in the Serve Translations in Storefront guide.
3379 requestBody:
3380 content:
3381 application/json:
3382 schema:
3383 $ref: '#/components/schemas/StoreAddGiftCardToCart'
3384 x-codeSamples:
3385 - lang: Shell
3386 label: cURL
3387 source: |-
3388 curl -X POST '{backend_url}/store/carts/{id}/gift-cards' \
3389 -H 'x-publishable-api-key: {your_publishable_api_key}' \
3390 -H 'Content-Type: application/json' \
3391 --data-raw '{
3392 "code": "{value}"
3393 }'
3394 tags:
3395 - Carts
3396 responses:
3397 '200':
3398 description: OK
3399 content:
3400 application/json:
3401 schema:
3402 $ref: '#/components/schemas/StoreCartResponse'
3403 '400':
3404 $ref: '#/components/responses/400_error'
3405 '401':
3406 $ref: '#/components/responses/unauthorized'
3407 '404':
3408 $ref: '#/components/responses/not_found_error'
3409 '409':
3410 $ref: '#/components/responses/invalid_state_error'
3411 '422':
3412 $ref: '#/components/responses/invalid_request_error'
3413 '500':
3414 $ref: '#/components/responses/500_error'
3415 x-badges:
3416 - text: Plugin
3417 description: |
3418 This API route is only available through the [Loyalty Plugin](https://docs.medusajs.com/resources/commerce-modules/loyalty).
3419 delete:
3420 operationId: DeleteCartsIdGiftCards
3421 summary: Remove Gift Card from Cart
3422 x-sidebar-summary: Remove Gift Card
3423 description: Remove a Gift Card from a cart.
3424 x-authenticated: false
3425 x-ignoreCleanup: true
3426 parameters:
3427 - name: id
3428 in: path
3429 description: The cart's ID.
3430 required: true
3431 schema:
3432 type: string
3433 - name: x-publishable-api-key
3434 in: header
3435 description: Publishable API Key created in the Medusa Admin.
3436 required: true
3437 schema:
3438 type: string
3439 externalDocs:
3440 url: https://docs.medusajs.com/api/store#publishable-api-key
3441 - name: x-medusa-locale
3442 in: header
3443 description: The locale in BCP 47 format to retrieve localized content.
3444 required: false
3445 schema:
3446 type: string
3447 example: en-US
3448 externalDocs:
3449 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3450 description: Learn more in the Serve Translations in Storefront guide.
3451 - name: locale
3452 in: query
3453 description: The locale in BCP 47 format to retrieve localized content.
3454 required: false
3455 schema:
3456 type: string
3457 example: en-US
3458 externalDocs:
3459 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3460 description: Learn more in the Serve Translations in Storefront guide.
3461 requestBody:
3462 content:
3463 application/json:
3464 schema:
3465 $ref: '#/components/schemas/StoreRemoveGiftCardFromCart'
3466 x-codeSamples:
3467 - lang: Shell
3468 label: cURL
3469 source: |-
3470 curl -X DELETE '{backend_url}/store/carts/{id}/gift-cards' \
3471 -H 'x-publishable-api-key: {your_publishable_api_key}' \
3472 -H 'Content-Type: application/json' \
3473 --data-raw '{
3474 "code": "{value}"
3475 }'
3476 tags:
3477 - Carts
3478 responses:
3479 '200':
3480 description: OK
3481 content:
3482 application/json:
3483 schema:
3484 $ref: '#/components/schemas/StoreCartResponse'
3485 '400':
3486 $ref: '#/components/responses/400_error'
3487 '401':
3488 $ref: '#/components/responses/unauthorized'
3489 '404':
3490 $ref: '#/components/responses/not_found_error'
3491 '409':
3492 $ref: '#/components/responses/invalid_state_error'
3493 '422':
3494 $ref: '#/components/responses/invalid_request_error'
3495 '500':
3496 $ref: '#/components/responses/500_error'
3497 x-badges:
3498 - text: Plugin
3499 description: |
3500 This API route is only available through the [Loyalty Plugin](https://docs.medusajs.com/resources/commerce-modules/loyalty).
3501 /store/carts/{id}/line-items:
3502 post:
3503 operationId: PostCartsIdLineItems
3504 summary: Add Line Item to Cart
3505 x-sidebar-summary: Add Line Item
3506 description: Add a product variant as a line item in the cart.
3507 externalDocs:
3508 url: https://docs.medusajs.com/resources/storefront-development/cart/manage-items#add-product-variant-to-cart
3509 description: 'Storefront guide: How to add a product variant to the cart.'
3510 x-authenticated: false
3511 parameters:
3512 - name: id
3513 in: path
3514 description: The cart's ID.
3515 required: true
3516 schema:
3517 type: string
3518 - name: x-publishable-api-key
3519 in: header
3520 description: Publishable API Key created in the Medusa Admin.
3521 required: true
3522 schema:
3523 type: string
3524 externalDocs:
3525 url: https://docs.medusajs.com/api/store#publishable-api-key
3526 - name: x-medusa-locale
3527 in: header
3528 description: The locale in BCP 47 format to retrieve localized content.
3529 required: false
3530 schema:
3531 type: string
3532 example: en-US
3533 externalDocs:
3534 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3535 description: Learn more in the Serve Translations in Storefront guide.
3536 - name: fields
3537 in: query
3538 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
3539 required: false
3540 schema:
3541 type: string
3542 title: fields
3543 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
3544 externalDocs:
3545 url: '#select-fields-and-relations'
3546 - name: locale
3547 in: query
3548 description: The locale in BCP 47 format to retrieve localized content.
3549 required: false
3550 schema:
3551 type: string
3552 example: en-US
3553 externalDocs:
3554 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3555 description: Learn more in the Serve Translations in Storefront guide.
3556 requestBody:
3557 content:
3558 application/json:
3559 schema:
3560 allOf:
3561 - type: object
3562 description: The details of the line item to add.
3563 required:
3564 - variant_id
3565 - quantity
3566 properties:
3567 variant_id:
3568 type: string
3569 title: variant_id
3570 description: The ID of the product variant to add as a line item.
3571 quantity:
3572 type: number
3573 title: quantity
3574 description: The item's quantity.
3575 metadata:
3576 type: object
3577 description: The item's metadata, can hold custom key-value pairs.
3578 - type: object
3579 description: The details of the line item to add.
3580 properties:
3581 additional_data:
3582 type: object
3583 description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
3584 description: The details of the line item to add.
3585 x-codeSamples:
3586 - lang: JavaScript
3587 label: JS SDK
3588 source: |-
3589 import Medusa from "@medusajs/js-sdk"
3590
3591 let MEDUSA_BACKEND_URL = "http://localhost:9000"
3592
3593 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
3594 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
3595 }
3596
3597 export const sdk = new Medusa({
3598 baseUrl: MEDUSA_BACKEND_URL,
3599 debug: process.env.NODE_ENV === "development",
3600 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
3601 })
3602
3603 sdk.store.cart.createLineItem("cart_123", {
3604 variant_id: "variant_123",
3605 quantity: 1
3606 })
3607 .then(({ cart }) => {
3608 console.log(cart)
3609 })
3610 - lang: Shell
3611 label: cURL
3612 source: |-
3613 curl -X POST '{backend_url}/store/carts/{id}/line-items' \
3614 -H 'Content-Type: application/json' \
3615 -H 'x-publishable-api-key: {your_publishable_api_key}' \
3616 --data-raw '{
3617 "variant_id": "{value}",
3618 "quantity": 3360689747918848,
3619 "metadata": {}
3620 }'
3621 tags:
3622 - Carts
3623 responses:
3624 '200':
3625 description: OK
3626 content:
3627 application/json:
3628 schema:
3629 $ref: '#/components/schemas/StoreCartResponse'
3630 '400':
3631 $ref: '#/components/responses/400_error'
3632 '401':
3633 $ref: '#/components/responses/unauthorized'
3634 '404':
3635 $ref: '#/components/responses/not_found_error'
3636 '409':
3637 $ref: '#/components/responses/invalid_state_error'
3638 '422':
3639 $ref: '#/components/responses/invalid_request_error'
3640 '500':
3641 $ref: '#/components/responses/500_error'
3642 x-workflow: addToCartWorkflow
3643 x-events:
3644 - name: cart.updated
3645 payload: |-
3646 ```ts
3647 {
3648 id, // The ID of the cart
3649 }
3650 ```
3651 description: Emitted when a cart's details are updated.
3652 deprecated: false
3653 x-allowed:
3654 - id
3655 - currency_code
3656 - email
3657 - locale
3658 - region_id
3659 - created_at
3660 - updated_at
3661 - completed_at
3662 - total
3663 - subtotal
3664 - tax_total
3665 - discount_total
3666 - discount_subtotal
3667 - discount_tax_total
3668 - original_total
3669 - original_tax_total
3670 - item_total
3671 - item_subtotal
3672 - item_tax_total
3673 - item_discount_total
3674 - original_item_total
3675 - original_item_subtotal
3676 - original_item_tax_total
3677 - shipping_total
3678 - shipping_subtotal
3679 - shipping_tax_total
3680 - shipping_discount_total
3681 - original_shipping_tax_total
3682 - original_shipping_subtotal
3683 - original_shipping_total
3684 - credit_line_subtotal
3685 - credit_line_tax_total
3686 - credit_line_total
3687 - metadata
3688 - sales_channel_id
3689 - promotions.id
3690 - promotions.code
3691 - promotions.is_automatic
3692 - promotions.is_tax_inclusive
3693 - promotions.application_method.value
3694 - promotions.application_method.type
3695 - promotions.application_method.currency_code
3696 - items.id
3697 - items.thumbnail
3698 - items.product
3699 - items.product.id
3700 - items.variant
3701 - items.variant_id
3702 - items.product_id
3703 - items.is_giftcard
3704 - items.product.categories.id
3705 - items.product.tags.id
3706 - items.product.collection_id
3707 - items.product.type_id
3708 - items.product_type_id
3709 - items.product_title
3710 - items.product_description
3711 - items.product_subtitle
3712 - items.product_type
3713 - items.product_collection
3714 - items.product_handle
3715 - items.variant_sku
3716 - items.variant_barcode
3717 - items.variant_title
3718 - items.requires_shipping
3719 - items.metadata
3720 - items.created_at
3721 - items.updated_at
3722 - items.title
3723 - items.quantity
3724 - items.unit_price
3725 - items.compare_at_unit_price
3726 - items.is_tax_inclusive
3727 - items.tax_lines.id
3728 - items.tax_lines.description
3729 - items.tax_lines.code
3730 - items.tax_lines.rate
3731 - items.tax_lines.provider_id
3732 - items.tax_lines.data
3733 - items.tax_lines.metadata
3734 - items.adjustments.id
3735 - items.adjustments.code
3736 - items.adjustments.promotion_id
3737 - items.adjustments.amount
3738 - items.adjustments.is_tax_inclusive
3739 - customer.id
3740 - customer.email
3741 - customer.groups.id
3742 - shipping_methods.tax_lines.id
3743 - shipping_methods.tax_lines.description
3744 - shipping_methods.tax_lines.code
3745 - shipping_methods.tax_lines.rate
3746 - shipping_methods.tax_lines.provider_id
3747 - shipping_methods.tax_lines.data
3748 - shipping_methods.tax_lines.metadata
3749 - shipping_methods.amount
3750 - shipping_methods.is_tax_inclusive
3751 - shipping_methods.adjustments.id
3752 - shipping_methods.adjustments.code
3753 - shipping_methods.adjustments.amount
3754 - shipping_methods.shipping_option_id
3755 - shipping_address_id
3756 - shipping_address.id
3757 - shipping_address.first_name
3758 - shipping_address.last_name
3759 - shipping_address.company
3760 - shipping_address.address_1
3761 - shipping_address.address_2
3762 - shipping_address.city
3763 - shipping_address.postal_code
3764 - shipping_address.country_code
3765 - shipping_address.region_code
3766 - shipping_address.province
3767 - shipping_address.phone
3768 - billing_address_id
3769 - billing_address.id
3770 - billing_address.first_name
3771 - billing_address.last_name
3772 - billing_address.company
3773 - billing_address.address_1
3774 - billing_address.address_2
3775 - billing_address.city
3776 - billing_address.postal_code
3777 - billing_address.country_code
3778 - billing_address.region_code
3779 - billing_address.province
3780 - billing_address.phone
3781 - region.id
3782 - region.name
3783 - region.currency_code
3784 - region.automatic_taxes
3785 - region.countries
3786 - payment_collection
3787 - payment_collection.payment_sessions
3788 - credit_lines
3789 - items
3790 - region
3791 - promotions
3792 - customer
3793 - shipping_methods
3794 - shipping_address
3795 - billing_address
3796 - items.total
3797 - items.subtotal
3798 - items.tax_total
3799 - items.discount_total
3800 - items.discount_tax_total
3801 - items.original_total
3802 - items.original_subtotal
3803 - items.original_tax_total
3804 - items.item_total
3805 - items.item_subtotal
3806 - items.item_tax_total
3807 - shipping_methods.name
3808 - payment_collection.payment_sessions.data
3809 - original_subtotal
3810 - gift_card_total
3811 - gift_card_tax_total
3812 - items.cart_id
3813 - items.is_discountable
3814 - items.tax_lines
3815 - items.tax_lines.item_id
3816 - items.tax_lines.total
3817 - items.tax_lines.subtotal
3818 - items.tax_lines.tax_rate_id
3819 - items.tax_lines.created_at
3820 - items.tax_lines.updated_at
3821 - items.adjustments
3822 - items.adjustments.cart_id
3823 - items.adjustments.item_id
3824 - items.adjustments.description
3825 - items.adjustments.provider_id
3826 - items.adjustments.created_at
3827 - items.adjustments.updated_at
3828 - shipping_methods.id
3829 - shipping_methods.cart_id
3830 - shipping_methods.description
3831 - shipping_methods.data
3832 - shipping_methods.metadata
3833 - shipping_methods.original_total
3834 - shipping_methods.original_subtotal
3835 - shipping_methods.original_tax_total
3836 - shipping_methods.total
3837 - shipping_methods.subtotal
3838 - shipping_methods.tax_total
3839 - shipping_methods.discount_total
3840 - shipping_methods.discount_tax_total
3841 - shipping_methods.created_at
3842 - shipping_methods.updated_at
3843 - shipping_methods.tax_lines
3844 - shipping_methods.tax_lines.shipping_method_id
3845 - shipping_methods.tax_lines.total
3846 - shipping_methods.tax_lines.subtotal
3847 - shipping_methods.tax_lines.tax_rate_id
3848 - shipping_methods.tax_lines.created_at
3849 - shipping_methods.tax_lines.updated_at
3850 - shipping_methods.adjustments
3851 - shipping_methods.adjustments.cart_id
3852 - shipping_methods.adjustments.shipping_method_id
3853 - shipping_methods.adjustments.description
3854 - shipping_methods.adjustments.provider_id
3855 - shipping_methods.adjustments.promotion_id
3856 - shipping_methods.adjustments.created_at
3857 - shipping_methods.adjustments.updated_at
3858 - shipping_address.created_at
3859 - shipping_address.updated_at
3860 - billing_address.created_at
3861 - billing_address.updated_at
3862 - region.countries.id
3863 - payment_collection.id
3864 - payment_collection.currency_code
3865 - payment_collection.amount
3866 - payment_collection.status
3867 - payment_collection.payment_providers
3868 - payment_collection.payment_providers.id
3869 - payment_collection.payment_sessions.id
3870 - payment_collection.payment_sessions.amount
3871 - payment_collection.payment_sessions.currency_code
3872 - payment_collection.payment_sessions.provider_id
3873 - payment_collection.payment_sessions.status
3874 /store/carts/{id}/line-items/{line_id}:
3875 post:
3876 operationId: PostCartsIdLineItemsLine_id
3877 summary: Update a Line Item in a Cart
3878 x-sidebar-summary: Update Line Item
3879 description: Update a line item's details in the cart.
3880 externalDocs:
3881 url: https://docs.medusajs.com/resources/storefront-development/cart/manage-items#update-line-item-in-cart
3882 description: 'Storefront guide: How to update a cart''s line item.'
3883 x-authenticated: false
3884 parameters:
3885 - name: id
3886 in: path
3887 description: The cart's ID.
3888 required: true
3889 schema:
3890 type: string
3891 - name: line_id
3892 in: path
3893 description: The line item's ID.
3894 required: true
3895 schema:
3896 type: string
3897 - name: x-publishable-api-key
3898 in: header
3899 description: Publishable API Key created in the Medusa Admin.
3900 required: true
3901 schema:
3902 type: string
3903 externalDocs:
3904 url: https://docs.medusajs.com/api/store#publishable-api-key
3905 - name: x-medusa-locale
3906 in: header
3907 description: The locale in BCP 47 format to retrieve localized content.
3908 required: false
3909 schema:
3910 type: string
3911 example: en-US
3912 externalDocs:
3913 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3914 description: Learn more in the Serve Translations in Storefront guide.
3915 - name: fields
3916 in: query
3917 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
3918 required: false
3919 schema:
3920 type: string
3921 title: fields
3922 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
3923 externalDocs:
3924 url: '#select-fields-and-relations'
3925 - name: locale
3926 in: query
3927 description: The locale in BCP 47 format to retrieve localized content.
3928 required: false
3929 schema:
3930 type: string
3931 example: en-US
3932 externalDocs:
3933 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
3934 description: Learn more in the Serve Translations in Storefront guide.
3935 requestBody:
3936 content:
3937 application/json:
3938 schema:
3939 allOf:
3940 - type: object
3941 description: The details to update in the line item.
3942 required:
3943 - quantity
3944 properties:
3945 quantity:
3946 type: number
3947 title: quantity
3948 description: The item's quantity.
3949 metadata:
3950 type: object
3951 description: The item's metadata, can hold custom key-value pairs.
3952 - type: object
3953 description: The details to update in the line item.
3954 properties:
3955 additional_data:
3956 type: object
3957 description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
3958 description: The details to update in the line item.
3959 x-codeSamples:
3960 - lang: JavaScript
3961 label: JS SDK
3962 source: |-
3963 import Medusa from "@medusajs/js-sdk"
3964
3965 let MEDUSA_BACKEND_URL = "http://localhost:9000"
3966
3967 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
3968 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
3969 }
3970
3971 export const sdk = new Medusa({
3972 baseUrl: MEDUSA_BACKEND_URL,
3973 debug: process.env.NODE_ENV === "development",
3974 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
3975 })
3976
3977 sdk.store.cart.updateLineItem(
3978 "cart_123",
3979 "li_123",
3980 {
3981 quantity: 1
3982 }
3983 )
3984 .then(({ cart }) => {
3985 console.log(cart)
3986 })
3987 - lang: Shell
3988 label: cURL
3989 source: |-
3990 curl -X POST '{backend_url}/store/carts/{id}/line-items/{line_id}' \
3991 -H 'Content-Type: application/json' \
3992 -H 'x-publishable-api-key: {your_publishable_api_key}' \
3993 --data-raw '{
3994 "quantity": 8980402259623936,
3995 "metadata": {}
3996 }'
3997 tags:
3998 - Carts
3999 responses:
4000 '200':
4001 description: OK
4002 content:
4003 application/json:
4004 schema:
4005 $ref: '#/components/schemas/StoreCartResponse'
4006 '400':
4007 $ref: '#/components/responses/400_error'
4008 '401':
4009 $ref: '#/components/responses/unauthorized'
4010 '404':
4011 $ref: '#/components/responses/not_found_error'
4012 '409':
4013 $ref: '#/components/responses/invalid_state_error'
4014 '422':
4015 $ref: '#/components/responses/invalid_request_error'
4016 '500':
4017 $ref: '#/components/responses/500_error'
4018 x-workflow: updateLineItemInCartWorkflow
4019 x-events:
4020 - name: cart.updated
4021 payload: |-
4022 ```ts
4023 {
4024 id, // The ID of the cart
4025 }
4026 ```
4027 description: Emitted when a cart's details are updated.
4028 deprecated: false
4029 x-allowed:
4030 - id
4031 - currency_code
4032 - email
4033 - locale
4034 - region_id
4035 - created_at
4036 - updated_at
4037 - completed_at
4038 - total
4039 - subtotal
4040 - tax_total
4041 - discount_total
4042 - discount_subtotal
4043 - discount_tax_total
4044 - original_total
4045 - original_tax_total
4046 - item_total
4047 - item_subtotal
4048 - item_tax_total
4049 - item_discount_total
4050 - original_item_total
4051 - original_item_subtotal
4052 - original_item_tax_total
4053 - shipping_total
4054 - shipping_subtotal
4055 - shipping_tax_total
4056 - shipping_discount_total
4057 - original_shipping_tax_total
4058 - original_shipping_subtotal
4059 - original_shipping_total
4060 - credit_line_subtotal
4061 - credit_line_tax_total
4062 - credit_line_total
4063 - metadata
4064 - sales_channel_id
4065 - promotions.id
4066 - promotions.code
4067 - promotions.is_automatic
4068 - promotions.is_tax_inclusive
4069 - promotions.application_method.value
4070 - promotions.application_method.type
4071 - promotions.application_method.currency_code
4072 - items.id
4073 - items.thumbnail
4074 - items.product
4075 - items.product.id
4076 - items.variant
4077 - items.variant_id
4078 - items.product_id
4079 - items.is_giftcard
4080 - items.product.categories.id
4081 - items.product.tags.id
4082 - items.product.collection_id
4083 - items.product.type_id
4084 - items.product_type_id
4085 - items.product_title
4086 - items.product_description
4087 - items.product_subtitle
4088 - items.product_type
4089 - items.product_collection
4090 - items.product_handle
4091 - items.variant_sku
4092 - items.variant_barcode
4093 - items.variant_title
4094 - items.requires_shipping
4095 - items.metadata
4096 - items.created_at
4097 - items.updated_at
4098 - items.title
4099 - items.quantity
4100 - items.unit_price
4101 - items.compare_at_unit_price
4102 - items.is_tax_inclusive
4103 - items.tax_lines.id
4104 - items.tax_lines.description
4105 - items.tax_lines.code
4106 - items.tax_lines.rate
4107 - items.tax_lines.provider_id
4108 - items.tax_lines.data
4109 - items.tax_lines.metadata
4110 - items.adjustments.id
4111 - items.adjustments.code
4112 - items.adjustments.promotion_id
4113 - items.adjustments.amount
4114 - items.adjustments.is_tax_inclusive
4115 - customer.id
4116 - customer.email
4117 - customer.groups.id
4118 - shipping_methods.tax_lines.id
4119 - shipping_methods.tax_lines.description
4120 - shipping_methods.tax_lines.code
4121 - shipping_methods.tax_lines.rate
4122 - shipping_methods.tax_lines.provider_id
4123 - shipping_methods.tax_lines.data
4124 - shipping_methods.tax_lines.metadata
4125 - shipping_methods.amount
4126 - shipping_methods.is_tax_inclusive
4127 - shipping_methods.adjustments.id
4128 - shipping_methods.adjustments.code
4129 - shipping_methods.adjustments.amount
4130 - shipping_methods.shipping_option_id
4131 - shipping_address_id
4132 - shipping_address.id
4133 - shipping_address.first_name
4134 - shipping_address.last_name
4135 - shipping_address.company
4136 - shipping_address.address_1
4137 - shipping_address.address_2
4138 - shipping_address.city
4139 - shipping_address.postal_code
4140 - shipping_address.country_code
4141 - shipping_address.region_code
4142 - shipping_address.province
4143 - shipping_address.phone
4144 - billing_address_id
4145 - billing_address.id
4146 - billing_address.first_name
4147 - billing_address.last_name
4148 - billing_address.company
4149 - billing_address.address_1
4150 - billing_address.address_2
4151 - billing_address.city
4152 - billing_address.postal_code
4153 - billing_address.country_code
4154 - billing_address.region_code
4155 - billing_address.province
4156 - billing_address.phone
4157 - region.id
4158 - region.name
4159 - region.currency_code
4160 - region.automatic_taxes
4161 - region.countries
4162 - payment_collection
4163 - payment_collection.payment_sessions
4164 - credit_lines
4165 - items
4166 - region
4167 - promotions
4168 - customer
4169 - shipping_methods
4170 - shipping_address
4171 - billing_address
4172 - items.total
4173 - items.subtotal
4174 - items.tax_total
4175 - items.discount_total
4176 - items.discount_tax_total
4177 - items.original_total
4178 - items.original_subtotal
4179 - items.original_tax_total
4180 - items.item_total
4181 - items.item_subtotal
4182 - items.item_tax_total
4183 - shipping_methods.name
4184 - payment_collection.payment_sessions.data
4185 - original_subtotal
4186 - gift_card_total
4187 - gift_card_tax_total
4188 - items.cart_id
4189 - items.is_discountable
4190 - items.tax_lines
4191 - items.tax_lines.item_id
4192 - items.tax_lines.total
4193 - items.tax_lines.subtotal
4194 - items.tax_lines.tax_rate_id
4195 - items.tax_lines.created_at
4196 - items.tax_lines.updated_at
4197 - items.adjustments
4198 - items.adjustments.cart_id
4199 - items.adjustments.item_id
4200 - items.adjustments.description
4201 - items.adjustments.provider_id
4202 - items.adjustments.created_at
4203 - items.adjustments.updated_at
4204 - shipping_methods.id
4205 - shipping_methods.cart_id
4206 - shipping_methods.description
4207 - shipping_methods.data
4208 - shipping_methods.metadata
4209 - shipping_methods.original_total
4210 - shipping_methods.original_subtotal
4211 - shipping_methods.original_tax_total
4212 - shipping_methods.total
4213 - shipping_methods.subtotal
4214 - shipping_methods.tax_total
4215 - shipping_methods.discount_total
4216 - shipping_methods.discount_tax_total
4217 - shipping_methods.created_at
4218 - shipping_methods.updated_at
4219 - shipping_methods.tax_lines
4220 - shipping_methods.tax_lines.shipping_method_id
4221 - shipping_methods.tax_lines.total
4222 - shipping_methods.tax_lines.subtotal
4223 - shipping_methods.tax_lines.tax_rate_id
4224 - shipping_methods.tax_lines.created_at
4225 - shipping_methods.tax_lines.updated_at
4226 - shipping_methods.adjustments
4227 - shipping_methods.adjustments.cart_id
4228 - shipping_methods.adjustments.shipping_method_id
4229 - shipping_methods.adjustments.description
4230 - shipping_methods.adjustments.provider_id
4231 - shipping_methods.adjustments.promotion_id
4232 - shipping_methods.adjustments.created_at
4233 - shipping_methods.adjustments.updated_at
4234 - shipping_address.created_at
4235 - shipping_address.updated_at
4236 - billing_address.created_at
4237 - billing_address.updated_at
4238 - region.countries.id
4239 - payment_collection.id
4240 - payment_collection.currency_code
4241 - payment_collection.amount
4242 - payment_collection.status
4243 - payment_collection.payment_providers
4244 - payment_collection.payment_providers.id
4245 - payment_collection.payment_sessions.id
4246 - payment_collection.payment_sessions.amount
4247 - payment_collection.payment_sessions.currency_code
4248 - payment_collection.payment_sessions.provider_id
4249 - payment_collection.payment_sessions.status
4250 delete:
4251 operationId: DeleteCartsIdLineItemsLine_id
4252 summary: Remove Line Item from Cart
4253 x-sidebar-summary: Remove Line Item
4254 description: Remove a line item from a cart.
4255 externalDocs:
4256 url: https://docs.medusajs.com/resources/storefront-development/cart/manage-items#remove-line-item-from-cart
4257 description: 'Storefront guide: How to remove line item from cart.'
4258 x-authenticated: false
4259 parameters:
4260 - name: id
4261 in: path
4262 description: The cart's ID.
4263 required: true
4264 schema:
4265 type: string
4266 - name: line_id
4267 in: path
4268 description: The line item's ID.
4269 required: true
4270 schema:
4271 type: string
4272 - name: x-publishable-api-key
4273 in: header
4274 description: Publishable API Key created in the Medusa Admin.
4275 required: true
4276 schema:
4277 type: string
4278 externalDocs:
4279 url: https://docs.medusajs.com/api/store#publishable-api-key
4280 - name: x-medusa-locale
4281 in: header
4282 description: The locale in BCP 47 format to retrieve localized content.
4283 required: false
4284 schema:
4285 type: string
4286 example: en-US
4287 externalDocs:
4288 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
4289 description: Learn more in the Serve Translations in Storefront guide.
4290 - name: fields
4291 in: query
4292 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
4293 required: false
4294 schema:
4295 type: string
4296 title: fields
4297 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
4298 externalDocs:
4299 url: '#select-fields-and-relations'
4300 - name: locale
4301 in: query
4302 description: The locale in BCP 47 format to retrieve localized content.
4303 required: false
4304 schema:
4305 type: string
4306 example: en-US
4307 externalDocs:
4308 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
4309 description: Learn more in the Serve Translations in Storefront guide.
4310 x-codeSamples:
4311 - lang: JavaScript
4312 label: JS SDK
4313 source: |-
4314 import Medusa from "@medusajs/js-sdk"
4315
4316 let MEDUSA_BACKEND_URL = "http://localhost:9000"
4317
4318 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
4319 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
4320 }
4321
4322 export const sdk = new Medusa({
4323 baseUrl: MEDUSA_BACKEND_URL,
4324 debug: process.env.NODE_ENV === "development",
4325 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
4326 })
4327
4328 sdk.store.cart.deleteLineItem(
4329 "cart_123",
4330 "li_123"
4331 )
4332 .then(({ deleted, parent: cart }) => {
4333 console.log(deleted, cart)
4334 })
4335 - lang: Shell
4336 label: cURL
4337 source: |-
4338 curl -X DELETE '{backend_url}/store/carts/{id}/line-items/{line_id}' \
4339 -H 'x-publishable-api-key: {your_publishable_api_key}'
4340 tags:
4341 - Carts
4342 responses:
4343 '200':
4344 description: OK
4345 content:
4346 application/json:
4347 schema:
4348 allOf:
4349 - type: object
4350 description: The deletion's details.
4351 required:
4352 - id
4353 - object
4354 - deleted
4355 properties:
4356 id:
4357 type: string
4358 title: id
4359 description: The ID of the deleted line item.
4360 object:
4361 type: string
4362 title: object
4363 description: The name of the deleted object.
4364 default: line-item
4365 deleted:
4366 type: boolean
4367 title: deleted
4368 description: Whether the item was deleted.
4369 - type: object
4370 description: The deletion's details.
4371 properties:
4372 parent:
4373 $ref: '#/components/schemas/StoreCart'
4374 description: The cart that the item belonged to.
4375 description: The deletion's details.
4376 '400':
4377 $ref: '#/components/responses/400_error'
4378 '401':
4379 $ref: '#/components/responses/unauthorized'
4380 '404':
4381 $ref: '#/components/responses/not_found_error'
4382 '409':
4383 $ref: '#/components/responses/invalid_state_error'
4384 '422':
4385 $ref: '#/components/responses/invalid_request_error'
4386 '500':
4387 $ref: '#/components/responses/500_error'
4388 x-workflow: deleteLineItemsWorkflow
4389 x-events:
4390 - name: cart.updated
4391 payload: |-
4392 ```ts
4393 {
4394 id, // The ID of the cart
4395 }
4396 ```
4397 description: Emitted when a cart's details are updated.
4398 deprecated: false
4399 x-allowed:
4400 - id
4401 - currency_code
4402 - email
4403 - locale
4404 - region_id
4405 - created_at
4406 - updated_at
4407 - completed_at
4408 - total
4409 - subtotal
4410 - tax_total
4411 - discount_total
4412 - discount_subtotal
4413 - discount_tax_total
4414 - original_total
4415 - original_tax_total
4416 - item_total
4417 - item_subtotal
4418 - item_tax_total
4419 - item_discount_total
4420 - original_item_total
4421 - original_item_subtotal
4422 - original_item_tax_total
4423 - shipping_total
4424 - shipping_subtotal
4425 - shipping_tax_total
4426 - shipping_discount_total
4427 - original_shipping_tax_total
4428 - original_shipping_subtotal
4429 - original_shipping_total
4430 - credit_line_subtotal
4431 - credit_line_tax_total
4432 - credit_line_total
4433 - metadata
4434 - sales_channel_id
4435 - promotions.id
4436 - promotions.code
4437 - promotions.is_automatic
4438 - promotions.is_tax_inclusive
4439 - promotions.application_method.value
4440 - promotions.application_method.type
4441 - promotions.application_method.currency_code
4442 - items.id
4443 - items.thumbnail
4444 - items.product
4445 - items.product.id
4446 - items.variant
4447 - items.variant_id
4448 - items.product_id
4449 - items.is_giftcard
4450 - items.product.categories.id
4451 - items.product.tags.id
4452 - items.product.collection_id
4453 - items.product.type_id
4454 - items.product_type_id
4455 - items.product_title
4456 - items.product_description
4457 - items.product_subtitle
4458 - items.product_type
4459 - items.product_collection
4460 - items.product_handle
4461 - items.variant_sku
4462 - items.variant_barcode
4463 - items.variant_title
4464 - items.requires_shipping
4465 - items.metadata
4466 - items.created_at
4467 - items.updated_at
4468 - items.title
4469 - items.quantity
4470 - items.unit_price
4471 - items.compare_at_unit_price
4472 - items.is_tax_inclusive
4473 - items.tax_lines.id
4474 - items.tax_lines.description
4475 - items.tax_lines.code
4476 - items.tax_lines.rate
4477 - items.tax_lines.provider_id
4478 - items.tax_lines.data
4479 - items.tax_lines.metadata
4480 - items.adjustments.id
4481 - items.adjustments.code
4482 - items.adjustments.promotion_id
4483 - items.adjustments.amount
4484 - items.adjustments.is_tax_inclusive
4485 - customer.id
4486 - customer.email
4487 - customer.groups.id
4488 - shipping_methods.tax_lines.id
4489 - shipping_methods.tax_lines.description
4490 - shipping_methods.tax_lines.code
4491 - shipping_methods.tax_lines.rate
4492 - shipping_methods.tax_lines.provider_id
4493 - shipping_methods.tax_lines.data
4494 - shipping_methods.tax_lines.metadata
4495 - shipping_methods.amount
4496 - shipping_methods.is_tax_inclusive
4497 - shipping_methods.adjustments.id
4498 - shipping_methods.adjustments.code
4499 - shipping_methods.adjustments.amount
4500 - shipping_methods.shipping_option_id
4501 - shipping_address_id
4502 - shipping_address.id
4503 - shipping_address.first_name
4504 - shipping_address.last_name
4505 - shipping_address.company
4506 - shipping_address.address_1
4507 - shipping_address.address_2
4508 - shipping_address.city
4509 - shipping_address.postal_code
4510 - shipping_address.country_code
4511 - shipping_address.region_code
4512 - shipping_address.province
4513 - shipping_address.phone
4514 - billing_address_id
4515 - billing_address.id
4516 - billing_address.first_name
4517 - billing_address.last_name
4518 - billing_address.company
4519 - billing_address.address_1
4520 - billing_address.address_2
4521 - billing_address.city
4522 - billing_address.postal_code
4523 - billing_address.country_code
4524 - billing_address.region_code
4525 - billing_address.province
4526 - billing_address.phone
4527 - region.id
4528 - region.name
4529 - region.currency_code
4530 - region.automatic_taxes
4531 - region.countries
4532 - payment_collection
4533 - payment_collection.payment_sessions
4534 - credit_lines
4535 - items
4536 - region
4537 - promotions
4538 - customer
4539 - shipping_methods
4540 - shipping_address
4541 - billing_address
4542 - items.total
4543 - items.subtotal
4544 - items.tax_total
4545 - items.discount_total
4546 - items.discount_tax_total
4547 - items.original_total
4548 - items.original_subtotal
4549 - items.original_tax_total
4550 - items.item_total
4551 - items.item_subtotal
4552 - items.item_tax_total
4553 - shipping_methods.name
4554 - payment_collection.payment_sessions.data
4555 - original_subtotal
4556 - gift_card_total
4557 - gift_card_tax_total
4558 - items.cart_id
4559 - items.is_discountable
4560 - items.tax_lines
4561 - items.tax_lines.item_id
4562 - items.tax_lines.total
4563 - items.tax_lines.subtotal
4564 - items.tax_lines.tax_rate_id
4565 - items.tax_lines.created_at
4566 - items.tax_lines.updated_at
4567 - items.adjustments
4568 - items.adjustments.cart_id
4569 - items.adjustments.item_id
4570 - items.adjustments.description
4571 - items.adjustments.provider_id
4572 - items.adjustments.created_at
4573 - items.adjustments.updated_at
4574 - shipping_methods.id
4575 - shipping_methods.cart_id
4576 - shipping_methods.description
4577 - shipping_methods.data
4578 - shipping_methods.metadata
4579 - shipping_methods.original_total
4580 - shipping_methods.original_subtotal
4581 - shipping_methods.original_tax_total
4582 - shipping_methods.total
4583 - shipping_methods.subtotal
4584 - shipping_methods.tax_total
4585 - shipping_methods.discount_total
4586 - shipping_methods.discount_tax_total
4587 - shipping_methods.created_at
4588 - shipping_methods.updated_at
4589 - shipping_methods.tax_lines
4590 - shipping_methods.tax_lines.shipping_method_id
4591 - shipping_methods.tax_lines.total
4592 - shipping_methods.tax_lines.subtotal
4593 - shipping_methods.tax_lines.tax_rate_id
4594 - shipping_methods.tax_lines.created_at
4595 - shipping_methods.tax_lines.updated_at
4596 - shipping_methods.adjustments
4597 - shipping_methods.adjustments.cart_id
4598 - shipping_methods.adjustments.shipping_method_id
4599 - shipping_methods.adjustments.description
4600 - shipping_methods.adjustments.provider_id
4601 - shipping_methods.adjustments.promotion_id
4602 - shipping_methods.adjustments.created_at
4603 - shipping_methods.adjustments.updated_at
4604 - shipping_address.created_at
4605 - shipping_address.updated_at
4606 - billing_address.created_at
4607 - billing_address.updated_at
4608 - region.countries.id
4609 - payment_collection.id
4610 - payment_collection.currency_code
4611 - payment_collection.amount
4612 - payment_collection.status
4613 - payment_collection.payment_providers
4614 - payment_collection.payment_providers.id
4615 - payment_collection.payment_sessions.id
4616 - payment_collection.payment_sessions.amount
4617 - payment_collection.payment_sessions.currency_code
4618 - payment_collection.payment_sessions.provider_id
4619 - payment_collection.payment_sessions.status
4620 /store/carts/{id}/promotions:
4621 post:
4622 operationId: PostCartsIdPromotions
4623 summary: Add Promotions to Cart
4624 x-sidebar-summary: Add Promotions
4625 description: Add a list of promotions to a cart.
4626 x-authenticated: false
4627 externalDocs:
4628 url: https://docs.medusajs.com/resources/storefront-development/cart/manage-promotions#add-promotion-to-cart
4629 description: 'Storefront guide: How to add a promotion to cart.'
4630 parameters:
4631 - name: id
4632 in: path
4633 description: The cart's ID.
4634 required: true
4635 schema:
4636 type: string
4637 - name: x-publishable-api-key
4638 in: header
4639 description: Publishable API Key created in the Medusa Admin.
4640 required: true
4641 schema:
4642 type: string
4643 externalDocs:
4644 url: https://docs.medusajs.com/api/store#publishable-api-key
4645 - name: x-medusa-locale
4646 in: header
4647 description: The locale in BCP 47 format to retrieve localized content.
4648 required: false
4649 schema:
4650 type: string
4651 example: en-US
4652 externalDocs:
4653 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
4654 description: Learn more in the Serve Translations in Storefront guide.
4655 - name: fields
4656 in: query
4657 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
4658 required: false
4659 schema:
4660 type: string
4661 title: fields
4662 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
4663 externalDocs:
4664 url: '#select-fields-and-relations'
4665 - name: locale
4666 in: query
4667 description: The locale in BCP 47 format to retrieve localized content.
4668 required: false
4669 schema:
4670 type: string
4671 example: en-US
4672 externalDocs:
4673 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
4674 description: Learn more in the Serve Translations in Storefront guide.
4675 requestBody:
4676 content:
4677 application/json:
4678 schema:
4679 $ref: '#/components/schemas/StoreCartAddPromotion'
4680 x-codeSamples:
4681 - lang: JavaScript
4682 label: JS SDK
4683 source: |-
4684 import Medusa from "@medusajs/js-sdk"
4685
4686 let MEDUSA_BACKEND_URL = "http://localhost:9000"
4687
4688 if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
4689 MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
4690 }
4691
4692 export const sdk = new Medusa({
4693 baseUrl: MEDUSA_BACKEND_URL,
4694 debug: process.env.NODE_ENV === "development",
4695 publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
4696 })
4697
4698 sdk.store.cart.addPromotions("cart_123", {
4699 promo_codes: ["20OFF"]
4700 })
4701 .then(({ cart }) => {
4702 console.log(cart)
4703 })
4704 - lang: Shell
4705 label: cURL
4706 source: |-
4707 curl -X POST '{backend_url}/store/carts/{id}/promotions' \
4708 -H 'Content-Type: application/json' \
4709 -H 'x-publishable-api-key: {your_publishable_api_key}' \
4710 --data-raw '{
4711 "promo_codes": [
4712 "{value}"
4713 ]
4714 }'
4715 tags:
4716 - Carts
4717 responses:
4718 '200':
4719 description: OK
4720 content:
4721 application/json:
4722 schema:
4723 $ref: '#/components/schemas/StoreCartResponse'
4724 '400':
4725 $ref: '#/components/responses/400_error'
4726 '401':
4727 $ref: '#/components/responses/unauthorized'
4728 '404':
4729 $ref: '#/components/responses/not_found_error'
4730 '409':
4731 $ref: '#/components/responses/invalid_state_error'
4732 '422':
4733 $ref: '#/components/responses/invalid_request_error'
4734 '500':
4735 $ref: '#/components/responses/500_error'
4736 x-workflow: updateCartPromotionsWorkflow
4737 x-events: []
4738 x-allowed:
4739 - id
4740 - currency_code
4741 - email
4742 - locale
4743 - region_id
4744 - created_at
4745 - updated_at
4746 - completed_at
4747 - total
4748 - subtotal
4749 - tax_total
4750 - discount_total
4751 - discount_subtotal
4752 - discount_tax_total
4753 - original_total
4754 - original_tax_total
4755 - item_total
4756 - item_subtotal
4757 - item_tax_total
4758 - item_discount_total
4759 - original_item_total
4760 - original_item_subtotal
4761 - original_item_tax_total
4762 - shipping_total
4763 - shipping_subtotal
4764 - shipping_tax_total
4765 - shipping_discount_total
4766 - original_shipping_tax_total
4767 - original_shipping_subtotal
4768 - original_shipping_total
4769 - credit_line_subtotal
4770 - credit_line_tax_total
4771 - credit_line_total
4772 - metadata
4773 - sales_channel_id
4774 - promotions.id
4775 - promotions.code
4776 - promotions.is_automatic
4777 - promotions.is_tax_inclusive
4778 - promotions.application_method.value
4779 - promotions.application_method.type
4780 - promotions.application_method.currency_code
4781 - items.id
4782 - items.thumbnail
4783 - items.product
4784 - items.product.id
4785 - items.variant
4786 - items.variant_id
4787 - items.product_id
4788 - items.is_giftcard
4789 - items.product.categories.id
4790 - items.product.tags.id
4791 - items.product.collection_id
4792 - items.product.type_id
4793 - items.product_type_id
4794 - items.product_title
4795 - items.product_description
4796 - items.product_subtitle
4797 - items.product_type
4798 - items.product_collection
4799 - items.product_handle
4800 - items.variant_sku
4801 - items.variant_barcode
4802 - items.variant_title
4803 - items.requires_shipping
4804 - items.metadata
4805 - items.created_at
4806 - items.updated_at
4807 - items.title
4808 - items.quantity
4809 - items.unit_price
4810 - items.compare_at_unit_price
4811 - items.is_tax_inclusive
4812 - items.tax_lines.id
4813 - items.tax_lines.description
4814 - items.tax_lines.code
4815 - items.tax_lines.rate
4816 - items.tax_lines.provider_id
4817 - items.tax_lines.data
4818 - items.tax_lines.metadata
4819 - items.adjustments.id
4820 - items.adjustments.code
4821 - items.adjustments.promotion_id
4822 - items.adjustments.amount
4823 - items.adjustments.is_tax_inclusive
4824 - customer.id
4825 - customer.email
4826 - customer.groups.id
4827 - shipping_methods.tax_lines.id
4828 - shipping_methods.tax_lines.description
4829 - shipping_methods.tax_lines.code
4830 - shipping_methods.tax_lines.rate
4831 - shipping_methods.tax_lines.provider_id
4832 - shipping_methods.tax_lines.data
4833 - shipping_methods.tax_lines.metadata
4834 - shipping_methods.amount
4835 - shipping_methods.is_tax_inclusive
4836 - shipping_methods.adjustments.id
4837 - shipping_methods.adjustments.code
4838 - shipping_methods.adjustments.amount
4839 - shipping_methods.shipping_option_id
4840 - shipping_address_id
4841 - shipping_address.id
4842 - shipping_address.first_name
4843 - shipping_address.last_name
4844 - shipping_address.company
4845 - shipping_address.address_1
4846 - shipping_address.address_2
4847 - shipping_address.city
4848 - shipping_address.postal_code
4849 - shipping_address.country_code
4850 - shipping_address.region_code
4851 - shipping_address.province
4852 - shipping_address.phone
4853 - billing_address_id
4854 - billing_address.id
4855 - billing_address.first_name
4856 - billing_address.last_name
4857 - billing_address.company
4858 - billing_address.address_1
4859 - billing_address.address_2
4860 - billing_address.city
4861 - billing_address.postal_code
4862 - billing_address.country_code
4863 - billing_address.region_code
4864 - billing_address.province
4865 - billing_address.phone
4866 - region.id
4867 - region.name
4868 - region.currency_code
4869 - region.automatic_taxes
4870 - region.countries
4871 - payment_collection
4872 - payment_collection.payment_sessions
4873 - credit_lines
4874 - items
4875 - region
4876 - promotions
4877 - customer
4878 - shipping_methods
4879 - shipping_address
4880 - billing_address
4881 - items.total
4882 - items.subtotal
4883 - items.tax_total
4884 - items.discount_total
4885 - items.discount_tax_total
4886 - items.original_total
4887 - items.original_subtotal
4888 - items.original_tax_total
4889 - items.item_total
4890 - items.item_subtotal
4891 - items.item_tax_total
4892 - shipping_methods.name
4893 - payment_collection.payment_sessions.data
4894 - original_subtotal
4895 - gift_card_total
4896 - gift_card_tax_total
4897 - items.cart_id
4898 - items.is_discountable
4899 - items.tax_lines
4900 - items.tax_lines.item_id
4901 - items.tax_lines.total
4902 - items.tax_lines.subtotal
4903 - items.tax_lines.tax_rate_id
4904 - items.tax_lines.created_at
4905 - items.tax_lines.updated_at
4906 - items.adjustments
4907 - items.adjustments.cart_id
4908 - items.adjustments.item_id
4909 - items.adjustments.description
4910 - items.adjustments.provider_id
4911 - items.adjustments.created_at
4912 - items.adjustments.updated_at
4913 - shipping_methods.id
4914 - shipping_methods.cart_id
4915 - shipping_methods.description
4916 - shipping_methods.data
4917 - shipping_methods.metadata
4918 - shipping_methods.original_total
4919 - shipping_methods.original_subtotal
4920 - shipping_methods.original_tax_total
4921 - shipping_methods.total
4922 - shipping_methods.subtotal
4923 - shipping_methods.tax_total
4924 - shipping_methods.discount_total
4925 - shipping_methods.discount_tax_total
4926 - shipping_methods.created_at
4927 - shipping_methods.updated_at
4928 - shipping_methods.tax_lines
4929 - shipping_methods.tax_lines.shipping_method_id
4930 - shipping_methods.tax_lines.total
4931 - shipping_methods.tax_lines.subtotal
4932 - shipping_methods.tax_lines.tax_rate_id
4933 - shipping_methods.tax_lines.created_at
4934 - shipping_methods.tax_lines.updated_at
4935 - shipping_methods.adjustments
4936 - shipping_methods.adjustments.cart_id
4937 - shipping_methods.adjustments.shipping_method_id
4938 - shipping_methods.adjustments.description
4939 - shipping_methods.adjustments.provider_id
4940 - shipping_methods.adjustments.promotion_id
4941 - shipping_methods.adjustments.created_at
4942 - shipping_methods.adjustments.updated_at
4943 - shipping_address.created_at
4944 - shipping_address.updated_at
4945 - billing_address.created_at
4946 - billing_address.updated_at
4947 - region.countries.id
4948 - payment_collection.id
4949 - payment_collection.currency_code
4950 - payment_collection.amount
4951 - payment_collection.status
4952 - payment_collection.payment_providers
4953 - payment_collection.payment_providers.id
4954 - payment_collection.payment_sessions.id
4955 - payment_collection.payment_sessions.amount
4956 - payment_collection.payment_sessions.currency_code
4957 - payment_collection.payment_sessions.provider_id
4958 - payment_collection.payment_sessions.status
4959 delete:
4960 operationId: DeleteCartsIdPromotions
4961 summary: Remove Promotions from Cart
4962 description: Remove a list of promotions from a cart.
4963 x-authenticated: false
4964 externalDocs:
4965 url: https://docs.medusajs.com/resources/storefront-development/cart/manage-promotions#remove-promotion-from-cart
4966 description: 'Storefront guide: How to remove a promotion from cart.'
4967 parameters:
4968 - name: id
4969 in: path
4970 description: The cart's ID.
4971 required: true
4972 schema:
4973 type: string
4974 - name: x-publishable-api-key
4975 in: header
4976 description: Publishable API Key created in the Medusa Admin.
4977 required: true
4978 schema:
4979 type: string
4980 externalDocs:
4981 url: https://docs.medusajs.com/api/store#publishable-api-key
4982 - name: x-medusa-locale
4983 in: header
4984 description: The locale in BCP 47 format to retrieve localized content.
4985 required: false
4986 schema:
4987 type: string
4988 example: en-US
4989 externalDocs:
4990 url: https://docs.medusajs.com/resources/commerce-modules/translation/storefront
4991 description: Learn more in the Serve Translations in Storefront guide.
4992 - name: fields
4993 in: query
4994 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
4995 required: false
4996 schema:
4997 type: string
4998 title: fields
4999 description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.
5000 externalDocs:
Showing first 5,000 of 47,001 lines. View raw