import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.campaign.create({
name: "Summer Campaign"
})
.then(({ campaign }) => {
console.log(campaign)
}){
"campaign": {
"id": "<string>",
"name": "<string>",
"description": "<string>",
"currency": "<string>",
"campaign_identifier": "<string>",
"starts_at": "<string>",
"ends_at": "<string>",
"budget": {
"id": "<string>",
"type": "spend",
"currency_code": "<string>",
"limit": 123,
"used": 123,
"attribute": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Create a campaign.
import Switchyard from "@switchyard/js-sdk"
export const sdk = new Medusa({
baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
debug: import.meta.env.DEV,
auth: {
type: "session",
},
})
sdk.admin.campaign.create({
name: "Summer Campaign"
})
.then(({ campaign }) => {
console.log(campaign)
}){
"campaign": {
"id": "<string>",
"name": "<string>",
"description": "<string>",
"currency": "<string>",
"campaign_identifier": "<string>",
"starts_at": "<string>",
"ends_at": "<string>",
"budget": {
"id": "<string>",
"type": "spend",
"currency_code": "<string>",
"limit": 123,
"used": 123,
"attribute": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
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 fields. without prefix it will replace the entire default fields.
The campaign's details.
The campaign's name.
The campaign's identifier.
The campaign's description.
The campaign's budget which, when crossed, ends the campaign.
Show child attributes
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.
spend, usage The campaign budget's limit.
The campaign budget's currency code. This can't be edited later.
The campaign's start date.
The campaign's end date.
Pass additional custom data to the API route. This data is passed to the underlying workflow under the additional_data parameter.
OK
The campaign's details.
The campaign's details.
Show child attributes
The campaign's ID.
The campaign's name.
The campaign's description.
The campaign's currency.
The campaign's identifier.
The date and time that the campaign starts.
The date and time that the campaign ends.
The campaign's budget.
Show child attributes
The budget's ID.
The budget's type. spend means the limit is set on the total amount discounted by the campaign's promotions; usage means the limit is set on the total number of times the campaign's promotions can be used.
spend, usage The budget's currency code.
The budget's limit.
How much of the budget has been used. If the limit is spend, this property holds the total amount discounted so far. If the limit is usage, it holds the number of times the campaign's promotions have been used so far.
The cart attribute to limit the budget by.
The date the campaign was created.
The date the campaign was updated.
The date the campaign was deleted.