1 get:
2 operationId: GetPromotionsId
3 summary: Get a Promotion
4 description: >-
5 Retrieve a promotion by its ID. You can expand the promotion's relations or
6 select the fields that should be returned.
7 x-authenticated: true
8 parameters:
9 - name: id
10 in: path
11 description: The promotion's ID.
12 required: true
13 schema:
14 type: string
15 - name: fields
16 in: query
17 description: >-
18 Comma-separated fields that should be included in the returned data. if
19 a field is prefixed with `+` it will be added to the default fields,
20 using `-` will remove it from the default fields. without prefix it will
21 replace the entire default fields.
22 required: false
23 schema:
24 type: string
25 title: fields
26 description: >-
27 Comma-separated fields that should be included in the returned data.
28 if a field is prefixed with `+` it will be added to the default
29 fields, using `-` will remove it from the default fields. without
30 prefix it will replace the entire default fields.
31 externalDocs:
32 url: '#select-fields-and-relations'
33 security:
34 - api_token: []
35 - cookie_auth: []
36 - jwt_token: []
37 x-codeSamples:
38 - lang: JavaScript
39 label: JS SDK
40 source:
41 $ref: ../code_samples/JavaScript/admin_promotions_{id}/get.js
42 - lang: Shell
43 label: cURL
44 source:
45 $ref: ../code_samples/Shell/admin_promotions_{id}/get.sh
46 tags:
47 - Promotions
48 responses:
49 '200':
50 description: OK
51 content:
52 application/json:
53 schema:
54 $ref: ../components/schemas/AdminPromotionResponse.yaml
55 '400':
56 $ref: ../components/responses/400_error.yaml
57 '401':
58 $ref: ../components/responses/unauthorized.yaml
59 '404':
60 $ref: ../components/responses/not_found_error.yaml
61 '409':
62 $ref: ../components/responses/invalid_state_error.yaml
63 '422':
64 $ref: ../components/responses/invalid_request_error.yaml
65 '500':
66 $ref: ../components/responses/500_error.yaml
67 post:
68 operationId: PostPromotionsId
69 summary: Update a Promotion
70 description: Update a promotion's details.
71 x-authenticated: true
72 parameters:
73 - name: id
74 in: path
75 description: The promotion's ID.
76 required: true
77 schema:
78 type: string
79 - name: fields
80 in: query
81 description: >-
82 Comma-separated fields that should be included in the returned data. if
83 a field is prefixed with `+` it will be added to the default fields,
84 using `-` will remove it from the default fields. without prefix it will
85 replace the entire default fields.
86 required: false
87 schema:
88 type: string
89 title: fields
90 description: >-
91 Comma-separated fields that should be included in the returned data.
92 if a field is prefixed with `+` it will be added to the default
93 fields, using `-` will remove it from the default fields. without
94 prefix it will replace the entire default fields.
95 externalDocs:
96 url: '#select-fields-and-relations'
97 security:
98 - api_token: []
99 - cookie_auth: []
100 - jwt_token: []
101 requestBody:
102 content:
103 application/json:
104 schema:
105 allOf:
106 - type: object
107 description: The properties to update in a promotion.
108 required:
109 - campaign_id
110 properties:
111 code:
112 type: string
113 title: code
114 description: The promotion's code.
115 is_automatic:
116 type: boolean
117 title: is_automatic
118 description: Whether the promotion is applied automatically.
119 type:
120 type: string
121 description: The promotion's type.
122 externalDocs:
123 url: >-
124 https://docs.medusajs.com/resources/commerce-modules/promotion/concepts#what-is-a-promotion
125 enum:
126 - standard
127 - buyget
128 campaign_id:
129 type: string
130 title: campaign_id
131 description: The ID of the campaign that the promotion belongs to.
132 application_method:
133 type: object
134 description: The properties to update in the application method.
135 required:
136 - id
137 - description
138 - max_quantity
139 - currency_code
140 - apply_to_quantity
141 - buy_rules_min_quantity
142 properties:
143 id:
144 type: string
145 title: id
146 description: The application method's ID.
147 description:
148 type: string
149 title: description
150 description: The application method's description.
151 value:
152 type: number
153 title: value
154 description: >-
155 The discounted amount applied by the associated
156 promotion based on the `type`.
157 max_quantity:
158 type: number
159 title: max_quantity
160 description: >-
161 The max quantity allowed in the cart for the associated
162 promotion to be applied.
163 currency_code:
164 type: string
165 title: currency_code
166 description: The application method's currency code.
167 type:
168 type: string
169 description: >-
170 The type of the application method indicating how the
171 associated promotion is applied.
172 enum:
173 - fixed
174 - percentage
175 target_type:
176 type: string
177 description: >-
178 The target type of the application method indicating
179 whether the associated promotion is applied to the
180 cart's items, shipping methods, or the whole order.
181 enum:
182 - order
183 - shipping_methods
184 - items
185 allocation:
186 type: string
187 description: >-
188 The allocation value that indicates whether the
189 associated promotion is applied on each item in a cart
190 or split between the items in the cart.
191 enum:
192 - each
193 - across
194 apply_to_quantity:
195 type: number
196 title: apply_to_quantity
197 description: >-
198 The quantity that results from matching the `buyget`
199 promotion's condition. For example, if the promotion is
200 a "Buy 2 shirts get 1 free", the value f this attribute
201 is `1`.
202 buy_rules_min_quantity:
203 type: number
204 title: buy_rules_min_quantity
205 description: >-
206 The minimum quantity required for a `buyget` promotion
207 to be applied. For example, if the promotion is a "Buy 2
208 shirts get 1 free", the value of this attribute is `2`.
209 - type: object
210 description: The properties to update in a promotion.
211 properties:
212 additional_data:
213 type: object
214 description: >-
215 Pass additional custom data to the API route. This data is
216 passed to the underlying workflow under the
217 `additional_data` parameter.
218 description: The properties to update in a promotion.
219 x-codeSamples:
220 - lang: JavaScript
221 label: JS SDK
222 source:
223 $ref: ../code_samples/JavaScript/admin_promotions_{id}/post.js
224 - lang: Shell
225 label: cURL
226 source:
227 $ref: ../code_samples/Shell/admin_promotions_{id}/post.sh
228 tags:
229 - Promotions
230 responses:
231 '200':
232 description: OK
233 content:
234 application/json:
235 schema:
236 $ref: ../components/schemas/AdminPromotionResponse.yaml
237 '400':
238 $ref: ../components/responses/400_error.yaml
239 '401':
240 $ref: ../components/responses/unauthorized.yaml
241 '404':
242 $ref: ../components/responses/not_found_error.yaml
243 '409':
244 $ref: ../components/responses/invalid_state_error.yaml
245 '422':
246 $ref: ../components/responses/invalid_request_error.yaml
247 '500':
248 $ref: ../components/responses/500_error.yaml
249 x-workflow: updatePromotionsWorkflow
250 x-events: []
251 delete:
252 operationId: DeletePromotionsId
253 summary: Delete a Promotion
254 description: Delete a promotion.
255 x-authenticated: true
256 parameters:
257 - name: id
258 in: path
259 description: The promotion's ID.
260 required: true
261 schema:
262 type: string
263 security:
264 - api_token: []
265 - cookie_auth: []
266 - jwt_token: []
267 x-codeSamples:
268 - lang: JavaScript
269 label: JS SDK
270 source:
271 $ref: ../code_samples/JavaScript/admin_promotions_{id}/delete.js
272 - lang: Shell
273 label: cURL
274 source:
275 $ref: ../code_samples/Shell/admin_promotions_{id}/delete.sh
276 tags:
277 - Promotions
278 responses:
279 '200':
280 description: OK
281 content:
282 application/json:
283 schema:
284 type: object
285 description: The deletion's details.
286 required:
287 - id
288 - object
289 - deleted
290 properties:
291 id:
292 type: string
293 title: id
294 description: The promotion's ID.
295 object:
296 type: string
297 title: object
298 description: The name of the deleted object.
299 default: promotion
300 deleted:
301 type: boolean
302 title: deleted
303 description: Whether the promotion was deleted.
304 '400':
305 $ref: ../components/responses/400_error.yaml
306 '401':
307 $ref: ../components/responses/unauthorized.yaml
308 '404':
309 $ref: ../components/responses/not_found_error.yaml
310 '409':
311 $ref: ../components/responses/invalid_state_error.yaml
312 '422':
313 $ref: ../components/responses/invalid_request_error.yaml
314 '500':
315 $ref: ../components/responses/500_error.yaml
316 x-workflow: deletePromotionsWorkflow
317 x-events: []