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