@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Carts
@base https://api.bigcommerce.com/stores/{store_hash}/v3
@auth ApiKey X-Auth-Token in header
@endpoints 21
@hint download_for_search
@toc carts(21)

@endpoint POST /carts
@required {Content-Type: str=application/json}
@optional {include: [str], customer_id: int, line_items: [any], custom_items: [map{sku: str, name: str, quantity: num, list_price: num, image_url: str(uri)}], gift_certificates: [map{name!: str, theme!: str, amount!: num, quantity!: int, sender!: map, recipient!: map, message: str}], channel_id: int, currency: map{code: str(ISO-4217)}, locale: str(ISO-639)}
@returns(201) {data: map{id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}, meta: map}

@endpoint POST /carts/{cartId}/items
@optional {include: [str], line_items: any, gift_certificates: [map{name!: str, theme!: str, amount!: num, quantity!: int, sender!: map, recipient!: map, message: str}], custom_items: [map{sku: str, name: str, quantity: num, list_price: num, image_url: str(uri)}], version: int}
@returns(201) {data: map{id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}, meta: map}

@endpoint POST /carts/{cartId}/redirect_urls
@optional {query_params: map{key: str, value: str}}
@returns(201) {data: map{cart_url: str(url), checkout_url: str(Url), embedded_checkout_url: str(url)}, meta: map}

@endpoint PUT /carts/{cartId}/items/{itemId}
@required {Content-Type: str=application/json}
@optional {include: [str], line_item: any, gift_certificates: [map{name!: str, theme!: str, amount!: num, quantity!: int, sender!: map, recipient!: map, message: str}], custom_items: [map{sku: str, name: str, quantity: num, list_price: num, image_url: str(uri)}], version: int}
@returns(200) {data: map{id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}, meta: map}
@errors {409}

@endpoint DELETE /carts/{cartId}/items/{itemId}
@optional {include: [str], version: int}
@returns(200) {id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}
@returns(204)
@errors {409}

@endpoint GET /carts/{cartId}
@optional {include: [str]}
@returns(200) {data: map{id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}, meta: map}
@errors {404}

@endpoint PUT /carts/{cartId}
@required {Content-Type: str=application/json}
@optional {include: [str], customer_id: int, version: int}
@returns(201) {data: map{id: str(UUID), customer_id: int, channel_id: int, email: str, currency: map{code: str(ISO-4217)}, tax_included: bool, base_amount: num, discount_amount: num, manual_discount_amount: num, cart_amount: num, coupons: [map], discounts: [map], line_items: map{physical_items: [any], digital_items: [any], gift_certificates: [map], custom_items: [map]}, created_time: str(ISO-8601), updated_time: str(ISO-8601), locale: str(ISO-639), promotions: map{banners: map{id: str, type: str, page: [str], text: str}}, version: int}, meta: map}
@errors {409}

@endpoint DELETE /carts/{cartId}
@returns(204)

@endpoint GET /carts/settings
@returns(200) {data: map{allow_purchasing: bool}, meta: map}
@errors {401}

@endpoint PUT /carts/settings
@required {Content-Type: str=application/json}
@returns(200) {data: map{allow_purchasing: bool}, meta: map}
@errors {400, 401, 422}

@endpoint GET /carts/settings/channels/{channel_id}
@returns(200) {data: map{allow_purchasing: bool?}, meta: map}
@errors {401}

@endpoint PUT /carts/settings/channels/{channel_id}
@required {Content-Type: str=application/json}
@returns(200) {data: map{allow_purchasing: bool?}, meta: map}
@errors {400, 401, 422}

@endpoint GET /carts/{cart_id}/metafields
@optional {page: int, limit: int, key: str, namespace: str, direction: str(asc/desc), before: str, after: str}
@returns(200) {data: any}

@endpoint POST /carts/{cart_id}/metafields
@required {Content-Type: str=application/json, permission_set: str(app_only/read/write/read_and_sf_access/write_and_sf_access), namespace: str, key: str, value: str}
@optional {description: str}
@returns(200) {data: any, meta: map}
@errors {400, 409, 422}

@endpoint GET /carts/{cart_id}/metafields/{metafield_id}
@optional {page: int, limit: int, key: str, namespace: str, direction: str(asc/desc)}
@returns(200) {data: any}
@errors {404}

@endpoint PUT /carts/{cart_id}/metafields/{metafield_id}
@required {Content-Type: str=application/json, permission_set: str(app_only/read/write/read_and_sf_access/write_and_sf_access), namespace: str, key: str, value: str}
@optional {description: str}
@returns(200) {data: any, meta: map}
@errors {400, 422}

@endpoint DELETE /carts/{cart_id}/metafields/{metafield_id}
@returns(204)
@errors {404}

@endpoint GET /carts/metafields
@optional {page: int, limit: int, key: str, key:in: [str], namespace: str, namespace:in: [str], direction: str(asc/desc), include_fields: [str], date_modified:min: str, date_modified:max: str, date_created:min: str, date_created:max: str, before: str, after: str}
@returns(200) {data: [any], meta: map{pagination: map{total: int, count: int, per_page: int, current_page: int, total_pages: int, links: map{previous: str, current: str, next: str}}, cursor_pagination: map{count: int, per_page: int, start_cursor: str, end_cursor: str, links: map{previous: str, current: str, next: str}}}}

@endpoint POST /carts/metafields
@returns(200) {data: [any], errors: [any], meta: map{total: int, success: int, failed: int}}
@errors {400, 422}

@endpoint PUT /carts/metafields
@returns(200) {data: [any], errors: [any], meta: map{total: int, success: int, failed: int}}
@errors {400, 422}

@endpoint DELETE /carts/metafields
@returns(200) {data: [int], errors: [any], meta: map{total: int, success: int, failed: int}}
@errors {400, 422}

@end
