get-variant-detail
Method: GET
Path: /catalog/products/{product_id}/variants/{variant_id}
Tags: Products
Summary
Retrieve variant detail
Description
Retrieves the details of a particular variant. Product slug is supported in place of product ID, and variant slug in place of variant ID, in the path.
Storefront SDK Usage
SDK Method: sdk.catalog.getVariantDetail()
Example:
// By product ID and variant ID
const { data, error } = await sdk.catalog.getVariantDetail(
{
product_id: "prod_123",
variant_id: "var_456"
}
);
if (error) {
console.error("Failed to get variant details:", error);
return;
}
console.log("Variant:", data.variant.name);
console.log("SKU:", data.variant.sku);
console.log("Price:", data.variant.pricing?.selling_price);
console.log("Stock available:", data.variant.stock_available);
// By product slug and variant slug (also accepted in place of IDs)
const { data: slugData, error: slugError } = await sdk.catalog.getVariantDetail(
{
product_id: "detox-candy",
variant_id: "detox-candy-100g"
}
);TypeScript Definition
"get-variant-detail": {
parameters: {
query?: {
/** @description Determines whether to include or exclude inventory details in response json */
inventory?: boolean;
};
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: {
/** @description Product ID or product slug. Either is accepted in the path. */
product_id: string;
/** @description Variant ID or variant slug. Either is accepted in the path. */
variant_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Success response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @example Products retrieved successfully. */
message: string;
success: boolean;
content: {
variant: components["schemas"]["VariantDetail"];
};
};
};
};
/** @description The request parameters or customer group are invalid. */
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["CustomerGroupId"] | CustomerGroupId |
components["schemas"]["VariantDetail"] | VariantDetail |
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): 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.
- inventory (query): Determines whether to include or exclude inventory details in response json
- product_id (path): Product ID or product slug. Either is accepted in the path.
- variant_id (path): Variant ID or variant slug. Either is accepted in the path.
Responses
200
Success response
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": [
"Products"
],
"operationId": "get-variant-detail",
"summary": "Retrieve variant detail",
"description": "Retrieves the details of a particular variant. Product slug is supported in place of product ID, and variant slug in place of variant ID, in the path.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/get-variant-detail",
"description": "API reference for the get-variant-detail operation"
},
"parameters": [
{
"$ref": "#/components/parameters/CustomerGroupId"
},
{
"name": "inventory",
"in": "query",
"description": "Determines whether to include or exclude inventory details in response json",
"schema": {
"type": "boolean"
}
},
{
"name": "product_id",
"in": "path",
"description": "Product ID or product slug. Either is accepted in the path.",
"required": true,
"schema": {
"type": "string",
"examples": [
"01H7YK0C86V9PGT0HXRJVEZXJQ",
"detox-candy"
],
"minLength": 1
}
},
{
"name": "variant_id",
"in": "path",
"description": "Variant ID or variant slug. Either is accepted in the path.",
"required": true,
"schema": {
"type": "string",
"examples": [
"01H7YK0D12ABC123VARIANT456",
"large-blue"
],
"minLength": 1
}
}
],
"responses": {
"200": {
"description": "Success response",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string",
"examples": [
"Products retrieved successfully."
]
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"variant": {
"$ref": "#/components/schemas/VariantDetail"
}
},
"required": [
"variant"
],
"type": "object"
}
}
}
}
},
"links": {
"AddVariantToCart": {
"operationId": "update-cart",
"requestBody": {
"product_id": "$request.path.product_id",
"variant_id": "$request.path.variant_id"
},
"description": "Add this variant to a cart."
}
}
},
"400": {
"description": "The request parameters or customer group are invalid.",
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
},
{
"X-Api-Key": []
}
],
"x-speakeasy-group": "catalog",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "getVariantDetail"
}Auto-generated from OpenAPI spec and TypeScript definitions