Create campaign
https://app.iteras.dk/api/campaigns/createcampaign/
The API key must allow "Change campaigns".
Creates a campaign, which describes what a subscription receives in a period, how long the period is and how it is invoiced, and which campaign the subscription continues on. Listing the campaigns shows how the existing campaigns are set up.
Plans are built out of campaigns. For instance, you can build an intro offer followed by the permanent plan by having a cheaper intro campaign followed by the permanent campaign. The intro campaign has its next campaign set to the permanent campaign, and the permanent campaign has its next campaign set to itself.
Parameters
-
campaign_id string required
Self-chosen ID for the campaign, e.g.
3months. Must be unique in the account and must not collide with a product's external ID. -
name string required
Internal campaign name shown inside Iteras, e.g.
3 months. -
customer_facing_name string required
Campaign name shown to customers, e.g.
3 months. -
business_entity string
External ID of the business entity the campaign belongs to, e.g.
DKbranch. Can be left out if the account has only one business entity. -
products array required
The products in the campaign, each an object identifying the product by its
external_idor, if it has none, itsname, e.g.[{"external_id": "example_product"}]. When the duration of the campaign is based on counting assignments, one of the objects needsused_for_period_durationset to true, e.g.[{"external_id": "example_product", "used_for_period_duration": true}]. At least one of the account's subscription products is required unlesspro_forma_subscriptionis true.Log in, or send your API key as a bearer token, to see the subscription products set up for your account.
-
duration_based_on string required
How the period length is determined:
timefor calendar time, given intime, orassignmentsfor counting assignments of products, given inperiod_assignments. -
time string
Length of each period in calendar time, required when
duration_based_onistime: a number followed byd,w,moryfor days, weeks, calendar months or calendar years, e.g.6m, orfixedto end on the date infixed_date.Durations are written as:
- Nd, e.g.
3dfor 3 days - Nw, e.g.
2wfor 2 weeks - Nm, e.g.
6mfor 6 calendar months, calculated precisely, so not the same as 6×30 days - Ny, e.g.
1yfor 1 calendar year, which handles leap years
- Nd, e.g.
-
period_assignments integer
Number of assigned products in each period, e.g. set it to 3, and the period ends when 3 products have been assigned to the period. Required when
duration_based_onisassignments. -
fixed_date date
Date the period ends, as
YYYY-MM-DD, e.g.2027-03-01. Required whentimeisfixed. -
next_campaign_id string
campaign_idof the campaign the subscription continues on, e.g.3months. For introduction campaigns, this will usually be the permanent campaign. For permanent recurring campaigns, this will usually be the campaign's owncampaign_id. -
repeat_number_of_times integer Defaults to
1How many times in a row the subscription gets a period on the campaign before continuing, e.g. 3.
-
policies array
External IDs of business policies to optionally override the business entity's settings with, e.g.
["no_pause"], as listed with the business policies. The first policy in the list that sets a setting decides it. -
active bool Defaults to
trueWhether the campaign is active. An inactive campaign isn't offered in ordering forms or for new subscriptions in Iteras, and existing subscriptions continue on it. Once a campaign has been used, you cannot delete it, but you can make it inactive.
-
lines array
What to invoice for each period, e.g.
[{"text": "3 issues", "amount": 24950, "tax_rate": 0.25, "extra_info": ["period"]}], in the invoice line format. No lines means the campaign is free. A price change is planned with dates: the current line gets avalid_to, and a copy with the new amount gets the same date asvalid_from. -
controlled_group_campaigns array
Any recipient campaigns that can be used for recipient subscriptions for a subscription on this campaign, e.g.
[{"campaign_id": "employee", "max_controlled_subscriptions": 5}].Each object has the following parameters:
-
campaign_id string requiredID of the recipient campaign, e.g.
employee. -
sync_with_controlling_period bool Defaults to
trueSynchronize the recipient subscriptions' periods with the controlling subscription's period, so they can be invoiced together. -
max_controlled_subscriptions integerLimit how many subscriptions the controlling subscription may have on the campaign, e.g.
5. No limit if left out.
-
-
controlled_addon_campaigns array
Any add-on campaigns that can be used for add-on subscriptions for a subscription on this campaign, e.g.
[{"campaign_id": "digital-extra", "max_controlled_subscriptions": 5}].Each object has the following parameters:
-
campaign_id string requiredID of the add-on campaign, e.g.
digital-extra. -
sync_with_controlling_period bool Defaults to
trueSynchronize the add-on subscriptions' periods with the base subscription's period, so they can be invoiced together. -
max_controlled_subscriptions integerLimit how many subscriptions the controlling subscription may have on the campaign, e.g.
5. No limit if left out.
-
-
switching object
Campaigns the customer can switch to, grouped by situation, each a list of objects with
campaign_id, e.g.{"allowed_from_selfservice": [{"campaign_id": "3months"}]}.allowed_from_selfservice, campaigns the customer can switch to from the self-serviceoffered_instead_of_cancel, campaigns offered instead of cancelling in the self-serviceoffered_from_invoice, campaigns offered through a link in the invoice
-
Whether the subscription is only pro forma for accounting purposes and receives nothing.
-
Name of an image from the image library in Iteras to show as the campaign's product image, e.g.
cover.jpg. -
Whether an active subscription gets access to content protected by a paywall.
-
The access to previous products when integrating with digital edition platforms, one of:
"", no productsreceived, assigned productsall, all products while active plus assigned products
-
In case of customer complaints that warrant crediting, you can specify the unit price in cents including tax, e.g.
150for €1.50. -
For subscriptions where products are periodically assigned, e.g. magazines, whether upcoming products are assigned to the subscription automatically. If false, products are not assigned.
You can set any custom campaign field, using its field id (the field name with a colon prepended, or its external identifier).
Log in, or send your API key as a bearer token, to see the custom campaign fields set up for your account.
A yes/no field (type bool) is true or false, and has no value when it isn't set. Set it with true or false, and clear it with null.
Examples
POST /api/campaigns/createcampaign/ HTTP/1.1
Content-Type: application/json{
"campaign_id": "3months",
"name": "3 months",
"customer_facing_name": "3 months",
"business_entity": "DKbranch",
"duration_based_on": "assignments",
"period_assignments": 3,
"products": [
{ "external_id": "example_product", "used_for_period_duration": true }
],
"lines": [
{ "text": "3 issues", "amount": 24950, "tax_rate": 0.25 }
]
}Return value
On success the endpoint returns the Iteras ID and the campaign ID of the created campaign:
{ "created": true, "id": "308", "campaign_id": "3months" }
Errors
Invalid JSON returns 400.
A well-formed request with invalid values is not executed and returns 422
with the errors keyed by field, for instance an already-used
campaign_id:
{ "created": false, "errors": { "campaign_id": ["A campaign with this ID already exists."] } }
This also covers needing to specify business_entity when the
account has several:
{ "created": false, "errors": { "business_entity": ["Must specify \"business_entity\"."] } }