Skip to main content

Adding a campaign

Adding a campaign​

Overview​

  • Call name: add-campaign
  • Endpoint URL: https://{API hostname}/internal/add-campaign
  • Request methods: Form POST or JSON POST
  • Auth required: yes

This API call creates a new campaign. Campaigns are a generic mechanism for doing time based discounting and personal pricing actions. There are multiple types of campaigns.

HTTP Parameters​

The following HTTP parameters can be passed to the API:

business_id or chain_id (mandatory, not both) the ID of the business or chain (entity) which the campaign is to be associated with.

type (mandatory) A string which indicates the campaign type. The following types are allowed:

  • basket
  • birthday
  • cashback
  • competition
  • composable
  • content
  • interaction
  • item_purchase_count
  • login
  • loyalty
  • matching_item
  • mobile_content
  • points_wallet
  • product
  • profile_completion
  • progress
  • purchase_count
  • referral
  • signup
  • subscription
  • issue_rewards
  • wallet

Different campaign types in Spaaza require different parameters to be passed. For a detailed breakdown of campaign types and fields see this page

is_default (boolean, optional) For loyalty, wallet, and points_wallet campaign types, this flag marks the campaign as the default for its chain. For loyalty campaigns, only one active default loyalty campaign is allowed per chain. Attempting to create a second active default loyalty campaign for the same chain will return a parameter_invalid error.

Permissions​

The performing user needs to be logged in and have write access to the entity (business or chain) to which the campaign is connected and the user must have permissions_business_chain_campaign set to true in the permissions table.

If the chain has restrict_campaign_enable set to true, creating a campaign with active set to true additionally requires the campaign_enable permission (or super user access). Without campaign_enable, the user can still create campaigns but only in an inactive state.

Output​

Returns an OK code and a JSON representation of the newly created campaign. Note that it includes a rules field which will hold information about each rule that is part of this campaign. Rules are optional for basket campaigns and can be provided inline in the add-campaign call or added later. Passing null or an empty array clears any existing rules.

Returns an OK code and a JSON representation of the newly created campaign. A sample is below:


{
"result": {
"code": 1,
"status": "ok"
},
"results": {
"campaign": {
"id": 2,
"chain_id": 1,
"title": "ACME Login Campaign",
"description": "€10 reward for logging into our app for the first time",
"active": true,
"active_time_from": "12:13",
"active_time_until": "13:14",
"active_weekdays": "7",
"operator_type": "or",
"created_date": "2021-04-02T11:58:15+00:00",
"last_modified_date": "2021-04-02T11:58:15+00:00",
"rounding_strategy": "neutral",
"rounding_precision": 2,
"created_voucher_claimed_by_default": false,
"voucher_expiry_days": 365,
"excludes_assignment_matches": false,
"recipient_reward_method": "voucher",
"recipient_reward_amount": 5,
"recipient_reward_discount_ratio": 0,
"user_channel": "mobile:ios",
"currency": {
"currency_id": 2,
"currency_code": "EUR",
"currency_name_en": "Euro",
"currency_symbol": "\u20ac"
},
"is_active": false,
"is_deleted": false,
"is_default": false,
"excludes_referred_users": false,
"visible_to_all_user_segments": true,
"type": "login",
"max_basket_discount_amount": null,
"minimum_basket_total_value_earn": 0,
"maximum_basket_total_value_earn": null,
"minimum_basket_total_value_spend": null,
"maximum_basket_total_value_spend": null,
"redemption_grace_period": 0,
"last_updated_date": null,
"field_localisations": null,
"assignment_count": 0,
"parameters": [],
"image_filename": null,
"image_url": null,
"image_link": null,
"image_dimension_x": null,
"image_dimension_y": null,
"supports_contribution": false,
"is_contributor": false,
"recipient_campaign_id": null,
"supports_user_segments": true,
"user_segment_id": null,
"excluded_user_segment_id": null,
"voucher_title": null,
"voucher_description": null,
"voucher_notes": null,
"voucher_text": null,
"voucher_image_url": null
},
"result_type": "add-campaign"
}
}