> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loopreturns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Cart

> Create a cart object and populate it with one or more product variants.
> 🚧 Create Cart Object
>
> When setting up Shop Now: On-Store for a headless store, be sure to create a
> base 64-encoded liquid cart object and send it to Loop.

### Required API key scope
- Carts




## OpenAPI

````yaml post /cart
openapi: 3.1.0
info:
  title: Cart API (On-Store)
  description: This API can be used to manage your shop's carts.
  version: v1
servers:
  - url: https://api.loopreturns.com/api/v1
security: []
tags:
  - name: Cart
paths:
  /cart:
    post:
      tags:
        - Cart
      summary: Create Cart
      description: >
        Create a cart object and populate it with one or more product variants.

        > 🚧 Create Cart Object

        >

        > When setting up Shop Now: On-Store for a headless store, be sure to
        create a

        > base 64-encoded liquid cart object and send it to Loop.


        ### Required API key scope

        - Carts
      operationId: createCart
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCartRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CreatedCart'
                  - $ref: '#/components/schemas/EmptyCart'
                  - $ref: '#/components/schemas/VariantNotFound'
                  - $ref: '#/components/schemas/CartNotSaved'
                  - $ref: '#/components/schemas/InvalidCart'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
      security:
        - api_key: []
components:
  schemas:
    CreateCartRequest:
      type: object
      required:
        - cart
      properties:
        cart:
          type: array
          items:
            $ref: '#/components/schemas/Variant'
          description: An array of product variants.
        shopify:
          description: >-
            A Base64-encoded liquid cart object, used to reflect any additional
            transaction details in Shopify such as discounts.
          type: string
          example: c2FtcGxlLXN0cmluZw==
    CreatedCart:
      type: object
      properties:
        token:
          type: string
          example: 46923497728c9a7b5o8a433zz5c0bbbb683319824778
          description: The cart's unique identifier.
        data:
          type: object
          description: Echoes the contents of the create request.
          properties:
            cart:
              description: >-
                An array of product variants representing the contents of the
                cart.
              type: array
              items:
                $ref: '#/components/schemas/Variant'
            shopify:
              type: string
              description: >-
                The Base64-encoded liquid cart object, if one was provided in
                the request.
              example: c2FtcGxlLXN0cmluZw==
    EmptyCart:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              description: >-
                The error message returned when an attempt is made to create an
                empty cart.
              example: Cart is empty.
        data:
          type: object
          properties:
            cart:
              type: array
              description: An array of product variant IDs (empty if cart is empty).
              items:
                $ref: '#/components/schemas/Variant'
    VariantNotFound:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              description: >-
                The error message returned when one of the product variants
                included in the request couldn't be found.
              example: Variant ID 777777 not found.
        data:
          type: object
          properties:
            cart:
              description: >-
                An array of product variants representing the contents of the
                cart.
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    CartNotSaved:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              description: The error message returned when the cart couldn't be created.
              example: There was an error attempting to create the cart.
        data:
          type: object
          properties:
            cart:
              description: >-
                An array of product variants representing the contents of the
                cart.
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    InvalidCart:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              description: >-
                The error message returned when the request includes one or more
                invalid variant IDs.
              example: Cart should contain a list of variant IDs.
        data:
          type: object
          properties:
            cart:
              description: >-
                An array of product variants representing the contents of the
                cart.
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    UnauthorizedResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '401'
            http_code:
              type: string
              example: GEN-UNAUTHORIZED
            message:
              type: string
              example: Unauthorized.
    Variant:
      description: >-
        A product variant, provided either as a plain variant ID or as an object
        with a `variant_id`.
      oneOf:
        - type: integer
          description: The unique identifier associated with a product variant.
          example: 39076568408247
        - type: object
          properties:
            variant_id:
              type: integer
              description: The unique identifier associated with a product variant.
              example: 39076568408247
          required:
            - variant_id
  securitySchemes:
    api_key:
      type: apiKey
      name: X-Authorization
      in: header

````