Skip to content

pos-get-user-cart ​

Method: GET
Path: /pos/carts/users/{user_id}

Tags: Carts

Summary ​

Retrieve cart by user ID

Description ​

Retrieves the active Cart for this user. Returns cart: null when no active cart exists. Refresh failures return 500 rather than cart:null.

Pos SDK Usage ​

SDK Method: pos.getUserCart()

Example:

typescript
const { data, error } = await pos.getUserCart({
  user_id: "01H9CART12345ABCDE"
});

if (error) {
  console.error("Failed to get user cart:", error.message);
} else {
  console.log("User cart ID:", data.cart?.id);
  console.log("Cart value:", data.cart?.subtotal);
}

TypeScript Definition ​

typescript
"pos-get-user-cart": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description User ID */
                user_id: string;
            };
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @example cart details */
                        message: $Read<string>;
                        success: $Read<boolean>;
                        content: {
                            cart: components["schemas"]["CartRead"] | null;
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
            403: components["responses"]["Forbidden"];
            408: components["responses"]["RequestTimeout"];
            500: components["responses"]["InternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["CartRead"]CartRead
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["RequestTimeout"]RequestTimeout
components["responses"]["InternalServerError"]InternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

Parameters ​

  • user_id (path): User ID

Responses ​

200 ​

OK

401 ​

Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.

403 ​

Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.

408 ​

500 ​

The request failed because of an unexpected error.

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "operationId": "pos-get-user-cart",
  "summary": "Retrieve cart by user ID",
  "description": "Retrieves the active `Cart` for this user. Returns `cart: null` when no active cart exists. Refresh failures return 500 rather than cart:null.",
  "parameters": [
    {
      "name": "user_id",
      "in": "path",
      "description": "User ID",
      "required": true,
      "schema": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9_-]{1,128}$"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string",
                "examples": [
                  "cart details"
                ],
                "readOnly": true
              },
              "success": {
                "type": "boolean",
                "readOnly": true
              },
              "content": {
                "properties": {
                  "cart": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/CartRead"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "cart"
                ],
                "type": "object"
              }
            },
            "required": [
              "message",
              "success",
              "content"
            ]
          }
        }
      },
      "links": {
        "AddItemToUserCart": {
          "operationId": "pos-update-cart",
          "parameters": {
            "id": "$response.body#/content/cart/id"
          },
          "description": "Add items to the user's cart."
        },
        "SetUserCartAddress": {
          "operationId": "pos-create-cart-address",
          "parameters": {
            "id": "$response.body#/content/cart/id"
          },
          "description": "Set billing and shipping address on the user's cart."
        },
        "SetUserCartFulfillment": {
          "operationId": "pos-update-fulfillment-preference",
          "parameters": {
            "id": "$response.body#/content/cart/id"
          },
          "description": "Set the fulfillment preference on the user's cart."
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "408": {
      "$ref": "#/components/responses/RequestTimeout"
    },
    "500": {
      "$ref": "#/components/responses/InternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/admin-pos/operations/pos-get-user-cart"
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "tags": [
    "Carts"
  ],
  "x-speakeasy-group": "pos",
  "x-speakeasy-name-override": "getUserCart"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: