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