Skip to content

Create

/campaigns

Target audience: Developers

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

Required scope

1
/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 Required String The description used when presenting the campaign. 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: creditcard, sms, directdebit, free, invoice
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
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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",
      "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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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",
      "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,
          "iterations": 2,
          "details": [
            {
              "name": "Digital",
              "price": "10",
              "vat_code": 24
            },
            {
              "name": "Paper",
              "price": "34.9",
              "vat_code": 10
            }
          ]
        }
      ]
    }'

Find package using package_integration_code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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

1
2
3
4
HTTP 201
{
    "id": "50f3ac249f6aef294d000007"
}

Errors

Example error response

1
2
3
4
5
6
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