
For years, every time a TYPO3 site had to tell another system “something changed”, I wrote the same thing again. A DataHandler hook, a Guzzle call inside it, a try/catch so the editor does not get an exception when the other server is down, and a log line nobody reads. It worked. It was also a small piece of custom code in every project that had to survive every upgrade.
The other direction was even more fun. An external tool wants to create a record in TYPO3, so you build a tiny eID script or a middleware with its own token check. Every project had its own flavour of this.
Since TYPO3 v12.1 the core ships two system extensions for exactly these jobs, and in v14 they are mature enough that I reach for them first: typo3/cms-webhooks for outgoing calls and typo3/cms-reactions for incoming ones. Honestly, I ignored them for quite a while because the names sounded like marketing. They are not.
Two directions, two extensions
The simplest way to keep them apart:
- Webhooks are TYPO3 calling out. Something happens inside TYPO3 (a page is changed, a file is added, a login fails), and TYPO3 sends a JSON request to a URL you configure.
- Reactions are TYPO3 being called. An external system sends a POST request with a secret to a TYPO3 endpoint, and TYPO3 does something, for example creates a record.
Both are configured as records in the backend, under the Integrations module, not in PHP files. That was the part that convinced me. An integrator can switch a webhook off, change the target URL or rotate a secret without a deployment.
Both are separate packages, so in a Composer project you add them first:
ddev composer require typo3/cms-webhooks typo3/cms-reactions
ddev exec vendor/bin/typo3 extension:setupWebhooks: what comes out of the box
The core already brings a few webhook types: page modifications, files added, updated and removed, failed logins and failed MFA verifications. You create a webhook record, pick the type, enter the target URL and the HTTP method, and TYPO3 generates a secret for you.
Every request carries two headers you should care about: Webhook-Signature-Algo (currently sha256) and Webhook-Signature. The signature is an HMAC of the webhook identifier and the body, joined with a colon, using the secret. I had to read the message handler in the core to get the exact format right the first time, so here it is for the receiving side:
<?php
// Receiver, e.g. a small PHP endpoint on the other system
$secret = getenv('TYPO3_WEBHOOK_SECRET');
$identifier = getenv('TYPO3_WEBHOOK_IDENTIFIER'); // the UUID of the webhook record
$body = file_get_contents('php://input');
$expected = hash_hmac('sha256', $identifier . ':' . $body, $secret);
$given = $_SERVER['HTTP_WEBHOOK_SIGNATURE'] ?? '';
if (!hash_equals($expected, $given)) {
http_response_code(401);
exit;
}
$payload = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
// $payload['action'], $payload['record'], $payload['site'] ...Always use hash_equals() there, not ===. It is a small thing that people skip.
Solution: your own webhook type from a PSR-14 event
The nice part is how you add your own types. A webhook message is just a class with an attribute. Let’s say the security team wants a ping in their chat tool every time a backend user logs in. TYPO3 already dispatches AfterUserLoggedInEvent, so we only need a message for it.
Step 1: Create the message class in your site package or extension:
<?php
declare(strict_types=1);
namespace HojaSitepackageWebhook;
use TYPO3CMSCoreAttributeWebhookMessage;
use TYPO3CMSCoreAuthenticationBackendUserAuthentication;
use TYPO3CMSCoreAuthenticationEventAfterUserLoggedInEvent;
use TYPO3CMSCoreMessagingWebhookMessageInterface;
#[WebhookMessage(
identifier: 'hoja/backend-login',
description: 'A backend user logged in'
)]
final readonly class BackendLoginMessage implements WebhookMessageInterface
{
public function __construct(
private string $username,
private bool $isAdmin,
private string $ip,
) {}
public static function createFromEvent(AfterUserLoggedInEvent $event): ?self
{
$user = $event->getUser();
if (!$user instanceof BackendUserAuthentication) {
return null;
}
return new self(
(string)($user->user['username'] ?? ''),
$user->isAdmin(),
(string)($event->getRequest()?->getServerParams()['REMOTE_ADDR'] ?? ''),
);
}
public function jsonSerialize(): array
{
return [
'username' => $this->username,
'isAdmin' => $this->isAdmin,
'ip' => $this->ip,
];
}
}Step 2: Make sure your Services.yaml has autowire: true and autoconfigure: true for your classes (the usual default). The compiler pass of the webhooks extension reads the attribute and looks at the type of the first parameter of createFromEvent(). That type is the event it listens to. No listener class, no registration file.
Step 3: Flush caches, open the Webhooks module, and your type “A backend user logged in” is in the list. Create a record, point it at the receiver, done.
Returning null from the factory is allowed. The core listener simply skips sending in that case, which is how I filter out frontend logins here. I checked that in the listener code because I didn’t want to rely on a guess.
Sync or async
Webhook messages go through TYPO3’s message bus, which is Symfony Messenger underneath. By default the routing is synchronous. That means the editor’s save request waits until the other server answers. For a slow or flaky target, I don’t like that at all.
You can route the messages to the Doctrine transport and let a worker send them:
// config/system/additional.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['messenger']['routing'][
TYPO3CMSCoreMessagingWebhookMessageInterface::class
] = 'doctrine'; ddev exec vendor/bin/typo3 messenger:consume doctrineOn production, the consume command needs a cron job or a supervisor process. If nobody runs it, the messages just pile up in the database, and you will wonder why nothing arrives.
Reactions: TYPO3 being called
Reactions are the mirror. You create a reaction record, TYPO3 gives it a UUID and a secret, and the endpoint becomes:
curl -X POST 'https://example.org/typo3/reaction/a5cffc58-b69a-42f6-9866-f93ec1ad9dc5'
-H 'x-api-key: the-secret-from-the-record'
-H 'Content-Type: application/json'
-d '{"title": "New event from the booking tool", "teaser": "Opens on Monday"}'The built-in type is “Create database record”. You choose the table, the storage page and map fields with placeholders like ${title} to values from the JSON payload. The response has an X-TYPO3-Reaction-Success header, which is handy in the logs of the calling system.
For anything beyond creating a record, you write your own reaction type. The interface is small:
<?php
declare(strict_types=1);
namespace HojaSitepackageReaction;
use PsrHttpMessageResponseFactoryInterface;
use PsrHttpMessageResponseInterface;
use PsrHttpMessageServerRequestInterface;
use PsrHttpMessageStreamFactoryInterface;
use TYPO3CMSCoreCacheCacheManager;
use TYPO3CMSReactionsModelReactionInstruction;
use TYPO3CMSReactionsReactionReactionInterface;
final readonly class FlushPageCacheReaction implements ReactionInterface
{
public function __construct(
private CacheManager $cacheManager,
private ResponseFactoryInterface $responseFactory,
private StreamFactoryInterface $streamFactory,
) {}
public static function getType(): string
{
return 'hoja-flush-page-cache';
}
public static function getDescription(): string
{
return 'Flush the page cache for a tag';
}
public static function getIconIdentifier(): string
{
return 'actions-system-cache-clear';
}
public function react(ServerRequestInterface $request, array $payload, ReactionInstruction $reaction): ResponseInterface
{
$tag = (string)($payload['tag'] ?? '');
if (!preg_match('/^[a-z0-9_]+$/', $tag)) {
return $this->json(['success' => false, 'error' => 'invalid tag'], 400);
}
$this->cacheManager->flushCachesInGroupByTag('pages', $tag);
return $this->json(['success' => true]);
}
private function json(array $data, int $status = 200): ResponseInterface
{
return $this->responseFactory->createResponse($status)
->withHeader('Content-Type', 'application/json')
->withBody($this->streamFactory->createStream(json_encode($data, JSON_THROW_ON_ERROR)));
}
}With autoconfigure on, the class is picked up as a reaction type because it implements the interface. Validate the payload yourself. The secret check only proves who is calling, not that the data is sane.
What I would watch out for
- Secrets live in the database. Treat database dumps like you treat
.envfiles. - Webhooks fire in workspaces too; the page message includes the workspace id. Filter on the receiving side if you only care about live.
- Failed deliveries are logged, not retried by default. If the target matters, go async and keep an eye on the logs.
- The reaction endpoint sits under
/typo3/. If you protect the backend path with IP restrictions or basic auth on the web server, the caller needs an exception for that one route.
That’s it. Two small extensions that replace a lot of glue code I wrote by hand over the years. If you already use them in a bigger setup, I would love to hear how you handle retries.
Cheers!