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