Skip to content

Client Classes

N8nClient

Namespace:

php
PhpN8n\Client\N8nClient

Main entry point for webhook triggering and execution tracking.

Constructor

php
public function __construct(
    ClientInterface $httpClient,
    RequestFactoryInterface $requestFactory,
    StreamFactoryInterface $streamFactory,
    ?ApiConfig $apiConfig = null,
    ?WebhookResponseResolverContract $webhookResponseResolver = null,
    HookRunnerContract $hooks = new NullHookRunner(),
    ?WebhookTriggererContract $webhookTriggerer = null,
    ?ExecutionTrackerContract $executionTracker = null,
)
ParameterTypeRequiredPurpose
httpClientPsr\Http\Client\ClientInterfaceYesSends HTTP requests.
requestFactoryPsr\Http\Message\RequestFactoryInterfaceYesCreates PSR-7 requests.
streamFactoryPsr\Http\Message\StreamFactoryInterfaceYesCreates request body streams.
apiConfig`ApiConfignull`No
webhookResponseResolver`WebhookResponseResolverContractnull`No
hooksHookRunnerContractNoLifecycle hook runner.
webhookTriggerer`WebhookTriggererContractnull`No
executionTracker`ExecutionTrackerContractnull`No

webhooks()

php
public function webhooks(): WebhookTriggererContract

Returns the configured webhook triggerer or creates the default WebhookTriggerer.

executions()

php
public function executions(): ExecutionTrackerContract

Returns the configured execution tracker or creates the default ExecutionTracker.

Throws N8nException when no ApiConfig is available and no custom execution tracker was provided.

execution()

php
public function execution(ExecutionReference $reference): Execution

Returns a convenience wrapper for one execution reference.

Execution

Namespace:

php
PhpN8n\Client\Execution

Small wrapper around ExecutionTrackerContract for one ExecutionReference.

Constructor

php
public function __construct(
    ExecutionReference $reference,
    ExecutionTrackerContract $tracker,
)

Methods

MethodReturnsPurpose
reference()ExecutionReferenceReturns the wrapped reference.
refresh(?ExecutionFetchOptions $options = null)ExecutionResultFetches the latest execution result.
wait(?PollingConfig $polling = null)ExecutionResultWaits until the execution reaches a terminal status.

Released under the MIT License.