Booking · Events
Stop event pattern
Stops a course event's repeat pattern from the requested date, or from now if that date is in the past. It removes unbooked future dates and either keeps or cancels booked dates, with options for the cancellation reason, refund and attendee notification. Dates that have already started or were canceled remain unchanged. The response contains updated and deleted event IDs.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- The caller must have organization access with
mandate.readandevent.editpermissions.
Request
Path parameters
-
organizationIdidrequired -
mandateIdidrequired -
eventIdidrequired -
patternIdstringrequiredexactly 10 characters
Body
Content-Type: application/json
-
fromstring · date-timerequired -
bookedDatesobjectrequired
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/booking/events/YOUR_EVENT_ID/patterns/YOUR_PATTERN_ID/stop' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/booking/events/YOUR_EVENT_ID/patterns/YOUR_PATTERN_ID/stop", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY"
},
redirect: 'error',
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`campai HTTP ${response.status}`);
const text = await response.text();
const result = text ? JSON.parse(text) : null;
console.log(JSON.stringify(result, null, 2));<?php
$context = stream_context_create(['http' => [
'method' => 'POST',
'header' => [
'X-API-Key: YOUR_API_KEY',
],
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/booking/events/YOUR_EVENT_ID/patterns/YOUR_PATTERN_ID/stop', false, $context);
preg_match('/^HTTP\/\S+ (\d{3})/', $http_response_header[0] ?? '', $match);
$status = (int) ($match[1] ?? 0);
if ($text === false || $status < 200 || $status >= 300) {
throw new RuntimeException("campai HTTP $status (0 means no response)");
}
$result = $text === '' ? null : json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
No request that worked has been recorded yet, so the body is not shown.
Response
200 Successful response
Content-Type: application/json
-
updatedid[] -
deletedid[]
Response200
{
"updated": [
"000000000000000000000001"
],
"deleted": [
"000000000000000000000001"
]
}
What else happens
- The pattern is marked stopped across the course dates. The course dates are renumbered, and their series statistics are updated.
- When course date positions change, the corresponding attendee course indexes are updated.
- Course booking wallet pass expiry dates can change, and wallet updates can be requested.
- Resource reservations for deleted dates are removed; course numbering on remaining reservations can also change.
- When dates are deleted, their event tag usage counts can decrease.
- Deleting dates starts
booking.deleteEventDatajobs after the transaction. - Canceling booked dates starts
booking.processEventUpdatejobs after the transaction. - Deleting dates starts a
misc.deleteTodoItemsjob for their todo items after the transaction. - If an event date or title is updated, matching booking records can have their event date or title updated.
- If waitlist numbers are reserved, the event's waitlist sequence counter is increased by the number reserved.
- If waitlist numbers are reserved and no sequence exists, a sequence is initialized from the highest historical waitlist number, or zero if there is none.
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 400 | The repeat pattern is already stopped. | If the pattern is already stopped, the request returns HTTP 400 with booking.event.stopEventPattern.alreadyStopped. |
| 400 | Stopping the repeat pattern would remove every date of the course. Delete the course instead. | If stopping the pattern would delete every date of the course, the request returns HTTP 400 with booking.event.stopEventPattern.noDatesLeft. Delete the course instead. |
| 400 | One of the events deleted in the operation cannot be deleted because it has bookings. Please cancel the events first to refund all its bookings. | If a future, uncanceled date selected for deletion has an active booking, the request returns HTTP 400 with booking.event.eventMutation.hasBookings. |
| 404 | The given event was not found | If the event is not found in the requested organization and mandate, the request returns HTTP 404 with booking.event.eventNotFound. |
| 404 | The repeat pattern was not found. | If the event does not contain the requested repeat pattern, the request returns HTTP 404 with booking.event.getEventCoursePattern.patternNotFound. |
| 404 | Event was not found | If an event selected for update cannot be found during the mutation, the request returns HTTP 404 with booking.event.applyEventResourceReservationMutation.eventNotFound. |
Errors nearly every request can meet are listed under Errors.