Files
medusa-store/docs/api/store/paths/carts.yaml
2022-09-05 10:23:46 +03:00

85 lines
2.9 KiB
YAML

post:
summary: Create a Cart
operationId: PostCart
description: >-
Creates a Cart within the given region and with the initial items. If no
`region_id` is provided the cart will be associated with the first Region
available. If no items are provided the cart will be empty after creation.
If a user is logged in the cart's customer id and email will be set.
requestBody:
content:
application/json:
schema:
properties:
region_id:
type: string
description: The ID of the Region to create the Cart in.
sales_channel_id:
type: string
description: >-
[EXPERIMENTAL] The ID of the Sales channel to create the Cart
in.
country_code:
type: string
description: The 2 character ISO country code to create the Cart in.
externalDocs:
url: >-
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
description: See a list of codes.
items:
description: >-
An optional array of `variant_id`, `quantity` pairs to generate
Line Items from.
type: array
items:
required:
- variant_id
- quantity
properties:
variant_id:
description: >-
The id of the Product Variant to generate a Line Item
from.
type: string
quantity:
description: The quantity of the Product Variant to add
type: integer
context:
description: >-
An optional object to provide context to the Cart. The `context`
field is automatically populated with `ip` and `user_agent`
type: object
example:
ip: '::1'
user_agent: Chrome
x-codeSamples:
- lang: JavaScript
label: JS Client
source:
$ref: ../code_samples/JavaScript/carts/postundefined
- lang: Shell
label: cURL
source:
$ref: ../code_samples/Shell/carts/postundefined
tags:
- Cart
responses:
'200':
description: Successfully created a new Cart
content:
application/json:
schema:
properties:
cart:
$ref: ../components/schemas/cart.yaml
'400':
$ref: ../components/responses/400_error.yaml
'404':
$ref: ../components/responses/not_found_error.yaml
'409':
$ref: ../components/responses/invalid_state_error.yaml
'422':
$ref: ../components/responses/invalid_request_error.yaml
'500':
$ref: ../components/responses/500_error.yaml