Add a date for a course (start date, end date, place etc.) using POST.
Fields the endpoint doesn't know are ignored; the response then lists them in ignored_fields, so a request that changed less than you meant shows it. A field sent as an object or a list where a text or number is expected gives 400 naming the field. teaching_language may be sent as GET returns it ({"id": "nl", ...}).
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 | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| start_at | required | string | yyyy-mm-dd. A value that isn't a date gives 400 naming the field. | ||||||||||||||||||||||||||||||||||||||||||||||||
| end_at | required | string | yyyy-mm-dd. A value that isn't a date gives 400 naming the field. | ||||||||||||||||||||||||||||||||||||||||||||||||
| deadline_at | optional | string | yyyy-mm-dd. Registration deadline; left out, the course date has none (GET returns null). |
||||||||||||||||||||||||||||||||||||||||||||||||
| start_time_at | optional | string | hh:mm (or hh:mm:ss). When adding a date, a value that isn't a time is ignored and listed in ignored_fields. |
||||||||||||||||||||||||||||||||||||||||||||||||
| end_time_at | optional | string | hh:mm (or hh:mm:ss). When adding a date, a value that isn't a time is ignored and listed in ignored_fields. |
||||||||||||||||||||||||||||||||||||||||||||||||
| timezone | optional | string | Timezone in IANA format (e.g., "Europe/Oslo"). | ||||||||||||||||||||||||||||||||||||||||||||||||
| visible_when_passed_deadline | optional | bool | Default is 1 (not set). false hides the course date after its deadline; without a deadline that is at once. On update, send false (or "false") to set it; an empty value or 0 leaves it as it is. |
||||||||||||||||||||||||||||||||||||||||||||||||
| teaching_language | optional | string | Default is no ("no" as in Norwegian) | ||||||||||||||||||||||||||||||||||||||||||||||||
| place_id | optional | integer | Use integer found in this list. Or use place_by_search. | ||||||||||||||||||||||||||||||||||||||||||||||||
| location_id | optional | integer | Reference to a location ID from your location list. | ||||||||||||||||||||||||||||||||||||||||||||||||
| status_id | optional | integer | Use integer found in this list
|
||||||||||||||||||||||||||||||||||||||||||||||||
| place_by_search | optional | string | If place_id is not set. Search for place and use result if found. | ||||||||||||||||||||||||||||||||||||||||||||||||
| place_additional_info | optional | string | Additional info about the location. | ||||||||||||||||||||||||||||||||||||||||||||||||
| reference | optional | string | Your own reference, if needed. | ||||||||||||||||||||||||||||||||||||||||||||||||
| external_booking_url | optional | string | A link to book the course date somewhere else. On update, send an empty value to remove it. | ||||||||||||||||||||||||||||||||||||||||||||||||
| seats | optional Number of places, in the same shape GET returns. Whole numbers; 0 means no limit. Each value is optional; left out or empty, it is unchanged. A value that isn't a whole number (text, a decimal, an object) gives 400 naming the field. Only for accounts with the reservation function (GET shows the numbers only to them); otherwise it is ignored. |
object |
|
||||||||||||||||||||||||||||||||||||||||||||||||
| instructors | optional | array | List of instructor IDs associated with the event. | ||||||||||||||||||||||||||||||||||||||||||||||||
| custom_properties | optional Set arbitrary metadata on the course date. Keys up to 40 characters, values must be strings up to 255 characters. Send a key with an empty string or null to clear it. |
object |
|
||||||||||||||||||||||||||||||||||||||||||||||||
| gatherings (Known as meetups in FrontCore UI) | optional A list of the course date's meeting days (sessions). It replaces the ones there: sessions whose id is left out are removed. When a course date is added without it, one session is made from the course date's dates and times. On update, an empty list leaves the sessions as they are. |
array of objects |
|
$post_params = array();
$post_params['start_at'] = '2020-04-02';
$post_params['end_at'] = '2020-04-10';
$post_params['deadline_at'] = '2020-03-29';
$post_params['visible_when_passed_deadline'] = '1';
$post_params['teaching_language'] = 'no';
$post_params['place_id'] = '637';
$post_params['place_by_search'] = 'Oslo'; // An example. place_id takes precedence.
$post_params['place_additional_info'] = 'Vika';
$post_params['reference'] = 'COURSE1300';
$request_url = 'https://api.frontcore.com/v2/courses/22353/coursedates';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
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.
{
"coursedate_id": 13003688,
"course_id": 22353
}
Unsuccessful response sample:
{
"error": "Field(s) not valid: start_at"
}