Download the PHP package calisero/calisero-php without Composer
On this page you can find all versions of the php package calisero/calisero-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download calisero/calisero-php
More information about calisero/calisero-php
Files in calisero/calisero-php
Package calisero-php
Short Description Official PHP library for Calisero SMS API
License MIT
Informations about the package calisero-php
Calisero PHP SMS API Library
Official PHP library for the Calisero transactional SMS API.
Send SMS messages, manage opt-outs for GDPR compliance, and monitor your accountβall with a simple, type-safe PHP library that just works.
Features
- π Simple & Intuitive: Easy-to-use API with clean factory methods
- π Type Safe: Full PHP type declarations and PHPStan level 9 compliance
- π Self-Contained: Built-in HTTP client using cURL, no external dependencies
- π Idempotency: Built-in idempotency key generation for safe retries
- π± Complete API Coverage: All Calisero SMS API endpoints supported
- βοΈ URL Shortening: Shorten the links in a message body and track their clicks
- π Limits & Tracing: Daily sending limit, request rate limit and the trace ID of every message, verification and error
- π¬ Delivery Webhooks: Typed, validated parsing of delivery status callbacks
- π‘οΈ Error Handling: Comprehensive exception hierarchy for different error types
- π Rich Examples: 14+ working examples covering every use case
- β‘ Zero Configuration: Works immediately after installation
- ποΈ Production Ready: Used in production by businesses worldwide
- π¦ Minimal Dependencies: Only requires PHP and basic extensions
- π― Laravel Integration: Official Laravel wrapper
calisero/laravel-smsavailable - π Wide PHP Support: Runs on PHP 7.4 through PHP 8.5
Requirements
- PHP 7.4 or higher β tested on 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5
ext-jsonextensionext-curlextension
The library carries no runtime dependencies beyond those extensions, so it drops into any supported PHP version without a resolver conflict.
Installation
Install the library via Composer:
That's it! The library includes its own HTTP client implementation and requires no additional dependencies.
Getting Your API Key
To use this library, you'll need an API key from your Calisero account:
- Log in to your Calisero account at https://calisero.ro
- Navigate to the dashboard and go to the "API Keys" section
- Click "Add Key" to create a new API key
- Configure your key:
- Give it a descriptive name (e.g., "Production App", "Development")
- Set IP filters if needed for additional security
- Choose appropriate permissions
- Copy your API key and store it securely
API Key Management
From the API Keys section in your dashboard, you can:
- β Add new keys for different applications or environments
- βοΈ Edit existing keys to update names or permissions
- ποΈ Delete keys that are no longer needed
- π‘οΈ Add IP filters to restrict key usage to specific IP addresses
- π Monitor key usage and activity logs
Security Note: Never commit API keys to version control. Use environment variables or secure configuration files.
Quick Start
Basic SMS Sending
Environment Configuration
For production applications, store your API key securely:
π― Common Use Cases
OTP/2FA Authentication
Order Notifications
Marketing Campaigns with Opt-out Compliance
Advanced Message Creation
PHP 7.4: named arguments need PHP 8.0. On PHP 7.4 pass the arguments in the constructor's order:
recipient,body,visibleBody,validity,scheduleAt,callbackUrl,sender,shortenUrls(usenullfor the ones you skip).
sender must be one of the senders approved for your account (Messages > Senders
in the dashboard), written exactly as approved: the match is case-sensitive. A
sender that is unknown or not approved yet is refused with a ValidationException
("The sender is invalid or is not approved.") and nothing is sent; leave it out
for the default sender. callbackUrl must be an http or https address on the
public Internet: private, loopback and link-local addresses are refused, and
redirects are not followed.
Authentication
Using API Key (Bearer Token)
Custom Authentication Provider
SmsClient::create() takes the API key itself. To authenticate through a provider
like this one, build the HTTP client and the services yourself, as shown in
Building the Client Yourself.
π Examples
This library includes comprehensive examples for all operations. Check the examples/ directory for detailed usage patterns:
π± Message Examples
examples/messages/send_simple_sms.php- Send basic SMS messagesexamples/messages/send_advanced_sms.php- Advanced SMS with scheduling, callbacks, custom sender and URL shorteningexamples/messages/send_bulk_sms.php- Bulk SMS with rate limiting, error handling and the daily sending limitexamples/messages/get_sms.php- Retrieve message details and statusexamples/messages/list_sms.php- List messages with paginationexamples/messages/delete_sms.php- Cancel scheduled messages
π« OptOut Examples (GDPR Compliance)
examples/optouts/create_optout.php- Add phone numbers to opt-out listexamples/optouts/get_optout.php- Check opt-out statusexamples/optouts/list_optouts.php- List all opt-outs with paginationexamples/optouts/update_optout.php- Update opt-out reasonsexamples/optouts/delete_optout.php- Remove opt-out (re-enable SMS)
β Verification Examples (OTP)
examples/verifications/create_verification.php- Start a verification (send OTP)examples/verifications/get_verification.php- Retrieve verification detailsexamples/verifications/list_verifications.php- List verifications with pagination and status filterexamples/verifications/validate_verification.php- Validate an OTP code for a phone number
π€ Account Examples
examples/account/get_account.php- Get account information and detailsexamples/account/check_balance.php- Check balance and daily sending limit with analysis and recommendations
π¬ Webhook Examples
examples/webhooks/delivery_webhook.php- Receive delivery status callbacks
π‘οΈ Error Handling
examples/error_handling_complete.php- Comprehensive error handling for all exception types
π Running Examples
-
Clone this repository and install dependencies:
-
Set your API key in any example file:
- Run an example:
Note: Examples use masked phone numbers (
+40742***350) for security. Replace with actual phone numbers when testing.
API Reference
Messages
Send a Message
Shorten URLs
Set shortenUrls to true and Calisero replaces every http:// and https://
link of the body with a short one before sending, so the SMS gets shorter (and may
take fewer parts). Each shortened link comes back with its click statistics:
Links are not shortened unless you ask: leave shortenUrls out (or pass false)
and the body is sent as written.
Get Message Details
List Messages
Delete a Message
Verifications (OTP)
Create a Verification
The code is sent from a shared sender, so neither the brand nor a custom template
(which must hold {code}) may contain links (web addresses, domains, emails or IP
addresses): the API refuses them with a ValidationException.
Get Verification Details
List Verifications
Validate a Verification Code (OTP)
Opt-outs
Create an Opt-out
List Opt-outs
Update an Opt-out
Delete an Opt-out
Accounts
Get Account Information
Delivery Status Webhooks
When a message has a callbackUrl, Calisero posts a JSON payload to it each time
the message's status changes (sent, delivered or undelivered).
DeliveryWebhookMessage reads and validates it:
Only a failed connection or an answer slower than 2 seconds is retried (at most 5
attempts in total); a non-2xx answer is not. Keep the endpoint fast: record the
status or queue a job, then answer. In a framework, pass the decoded request body
to DeliveryWebhookMessage::fromArray() instead.
The callback URL must be reachable from the Internet: the API refuses private,
loopback and link-local addresses (localhost, 192.168.x.xβ¦) and does not follow
redirects. To receive callbacks on a development machine, expose the endpoint
through a public tunnel and use its URL.
Daily Sending Limit
Every account has its own daily sending limit: how many messages it can send in a day. A new account starts with a default limit and keeps it until Calisero raises it on request.
- Every real message counts once, whatever its number of parts: the messages of
messages()->create()and the OTP codes ofverifications()->create()alike. A scheduled message counts on the day it is created. - Test messages (a sandbox account or a sandbox API key) never count and are never refused.
- The day ends at midnight, Romania time (Europe/Bucharest), whatever time zone you send from.
You can see the limit and what is left of it in three places:
Once the limit is reached, new messages and verifications are refused with a
DailyLimitExceededException until midnight, Romania time. Nothing is sent and
nothing is billed:
To raise the limit, contact Calisero with your account and the daily volume you expect.
Rate Limits & Trace ID
Request Rate Limit
Separately from the daily sending limit, each API user may make 240 requests a
minute, on every endpoint. Above that the API answers 429 and the library throws
a RateLimitedException:
DailyLimitExceededException extends RateLimitedException, so catch it first.
After a successful create, getResponseMeta()->getRateLimitRemaining() tells how many
requests are left in the current minute.
Trace ID
Every API answer carries the request's trace ID. Log it: quoting it to support lets Calisero find the request at once, and the dashboard shows everything that happened to it under Developers β Debug.
Error Handling
The library provides specific exception types for different error scenarios:
Every ApiException carries the API's own error message (getMessage()), the HTTP
status (getStatusCode()), the request's trace ID (getTraceId(); getRequestId()
returns the same value) and the decoded error body (getErrorDetails()).
| Exception | When |
|---|---|
UnauthorizedException |
401: invalid or missing API key |
ForbiddenException |
403: not allowed, e.g. deleting a message already sent |
NotFoundException |
404: the resource does not exist |
ValidationException |
422: invalid request data; field errors in getValidationErrors() |
DailyLimitExceededException |
429: the account reached its daily sending limit |
RateLimitedException |
429: more than 240 requests a minute |
ServerException |
500, 502, 503, 504 |
ApiException |
Any other API error; base class of the above |
TransportException |
The request got no answer (network error, timeout) |
Advanced Configuration
Simple Client Creation
The library uses a simplified approach with built-in HTTP client:
The library uses an optimized cURL-based HTTP client internally, providing excellent performance without external dependencies.
SmsClient::create() sends every request to https://rest.calisero.ro/api/v1 with
a 30-second timeout (10 seconds to connect), authenticates with the API key you
pass, and adds a random UUID Idempotency-Key header to each message and
verification it creates. Every request names the library, PHP and the platform in
its User-Agent header, e.g. Calisero-SMS-PHP/2.3.2 (PHP 8.5.3; linux x86_64).
The API accepts TLS 1.2 and TLS 1.3 only: from 1 November 2026 a connection that
offers only TLS 1.0 or 1.1 is refused during the handshake, before any request is
read. The library never offers less than TLS 1.2, so it needs a cURL built with an
SSL library that supports it (any OpenSSL from 1.0.1 on). If you build the client
yourself, keep the https:// base URL: a request to http:// is redirected, and
the library does not follow redirects.
Building the Client Yourself
SmsClient::create() is the only way to get an SmsClient, and its setup is
fixed. For anything else (your own authentication or idempotency key provider,
other timeouts, or the raw response to each request), build the HTTP client and
the services yourself: every service takes the HttpClient in its constructor.
Custom Idempotency Key Provider
The library sends an Idempotency-Key header with each message and verification it
creates, a random UUID by default. To generate the key yourself, implement
IdempotencyKeyProviderInterface and pass your provider as the last argument of
HttpClient:
Testing
The library includes comprehensive test coverage:
Testing Your Implementation
SmsClient::create() builds its own HTTP client, so let the code you want to test
receive the service it uses, such as a MessageService: pass it
$client->messages() in production. In tests, build the service on a mocked
HttpClient that returns the API's JSON body, decoded:
The library's own service tests, in tests/Unit/Services,
work the same way; TESTING.md describes the whole suite.
Contributing
Please see CONTRIBUTING.md for details on how to contribute to this project.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
This library is open-sourced software licensed under the MIT license.
Support
- Documentation: Official API Docs
- GitHub Issues: Report Issues
-
Email Support: [email protected]
- π§ Email: [email protected]
- π Documentation: https://docs.calisero.ro
- π Issues: GitHub Issues
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
All versions of calisero-php with dependencies
ext-json Version *
ext-curl Version *