Skip to content

API reference

This page summarizes the public API. For implementation details and the latest release history, view the source repository.

Member Returns Purpose
__construct(string $apiKey, string|array $baseUrlOrOptions, array $options = []) Client Configure credentials, base URL, and Guzzle options
getBaseUrl() string Return the normalized URL ending in /v1/
sendSms(SmsRequest|array $payload) SmsResponse Send immediately or schedule
getBalance() BalanceResponse Retrieve credits
getBalanceInCredits() BalanceResponse Alias for getBalance()
checkStatus(?string $serverId, ?string $clientId) SmsDeliveryStatusItem[] Query using exactly one identifier
checkStatusByServerRequestId(string $id) SmsDeliveryStatusItem[] Query by server ID
checkStatusByClientRequestId(string $id) SmsDeliveryStatusItem[] Query by client ID
deleteSchedule(string $id) DeleteScheduleResponse Cancel a future message
deleteSmsRequestSchedule(string $id) DeleteScheduleResponse Alias for deleteSchedule()

Constants: Client::DEFAULT_TIMEOUT is 10.0; Client::API_VERSION_PREFIX is v1.

Constructor:

new SmsRequest(
string $fromLabel,
string $smsBody,
string|array|null $toMobileNumber = null,
string|array|null $toGroup = null,
?string $clientRequestId = null,
?bool $callbackWhenProcessedFlag = null,
?bool $simulateSendFlag = null,
?bool $concatFlag = null,
DateTimeInterface|string|null $scheduledAt = null
);

Factory and serialization: fromArray(), validate(), toArray(), jsonSerialize().

Getters correspond to every constructor field. SmsRequest::MAXIMUM_SMS_LENGTH is 1000.

All response models are immutable, JSON-serializable, and provide read-only ArrayAccess to their raw response.

  • State: isSuccess(), isScheduled().
  • Getters: getUsername(), getResultCode(), getResultDescription(), getClientRequestId(), getSmsServerRequestId(), getSmsRequestScheduleId(), getError().
  • State: isSuccess().
  • Getters: getUsername(), getResultCode(), getResultDescription(), getSmsRequestScheduleId(), getError().
  • Getters: getRequestId(), getCredits().
  • State: isDelivered(), isFinalStatus().
  • Getters: getSmsServerRequestId(), getClientRequestId(), getInternalSmsOutDeliveryId(), getMobileNumber(), getStatus().
  • Factories: fromArray(), fromJson(), fromQueryString().
  • State: isDelivered(), isFinalStatus().
  • Getters: getSmsServerRequestId(), getClientRequestId(), getInternalSmsOutDeliveryId(), getSenderId(), getMobileNumber(), getStatus(), getErrorDescription(), getRequestTimestamp(), getLastStatusUpdatedTimestamp().

The timestamp parser accepts the documented requestTimestamp and the server variant requestedTimestamp.

Constants: NEW, TEMP_LOCKED, PROCESSING_ERROR, FAILURE, SENT, ERROR, DELIVERED, NOT_DELIVERED, and UNKNOWN_DELIVERY.

Use DeliveryStatus::all() to list every value and DeliveryStatus::isFinal($status) to test terminal status.

Method Purpose
computeSignature(...) Compute the expected HMAC-SHA256 digest
verify(...) Return whether a raw request signature is valid
verifyOrThrow(...) Throw RayoException for an invalid signature
verifyPsr7Request(...) Verify a PSR-7 server request

Extends RuntimeException. In addition to inherited exception methods, it exposes getStatusCode(), getErrorPayload(), getRawResponseBody(), getErrorMessage(), getResultCode(), and getResultDescription().