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/v1/campaigns
Production https://backend.worldoftulo.com/external/api/v1/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

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/v1/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/v1/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/v1/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/v1/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

Example error response

HTTP 400 Bad Request
{
    "code": "invalid_parameter",
    "field": "account_id",
    "message": "Parameter must match format (/^[a-f\d]{24}$/)"
}

HTTP 400 Bad Request

Name Type Description
invalid_parameter Object Validation error on any of the fields in the posted json
json_parser_error Object The request body could not be parsed as valid json
invalid_content_type_error Object The requests Content-Type header isn't set to application/json
unknown_parameter Object One or more of the fields in the posted json was not recognized

HTTP 404 Not Found

Name Type Description
not_found Object The package could not be found

HTTP 409 Conflict

Name Type Description
already_exist Object Indicates that a value that must be unique and already exists have been used. I.e. the campaign code is already taken
payment_option_already_exists Object There is already a duplicate payment option on the campaign
payment_option_cannot_transform Object The campaign cannot transform to normal package
no_transition_period Object One of the payment options does not have a transition period

HTTP 500 Internal Server Error

Name Type Description
internal_server_error Object Something unexpected happened server side