import { ProductVariantPricesCreateReq } from "../../../../types/product-variant"; import { ProductSalesChannelReq, ProductTagReq, ProductTypeReq } from "../../../../types/product"; import { ProductStatus } from "../../../../models"; /** * @oas [post] /products * operationId: "PostProducts" * summary: "Create a Product" * x-authenticated: true * description: "Creates a Product" * requestBody: * content: * application/json: * schema: * required: * - title * properties: * title: * description: "The title of the Product" * type: string * subtitle: * description: "The subtitle of the Product" * type: string * description: * description: "A description of the Product." * type: string * is_giftcard: * description: A flag to indicate if the Product represents a Gift Card. Purchasing Products with this flag set to `true` will result in a Gift Card being created. * type: boolean * default: false * discountable: * description: A flag to indicate if discounts can be applied to the LineItems generated from this Product * type: boolean * default: true * images: * description: Images of the Product. * type: array * items: * type: string * thumbnail: * description: The thumbnail to use for the Product. * type: string * handle: * description: A unique handle to identify the Product by. * type: string * status: * description: The status of the product. * type: string * enum: [draft, proposed, published, rejected] * default: draft * type: * description: The Product Type to associate the Product with. * type: object * required: * - value * properties: * id: * description: The ID of the Product Type. * type: string * value: * description: The value of the Product Type. * type: string * collection_id: * description: The ID of the Collection the Product should belong to. * type: string * tags: * description: Tags to associate the Product with. * type: array * items: * required: * - value * properties: * id: * description: The ID of an existing Tag. * type: string * value: * description: The value of the Tag, these will be upserted. * type: string * sales_channels: * description: "[EXPERIMENTAL] Sales channels to associate the Product with." * type: array * items: * required: * - id * properties: * id: * description: The ID of an existing Sales channel. * type: string * options: * description: The Options that the Product should have. These define on which properties the Product's Product Variants will differ. * type: array * items: * required: * - title * properties: * title: * description: The title to identify the Product Option by. * type: string * variants: * description: A list of Product Variants to create with the Product. * type: array * items: * required: * - title * 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: * 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: * - value * properties: * value: * description: The value to give for the Product Option at the same index in the Product's `options` field. * type: string * weight: * description: The weight of the Product. * type: number * length: * description: The length of the Product. * type: number * height: * description: The height of the Product. * type: number * width: * description: The width of the Product. * type: number * hs_code: * description: The Harmonized System code for the Product Variant. * type: string * origin_country: * description: The country of origin of the Product. * type: string * mid_code: * description: The Manufacturer Identification code for the Product. * type: string * material: * description: The material composition of the Product. * type: string * metadata: * description: An optional set of key-value pairs with additional information. * type: object * 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.create({ * title: 'Shirt', * is_giftcard: false, * discountable: true * }) * .then(({ product }) => { * console.log(product.id); * }); * - lang: Shell * label: cURL * source: | * curl --location --request POST 'https://medusa-url.com/admin/products' \ * --header 'Authorization: Bearer {api_token}' \ * --header 'Content-Type: application/json' \ * --data-raw '{ * "title": "Shirt" * }' * 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; } declare class ProductOptionReq { title: string; } declare class ProductVariantReq { 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[]; } export declare class AdminPostProductsReq { title: string; subtitle?: string; description?: string; is_giftcard: boolean; discountable: boolean; images?: string[]; thumbnail?: string; handle?: string; status?: ProductStatus; type?: ProductTypeReq; collection_id?: string; tags?: ProductTagReq[]; sales_channels?: ProductSalesChannelReq[]; options?: ProductOptionReq[]; variants?: ProductVariantReq[]; weight?: number; length?: number; height?: number; width?: number; hs_code?: string; origin_country?: string; mid_code?: string; material?: string; metadata?: Record; }