Documentation for 4.0 (pre-release). Using 3.x? See the README on main.
Skip to content

Email Templates (E-Mail-Vorlagen) ​

API wrapper for e-mail templates at /email-templates. Templates are chosen in the Billomat UI when sending documents (invoices, offers, reminders, etc.); each document type has exactly one default template.

Access ​

php
$billomat->emailTemplates

Justpilot\Billomat\Api\EmailTemplatesApi.

Endpoints ​

MethodHTTPPath
list($filters?)GET/email-templates
listPage($filters?)GET/email-templates
iterateAll($filters?, $pageSize?)GET/email-templates (all pages)
get($id)GET/email-templates/{id}
getOrFail($id)GET/email-templates/{id}

Read-only in the SDK. Billomat supports create/update/delete, but the SDK doesn't expose them as methods.

Methods ​

list(array $filters = []): list<EmailTemplate> ​

php
foreach ($billomat->emailTemplates->list() as $tpl) {
    printf("#%d %s%s\n",
        $tpl->id,
        $tpl->name ?? '(no name)',
        $tpl->isDefault ? ' (default)' : '',
    );
}

Pagination via page/per_page; see Pagination and filtering.

listPage(array $filters = []): Page<EmailTemplate> ​

One page plus PageInfo.

iterateAll(array $filters = [], int $pageSize = 100): Generator<EmailTemplate> ​

Lazy iteration over all pages.

get(int $id): ?EmailTemplate ​

Returns null on 404.

getOrFail(int $id): EmailTemplate ​

Like get(), but throws NotFoundException instead of returning null.

Read model: EmailTemplate ​

final readonly class EmailTemplate.

PropertyBillomat fieldType
ididint
namename?string
subjectsubject?string
bodytext (fallback body)?string
fromAddressfrom?string
isDefaultis_default?bool
typetype?EmailTemplateType
bccbcc?bool
created, updatedcreated, updated?\DateTimeImmutable
extra—array<string,mixed>: fields the SDK doesn't map yet, raw (see Read models)

Billomat returns the message text in the field text; the SDK still exposes it as $body. The API no longer returns a from field, so fromAddress is usually null and only kept for backward compatibility.

Document types (EmailTemplateType) ​

ValueUsed for
INVOICESInvoices
OFFERSOffers
CONFIRMATIONSOrder confirmations
CREDIT_NOTESCredit notes
DELIVERY_NOTESDelivery notes
REMINDERSReminders (dunning letters)
PAYMENT_THANKSPayment confirmation

Unknown values become null.

Pitfalls ​

  • isDefault is unique per type. Each document type has exactly one default template; setting a new default replaces the old one on the server.
  • Single-item list quirk. With only one template Billomat returns an object instead of a list; listResource() normalizes this.

End-to-end example ​

php
<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use Justpilot\Billomat\BillomatClient;
use Justpilot\Billomat\Model\Enum\EmailTemplateType;

$billomat = BillomatClient::create(
    billomatId: 'mycompany',
    apiKey: getenv('BILLOMAT_API_KEY'),
);

$defaults = array_filter(
    $billomat->emailTemplates->list(),
    static fn ($tpl) => $tpl->isDefault === true,
);

foreach ($defaults as $tpl) {
    printf("Default: #%d %s — subject '%s'\n",
        $tpl->id,
        $tpl->name ?? '',
        $tpl->subject ?? '',
    );
}

// Default template for invoices
$invoiceDefault = array_find(
    $defaults,
    static fn ($tpl) => $tpl->type === EmailTemplateType::INVOICES,
);

Unofficial SDK, not affiliated with Billomat GmbH. Released under the Apache License 2.0.