The query attribute specifies a complex query that you can use to narrow down the search. A subset of these attributes can optionally be used to sort the returned results.
Attribute | Type | Sortable |
---|---|---|
campaignId | String | yes |
description | String | yes |
enabled | Boolean | yes |
couponId | String | no |
customerGroup | String | no |
sourceCode | String | no |
startDate | Date | no |
endDate | Date | no |
lastModified | Date | no |
These fields can only be used in queries as conjunctions (using AND
). If the field is used in a disjunction (OR
), an exception is thrown.
If you would like to get a raw Response object use the other campaignsSearch function.
An object containing the options for this method.
A promise of type CampaignSearchResult.
The query attribute specifies a complex query that you can use to narrow down the search. A subset of these attributes can optionally be used to sort the returned results.
Attribute | Type | Sortable |
---|---|---|
campaignId | String | yes |
description | String | yes |
enabled | Boolean | yes |
couponId | String | no |
customerGroup | String | no |
sourceCode | String | no |
startDate | Date | no |
endDate | Date | no |
lastModified | Date | no |
These fields can only be used in queries as conjunctions (using AND
). If the field is used in a disjunction (OR
), an exception is thrown.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type CampaignSearchResult otherwise.
If you would like to get a raw Response object use the other createCampaign function.
An object containing the options for this method.
A promise of type Campaign.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type Campaign otherwise.
If you would like to get a raw Response object use the other deleteCampaign function.
An object containing the options for this method.
A promise of type void.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type void otherwise.
If you would like to get a raw Response object use the other getCampaign function.
An object containing the options for this method.
A promise of type Campaign.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type Campaign otherwise.
If you would like to get a raw Response object use the other updateCampaign function.
An object containing the options for this method.
A promise of type Campaign.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type Campaign otherwise.
Generated using TypeDoc
Campaigns
*# API Overview
Campaigns enable experiences based on an optional schedule and qualifying criteria.
When an experience is assigned to a campaign, the schedule and qualifiers can only refine the containing campaign. A campaign is defined in the context of a site and is not shared among sites. A campaign can be enabled or disabled. A disabled campaign is inactive and not available to consumers. Enabled promotions contained within a disabled campaign are also inactive.
Qualifiers
Qualifiers are requirements that must be met to enable a campaign's experience.
For more details, see Qualifiers on the Salesforce B2C Commerce Infocenter.
Experiences
Promotion: A monetary discount or bonus item. Promotions can have additional criteria such as quantity or number of products gating the discount.
Authentication & Authorization
The client requesting the campaign information must have access to the Campaign resource. For resource access, you must use a client ID and client secret from Account Manager to request an access token. The access token is used as a bearer token and added to the Authorization header of your API request. The client must first authenticate against Account Manager to log in.
You must include the relevant scope(s) in the client ID used to generate the token. For details, see Authorization Scopes Catalog.
For detailed setup instructions, see Authorization for Admin APIs.
Use Cases
Flash Sales
Use single date promotions when you want to run a campaign for a short period of time.
For example, a '20% Off Black Friday' campaign enables a 20% off promotion for registered customers on Black Friday.
No Date or Time Restrictions
You can also configure promotions with no time or date restrictions. This is useful when running coupon-coded promotions, or qualifier-based promotions that require certain criteria to be met.
For example, a 'Free Shipping' campaign enables a free shipping promotion when the coupon code "freeship" is added to the cart.
Redirections
Use redirection promotions to trigger a promotion when a customer arrives at the storefront from a specific location. You may want to use this when partnering with other resources or running external advertisements.
For example, all users directed from Facebook receive a free hat with purchase.
For more information, see Use Source Codes as Qualifiers in the Salesforce B2C Commerce Infocenter.*
For instructions on how to retrieve access token for admin APIs: https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html
Example with admin auth
API Version: 1.4.4import { Campaigns, ClientConfig } from "commerce-sdk"; // or const { Campaigns, ClientConfig } = require("commerce-sdk"); const clientConfig: ClientConfig = { parameters: { clientId: "XXXXXX", organizationId: "XXXX", shortCode: "XXX", siteId: "XX" } }; token = { access_token: 'INSERT_ACCESS_TOKEN_HERE' }; clientConfig.headers['authorization'] = `Bearer ${token.access_token}`; const campaignsClient = new Campaigns(clientConfig);
Last Updated: