The PHP SDK is currently in beta. APIs may change between releases. Share feedback or report issues on GitHub.
Installation
Add to yourcomposer.json:
composer install. Requires PHP 8.1+. Find the latest version on GitHub Releases.
Quick Start
Authentication
Get your API key from Settings > API Keys in the Courier dashboard. Set it as an environment variable:Sending Notifications
With a template
With inline content
Available Resources
The SDK covers the full Courier API.| Resource | Namespace | Description |
|---|---|---|
| Send | $client->send | Send messages to one or more recipients |
| Messages | $client->messages | Retrieve status, history, and content of sent messages |
| Profiles | $client->profiles | Create, update, and retrieve user profiles |
| Users | $client->users | Manage preferences, tenants, and push tokens per user |
| Auth | $client->auth | Issue JWT tokens for client-side SDK authentication |
| Bulk | $client->bulk | Send messages to large recipient lists via jobs |
| Lists | $client->lists | Manage subscription lists and their subscribers |
| Audiences | $client->audiences | Define and query audience segments |
| Tenants | $client->tenants | Manage tenants for multi-tenant setups |
| Automations | $client->automations | Invoke multi-step automation workflows |
| Brands | $client->brands | Manage brand settings (logos, colors, templates) |
| Notifications | $client->notifications | List and inspect notification templates |
| Translations | $client->translations | Manage localized content |
Common Operations
Checking Message Status
Managing User Profiles
Issuing JWT Tokens
| Scope | Permission |
|---|---|
user_id:<id> | Which user the token is for (required) |
inbox:read:messages | Read inbox messages |
inbox:write:events | Mark messages as read/archived |
read:preferences | Read notification preferences |
write:preferences | Update notification preferences |
write:user-tokens | Register push notification tokens |
Configuration
Error Handling
The SDK throws typed exceptions for API failures. All extendCourier\Core\Exceptions\APIException:
Retries
The SDK automatically retries failed requests up to 2 times with exponential backoff.More Operations
The SDK covers the full Courier REST API. Here are a few more resources beyond what’s documented above:| Resource | Method | Use case |
|---|---|---|
| User preferences | $client->users->preferences->retrieve($userId) | Fetch a user’s notification preferences for your preference center |
| Cancel a message | $client->messages->cancel($messageId) | Cancel a delayed or queued message before delivery |
| Push tokens | $client->users->tokens->addSingle($token, userId: $userId) | Register a device push token for iOS, Android, or React Native |
| Automations | $client->automations->invoke->invokeAdHoc(automation: ...) | Run a multi-step workflow via Automations |
API Reference
Full REST API docs with request/response examples.
Send API
Learn about the Send endpoint, routing, and message options.
Quickstart
Send your first notification in under two minutes.
GitHub
Source code, issues, and changelog.