1 /**
2 * @oas [post] /admin/campaigns
3 * operationId: PostCampaigns
4 * summary: Create Campaign
5 * description: Create a campaign.
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 * allOf:
29 * - type: object
30 * description: The campaign's details.
31 * required:
32 * - name
33 * - campaign_identifier
34 * - description
35 * - budget
36 * - starts_at
37 * - ends_at
38 * properties:
39 * name:
40 * type: string
41 * title: name
42 * description: The campaign's name.
43 * campaign_identifier:
44 * type: string
45 * title: campaign_identifier
46 * description: The campaign's identifier.
47 * description:
48 * type: string
49 * title: description
50 * description: The campaign's description.
51 * budget:
52 * type: object
53 * description: The campaign's budget which, when crossed, ends the campaign.
54 * required:
55 * - type
56 * - limit
57 * - currency_code
58 * properties:
59 * type:
60 * type: string
61 * title: type
62 * description: |
63 * The budget's type. This can't be edited later. Use `spend` to set a limit on the total amount discounted by the campaign's promotions. Use `usage` to set a limit on the total number of times the campaign's promotions can be used.
64 * enum:
65 * - spend
66 * - usage
67 * limit:
68 * type: number
69 * title: limit
70 * description: The campaign budget's limit.
71 * currency_code:
72 * type: string
73 * title: currency_code
74 * description: The campaign budget's currency code. This can't be edited later.
75 * starts_at:
76 * type: string
77 * title: starts_at
78 * description: The campaign's start date.
79 * format: date-time
80 * ends_at:
81 * type: string
82 * title: ends_at
83 * description: The campaign's end date.
84 * format: date-time
85 * promotions:
86 * type: array
87 * description: The campaign's promotions.
88 * items:
89 * type: object
90 * description: The promotions to add to the campaign.
91 * required:
92 * - id
93 * properties:
94 * id:
95 * type: string
96 * title: id
97 * description: A promotion's ID.
98 * - type: object
99 * description: The campaign's details.
100 * properties:
101 * additional_data:
102 * type: object
103 * description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
104 * description: The campaign's details.
105 * x-codeSamples:
106 * - lang: JavaScript
107 * label: JS SDK
108 * source: |-
109 * import Medusa from "@medusajs/js-sdk"
110 *
111 * export const sdk = new Medusa({
112 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
113 * debug: import.meta.env.DEV,
114 * auth: {
115 * type: "session",
116 * },
117 * })
118 *
119 * sdk.admin.campaign.create({
120 * name: "Summer Campaign"
121 * })
122 * .then(({ campaign }) => {
123 * console.log(campaign)
124 * })
125 * - lang: Shell
126 * label: cURL
127 * source: |-
128 * curl -X POST '{backend_url}/admin/campaigns' \
129 * -H 'Authorization: Bearer {jwt_token}' \
130 * -H 'Content-Type: application/json' \
131 * --data-raw '{
132 * "name": "Gunner",
133 * "campaign_identifier": "{value}",
134 * "description": "{value}",
135 * "starts_at": "2024-08-24T00:19:14.144Z",
136 * "ends_at": "2024-10-01T06:47:50.133Z"
137 * }'
138 * tags:
139 * - Campaigns
140 * responses:
141 * "200":
142 * description: OK
143 * content:
144 * application/json:
145 * schema:
146 * $ref: "#/components/schemas/AdminCampaignResponse"
147 * "400":
148 * $ref: "#/components/responses/400_error"
149 * "401":
150 * $ref: "#/components/responses/unauthorized"
151 * "404":
152 * $ref: "#/components/responses/not_found_error"
153 * "409":
154 * $ref: "#/components/responses/invalid_state_error"
155 * "422":
156 * $ref: "#/components/responses/invalid_request_error"
157 * "500":
158 * $ref: "#/components/responses/500_error"
159 * x-workflow: createCampaignsWorkflow
160 * x-events: []
161 *
162 */
163