Check if campaign code is valid
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
Name | Required | Value | Description |
---|---|---|---|
code | required You can pass in the campaign code either in as path parameter or query-string parameter |
string | The campaign code |
coursedate_id | required Pass in coursedate_id, course_id or both. |
number | Pass in the coursedate id if you want to check if the campaign code can be applied to a given coursedate |
course_id | required Pass in coursedate_id, course_id or both. |
number | Pass in the course id if you want to check if the campaign code can be applied to a given course |
$request_url = 'https://api.frontcore.com/v2/campaigns/validate/:code';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-API-Key: {your-api-key}',
'Accept: application/json',
));
$result = curl_exec($ch);
curl_close($ch);
If the method is successful it responds with an JSON structure, as it is shown below.
{ "successful": true, "campaign": { "id": "1623", "title": "Discount 20% off", "type": "Campaign", "active": true, "discount_type": "Percent", /* Percent or Value*/ "discount_value": 12.34, /* Discount in percentage or amount depending on discount_type*/ "currency": "nok", "expired": false, "waiting": false, "running": true, "campaign_code": "discount50", "uses_code": true, "is_archived": false } }
Unsuccessful response sample:
{ "successful": false, "errors": [ { "code" => some_error_code, "message" => "A human readable error response" } ] }
unauthorized | You are not authorized to execute this operation. |
resource_not_found | We can not find any campaigns with given code. |
missing_course_id | A course id or coursedate id must be specified to validate the campaign code |