Skip to content

pos-create-cart

Method: POST
Path: /pos/carts

Tags: POS

Summary

Create cart

Description

Create cart

Pos SDK Usage

SDK Method: pos.createCart()

Example:

typescript
const { data, error } = await pos.createCart({
  items: [
    {
      product_id: "01H9XYZ12345ABCDE",
      variant_id: null,
      quantity: 2
    },
    {
      product_id: "01H9ABC67890FGHIJ",
      variant_id: "01H9XYZ67890KLMNO",
      quantity: 1
    }
  ],
  metadata: {
    "source": "pos-terminal-1",
    "staff_id": "staff-123"
  }
});

if (error) {
  console.error("Failed to create cart:", error.message);
} else {
  console.log("Cart created:", data.cart.id);
  console.log("Cart total:", data.cart.grand_total);
}

TypeScript Definition

typescript
"pos-create-cart": {
        parameters: {
            query?: never;
            header?: never;
            path?: never;
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": {
                    items: components["schemas"]["UpdateCartItem"][];
                    metadata?: {
                        [key: string]: string;
                    };
                };
            };
        };
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            cart: components["schemas"]["Cart"];
                        };
                    };
                };
            };
            400: components["responses"]["BadRequest"];
            401: components["responses"]["Unauthorized"];
            404: components["responses"]["NotFound"];
        };
    };

Component References

ReferenceResolves To
components["schemas"]["UpdateCartItem"]UpdateCartItem
components["schemas"]["Cart"]Cart
components["responses"]["BadRequest"]BadRequest
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["NotFound"]NotFound

Request Body

Content Types: application/json

Responses

200

OK

400

Bad request

401

Not authorized for given operation on the Resource

404

Requested resource not found

OpenAPI Definition

json
{
  "tags": [
    "POS"
  ],
  "operationId": "pos-create-cart",
  "summary": "Create cart",
  "description": "Create cart",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "items"
          ],
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/UpdateCartItem"
              }
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "cart": {
                    "$ref": "#/components/schemas/Cart"
                  }
                },
                "required": [
                  "cart"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "pos",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "createCart"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: