Courier PHP SDK supporting:
- Send API
- Messages API
- Profiles API
- Preferences API
- Events API
- Brands API
- Lists API
- Notifications API
- Automations API
- Bulk API
- Audiences API
- Token Management API
- Audit Events API
- Tenants API
- Users API
For a full description of request and response payloads and properties, please see the official Courier API docs.
- PHP 7.2+
- ext-json
This library uses HTTPlug as HTTP client. HTTPlug is an abstraction that allows this library to support different HTTP Clients. Therefore, you need to provide it with an client and/or adapter for the HTTP library you prefer. You can find all the available adapters in Packagist. This documentation assumes you use the Guzzle Client, but you can replace it with any client that you prefer.
The recommended way to install courier-php is through Composer:
composer require trycourier/courier guzzlehttp/guzzle
Instantiate the Courier client class with your authorization token OR username and password. Providing just an authorization token will generate a "Bearer" authorization header, while providing a username and password will generate a "Basic" (base64-encoded) authorization header
$client = new CourierClient("base-url", "authorization-token", "username", "password");
Many methods allow the passing of optional data to the Courier endpoints. This data should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Courier documentation for more information.
$profile = [
"firstname" => "Johnny",
"lastname" => "Appleseed",
"email" => "courier.pigeon@mail.com"
];
For a full description of request and response payloads and properties, please see the official Courier API docs.
sendNotification(string $event, string $recipient, string $brand = NULL, object $profile = NULL, object $data = NULL, object $preferences = NULL, object $override = NULL, string $idempotency_key = NULL): object
(Send API)sendEnhancedNotification(object $message, string $idempotency_key = NULL): object
(Send API)sendNotificationToList(string $event, string $list = NULL, string $pattern = NULL, string $brand = NULL, object $data = NULL, object $override = NULL, string $idempotency_key = NULL): object
(Send list API)
cancelMessage(string $message_id): object
[?]getMessages(string $cursor = NULL, string $event = NULL, string $list = NULL, string $message_id = NULL, string $notification = NULL, string $recipient = NULL): object
[?]getMessage(string $message_id): object
[?]getMessageHistory(string $message_id, string $type = NULL): object
[?]
getLists(string $cursor = NULL, string $pattern = NULL): object
[?]getList(string $list_id): object
[?]putList(string $list_id, string $name): object
[?]deleteList(string $list_id): object
[?]restoreList(string $list_id): object
[?]getListSubscriptions(string $list_id, string $cursor = NULL): object
[?]subscribeMultipleRecipientsToList(string $list_id, array $recipients): object
[?]subscribeRecipientToList(string $list_id, string $recipient_id): object
[?]deleteListSubscription(string $list_id, string $recipient_id): object
[?]
getBrands(string $cursor = NULL): object
[?]createBrand(string $id = NULL, string $name, object $settings, object $snippets = NULL, string $idempotency_key = NULL): object
[?]getBrand(string $brand_id): object
[?]replaceBrand(string $brand_id, string $name, object $settings, object $snippets = NULL): object
[?]deleteBrand(string $brand_id): object
[?]
getEvents(): object
[?]getEvent(string $event_id): object
[?]putEvent(string $event_id, string $id, string $type): object
[?]
getProfile(string $recipient_id): object
[?]upsertProfile(string $recipient_id, object $profile): object
[?]patchProfile(string $recipient_id, array $patch): object
[?]replaceProfile(string $recipient_id, object $profile): object
[?]getProfileLists(string $recipient_id, string $cursor = NULL): object
[?]
getPreferences(string $recipient_id, string $preferred_channel): object
[?]updatePreferences(string $recipient_id, string $preferred_channel): object
[?]
listNotifications(string $cursor = NULL): object
getNotificationContent(string $id): object
getNotificationDraftContent(string $id): object
postNotificationVariations(string $id, array $blocks, array $channels = NULL): object
postNotificationDraftVariations(string $id, array $blocks, array $channels = NULL): object
getNotificationSubmissionChecks(string $id, string $submissionId): object
putNotificationSubmissionChecks(string $id, string $submissionId, array $checks): object
deleteNotificationSubmission(string $id, string $submissionId): object
invokeAutomation(object $automation, string $brand = NULL, string $template = NULL, string $recipient = NULL, object $data = NULL, object $profile = NULL): object
[?]invokeAutomationFromTemplate(string $templateId, string $brand = NULL, object $data = NULL, object $profile = NULL, string $recipient = NULL, string $template = NULL): object
[?]getAutomationRun(string $runId): object
createBulkJob(object $message): object
(Create Bulk Job)ingestBulkJob(string $jobId, array $users): object
(Ingest Bulk Job Users)runBulkJob(string $jobId): object
(Run Bulk Job)getBulkJob(string $jobId): object
(Get Bulk Job)getBulkJobUsers(string $jobId): object
(Get Bulk Job Users)
putAudience(object $audience): object
(Create Audience)getAudience(string $audienceId): object
(Get Audience)getAudienceMembers(string $audienceId): object
(List audience members)getAudiences(): object
(List audiences)
putUserTokens(string $user_id, array $tokens): object
(Put User Tokens)putUserToken(string $user_id, array $token): object
(Put User Token)patchUserToken(string $user_id, string $token, array $patch): object
(Patch User Token)getUserToken(string $user_id, string $token): object
(Get User Token)getUserTokens(string $user_id): object
(Get User Tokens)
getAuditEvent(string $audit_event_id): object
(Get Audit Event)listAuditEvents(string $cursor = NULL): object
(List Audit Events)
getAccount(): object
(Get Account)listAccounts(string $cursor = NULL): object
(List Accounts)putAccount(string $account_id, object $account): object
(Put Account)deleteAccount(string $account_id): object
(Delete Account)
getTenant(): object
(Get Tenant)listTenants(string $cursor = NULL): object
(List Tenants)putTenant(string $tenant_id, object $tenant): object
(Put Tenant)deleteTenant(string $tenant_id): object
(Delete Tenant)
putUser(): object
(Put User)putUserTenants(): object
(Put User Tenants)
All unsuccessful (non 2xx) responses will throw a CourierRequestException
. The full response object is available via the getResponse()
method.