add-to-wishlist
Method: POST
Path: /wishlist/{user_id}
Tags: Carts
Summary
Add product to wishlist
Description
wishlist
Storefront SDK Usage
SDK Method: sdk.cart.addToWishlist()
Example:
typescript
const { data, error } = await sdk.cart.addToWishlist(
{ user_id: "01H9USER12345ABCDE" },
{
product_id: "01F3Z7KG06J4ACWH1C4926KJEC",
variant_id: null
}
);
if (error) {
console.error("Failed to add to wishlist:", error.message);
} else {
const products = data.products;
console.log("Item added to wishlist, total items:", products.length);
}TypeScript Definition
typescript
"add-to-wishlist": {
parameters: {
query?: never;
header?: never;
path: {
/** @description user id */
user_id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": {
/** @example 01F3Z7KG06J4ACWH1C4926KJEC */
product_id: string;
variant_id: string | null;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
content: {
products: components["schemas"]["Item"][];
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["Item"] | Item |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
Parameters
- user_id (path): user id
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": [
"Carts"
],
"operationId": "add-to-wishlist",
"summary": "Add product to wishlist",
"description": "wishlist",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/add-to-wishlist",
"description": "API reference for the add-to-wishlist operation"
},
"parameters": [
{
"name": "user_id",
"in": "path",
"description": "user id",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"product_id",
"variant_id"
],
"properties": {
"product_id": {
"type": "string",
"examples": [
"01F3Z7KG06J4ACWH1C4926KJEC"
]
},
"variant_id": {
"type": [
"string",
"null"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"products": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Item"
}
}
},
"required": [
"products"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "carts",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "addToWishlist"
}Auto-generated from OpenAPI spec and TypeScript definitions