1 /**
2 * @oas [post] /admin/inventory-items
3 * operationId: PostInventoryItems
4 * summary: Create Inventory Item
5 * description: Create an inventory item.
6 * x-authenticated: true
7 * parameters:
8 * - name: fields
9 * in: query
10 * description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
11 * fields. without prefix it will replace the entire default fields.
12 * required: false
13 * schema:
14 * type: string
15 * title: fields
16 * description: Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
17 * fields. without prefix it will replace the entire default fields.
18 * externalDocs:
19 * url: "#select-fields-and-relations"
20 * security:
21 * - api_token: []
22 * - cookie_auth: []
23 * - jwt_token: []
24 * requestBody:
25 * content:
26 * application/json:
27 * schema:
28 * $ref: "#/components/schemas/AdminCreateInventoryItem"
29 * x-codeSamples:
30 * - lang: JavaScript
31 * label: JS SDK
32 * source: |-
33 * import Medusa from "@medusajs/js-sdk"
34 *
35 * export const sdk = new Medusa({
36 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
37 * debug: import.meta.env.DEV,
38 * auth: {
39 * type: "session",
40 * },
41 * })
42 *
43 * sdk.admin.inventoryItem.create({
44 * sku: "SHIRT"
45 * })
46 * .then(({ inventory_item }) => {
47 * console.log(inventory_item)
48 * })
49 * - lang: Shell
50 * label: cURL
51 * source: |-
52 * curl -X POST '{backend_url}/admin/inventory-items' \
53 * -H 'Authorization: Bearer {jwt_token}' \
54 * -H 'Content-Type: application/json' \
55 * --data-raw '{
56 * "sku": "{value}",
57 * "hs_code": "{value}",
58 * "weight": 2857134683324416,
59 * "length": 2322256963305472,
60 * "height": 8391220613087232,
61 * "width": 1297863250280448,
62 * "origin_country": "{value}",
63 * "mid_code": "{value}",
64 * "material": "{value}",
65 * "title": "{value}",
66 * "description": "{value}",
67 * "thumbnail": "{value}",
68 * "metadata": {}
69 * }'
70 * tags:
71 * - Inventory Items
72 * responses:
73 * "200":
74 * description: OK
75 * content:
76 * application/json:
77 * schema:
78 * $ref: "#/components/schemas/AdminInventoryItemResponse"
79 * "400":
80 * $ref: "#/components/responses/400_error"
81 * "401":
82 * $ref: "#/components/responses/unauthorized"
83 * "404":
84 * $ref: "#/components/responses/not_found_error"
85 * "409":
86 * $ref: "#/components/responses/invalid_state_error"
87 * "422":
88 * $ref: "#/components/responses/invalid_request_error"
89 * "500":
90 * $ref: "#/components/responses/500_error"
91 * x-workflow: createInventoryItemsWorkflow
92 * x-events:
93 * - name: inventory-item.created
94 * payload: |-
95 * ```ts
96 * {
97 * id, // The ID of the inventory item
98 * }
99 * ```
100 * description: Emitted when inventory items are created.
101 * deprecated: false
102 * since: 2.18.0
103 * - name: inventory-level.created
104 * payload: |-
105 * ```ts
106 * {
107 * id, // The ID of the inventory level
108 * }
109 * ```
110 * description: Emitted when inventory levels are created.
111 * deprecated: false
112 * since: 2.18.0
113 *
114 */
115