import { ProductVariantPricesCreateReq } from "../../../../types/product-variant"; /** * @oas [post] /products/{id}/variants * operationId: "PostProductsProductVariants" * summary: "Create a Product Variant" * description: "Creates a Product Variant. Each Product Variant must have a unique combination of Product Option Values." * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Product. * requestBody: * content: * application/json: * schema: * required: * - title * - prices * - options * properties: * title: * description: The title to identify the Product Variant by. * type: string * sku: * description: The unique SKU for the Product Variant. * type: string * ean: * description: The EAN number of the item. * type: string * upc: * description: The UPC number of the item. * type: string * barcode: * description: A generic GTIN field for the Product Variant. * type: string * hs_code: * description: The Harmonized System code for the Product Variant. * type: string * inventory_quantity: * description: The amount of stock kept for the Product Variant. * type: integer * default: 0 * allow_backorder: * description: Whether the Product Variant can be purchased when out of stock. * type: boolean * manage_inventory: * description: Whether Medusa should keep track of the inventory for this Product Variant. * type: boolean * weight: * description: The wieght of the Product Variant. * type: number * length: * description: The length of the Product Variant. * type: number * height: * description: The height of the Product Variant. * type: number * width: * description: The width of the Product Variant. * type: number * origin_country: * description: The country of origin of the Product Variant. * type: string * mid_code: * description: The Manufacturer Identification code for the Product Variant. * type: string * material: * description: The material composition of the Product Variant. * type: string * metadata: * description: An optional set of key-value pairs with additional information. * type: object * prices: * type: array * items: * required: * - amount * properties: * id: * description: The ID of the price. * type: string * region_id: * description: The ID of the Region for which the price is used. Only required if currency_code is not provided. * type: string * currency_code: * description: The 3 character ISO currency code for which the price will be used. Only required if region_id is not provided. * type: string * externalDocs: * url: https://en.wikipedia.org/wiki/ISO_4217#Active_codes * description: See a list of codes. * amount: * description: The amount to charge for the Product Variant. * type: integer * min_quantity: * description: The minimum quantity for which the price will be used. * type: integer * max_quantity: * description: The maximum quantity for which the price will be used. * type: integer * options: * type: array * items: * required: * - option_id * - value * properties: * option_id: * description: The ID of the Product Option to set the value for. * type: string * value: * description: The value to give for the Product Option. * type: string * x-codeSamples: * - lang: JavaScript * label: JS Client * source: | * import Medusa from "@medusajs/medusa-js" * const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) * // must be previously logged in or use api token * medusa.admin.products.createVariant(product_id, { * title: 'Color', * prices: [ * { * amount: 1000, * currency_code: "eur" * } * ], * options: [ * { * option_id, * value: 'S' * } * ], * inventory_quantity: 100 * }) * .then(({ product }) => { * console.log(product.id); * }); * - lang: Shell * label: cURL * source: | * curl --location --request POST 'https://medusa-url.com/admin/products/{id}/variants' \ * --header 'Authorization: Bearer {api_token}' \ * --header 'Content-Type: application/json' \ * --data-raw '{ * "title": "Color", * "prices": [ * { * "amount": 1000, * "currency_code": "eur" * } * ], * "options": [ * { * "option_id": "asdasf", * "value": "S" * } * ] * }' * security: * - api_token: [] * - cookie_auth: [] * tags: * - Product * responses: * 200: * description: OK * content: * application/json: * schema: * properties: * product: * $ref: "#/components/schemas/product" * "400": * $ref: "#/components/responses/400_error" * "401": * $ref: "#/components/responses/unauthorized" * "404": * $ref: "#/components/responses/not_found_error" * "409": * $ref: "#/components/responses/invalid_state_error" * "422": * $ref: "#/components/responses/invalid_request_error" * "500": * $ref: "#/components/responses/500_error" */ declare const _default: (req: any, res: any) => Promise; export default _default; declare class ProductVariantOptionReq { value: string; option_id: string; } export declare class AdminPostProductsProductVariantsReq { title: string; sku?: string; ean?: string; upc?: string; barcode?: string; hs_code?: string; inventory_quantity: number; allow_backorder?: boolean; manage_inventory?: boolean; weight?: number; length?: number; height?: number; width?: number; origin_country?: string; mid_code?: string; material?: string; metadata?: Record; prices: ProductVariantPricesCreateReq[]; options: ProductVariantOptionReq[]; }