redeem-credit-balance
Method: POST
Path: /carts/{id}/credit-balance
Tags: Carts
Summary
Use credit balance
Description
Applies credit balance to reduce the cart total. Returns a fully updated Cart object. The amount can't exceed what the customer can spend now: their credit balance less what their unpaid orders have claimed and what is being refunded to them.
Storefront SDK Usage
SDK Method: sdk.cart.redeemCreditBalance()
Example:
const { data, error } = await sdk.cart.redeemCreditBalance(
{ id: "01H9CART12345ABCDE" },
{ credit_balance_used: 250.00 }
);
if (error) {
console.error("Failed to redeem credit balance:", error.message);
} else {
console.log("Credit applied, new total:", data.cart.grand_total);
console.log("Credit used:", data.cart.credit_balance_used);
}TypeScript Definition
"redeem-credit-balance": {
parameters: {
query?: never;
header?: {
/** @description Customer group used for loyalty eligibility when the signed-in user's session does not name a group. The session's group takes precedence. */
"x-customer-group-id"?: string;
};
path: {
/** @description Cart ID */
id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/**
* Format: double
* @description Cannot exceed the available customer credit balance or cart grand total. Accepts up to four decimal places.
* @example 200
*/
credit_balance_used: number;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
content: {
cart: components["schemas"]["CartRead"];
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
/** @description The active cart or requested customer resource was not found. */
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["CartRead"] | CartRead |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["NotFound"] | NotFound |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Parameters
- x-customer-group-id (header): Customer group used for loyalty eligibility when the signed-in user's session does not name a group. The session's group takes precedence.
Request Body
Content Types: application/json
Responses
200
OK
400
Bad request
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.
404
Requested resource not found
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
{
"tags": [
"Carts"
],
"operationId": "redeem-credit-balance",
"summary": "Use credit balance",
"description": "Applies credit balance to reduce the cart total. Returns a fully updated `Cart` object. The amount can't exceed what the customer can spend now: their credit balance less what their unpaid orders have claimed and what is being refunded to them.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/redeem-credit-balance",
"description": "API reference for the redeem-credit-balance operation"
},
"parameters": [
{
"name": "x-customer-group-id",
"in": "header",
"description": "Customer group used for loyalty eligibility when the signed-in user's session does not name a group. The session's group takes precedence.",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"credit_balance_used"
],
"properties": {
"credit_balance_used": {
"description": "Cannot exceed the available customer credit balance or cart grand total. Accepts up to four decimal places.",
"type": "number",
"format": "double",
"examples": [
200
],
"maximum": 99999999999.9999,
"minimum": 1
}
}
}
}
}
},
"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/CartRead"
}
},
"required": [
"cart"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"description": "The active cart or requested customer resource was not found.",
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "carts",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "redeemCreditBalance"
}Auto-generated from OpenAPI spec and TypeScript definitions