Discard
GuidesAPI ReferenceChangelogDiscussions
GuidesAPI ReferenceChangelogDiscussionsLog In

Update Campaigns

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-04/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-04/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.


What’s Next

Learn about possible campaign validation errors

Did this page help you?