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
$billomat->emailTemplatesJustpilot\Billomat\Api\EmailTemplatesApi.
Endpoints
| Method | HTTP | Path |
|---|---|---|
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>
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.
| Property | Billomat field | Type |
|---|---|---|
id | id | int |
name | name | ?string |
subject | subject | ?string |
body | text (fallback body) | ?string |
fromAddress | from | ?string |
isDefault | is_default | ?bool |
type | type | ?EmailTemplateType |
bcc | bcc | ?bool |
created, updated | created, 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 afromfield, sofromAddressis usuallynulland only kept for backward compatibility.
Document types (EmailTemplateType)
| Value | Used for |
|---|---|
INVOICES | Invoices |
OFFERS | Offers |
CONFIRMATIONS | Order confirmations |
CREDIT_NOTES | Credit notes |
DELIVERY_NOTES | Delivery notes |
REMINDERS | Reminders (dunning letters) |
PAYMENT_THANKS | Payment confirmation |
Unknown values become null.
Pitfalls
isDefaultis 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
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,
);