GuidesAPI ReferenceChangelog
GuidesAPI ReferenceChangelogLog In

Campaign Example

The following is an example of the JSON data structure of an Campaign.

Additional details about the individual attributes of Campaigns can be found below.

{
    "type": "Campaign",
    "id": "99999",
    "attributes": {
        "name": "My Campaign",
        "advertiserId": 12345,
        "objective": "BrandAwareness",
        "spendLimit": {
            "spendLimitRenewal": "daily",
            "spendLimitType": "capped",
            "spendLimitAmount": {
                "value": 123.45
            }
        }
    }
}

 

Campaign Attributes

name
Currently read-only. The Campaign name, set by the advertiser.

advertiserId
Read-only. The advertiser associated with the Campaign.

objective
The marketing objective of the Campaign. Can be AppInstall, BrandAwareness, CatalogSales, Conversion, ResellerProgram, StoreSales, Traffic, VideoViews, or Unknown.

spendLimit.spendLimitRenewal
The cadence of spend limit renewal. Can be daily, monthly, lifetime, or undefined in the case of an uncapped limit type.

spendLimit.spendLimitType
Whether the Campaign spend is capped or not. Can be capped or uncapped.

spendLimit.spendLimitAmount.value
A decimal value representing the spend limit for the Campaign. If spendLimitType is uncapped, the value will be null.

Retrieving Campaigns by Filtering

Campaigns can be retrieved by specifying filters to apply to the set of all Campaigns in your portfolio.

Using filters, you can restrict the returned results to particular advertiserIds or specific campaignIds. Filters can be combined.

For example, to retrieve the Campaigns in your portfolio related to a particular advertiser, filter by advertiserIds:

 

https://api.criteo.com/2022-10/marketing-solutions/campaigns/search
{
    "filters": {
        "advertiserIds": [ "12345" ]
    }
}

The API will return an array of Campaigns that match the provided filters:

{
    "data": [
        {
            "type": "Campaign",
            "id": "99999",
            "attributes": {
                "name": "My Campaign",
                "advertiserId": 12345,
                "objective": "BrandAwareness",
                "spendLimit": {
                    "spendLimitRenewal": "daily",
                    "spendLimitType": "capped",
                    "spendLimitAmount": {
                        "value": 123.45
                    }
                }
            }
        }
    ],
    "errors": []
}

 

Retrieving All Campaigns

When no filters are specified in the JSON payload, all Campaigns in your portfolio will be returned, as in the example below:

https://api.criteo.com/2022-10/marketing-solutions/campaigns/search
{
    "filters": {}
}

 

Retrieving One Specific Campaign

You can also fetch the details for a single Campaign using a GET request:

https://api.criteo.com/2022-10/marketing-solutions/campaigns/{campaignId}

 

The response data will be a single object containing the Campaign details.

{
    "data": {
        "type": "Campaign",
        "id": "99999",
        "attributes": { ... }
    },
    "errors": []
}

 

Update Campaigns

The fields of one or more Campaigns can be updated by making a PATCH call to the Campaigns endpoint. The payload should be an array of partial or whole Campaigns, each specifying the fields to be modified.

For example, the following call would update the spendLimit settings of an existing Campaign:

https://api.criteo.com/2022-10/marketing-solutions/campaigns
{
    "data": [
        {
            "type": "Campaign",
            "id": "99999",
            "attributes": {
                "spendLimit": {
                    "spendLimitRenewal": "daily",
                    "spendLimitType": "capped",
                    "spendLimitAmount": {
                        "value": 123.45
                    }
                }
            }
        }
    ]
}

The API will return an array of Campaigns that have been updated successfully in the response data. These will contain only two parameters, type and id.

{
    "data": [
        {
            "type": "Campaign",
            "id": "99999"
        }
    ],
    "errors": [],
    "warnings": []
}

 

Partial Success / Partial Failure

Each Campaign update is processed individually and can succeed or fail without impacting other updates in the same payload.

As a result, those Campaign updates processed successfully will be returned in the data array of the response, while Campaign updates that have failed will return as an entry in the errors array of the response.

🚧

HTTP Response Codes

As a result of this individual processing, the API may respond with a 200 HTTP response code, but the result of its processing may have one or more failures.

 

For instance, for this payload which intends to update two Campaigns:

https://api.criteo.com/2022-10/marketing-solutions/campaigns
{
    "data": [
        {
            "type": "Campaign",
            "id": "99999",
            "attributes": {
                "spendLimit": {
                    "spendLimitRenewal": "daily",
                    "spendLimitType": "capped",
                    "spendLimitAmount": {
                        "value": 123.5
                    }
                }
            }
        },
        {
            "type": "Campaign",
            "id": "88888",
            "attributes": {
                "spendLimit": {
                    "spendLimitRenewal": "daily",
                    "spendLimitType": "capped",
                    "spendLimitAmount": {
                        "value": -9000
                    }
                }
            }
        }
    ]
}

 

The response might look like:

{
    "data": [
        {
            "type": "Campaign",
            "id": "99999"
        }
    ],
    "errors": [
        {
            "traceIdentifier": "56ed4096-f96a-4944-8881-05468efe0ec8",
            "type": "validation",
            "code": "campaign--campaign-update-check--validation-failed-on-spend-limit",
            "instance": "@data/1",
            "title": "Validation failed on spend limit",
            "detail": "There was an issue with the spend limit value specified."
        }
    ],
    "warnings": []
}

📘

Error instance

The instance field for validation errors will specify the index of the related update, beginning with index 0. For the example above, @data/1 refers to the second requested update in the request's data array.

A full list of error codes can be found on the Validation Errors page at the end of this section.

In addition to general API errors, you may encounter validation errors when updating a Campaign.

Below is a list of error codes for Campaign validation and a more detailed description of their meaning.

 

Campaign Update Validation Errors

campaign--campaign-update-check--spend-limit-does-not-exist
An update to spend limit was attempted on a Campaign which does not have a spend limit (e.g. an uncapped Campaign). Alternatively, the requestor may not have permissions to update the spend limit of the Campaign.


campaign--campaign-update-check--cannot-decrease-lifetime-spend-limit-below-what-is-already-spent
An update attempted to decrease a lifetime spend limit of a Campaign to a value lower than what has already been spent.


campaign--campaign-update-check--validation-failed-on-spend-limit
TK


campaign--campaign-update-check--cannot-update-same-campaign-multiple-times
The Campaign is included multiple times in the same update payload. All Campaign field updates should be consolidated into one array item.


campaign--campaign-update-check--unavailable-feature-for-this-advertiser
TK

Campaign Update Validation Warnings

campaign--campaign-update-check--new-spend-limit-amount-will-take-place-at-the-next-period-start
The update to spend limit was processed, but it will not take effect until the next period specified by spendLimitRenewal (e.g. the next day). This is typically because the new spend amount specified is lower than the amount already spent in the current period.