elasticemail/elasticemail-php
PHP client for Elastic Email’s REST API. Authenticate with your API key and manage campaigns and other resources via GET/POST/PUT/DELETE. Supports PHP 7.4+ (incl. 8.0) and uses Guzzle with configurable timeouts and connection limits.
All URIs are relative to https://api.elasticemail.com/v4, except if the operation defines another base path.
| Method | HTTP request | Description |
|---|---|---|
| segmentsByNameDelete() | DELETE /segments/{name} | Delete Segment |
| segmentsByNameGet() | GET /segments/{name} | Load Segment |
| segmentsByNamePut() | PUT /segments/{name} | Update Segment |
| segmentsGet() | GET /segments | Load Segments |
| segmentsPost() | POST /segments | Add Segment |
segmentsByNameDelete()segmentsByNameDelete($name)
Delete Segment
Delete an existing segment. Required Access Level: ModifyContacts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apikey
$config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKey('X-ElasticEmail-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-ElasticEmail-ApiKey', 'Bearer');
$apiInstance = new ElasticEmail\Api\SegmentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$name = My Segment 1; // string | Name of your segment.
try {
$apiInstance->segmentsByNameDelete($name);
} catch (Exception $e) {
echo 'Exception when calling SegmentsApi->segmentsByNameDelete: ', $e->getMessage(), PHP_EOL;
}
| Name | Type | Description | Notes |
|---|---|---|---|
| name | string | Name of your segment. |
void (empty response body)
[Back to top] [Back to API list] [Back to Model list] [Back to README]
segmentsByNameGet()segmentsByNameGet($name): \ElasticEmail\Model\Segment
Load Segment
Returns details for the specified segment. Required Access Level: ViewContacts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apikey
$config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKey('X-ElasticEmail-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-ElasticEmail-ApiKey', 'Bearer');
$apiInstance = new ElasticEmail\Api\SegmentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$name = 'name_example'; // string | Name of the segment you want to load. Will load all contacts if the 'All Contacts' name has been provided
try {
$result = $apiInstance->segmentsByNameGet($name);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SegmentsApi->segmentsByNameGet: ', $e->getMessage(), PHP_EOL;
}
| Name | Type | Description | Notes |
|---|---|---|---|
| name | string | Name of the segment you want to load. Will load all contacts if the 'All Contacts' name has been provided |
application/json[Back to top] [Back to API list] [Back to Model list] [Back to README]
segmentsByNamePut()segmentsByNamePut($name, $segment_payload): \ElasticEmail\Model\Segment
Update Segment
Rename or change RULE for your segment. Required Access Level: ModifyContacts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apikey
$config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKey('X-ElasticEmail-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-ElasticEmail-ApiKey', 'Bearer');
$apiInstance = new ElasticEmail\Api\SegmentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$name = My Segment 1; // string | Name of your segment.
$segment_payload = new \ElasticEmail\Model\SegmentPayload(); // \ElasticEmail\Model\SegmentPayload
try {
$result = $apiInstance->segmentsByNamePut($name, $segment_payload);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SegmentsApi->segmentsByNamePut: ', $e->getMessage(), PHP_EOL;
}
| Name | Type | Description | Notes |
|---|---|---|---|
| name | string | Name of your segment. | |
| segment_payload | \ElasticEmail\Model\SegmentPayload |
application/jsonapplication/json[Back to top] [Back to API list] [Back to Model list] [Back to README]
segmentsGet()segmentsGet($limit, $offset): \ElasticEmail\Model\Segment[]
Load Segments
Returns a list of all your available Segments. Required Access Level: ViewContacts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apikey
$config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKey('X-ElasticEmail-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-ElasticEmail-ApiKey', 'Bearer');
$apiInstance = new ElasticEmail\Api\SegmentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$limit = 100; // int | Maximum number of returned items.
$offset = 20; // int | How many items should be returned ahead.
try {
$result = $apiInstance->segmentsGet($limit, $offset);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SegmentsApi->segmentsGet: ', $e->getMessage(), PHP_EOL;
}
| Name | Type | Description | Notes |
|---|---|---|---|
| limit | int | Maximum number of returned items. | [optional] |
| offset | int | How many items should be returned ahead. | [optional] |
application/json[Back to top] [Back to API list] [Back to Model list] [Back to README]
segmentsPost()segmentsPost($segment_payload): \ElasticEmail\Model\Segment
Add Segment
Add a new segment, based on specified RULE. Required Access Level: ModifyContacts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: apikey
$config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKey('X-ElasticEmail-ApiKey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = ElasticEmail\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-ElasticEmail-ApiKey', 'Bearer');
$apiInstance = new ElasticEmail\Api\SegmentsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$segment_payload = new \ElasticEmail\Model\SegmentPayload(); // \ElasticEmail\Model\SegmentPayload
try {
$result = $apiInstance->segmentsPost($segment_payload);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SegmentsApi->segmentsPost: ', $e->getMessage(), PHP_EOL;
}
| Name | Type | Description | Notes |
|---|---|---|---|
| segment_payload | \ElasticEmail\Model\SegmentPayload |
application/jsonapplication/json[Back to top] [Back to API list] [Back to Model list] [Back to README]
How can I help you explore Laravel packages today?