Download the PHP package kayedspace/laravel-n8n without Composer
On this page you can find all versions of the php package kayedspace/laravel-n8n. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kayedspace/laravel-n8n
More information about kayedspace/laravel-n8n
Files in kayedspace/laravel-n8n
Package laravel-n8n
Short Description A complete, expressive, and fluent Laravel client for the n8n public REST API and Webhooks Triggering.
License MIT
Informations about the package laravel-n8n
Laravel N8N: A Fluent Client for n8n Automation Workflows
A complete, expressive, and fluent Laravel client for the n8n public REST API and Webhooks Triggering, empowering Laravel developers to interact seamlessly with n8n webhooks, workflows, executions, credentials, tags, users, variables, projects, source control operations and more.
Table of Contents
- ๐ฆ Installation
- โ๏ธ Configuration
- ๐ Quick Start
- โก Webhooks
- ๐๏ธ Workflow Builder
- ๐ API Resources
- ๐ต Audit
- ๐ Credentials
- โฏ๏ธ Executions
- ๐ง Projects
- ๐ Source Control
- ๐ท๏ธ Tags
- ๐ Users
- ๐ Variables
- ๐ Workflows
- ๐ง Advanced Features
- ๐ Events System
- ๐พ Response Caching
- ๐ Logging
- ๐ Client Modifiers
- ๐ง Macros
- โ ๏ธ Exception Handling
- ๐ฅ Health Checks
- ๐งช Testing
- ๐จ CLI Commands
- ๐ค Contributing
- ๐ Support
- ๐ License
๐ฆ Installation
Install via Composer:
Service providers and facades are auto-discovered by Laravel.
โ๏ธ Configuration
Publish and customize the configuration file:
Set environment variables in .env:
๐ Quick Start
โก Webhooks
The Webhooks client enables triggering n8n workflow webhooks with support for multiple HTTP methods, authentication, async processing, and signature verification.
Basic Usage
Basic auth is applied by default if
N8N_WEBHOOK_USERNAMEandN8N_WEBHOOK_PASSWORDare set in .env.
Async Webhook Triggering
Queue webhook triggers for background processing:
Webhook Signature Verification
Secure incoming n8n webhooks with HMAC verification:
๐๏ธ Workflow Builder
Build n8n workflows programmatically using a fluent, expressive DSL:
๐ API Resources
Below is an exhaustive reference covering every resource and method provided.
๐ต Audit
| Method | HTTP Method & Path | Description |
|---|---|---|
generate(array $additionalOptions = []) |
POST /audit |
Generate a full audit report based on optional categories or filters |
Description: This endpoint performs a security audit of your n8n instance and returns diagnostics grouped by category. It must be invoked by an account with owner privileges.
๐ Credentials
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
create(array $payload) |
POST /credentials |
Create a credential using the appropriate type schema. |
list(array $filters = []) |
GET /credentials |
List stored credentials with optional pagination. |
all(array $filters = []) |
GET /credentials |
Auto-paginate and retrieve all credentials. |
listIterator(array $filters = []) |
GET /credentials |
Memory-efficient generator for iterating credentials. |
get(string $id) |
GET /credentials/{id} |
Retrieve details of a specific credential by ID. |
delete(string $id) |
DELETE /credentials/{id} |
Delete a credential permanently. |
schema(string $typeName) |
GET /credentials/schema/{typeName} |
Get the schema definition for a credential type. |
transfer(string $id, string $destinationProjectId) |
PUT /credentials/{id}/transfer |
Move a credential to another project using its ID. |
Examples:
โฏ๏ธ Executions
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
list(array $filters = []) |
GET /executions |
Retrieve a paginated list of workflow executions. Supports filters such as status, workflowId, projectId, includeData, limit, cursor. |
all(array $filters = []) |
GET /executions |
Auto-paginate and retrieve all executions matching filters. |
listIterator(array $filters = []) |
GET /executions |
Memory-efficient generator for iterating through all executions. |
get(int $id, bool $includeData = false) |
GET /executions/{id} |
Retrieve detailed information for a specific execution. Optionally include execution data. |
wait(int $id, int $timeout = 60, int $interval = 2) |
GET /executions/{id} |
Poll an execution until completion or timeout. Throws ExecutionFailedException on failure. |
delete(int $id) |
DELETE /executions/{id} |
Delete an execution record by ID. |
deleteMany(array $ids) |
DELETE /executions/{id} |
Delete multiple executions. Returns results array with success/error for each ID. |
Examples:
๐ง Projects
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
create(array $payload) |
POST /projects |
Create a new project with name, description, etc. |
list(array $filters = []) |
GET /projects |
Retrieve a paginated list of projects. |
all(array $filters = []) |
GET /projects |
Auto-paginate and retrieve all projects. |
listIterator(array $filters = []) |
GET /projects |
Memory-efficient generator for iterating through all projects. |
update(string $projectId, array $payload) |
PUT /projects/{projectId} |
Update project name or metadata. Returns 204 No Content on success. |
delete(string $projectId) |
DELETE /projects/{projectId} |
Delete a project by ID. Returns 204 No Content on success. |
addUsers(string $projectId, array $relations) |
POST /projects/{projectId}/users |
Add users to a project with specified roles via the relations array. |
changeUserRole(string $projectId, string $userId, string $role) |
PATCH /projects/{projectId}/users/{userId} |
Change the role of an existing user within a project. |
removeUser(string $projectId, string $userId) |
DELETE /projects/{projectId}/users/{userId} |
Remove a user from a project. |
Examples:
๐ Source Control
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
pull(array $payload) |
POST /source-control/pull |
Trigger a pull operation from the connected Git source for all projects. |
Example:
Requires source control integration to be configured in the n8n instance.
๐ท๏ธ Tags
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
create(array $payload) |
POST /tags |
Create a new tag with the given name or properties. |
list(array $filters = []) |
GET /tags |
List all tags with optional pagination using limit/cursor. |
all(array $filters = []) |
GET /tags |
Auto-paginate and retrieve all tags. |
listIterator(array $filters = []) |
GET /tags |
Memory-efficient generator for iterating through all tags. |
get(string $id) |
GET /tags/{id} |
Retrieve a single tag by its ID. |
update(string $id, array $payload) |
PUT /tags/{id} |
Update the name or properties of a specific tag. |
delete(string $id) |
DELETE /tags/{id} |
Delete a tag permanently by its ID. |
createMany(array $tags) |
POST /tags |
Create multiple tags. Returns results with success/error. |
deleteMany(array $ids) |
DELETE /tags/{id} |
Delete multiple tags. Returns results with success/error. |
Examples:
๐ Users
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
list(array $filters = []) |
GET /users |
List users with optional filters: limit, cursor, includeRole, projectId. |
all(array $filters = []) |
GET /users |
Auto-paginate and retrieve all users. |
listIterator(array $filters = []) |
GET /users |
Memory-efficient generator for iterating through all users. |
create(array $userPayloads) |
POST /users |
Create (invite) one or more users by providing user objects. |
get(string $idOrEmail, bool $includeRole = false) |
GET /users/{idOrEmail} |
Get a user by ID or email. Optionally include role. |
delete(string $idOrEmail) |
DELETE /users/{idOrEmail} |
Delete a user by ID or email. |
changeRole(string $idOrEmail, string $newRoleName) |
PATCH /users/{idOrEmail}/role |
Change the user's role to the new role name. |
Examples:
๐ Variables
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
create(array $payload) |
POST /variables |
Create a new variable with a key-value pair. |
list(array $filters = []) |
GET /variables |
List variables with optional pagination using limit and cursor. |
all(array $filters = []) |
GET /variables |
Auto-paginate and retrieve all variables. |
listIterator(array $filters = []) |
GET /variables |
Memory-efficient generator for iterating through all variables. |
update(string $id, array $payload) |
PUT /variables/{id} |
Update the value of an existing variable. |
delete(string $id) |
DELETE /variables/{id} |
Permanently delete a variable. |
createMany(array $variables) |
POST /variables |
Create multiple variables. Returns results with success/error. |
deleteMany(array $ids) |
DELETE /variables/{id} |
Delete multiple variables. Returns results with success/error. |
Examples:
๐ Workflows
| Method Signature | HTTP Method & Path | Description |
|---|---|---|
create(array $payload) |
POST /workflows |
Create a new workflow using a flow definition. |
list(array $filters = []) |
GET /workflows |
List workflows with optional filters: active, tags, projectId, etc. |
all(array $filters = []) |
GET /workflows |
Auto-paginate and retrieve all workflows matching filters. |
listIterator(array $filters = []) |
GET /workflows |
Memory-efficient generator for iterating through all workflows. |
get(string $id, bool $excludePinnedData = false) |
GET /workflows/{id} |
Retrieve a specific workflow; optionally exclude pinned node data. |
update(string $id, array $payload) |
PUT /workflows/{id} |
Update the workflow definition. |
delete(string $id) |
DELETE /workflows/{id} |
Delete the specified workflow. |
activate(string $id) |
POST /workflows/{id}/activate |
Activate the workflow. |
deactivate(string $id) |
POST /workflows/{id}/deactivate |
Deactivate the workflow. |
activateMany(array $ids) |
POST /workflows/{id}/activate |
Activate multiple workflows. Returns results with success/error per ID. |
deactivateMany(array $ids) |
POST /workflows/{id}/deactivate |
Deactivate multiple workflows. Returns results with success/error per ID. |
deleteMany(array $ids) |
DELETE /workflows/{id} |
Delete multiple workflows. Returns results with success/error per ID. |
export(string $id) |
GET /workflows/{id} |
Export workflow definition (for backup/migration). |
import(array $workflow) |
POST /workflows |
Import a workflow definition. |
transfer(string $id, string $destinationProjectId) |
PUT /workflows/{id}/transfer |
Move a workflow to a different project. |
tags(string $id) |
GET /workflows/{id}/tags |
Get all tags associated with the workflow. |
updateTags(string $id, array $tagIds) |
PUT /workflows/{id}/tags |
Update the list of tag IDs for a workflow. |
Examples:
๐ง Advanced Features
๐ Events System
Every mutating request (create/update/delete/transfer/role-change, etc.) dispatches a strongly-typed Laravel event so you can observe n8n activity in real time. Cached reads still trigger the ApiRequestCompleted event, so metrics and listeners remain consistent even when responses are served from cache.
Available events
| Resource | Events Fired |
|---|---|
| API Client | ApiRequestCompleted, RateLimitEncountered |
| Workflows | WorkflowCreated, WorkflowUpdated, WorkflowDeleted, WorkflowActivated, WorkflowDeactivated, WorkflowTransferred, WorkflowTagsUpdated |
| Executions | ExecutionCompleted, ExecutionFailed, ExecutionDeleted |
| Credentials | CredentialCreated, CredentialDeleted, CredentialTransferred |
| Projects | ProjectCreated, ProjectUpdated, ProjectDeleted, ProjectUsersAdded, ProjectUserRoleChanged, ProjectUserRemoved |
| Users | UserCreated, UserDeleted, UserRoleChanged |
| Variables | VariableCreated, VariableUpdated, VariableDeleted |
| Tags | TagCreated, TagUpdated, TagDeleted |
| Webhooks | WebhookTriggered (sync and queued) |
Register listeners just like any other Laravel event:
Events can be enabled or disabled in config:
๐พ Response Caching
Improve performance by caching API responses:
Cache is automatically invalidated on create/update/delete operations.
๐ Metrics
Enable lightweight request metrics that are incremented during every API call (including cache hits when caching is enabled):
Metrics are grouped per hour and include total requests, counts per HTTP method, status code, and average duration. Consume them from your chosen cache store to drive dashboards or alerts.
๐ Logging
Comprehensive request/response logging for debugging and monitoring:
Logs include:
- HTTP method and URI
- Status codes
- Request/response duration
- Request and response bodies (if enabled)
- Error details
๐ Client Modifiers
Customize HTTP client behavior by adding modifiers to the request pipeline:
Client modifiers receive the PendingRequest instance and must return a modified PendingRequest.
๐ง Macros
Extend API resource classes with custom methods using Laravel's Macroable trait:
All API resource classes support macros.
โ ๏ธ Exception Handling
The package provides domain-specific exceptions with detailed context:
Exception hierarchy:
N8nException- Base exception (all others extend this)WorkflowNotFoundException- Workflow not found (404)ExecutionNotFoundException- Execution not found (404)ExecutionFailedException- Execution failed or crashedCredentialException- Credential-related errorsRateLimitException- Rate limiting (429)AuthenticationException- Auth errors (401/403)ValidationException- Validation errors (422)
All exceptions provide:
getCode()- HTTP status codegetResponse()- Full HTTP response objectgetContext()- Additional context array
๐ฅ Health Checks
Monitor your n8n instance connectivity and health:
CLI command also available:
๐งช Testing
Comprehensive testing utilities for your n8n integrations:
N8nFake
Mock n8n API responses in your tests:
Test Data Factories
Generate realistic test data:
๐จ CLI Commands
Manage n8n directly from your terminal:
๐ค Contributing
Contributions are welcome! If you have a feature request, bug report, or improvement:
-
Fork the repository
-
Create a topic branch: Choose the prefix that matches the purpose of your work:
feature/your-descriptionโ new functionalitybugfix/your-descriptionโ fix for an existing issuehotfix/your-descriptionโ urgent production fix
- Run Laravel Pint to ensure code style is consistent
composer pint - Add or update tests and make sure they pass
composer test - Commit your changes
git commit -am "Add: my awesome addition" - Push to your branch
git push origin feature/my-awesome-addition - Open a pull request
Please adhere to laravel pint and include tests where applicable.
๐ Support
If you encounter any issues or have questions:
- Open an issue in the GitHub repository
- Use Discussions for non-bug topics or feature proposals
- Pull requests are always welcome for fixes and improvements
๐ License
This package is open-sourced software licensed under the MIT license.