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