Skip to content

Create

/campaigns

Target audience: Developers

Create campaign

Introduction

This endpoint creates a new campaign.

URI

Environment URI
Stage https://payway-api.stage.adeprimo.se/external/api/v2/campaigns
Production https://backend.worldoftulo.com/external/api/v2/campaigns

Requirements

Identity Scope
No /external/campaign/w

Parameters

Field Required Type Description
campaign_code Required String The campaign code is the human readable unique id of the campaign e.g. adeprimo_digital_campaign.
Size range: ..50
Allowed values: "/^[a-zA-Z-_0-9]+$/"
package_code Optional String The code to the package that the campaign is to be based on. You must give either this parameter or package_integration_code
Size range: ..50
package_integration_code Optional String The package that the campaign is to be based on can be resolved based on it's integration code. Size range: ..1024
name Required String The name used when presenting the campaign. Size range ..100
description Optional String The description used when presenting the campaign. Size range ..1024
short_description Optional String The additional short description available when fetching the campaign from an API. Size range ..1024
integration_code Optional String The integration code is used to connect this campaign to it's corresponding campaign in an external subscription system. Size range ..1024
valid_from Optional DateTime When the campaign should be available for purchase. Defaults to now.
valid_to Optional DateTime How long the campaign will be available for purchase. Defaults to 100 years from now.
transform_to_package Required Boolean Decides if the campaign should transition to a normal subscription after the campaign period. Some payment options such as free and directdebit cannot transform. For creditcard and sms a corresponding period of 1 month must be available on the package for transform to be possible. Defaults to false.
price_periods Required Object[] Tells how the campaign will be charged. There can only be one period per payment option.
payment_option
Required String Allowed values: adyen, creditcard, sms, directdebit, free, invoice
payment_option_details
Optional Object Defines the payment method type and name for an Adyen payment. This is required if payment_option is adyen.
type
Required String Adyen payment method type. E.g.: scheme
name
Required String Adyen payment method name. E.g.: Card
type
Required String Allowed values: day, week, month, year
length
Required Integer Together with type it decides the total length of one iteration. E.g. 2 months
price
Required Float The price of one iteration
iterations
Required Integer The number of iterations before the campaign periods is over. E.g. type=month, length=2 and iteratins=2 would give a total campaign length of 4 months
enabled_for_purchase
Optional Boolean Show the price_period in PPF. Default: true. Allowed values: true, false.
details
Optional Object Defines the "complex pricemodel" for this period and should only be used if the organisation utilized the "complex pricemodel" in Payway
name
Required String Name of detail
price
Required Float The price of this detail
vat_code
Required Integer The vatcode of this detail
tags Optional Array String array including the names of all the Payway Tags that should be applied to the campaign. All of the given tags must exist beforehand.
gift_options Optional Object Object containing information about the rules regarding if the campaign can be bought as a gift/voucher
allow_voucher_purchase
Optional Boolean Whether this campaign allows voucher purchases to be made
allow_only_voucher_purchase
Optional Boolean Whether this campaign only allows voucher purchases to be made

Curl Example

Create campaign with Adyen Credit card and Invoice as payment options

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v2/campaigns \
  --header 'accept: application/json' \
  --header 'authorization: Bearer token' \
  --header 'content-type: application/json' \
  --data '{
      "campaign_code": "adeprimo_digital_campaign",
      "package_code": "adeprimo_digital",
      "name": "Adeprimos digital campaign",
      "description": "You must buy our fancy campaign",
      "short_description": "Buy today!",
      "integration_code": "123456",
      "valid_from": "2020-01-01 12:00 +0200",
      "valid_to": "2025-01-01 12:00 +0200",
      "transform_to_package": true,
      "price_periods": [
        {
          "payment_option": "adyen",
          "payment_option_details": 
            {
                "type": "scheme",
                "name": "Card"
            },
          "type": "month",
          "length": 1,
          "price": 9.9,
          "iterations": 1
        },
        {
          "payment_option": "invoice",
          "type": "month",
          "length": 1,
          "price": 9.9,
          "iterations": 1
        }
      ]
    }'

Create campaign with Credit card (Bambora)

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v2/campaigns \
  --header 'accept: application/json' \
  --header 'authorization: Bearer token' \
  --header 'content-type: application/json' \
  --data '{
      "campaign_code": "adeprimo_digital_campaign",
      "package_code": "adeprimo_digital",
      "name": "Adeprimos digital campaign",
      "description": "You must buy our fancy campaign",
      "short_description": "Buy today!",
      "integration_code": "123456",
      "valid_from": "2016-08-02 13:00 +0300",
      "valid_to": "2021-08-02 13:00 +0300",
      "transform_to_package": true,
      "price_periods": [
        {
          "payment_option": "creditcard",
          "type": "month",
          "length": 1,
          "price": 44.9,
          "iterations": 2
        }
      ]
    }'

Create campaign with complex price model

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v2/campaigns \
  --header 'accept: application/json' \
  --header 'authorization: Bearer token' \
  --header 'content-type: application/json' \
  --data '{
      "campaign_code": "adeprimo_digital_campaign",
      "package_code": "adeprimo_digital",
      "name": "Adeprimos digital campaign",
      "description": "You must buy our fancy campaign",
      "short_description": "Buy today!",
      "integration_code": "123456",
      "valid_from": "2016-08-02 13:00 +0300",
      "valid_to": "2021-08-02 13:00 +0300",
      "transform_to_package": true,
      "price_periods": [
        {
          "payment_option": "invoice",
          "type": "month",
          "length": 1,
          "iterations": 2,
          "details": [
            {
              "name": "Digital",
              "price": "10",
              "vat_code": 24
            },
            {
              "name": "Paper",
              "price": "34.9",
              "vat_code": 10
            }
          ]
        }
      ]
    }'

Create campaign using package_integration_code

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v2/campaigns \
  --header 'accept: application/json' \
  --header 'authorization: Bearer token' \
  --header 'content-type: application/json' \
  --data '{
      "campaign_code": "adeprimo_digital_campaign",
      "package_integration_code": "555",
      "name": "Adeprimos digital campaign"
    }'

Response

Field Description
id id of the created campaign

Example Response

HTTP 201
{
    "id": "50f3ac249f6aef294d000007"
}

Errors

This API uses the common error conventions of the Payway API

See common error responses