Campaigns categories API

These endpoints allow you to easily manage campaign categories. Campaign categories make it possibile to group campaigns into categories. One campaign can be assigned to many categories.

Create a new campaign category

To create a new category, you need to call the /api/<storeCode>/campaignCategory endpoint with the POST method.

Definition

POST /api/<storeCode>/campaignCategory
Parameter Parameter type Description
Authorization header Token received during authentication
<storeCode> query Code of the store the campaign category should belong to.
campaign_category[translations][en][name] request Campaign category name in given locale.
campaign_category[active] request Set 1 if active, otherwise 0
campaign_category[sortOrder] request Sort order key.

Example

curl http://localhost:8181/api/DEFAULT/campaignCategory \
    -X "POST" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..." \
    -d "campaign_category[translations][en][name]=Category+A" \
    -d "campaign_category[active]=1" \
    -d "campaign_category[sortOrder]=0"

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an example value. Your value may be different. Read more about Authorization here.

Example Response

STATUS: 200 OK
{
  "campaignCategoryId": "3062c881-93f3-496b-9669-4238c0a62be8"
}

Get a collection of campaign categories

To retrieve a paginated list of campaigns categories, you need to call the /api/<storeCode>/campaignCategory endpoint with the GET method.

Definition

GET /api/<storeCode>/campaignCategory
Parameter Parameter type Description
Authorization header Token received during authentication
<storeCode> query Code of the store to get the campaign categories from.
name request (optional) Filter by name
active request (optional) Filter by activity
page query (optional) Start from page, by default 1
perPage query (optional) Number of items to display per page, by default = 10
sort query (optional) Sort by column name
direction query (optional) Direction of sorting [ASC, DESC], by default = ASC
format query (optional) Format of descriptions [html]. Default is RAW.
_locale query (optional) Retrieves data in given locale

To see the first page of all campaigns categories, use the method below:

Example

curl http://localhost:8181/api/DEFAULT/campaignCategory \
    -X "GET" \
        -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an example value. Your value may be different. Read more about Authorization here.

Note

Translatable fields (name) are returned in given locale.

Example Response

STATUS: 200 OK
{
  "categories": [
    {
      "name": "Category A",
      "campaignCategoryId": "000096cf-32a3-43bd-9034-4df343e5fd99",
      "active": true,
      "sortOrder": 0,
      "translations": [
        {
          "name": "Category A",
          "id": 1,
          "locale": "en"
        },
        {
          "name": "Kategoria A",
          "id": 3,
          "locale": "pl"
        }
      ]
    },
    {
      "name": "Category B",
      "campaignCategoryId": "000096cf-32a3-43bd-9034-4df343e5fd98",
      "active": true,
      "sortOrder": 0,
      "translations": [
        {
          "name": "Category B",
          "id": 2,
          "locale": "en"
        },
        {
          "name": "Kategoria B",
          "id": 4,
          "locale": "pl"
        }
      ]
    }
  ],
  "total": 2
}

Update a campaign

To fully update a campaign, you need to call the /api/<storeCode>/campaignCategory/<campaign> endpoint with the PUT method.

Definition

PUT /api/<storeCode>/campaignCategory/<campaignCategory>
Parameter Parameter type Description
Authorization header Token received during authentication
<storeCode> query Code of the store the updated campaign category belongs to.
<campaignCategory> query Id of the campaign category
campaign_category[translations][en][name] request Campaign category name in given locale.
campaign_category[active] request Set 1 if active, otherwise 0
campaign_category[sortOrder] request Sort order key.

Example

To fully update a campaign category with id = 3062c881-93f3-496b-9669-4238c0a62be8, use the method below:
curl http://localhost:8181/api/DEFAULT/campaignCategory/3062c881-93f3-496b-9669-4238c0a62be8 \
    -X "PUT" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..." \
    -d "campaign_category[translations][en][name]=Category+A" \
    -d "campaign_category[active]=1" \
    -d "campaign_category[sortOrder]=0"

Warning

Remember, you must update all data of the campaign category.

Example Response

STATUS: 200 OK
{
    "campaignCategoryId": "3062c881-93f3-496b-9669-4238c0a62be8"
}

Get campaign category details

To retrieve the details of a campaign category, you need to call the /api/<storeCode>/campaignCategory/<campaignCategory> endpoint with the GET method.

Definition

GET /api/<storeCode>/campaignCategory/<campaignCategory>
Parameter Parameter type Description
Authorization header Token received during authentication
<storeCode> query Code of the store to get the campaign category from.
<campaignCategory> query Id of the campaign category
_locale query (optional) Retrieves data in given locale

Example

To see the details of the campaign category with campaignCategory = 3062c881-93f3-496b-9669-4238c0a62be8, use the method below:

curl http://localhost:8181/api/DEFAULT/campaignCategory/3062c881-93f3-496b-9669-4238c0a62be8 \
    -X "GET" -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an example value. Your value may be different. Read more about Authorization here.

Note

Translatable fields (name) are returned in given locale.

Example Response

STATUS: 200 OK
{
  "name": "Category A",
  "campaignCategoryId": "000096cf-32a3-43bd-9034-4df343e5fd99",
  "active": true,
  "sortOrder": 0,
  "translations": [
    {
      "name": "Category A",
      "id": 1,
      "locale": "en"
    },
    {
      "name": "Kategoria A",
      "id": 3,
      "locale": "pl"
    }
  ]
}

Activate or deactivate campaign category

To activate or deactivate a campaign category, you need to call the /api/<storeCode>/campaignCategory/<campaignCategory>/active endpoint with the POST method.

Definition

Parameter Parameter type Description
Authorization header Token received during authentication
<storeCode> query Code of the store the (de)activated campaign category belongs to.
<campaignCategory> query Id of the campaign category
active boolean True of False

Example

curl http://localhost:8181/api/DEFAULT/campaignCategory/00ca7e90-6361-4465-e76f-727900000001/active \
    -X "POST" \
        -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..." \
        -d "active=1"

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an example value. Your value may be different. Read more about Authorization here.

Example Response

STATUS: 200 OK
204 No Content