---
# System prepended metadata

title: Objects

---

# Objects

## ListableCampaign

```
{
    "id":1,
    "version": "2",
    "name":"FIRSTSUBSERV",
    "urlMapping":"",
    "code":"FIRSTSUBSERV",
    "countryCodes":["se"],
    "status":"active",
    "subscriptionDays":14,
    "validFrom":1581033600000,
    "validTo":1583625600000,
    "price":200.0    
}
```

## Campaign

```
{
    "result":{
        "id": 1,
        "gid": "dfe9c2de-a33e-4c5e-a1d1-27efd6c9e70e",
        "published": true,
        "draftOfCampaign": null,
        "version": "2",
        "name": "FIRSTSUBSERV",
        "code": "FIRSTSUBSERV",
        "creditCardRequired": true,
        "urlMapping": "",
        "countryCodes": [
            "se"
        ],
        "existingCustomerEligible": false,
        "status": "active",
        "subscriptionDays": 14,
        "validFrom": 1581033600000,
        "validTo": 1581552000000,
        "productId": 7717,
        "uniqueCodeRequired": false,
        "title": "",
        "message": "",
        "terms": "",
        "imagePath": "",
        "bullets": [],
        "contentBlocks": [
            {
                "type": "BANNER",
                "banner": {
                    "title": "assssddddddd",
                    "message": "",
                    "imageUrl": "https://www.storytel.com/images/web/default_campaign_image.jpg",
                    "buttonText": "Sign up now"
                }
            },
            {
                "type": "SIGNUP_FORM",
                "signupForm": {
                    "header": "Try storytel now"
                }
            }
        ],
        "price": 1
    }
}
```

## CreateOrUpdateCampaign
In order to create a Campaign some fields are mandatory:
```
{   
    published: boolean,
    version": string,
    name": string,
    code": string,
    urlMapping": string,
    countryCodes": []string,
    existingCustomerEligible": boolean,
    subscriptionDays": number,
    validFrom": number(unix),
    validTo": number(unix),
    productId": number,
    uniqueCodeRequired": boolean,
}

```
// Fill in later
```

# Endpoints

## Fetch Campaigns

`GET /v2/campaigns?countryIso={}&status={}&publishedStatus={}&searchQuery={}&showLegacyCampaigns={}&sortOrder={}&nextPageToken={}`
```
{
  result: []ListableCampaign,
  total: 1337,
  offsetToken: 50
}
```

Status:
- active
- ended
- scheduled

PublishedStatus:
- published
- draft

ShowLegacyCampaigns:
- boolean

SortOrder:
- ASCENDING
- DESCENDING

OrderBy:
- name
- url
- campaignCode
- status
- startDate
- endDate
- duration
- offer
- price

ex:
`GET /v2/campaigns?countryIso=se&status=active&searchQuery=oneyear&orderBy=name&sortOrder=DESCENDING&nextPageToken=0`
```
{
  result: []ListableCampaign,
  total: 1337,
  offsetToken: 50
}
```

### Count

`GET /v2/campaigns/count?countryIso={}&status={}&searchQuery={}`
```
{
    result: number
}
```

## Fetch Single Campaign

`GET /v2/campaings/{id}`
```
{
  result: Campaign
}
```

## Create Campaign

`POST /v2/campaigns/`
```
{
    "version":"2",
    "subscriptionDays":14,
    "countryCodes":["fi"],
    "validFrom":1581930000000,
    "validTo":1584522000000,
    "bullets":[],
    "contentBlocks":[
        {
            "type":"BANNER",
            "banner":{
                "title":"this is a title",
                "message":"",
                "imageUrl":"https://www.storytel.com/images/web/default_campaign_image.jpg",
                "buttonText":"Sign up now"
            }
        },
        {
            "type":"SIGNUP_FORM",
            "signupForm":{
                "header":"Try storytel now"
            }
        }],
    "name": "createCampaign",
    "code": "campaignCode",
    "price":1234,
    "productId":7717
}
```
resp:
```
{
  result: Campaign
}
```

## Update Campaign

`PATCH /v2/campaigns/{id}`
```
{
...campaign
}
```
resp:
```
{
  result: Campaign
}
```