https://github.com/braze-community/braze-php
📫 PHP library for Braze API.
https://github.com/braze-community/braze-php
api appboy braze braze-api composer jane php rest sdk
Last synced: 5 months ago
JSON representation
📫 PHP library for Braze API.
- Host: GitHub
- URL: https://github.com/braze-community/braze-php
- Owner: braze-community
- License: mit
- Created: 2023-08-13T04:02:49.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2026-01-16T23:29:41.000Z (5 months ago)
- Last Synced: 2026-01-17T11:38:31.601Z (5 months ago)
- Topics: api, appboy, braze, braze-api, composer, jane, php, rest, sdk
- Language: PHP
- Homepage: https://packagist.org/packages/braze/sdk
- Size: 1.38 MB
- Stars: 4
- Watchers: 0
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# braze-php
[](https://packagist.org/packages/braze/sdk)
[](https://github.com/braze-community/braze-php/actions/workflows/build.yml)
[](https://github.com/braze-community/braze-php/actions/workflows/test.yml)
PHP library for [Braze](https://www.braze.com/). The code is generated from the [OpenAPI spec](https://github.com/braze-community/braze-specification).
> [!NOTE]
> _Disclaimer:_ This is a community-maintained project and is not officially endorsed by or affiliated with Braze, Inc.
## Requirements
### Version
PHP >=8.1
### API URL
Use the [REST endpoint](https://www.braze.com/docs/api/basics#endpoints) provisioned to your account when you log in to the dashboard:
| Instance | REST Endpoint |
| -------- | ----------------------------- |
| US-01 | https://rest.iad-01.braze.com |
| US-02 | https://rest.iad-02.braze.com |
| US-03 | https://rest.iad-03.braze.com |
| US-04 | https://rest.iad-04.braze.com |
| US-05 | https://rest.iad-05.braze.com |
| US-06 | https://rest.iad-06.braze.com |
| US-08 | https://rest.iad-08.braze.com |
| EU-01 | https://rest.fra-01.braze.eu |
| EU-02 | https://rest.fra-02.braze.eu |
### API Key
The [API key](https://www.braze.com/docs/api/basics#creating-and-managing-rest-api-keys) can be created in your Braze dashboard.
## Install
Install the package with [Composer](https://getcomposer.org/):
```sh
composer require braze/sdk
```
If you're missing a package providing `psr/http-client-implementation`:
```sh
composer require php-http/guzzle7-adapter
```
Add [autoloading](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
```php
require_once 'vendor/autoload.php';
```
## Usage
Instantiate the SDK:
```php
use Braze\Braze;
$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');
$client = $braze->client;
```
[Send a message](https://www.braze.com/docs/api/endpoints/messaging/send_messages/post_send_messages) to your user:
```php
use Braze\Braze;
use Braze\Model\MessagesSendPostBody;
use Braze\Model\MessagesSendPostBodyMessages;
$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');
$body = new MessagesSendPostBody();
$body->setExternalUserIds(['your_external_user_id']);
$messages = new MessagesSendPostBodyMessages();
$messages->setEmail([
'app_id' => 'your_app_id',
'from' => 'Company ',
'email_template_id' => 'your_email_template_id',
]);
$body->setMessages($messages);
$response = $braze->client->postMessagesSend($body)->getBody();
```
Handle an API error:
```php
use Braze\Braze;
$braze = new Braze('YOUR_API_URL', 'YOUR_API_KEY');
try {
$response = $braze->client->getCatalog()->getBody();
} catch (Throwable $exception) {
echo $exception->getMessage();
echo $exception->getCode();
}
```
## Scripts
### `composer build`
Generate the code:
```sh
composer build
```
### `composer clean`
Delete the `lib/` directory:
```sh
composer clean
```
### `composer test`
Run the tests:
```sh
composer test
```
## About This Package
This package is automatically generated by [Jane](https://github.com/janephp/janephp).
## License
[MIT](https://github.com/braze-community/braze-php/blob/master/LICENSE)
Braze is a registered trademark of Braze, Inc. This project is not managed by Braze, Inc.