Skip to main content
POST
/
v1
/
templates
/
campaigns
/
{campaignTemplateId}
/
campaign-setup
Create Campaign From Template
curl --request POST \
  --url https://{cluster}.voucherify.io/v1/templates/campaigns/{campaignTemplateId}/campaign-setup \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-App-Id: <api-key>' \
  --header 'X-App-Token: <api-key>' \
  --data '{
  "name": "Campaign-out-of-template",
  "description": "Created out of a template",
  "auto_join": true,
  "join_once": true
}'
{
  "created_resources": [
    {
      "id": "val_3LBFw25WTmAK",
      "object": "validation_rules"
    }
  ],
  "campaign": {
    "id": "camp_txDwyDPeLvBEq490bfV2nLwo",
    "name": "Campaign-out-of-template",
    "campaign_type": "DISCOUNT_COUPONS",
    "type": "AUTO_UPDATE",
    "is_referral_code": false,
    "voucher": {
      "type": "DISCOUNT_VOUCHER",
      "discount": {
        "type": "AMOUNT",
        "amount_off": 2500,
        "aggregated_amount_limit": 25000,
        "units": null,
        "effect": "APPLY_TO_ITEMS"
      },
      "gift": null,
      "loyalty_card": null,
      "redemption": {
        "quantity": 4,
        "redeemed_quantity": 0
      },
      "code_config": {
        "pattern": "##",
        "length": 2,
        "charset": "xD",
        "prefix": "U-",
        "postfix": "-WOT"
      }
    },
    "auto_join": true,
    "join_once": true,
    "use_voucher_metadata_schema": true,
    "description": "Winter 2024-25",
    "start_date": null,
    "expiration_date": null,
    "validity_timeframe": null,
    "validity_hours": null,
    "validity_day_of_week": null,
    "activity_duration_after_publishing": null,
    "vouchers_count_invalid": null,
    "vouchers_count": 0,
    "active": true,
    "metadata": null,
    "created_at": "2024-09-26T17:14:56.226Z",
    "updated_at": null,
    "category": null,
    "creation_status": "DONE",
    "protected": false,
    "validation_rules_assignments": {
      "data": [
        {
          "id": "asgm_BLgJYmo64rnAK5eB",
          "rule_id": "val_3LBFw25WTmAK",
          "related_object_id": "camp_txDwyDPeLvBEq490bfV2nLwo",
          "related_object_type": "campaign",
          "created_at": "2024-09-26T17:14:56.226Z",
          "object": "validation_rules_assignment"
        }
      ],
      "total": 1
    },
    "object": "campaign",
    "deleted": false,
    "deleted_at": null,
    "category_id": null,
    "voucher_type": "DISCOUNT_VOUCHER",
    "discount": {
      "type": "AMOUNT",
      "amount_off": 2500,
      "aggregated_amount_limit": 25000,
      "units": null,
      "effect": "APPLY_TO_ITEMS"
    },
    "gift": null,
    "loyalty_card": null,
    "voucher_code_config": {
      "pattern": "##",
      "length": 2,
      "charset": "xD",
      "prefix": "Your-",
      "postfix": "-Voucher"
    },
    "default_voucher_redemption": {
      "quantity": 4
    }
  },
  "object": "campaign_setup"
}

Authorizations

X-App-Id
string
header
required
X-App-Token
string
header
required
Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

campaignTemplateId
string
required

Pass the campaign template ID that was assigned by Voucherify.

Example:

"camp_tpl_zLtn2H9fgcG3NwO7t4PAfHcq"

Body

application/json

Only name is required. The rest of the fields will overwrite the template configuration.

Request body schema for POST /v1/templates/campaigns/{campaignTemplateId}/campaign-setup. Base body schema for creating a campaign

name
string
required

Campaign name.

description
string

An optional field to keep any extra textual information about the campaign such as a campaign description and details.

type
enum<string>

Defines whether the campaign can be updated with new vouchers after campaign creation or if the campaign consists of generic (standalone) voucherss.

  • AUTO_UPDATE: the campaign is dynamic, i.e. vouchers will generate based on set criteria
  • STATIC: vouchers need to be manually published
Available options:
AUTO_UPDATE,
STATIC
join_once
boolean

If this value is set to true, customers will be able to join the campaign only once. For loyalty campaigns, it's forced to true, even if join_once: false is passed in the request.

auto_join
boolean

Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled.

use_voucher_metadata_schema
boolean

Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema.

vouchers_count
integer

Total number of unique vouchers in campaign (size of campaign).

start_date
string<date-time>

Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is inactive before this date.

Example:

"2022-09-20T00:00:00.000Z"

expiration_date
string<date-time>

Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is inactive after this date.

Example:

"2022-09-30T00:00:00.000Z"

validity_timeframe
object

Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe.

validity_day_of_week
enum<integer>[]

Integer array corresponding to the particular days of the week in which the voucher is valid.

  • 0 Sunday
  • 1 Monday
  • 2 Tuesday
  • 3 Wednesday
  • 4 Thursday
  • 5 Friday
  • 6 Saturday
validity_hours
object

Determines the hours of validity, e.g. to create a happy hours scenario.

activity_duration_after_publishing
string

Defines the amount of time the vouchers will be active after publishing. The value is shown in the ISO 8601 format. For example, a voucher with the value of P24D will be valid for a duration of 24 days.

category_id
string

Unique category ID that this campaign belongs to. Either pass this parameter OR the category.

Example:

"cat_0b688929a2476386a7"

category
string

The category assigned to the campaign. Either pass this parameter OR the category_id.

metadata
object

The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format.

access_settings
object

Assigns or unassigns an area or store to the campaign.

NOTE: this object can be sent if the Areas and Stores enterprise feature is enabled. Contact Voucherify Sales to learn more.

voucher
object

Response

Returns the details about the created campaign and about the resources that have been created out of the template and added to the project.

Response body schema for POST /v1/templates/campaigns/{campaignTemplateId}/campaign-setup.

created_resources
object[]
required

Contains a list of resources that have been added to the project when the campaign has been created out of the template.

campaign
object
required

Details of the created campaign. This is an object representing a campaign.

object
enum<string>
required

The type of the object represented by JSON. This object stores information about the campaign created out of the campaign template.

Available options:
campaign_setup
I