1 post:
2 operationId: PostCarts
3 summary: Create Cart
4 description: Create a cart.
5 x-authenticated: false
6 parameters:
7 - name: x-publishable-api-key
8 in: header
9 description: Publishable API Key created in the Medusa Admin.
10 required: true
11 schema:
12 type: string
13 externalDocs:
14 url: https://docs.medusajs.com/api/store#publishable-api-key
15 - name: x-medusa-locale
16 in: header
17 description: The locale in BCP 47 format to retrieve localized content.
18 required: false
19 schema:
20 type: string
21 example: en-US
22 externalDocs:
23 url: >-
24 https://docs.medusajs.com/resources/commerce-modules/translation/storefront
25 description: Learn more in the Serve Translations in Storefront guide.
26 - name: fields
27 in: query
28 description: >-
29 Comma-separated fields that should be included in the returned data. if
30 a field is prefixed with `+` it will be added to the default fields,
31 using `-` will remove it from the default fields. without prefix it will
32 replace the entire default fields.
33 required: false
34 schema:
35 type: string
36 title: fields
37 description: >-
38 Comma-separated fields that should be included in the returned data.
39 if a field is prefixed with `+` it will be added to the default
40 fields, using `-` will remove it from the default fields. without
41 prefix it will replace the entire default fields.
42 externalDocs:
43 url: '#select-fields-and-relations'
44 - name: locale
45 in: query
46 description: The locale in BCP 47 format to retrieve localized content.
47 required: false
48 schema:
49 type: string
50 example: en-US
51 externalDocs:
52 url: >-
53 https://docs.medusajs.com/resources/commerce-modules/translation/storefront
54 description: Learn more in the Serve Translations in Storefront guide.
55 requestBody:
56 content:
57 application/json:
58 schema:
59 allOf:
60 - $ref: ../components/schemas/StoreCreateCart.yaml
61 - type: object
62 description: The cart's details.
63 properties:
64 additional_data:
65 type: object
66 description: >-
67 Pass additional custom data to the API route. This data is
68 passed to the underlying workflow under the
69 `additional_data` parameter.
70 description: The cart's details.
71 x-codeSamples:
72 - lang: JavaScript
73 label: JS SDK
74 source:
75 $ref: ../code_samples/JavaScript/store_carts/post.js
76 - lang: Shell
77 label: cURL
78 source:
79 $ref: ../code_samples/Shell/store_carts/post.sh
80 tags:
81 - Carts
82 responses:
83 '200':
84 description: OK
85 content:
86 application/json:
87 schema:
88 $ref: ../components/schemas/StoreCartResponse.yaml
89 '400':
90 $ref: ../components/responses/400_error.yaml
91 '401':
92 $ref: ../components/responses/unauthorized.yaml
93 '404':
94 $ref: ../components/responses/not_found_error.yaml
95 '409':
96 $ref: ../components/responses/invalid_state_error.yaml
97 '422':
98 $ref: ../components/responses/invalid_request_error.yaml
99 '500':
100 $ref: ../components/responses/500_error.yaml
101 x-workflow: createCartWorkflow
102 x-events:
103 - name: cart.created
104 payload: |-
105 ```ts
106 {
107 id, // The ID of the cart
108 }
109 ```
110 description: Emitted when a cart is created.
111 deprecated: false
112 x-allowed:
113 - id
114 - currency_code
115 - email
116 - locale
117 - region_id
118 - created_at
119 - updated_at
120 - completed_at
121 - total
122 - subtotal
123 - tax_total
124 - discount_total
125 - discount_subtotal
126 - discount_tax_total
127 - original_total
128 - original_tax_total
129 - item_total
130 - item_subtotal
131 - item_tax_total
132 - item_discount_total
133 - original_item_total
134 - original_item_subtotal
135 - original_item_tax_total
136 - shipping_total
137 - shipping_subtotal
138 - shipping_tax_total
139 - shipping_discount_total
140 - original_shipping_tax_total
141 - original_shipping_subtotal
142 - original_shipping_total
143 - credit_line_subtotal
144 - credit_line_tax_total
145 - credit_line_total
146 - metadata
147 - sales_channel_id
148 - promotions.id
149 - promotions.code
150 - promotions.is_automatic
151 - promotions.is_tax_inclusive
152 - promotions.application_method.value
153 - promotions.application_method.type
154 - promotions.application_method.currency_code
155 - items.id
156 - items.thumbnail
157 - items.product
158 - items.product.id
159 - items.variant
160 - items.variant_id
161 - items.product_id
162 - items.is_giftcard
163 - items.product.categories.id
164 - items.product.tags.id
165 - items.product.collection_id
166 - items.product.type_id
167 - items.product_type_id
168 - items.product_title
169 - items.product_description
170 - items.product_subtitle
171 - items.product_type
172 - items.product_collection
173 - items.product_handle
174 - items.variant_sku
175 - items.variant_barcode
176 - items.variant_title
177 - items.requires_shipping
178 - items.metadata
179 - items.created_at
180 - items.updated_at
181 - items.title
182 - items.quantity
183 - items.unit_price
184 - items.compare_at_unit_price
185 - items.is_tax_inclusive
186 - items.tax_lines.id
187 - items.tax_lines.description
188 - items.tax_lines.code
189 - items.tax_lines.rate
190 - items.tax_lines.provider_id
191 - items.tax_lines.data
192 - items.tax_lines.metadata
193 - items.adjustments.id
194 - items.adjustments.code
195 - items.adjustments.promotion_id
196 - items.adjustments.amount
197 - items.adjustments.is_tax_inclusive
198 - customer.id
199 - customer.email
200 - customer.groups.id
201 - shipping_methods.tax_lines.id
202 - shipping_methods.tax_lines.description
203 - shipping_methods.tax_lines.code
204 - shipping_methods.tax_lines.rate
205 - shipping_methods.tax_lines.provider_id
206 - shipping_methods.tax_lines.data
207 - shipping_methods.tax_lines.metadata
208 - shipping_methods.amount
209 - shipping_methods.is_tax_inclusive
210 - shipping_methods.adjustments.id
211 - shipping_methods.adjustments.code
212 - shipping_methods.adjustments.amount
213 - shipping_methods.shipping_option_id
214 - shipping_address_id
215 - shipping_address.id
216 - shipping_address.first_name
217 - shipping_address.last_name
218 - shipping_address.company
219 - shipping_address.address_1
220 - shipping_address.address_2
221 - shipping_address.city
222 - shipping_address.postal_code
223 - shipping_address.country_code
224 - shipping_address.region_code
225 - shipping_address.province
226 - shipping_address.phone
227 - billing_address_id
228 - billing_address.id
229 - billing_address.first_name
230 - billing_address.last_name
231 - billing_address.company
232 - billing_address.address_1
233 - billing_address.address_2
234 - billing_address.city
235 - billing_address.postal_code
236 - billing_address.country_code
237 - billing_address.region_code
238 - billing_address.province
239 - billing_address.phone
240 - region.id
241 - region.name
242 - region.currency_code
243 - region.automatic_taxes
244 - region.countries
245 - payment_collection
246 - payment_collection.payment_sessions
247 - credit_lines
248 - items
249 - region
250 - promotions
251 - customer
252 - shipping_methods
253 - shipping_address
254 - billing_address
255 - items.total
256 - items.subtotal
257 - items.tax_total
258 - items.discount_total
259 - items.discount_tax_total
260 - items.original_total
261 - items.original_subtotal
262 - items.original_tax_total
263 - items.item_total
264 - items.item_subtotal
265 - items.item_tax_total
266 - shipping_methods.name
267 - payment_collection.payment_sessions.data
268 - original_subtotal
269 - gift_card_total
270 - gift_card_tax_total
271 - items.cart_id
272 - items.is_discountable
273 - items.tax_lines
274 - items.tax_lines.item_id
275 - items.tax_lines.total
276 - items.tax_lines.subtotal
277 - items.tax_lines.tax_rate_id
278 - items.tax_lines.created_at
279 - items.tax_lines.updated_at
280 - items.adjustments
281 - items.adjustments.cart_id
282 - items.adjustments.item_id
283 - items.adjustments.description
284 - items.adjustments.provider_id
285 - items.adjustments.created_at
286 - items.adjustments.updated_at
287 - shipping_methods.id
288 - shipping_methods.cart_id
289 - shipping_methods.description
290 - shipping_methods.data
291 - shipping_methods.metadata
292 - shipping_methods.original_total
293 - shipping_methods.original_subtotal
294 - shipping_methods.original_tax_total
295 - shipping_methods.total
296 - shipping_methods.subtotal
297 - shipping_methods.tax_total
298 - shipping_methods.discount_total
299 - shipping_methods.discount_tax_total
300 - shipping_methods.created_at
301 - shipping_methods.updated_at
302 - shipping_methods.tax_lines
303 - shipping_methods.tax_lines.shipping_method_id
304 - shipping_methods.tax_lines.total
305 - shipping_methods.tax_lines.subtotal
306 - shipping_methods.tax_lines.tax_rate_id
307 - shipping_methods.tax_lines.created_at
308 - shipping_methods.tax_lines.updated_at
309 - shipping_methods.adjustments
310 - shipping_methods.adjustments.cart_id
311 - shipping_methods.adjustments.shipping_method_id
312 - shipping_methods.adjustments.description
313 - shipping_methods.adjustments.provider_id
314 - shipping_methods.adjustments.promotion_id
315 - shipping_methods.adjustments.created_at
316 - shipping_methods.adjustments.updated_at
317 - shipping_address.created_at
318 - shipping_address.updated_at
319 - billing_address.created_at
320 - billing_address.updated_at
321 - region.countries.id
322 - payment_collection.id
323 - payment_collection.currency_code
324 - payment_collection.amount
325 - payment_collection.status
326 - payment_collection.payment_providers
327 - payment_collection.payment_providers.id
328 - payment_collection.payment_sessions.id
329 - payment_collection.payment_sessions.amount
330 - payment_collection.payment_sessions.currency_code
331 - payment_collection.payment_sessions.provider_id
332 - payment_collection.payment_sessions.status