1 /**
2 * @oas [post] /admin/shipping-options
3 * operationId: PostShippingOptions
4 * summary: Create Shipping Option
5 * description: Create a shipping option.
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 * oneOf:
29 * - $ref: "#/components/schemas/AdminCreateFlatRateShippingOption"
30 * - $ref: "#/components/schemas/AdminCreateCalculatedShippingOption"
31 * description: The shipping option's details.
32 * x-codeSamples:
33 * - lang: JavaScript
34 * label: JS SDK
35 * source: |-
36 * import Medusa from "@medusajs/js-sdk"
37 *
38 * export const sdk = new Medusa({
39 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
40 * debug: import.meta.env.DEV,
41 * auth: {
42 * type: "session",
43 * },
44 * })
45 *
46 * sdk.admin.shippingOption.create({
47 * name: "Standard Shipping",
48 * profile_id: "shp_123",
49 * })
50 * .then(({ shipping_option }) => {
51 * console.log(shipping_option)
52 * })
53 * - lang: Shell
54 * label: cURL
55 * source: |-
56 * curl -X POST '{backend_url}/admin/shipping-options' \
57 * -H 'Authorization: Bearer {jwt_token}' \
58 * -H 'Content-Type: application/json' \
59 * --data-raw '{
60 * "name": "Julie",
61 * "service_zone_id": "{value}",
62 * "shipping_profile_id": "{value}",
63 * "price_type": "{value}",
64 * "provider_id": "{value}",
65 * "type": {
66 * "label": "{value}",
67 * "description": "{value}",
68 * "code": "{value}"
69 * },
70 * "prices": []
71 * }'
72 * tags:
73 * - Shipping Options
74 * responses:
75 * "200":
76 * description: OK
77 * content:
78 * application/json:
79 * schema:
80 * $ref: "#/components/schemas/AdminShippingOptionResponse"
81 * "400":
82 * $ref: "#/components/responses/400_error"
83 * "401":
84 * $ref: "#/components/responses/unauthorized"
85 * "404":
86 * $ref: "#/components/responses/not_found_error"
87 * "409":
88 * $ref: "#/components/responses/invalid_state_error"
89 * "422":
90 * $ref: "#/components/responses/invalid_request_error"
91 * "500":
92 * $ref: "#/components/responses/500_error"
93 * x-workflow: createShippingOptionsWorkflow
94 * x-events:
95 * - name: shipping-option.created
96 * payload: |-
97 * ```ts
98 * {
99 * id, // The ID of the shipping option
100 * }
101 * ```
102 * description: Emitted when shipping options are created.
103 * deprecated: false
104 * since: 2.12.4
105 *
106 */
107