API Reference: On Behalf Of
Two modes for API-level impersonation.
Block-based (preferred): $client->performOnBehalfOf($userId, fn() => ...) sets the X-On-Behalf-Of header before the callback and clears it in a finally block — guaranteed cleanup even if the callback throws. Use for single or batched operations where impersonation should be temporary.
Persistent: $client->setOnBehalfOfUser($id) sets the header globally — all subsequent requests carry it until unsetOnBehalfOfUser() is called. Use when an entire process runs as a specific user.
The header is injected by RequestHandler — if onBehalfOfUser is set, every request() call adds the header before sending.
Acceptance Criteria
Depends on
Produces
ZammadClient (onBehalfOf methods)
RequestHandler (header injection)
API Reference: On Behalf Of
Two modes for API-level impersonation.
Block-based (preferred):
$client->performOnBehalfOf($userId, fn() => ...)sets theX-On-Behalf-Ofheader before the callback and clears it in afinallyblock — guaranteed cleanup even if the callback throws. Use for single or batched operations where impersonation should be temporary.Persistent:
$client->setOnBehalfOfUser($id)sets the header globally — all subsequent requests carry it untilunsetOnBehalfOfUser()is called. Use when an entire process runs as a specific user.The header is injected by
RequestHandler— ifonBehalfOfUseris set, everyrequest()call adds the header before sending.Acceptance Criteria
Depends on
Produces
ZammadClient(onBehalfOf methods)RequestHandler(header injection)