Use this file to discover all available pages before exploring further.
The audience API manages everything campaigns send to: contact lists, the contacts themselves, subscription topics, custom properties, and dynamic segments. Everything is reached through Lettr::audience():
Pass a DoubleOptInConfig to create the contact as unverified and trigger a confirmation email — the contact becomes subscribed once they click the link.
use Lettr\Dto\Audience\CreateAudienceContactData;use Lettr\Dto\Audience\DoubleOptInConfig;Lettr::audience()->contacts()->create(new CreateAudienceContactData( email: 'jane@example.com', doubleOptIn: new DoubleOptInConfig( from: 'hello@example.com', subject: 'Confirm your subscription', templateSlug: 'email-confirmation', redirectUrl: 'https://example.com/confirmed', fromName: 'Example', // optional ),));
A segment is a dynamic group defined by conditions. Groups are joined by OR, and conditions within a group are joined by AND.
use Lettr\Dto\Audience\CreateAudienceSegmentData;use Lettr\Dto\Audience\UpdateAudienceSegmentData;use Lettr\Dto\Audience\ListAudienceSegmentsFilter;use Lettr\Dto\Audience\SegmentConditionsInput;use Lettr\Dto\Audience\SegmentConditionGroup;use Lettr\Dto\Audience\SegmentCondition;use Lettr\Enums\SegmentOperator;$conditions = new SegmentConditionsInput(groups: [ new SegmentConditionGroup(conditions: [ new SegmentCondition('email', SegmentOperator::EndsWith, '@example.com'), new SegmentCondition('plan', SegmentOperator::Equals, 'pro'), ]),]);$segment = Lettr::audience()->segments()->create(new CreateAudienceSegmentData( name: 'Pro users at example.com', conditions: $conditions, listId: 'list-uuid', // optional: restrict to one list (null = all lists)));$response = Lettr::audience()->segments()->list( ListAudienceSegmentsFilter::create()->listId('list-uuid'));$segment = Lettr::audience()->segments()->get('segment-uuid');// The update DTO uses a builder — only the touched fields are sentLettr::audience()->segments()->update('segment-uuid', UpdateAudienceSegmentData::empty() ->withName('Renamed segment') ->withConditions($conditions));Lettr::audience()->segments()->delete('segment-uuid');
Operators that don’t take a value (SegmentOperator::IsTrue, SegmentOperator::IsFalse) report this via requiresValue().