Skip to content

Scheduling messages

Pass scheduledAt as an ISO-8601 string with a timezone offset or as a DateTimeInterface. The scheduled time must be more than five minutes in the future.

use DateTimeImmutable;
use Rayo\SmsSdk\Models\SmsRequest;
$scheduledAt = new DateTimeImmutable('+2 hours');
$response = $client->sendSms(new SmsRequest(
'MYBRAND',
'Reminder: your appointment is tomorrow at 10:00.',
'306912345678',
null,
'appointment-1001',
true,
false,
true,
$scheduledAt
));
if ($response->isScheduled()) {
$scheduleId = $response->getSmsRequestScheduleId();
}

Persist getSmsRequestScheduleId() if your application may need to cancel the request later.

$result = $client->deleteSchedule($scheduleId);
if ($result->isSuccess()) {
echo 'Deleted: ' . $result->getSmsRequestScheduleId();
}

deleteSmsRequestSchedule() is an alias matching the API operation name.