Skip to content

Working with Message Streams

Vlad-Cosmin Sandu edited this page Jun 8, 2020 · 1 revision

The PostmarkClient allows you to easily manage your Message Streams.

Get details about an existing message stream:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$messageStreamId = "my-stream-id";

$result = $client->getMessageStream($messageStreamId);

List existing message streams:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$messageStreamType = "Transactional"; // Filter by stream type; Defaults to All.
$includeArchivedStreams = true; // Optional. Defaults to false.

$result = $client->listMessageStreams($messageStreamType, $includeArchivedStreams);

Create a new message stream:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$id = "new-stream-id";
$messageStreamType = "Broadcasts";
$name = "My Broadcasts Stream";
$description = "This is my new stream description."; // optional

$createdStream = $client->createMessageStream($id, $messageStreamType, $name, $description);

Edit an existing message stream:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$id = "my-stream-id";
$updatedName = "New Name"; // optional
$updatedDescription = "New Description"; // optional

$updatedStream = $client->editMessageStream($id, $updatedName, $updatedDescription);

Archive a message stream:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$id = "stream-to-archive";

$archivalConfirmation = $client->archiveMessageStream($id);

Archiving a message stream will disable sending/receiving messages via that stream. The stream will also stop being shown in the Postmark UI. Once a stream has been archived, it will be deleted (alongside associated data) at the ExpectedPurgeDate in the response.

Unarchive a message stream:

use Postmark\PostmarkClient;

$client = new PostmarkClient("<server token>");

$id = "archived-stream-id";

$unarchivedStream = $client->unarchiveMessageStream($id);

Unarchiving a message stream will resume sending/receiving messages via that stream. The stream will also re-appear in the Postmark UI. A stream can be unarchived only before the stream's ExpectedPurgeDate.