Skip to content

list-promotions ​

Method: GET
Path: /carts/available-promotions

Tags: Carts

Summary ​

Retrieve all promotions

Description ​

All active promotions

Storefront SDK Usage ​

SDK Method: sdk.cart.getAvailablePromotions()

Example:

typescript
// Get all available promotions
const { data, error } = await sdk.cart.getAvailablePromotions();

if (error) {
  console.error("Failed to get available promotions:", error.message);
} else {
  const promotions = data.promotions || [];
  console.log("Available promotions:", promotions.length);
  promotions.forEach(promotion => {
    console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
  });
}

// Override customer group ID for this specific request
const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
  "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
});

TypeScript Definition ​

typescript
"list-promotions": {
        parameters: {
            query?: never;
            header?: {
                /** @description This param is used to determine product pricing, promotions, and subscription rates.  If a valid customer group id is provided, pricing details will be retrieved accordingly.  If no matching data is found for the specified customer group id, the system will fall back to the default customer group id.  If no data is found for the default group either, the highest applicable price will be returned. */
                "x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
            };
            path?: never;
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description OK */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            promotions: components["schemas"]["Promotion"][];
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
        };
    };

Component References ​

ReferenceResolves To
components["parameters"]["CustomerGroupId"]CustomerGroupId
components["schemas"]["Promotion"]Promotion
components["responses"]["Unauthorized"]Unauthorized

Parameters ​

  • x-customer-group-id (header): This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned.

Responses ​

200 ​

OK

401 ​

Not authorized for given operation on the Resource

OpenAPI Definition ​

json
{
  "tags": [
    "Carts"
  ],
  "operationId": "list-promotions",
  "summary": "Retrieve all promotions",
  "description": "All active promotions",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/list-promotions",
    "description": "API reference for the list-promotions operation"
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/CustomerGroupId"
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "promotions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Promotion"
                    }
                  }
                },
                "required": [
                  "promotions"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "carts",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "listPromotions"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: