PHPackages                             usmanzahid/n8n-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. usmanzahid/n8n-php

ActiveLibrary[API Development](/categories/api)

usmanzahid/n8n-php
==================

n8n-php is a lightweight PHP SDK for the n8n automation platform. It provides a fast, reliable way to connect to your n8n instance and interact with its API, making automation in PHP straightforward and efficient.

v0.1.3(6mo ago)72591[2 issues](https://github.com/Usmanzahidcode/n8n-php/issues)MITPHPPHP ^8.1

Since Sep 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/Usmanzahidcode/n8n-php)[ Packagist](https://packagist.org/packages/usmanzahid/n8n-php)[ Docs](https://github.com/usman/n8n-php)[ RSS](/packages/usmanzahid-n8n-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (6)Used By (0)

 [![n8n-php](assets/media/n8n_logo.png)](assets/media/n8n_logo.png)

[![Latest Stable Version](https://camo.githubusercontent.com/040dca5a6237936bacc6c521e2256fec171f9c734c3610184b6986709a467236/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75736d616e7a616869642f6e386e2d7068702e737667)](https://packagist.org/packages/usmanzahid/n8n-php)[![Total Downloads](https://camo.githubusercontent.com/c191341c1b34355e2756f8725c9572117f2782f47a846c79b059603fea0eb0fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75736d616e7a616869642f6e386e2d7068702e737667)](https://packagist.org/packages/usmanzahid/n8n-php)[![PHP Version](https://camo.githubusercontent.com/924d944b4240de7978a28cdd361c636e0009772d499eaeb537d5c87da0127351/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f75736d616e7a616869642f6e386e2d7068702e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/c93fed2f40d93e3ca05dbbcac9f06e33ec070f5375c28282a19276a8ed7b80ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f75736d616e7a616869642f6e386e2d7068702e737667)](https://opensource.org/licenses/MIT)

n8n-php
=======

[](#n8n-php)

A lightweight PHP SDK for [n8n](https://n8n.io), the open-source workflow automation tool. Control your n8n instance directly from PHP: manage workflows, trigger webhooks, handle users, and more.

---

Quick Start
-----------

[](#quick-start)

Install via Composer:

```
composer require usmanzahid/n8n-php
```

Connect and start using:

```
use UsmanZahid\N8n\N8nClient;

N8nClient::connect(
    'https://your-n8n-instance.com',
    'your-api-key'
);

// Get all users
$response = N8nClient::users()->listUsers();

if ($response->success) {
    foreach ($response->data->items as $user) {
        echo $user->email . PHP_EOL;
    }
}
```

That's it. You're ready to go.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Understanding Responses](#understanding-responses)
- [Working with Workflows](#working-with-workflows)
- [Working with Webhooks](#working-with-webhooks)
- [Working with Users](#working-with-users)
- [Working with Tags](#working-with-tags)
- [Working with Variables](#working-with-variables)
- [Working with Projects](#working-with-projects)
- [Working with Executions](#working-with-executions)
- [Working with Credentials](#working-with-credentials)
- [Working with Audit](#working-with-audit)
- [Pagination](#pagination)
- [Contributing](#contributing)
- [License](#license)

---

Installation
------------

[](#installation)

```
composer require usmanzahid/n8n-php
```

Requires PHP 7.4 or higher.

---

Configuration
-------------

[](#configuration)

Before making any requests, connect to your n8n instance:

```
use UsmanZahid\N8n\N8nClient;

N8nClient::connect(
    'https://your-n8n-instance.com',  // Your n8n instance URL
    'your-api-key'                     // Your n8n API key
);
```

**Optional webhook authentication:**

```
N8nClient::connect(
    'https://your-n8n-instance.com',
    'your-api-key',
    'webhook-username',  // Optional
    'webhook-password'   // Optional
);
```

---

Understanding Responses
-----------------------

[](#understanding-responses)

Every method returns an `N8nResponse` object with these properties:

```
$response->success;    // bool: true if successful, false otherwise
$response->data;       // object: The actual data returned (workflows, users, etc.)
$response->message;    // string: Error message if something went wrong
$response->statusCode; // int: HTTP status code
```

**Always check for success:**

```
$response = N8nClient::workflows()->getWorkflow('workflow-id');

if ($response->success) {
    $workflow = $response->data;
    // Use the workflow
} else {
    echo "Error: " . $response->message;
}
```

No exceptions are thrown. Everything is handled through the response object.

---

Working with Workflows
----------------------

[](#working-with-workflows)

### List workflows

[](#list-workflows)

```
// Get first page (default: 20 workflows)
$response = N8nClient::workflows()->listWorkflows();

// Get with custom limit
$response = N8nClient::workflows()->listWorkflows(['limit' => 50]);
```

### Get all workflows (handles pagination automatically)

[](#get-all-workflows-handles-pagination-automatically)

```
$response = N8nClient::workflows()->listWorkflowsAll();

if ($response->success) {
    foreach ($response->data->items as $workflow) {
        echo $workflow->name . PHP_EOL;
    }
}
```

### Get a single workflow

[](#get-a-single-workflow)

```
$response = N8nClient::workflows()->getWorkflow('workflow-id');
```

### Create a workflow

[](#create-a-workflow)

```
$response = N8nClient::workflows()->createWorkflow([
    'name' => 'My New Workflow',
    'nodes' => [],
    'connections' => []
]);
```

### Update a workflow

[](#update-a-workflow)

```
$response = N8nClient::workflows()->updateWorkflow('workflow-id', [
    'name' => 'Updated Workflow Name'
]);
```

### Delete a workflow

[](#delete-a-workflow)

```
$response = N8nClient::workflows()->deleteWorkflow('workflow-id');
```

### Activate or deactivate

[](#activate-or-deactivate)

```
N8nClient::workflows()->activateWorkflow('workflow-id');
N8nClient::workflows()->deactivateWorkflow('workflow-id');
```

### Transfer to another project

[](#transfer-to-another-project)

```
N8nClient::workflows()->transferWorkflow('workflow-id', 'destination-project-id');
```

### Manage workflow tags

[](#manage-workflow-tags)

```
// Get tags
$response = N8nClient::workflows()->getTags('workflow-id');

// Update tags (provide array of tag IDs)
N8nClient::workflows()->updateTags('workflow-id', ['tag-id-1', 'tag-id-2']);
```

---

Working with Webhooks
---------------------

[](#working-with-webhooks)

Trigger webhooks programmatically:

```
use UsmanZahid\N8n\Enums\WebhookMode;
use UsmanZahid\N8n\Enums\RequestMethod;

$response = N8nClient::webhook(WebhookMode::Production, RequestMethod::Post)
    ->send('your-webhook-id', [
        'key' => 'value',
        'data' => 'your data here'
    ]);

if ($response->success) {
    echo "Webhook triggered successfully!";
}
```

**Webhook modes:**

- `WebhookMode::Production` - Live workflows
- `WebhookMode::Test` - Test mode webhooks

**Request methods:**

- `RequestMethod::Get`
- `RequestMethod::Post`
- `RequestMethod::Put`
- `RequestMethod::Patch`
- `RequestMethod::Delete`

---

Working with Users
------------------

[](#working-with-users)

### List users

[](#list-users)

```
$response = N8nClient::users()->listUsers();
```

### Get all users

[](#get-all-users)

```
$response = N8nClient::users()->listUsersAll();
```

### Create a user

[](#create-a-user)

```
$response = N8nClient::users()->createUser([
    [
        'email' => 'newuser@example.com',
        'firstName' => 'John',
        'lastName' => 'Doe',
        'role' => 'member'
    ]
]);
```

### Get a user

[](#get-a-user)

```
$response = N8nClient::users()->getUser('user@example.com');
```

### Delete a user

[](#delete-a-user)

```
$response = N8nClient::users()->deleteUser('user@example.com');
```

### Change user role

[](#change-user-role)

```
$response = N8nClient::users()->changeUserRole('user@example.com', 'admin');
```

**Available roles:** `member`, `admin`, `owner`

---

Working with Tags
-----------------

[](#working-with-tags)

### List tags

[](#list-tags)

```
$response = N8nClient::tags()->listTags();
```

### Get all tags

[](#get-all-tags)

```
$response = N8nClient::tags()->listTagsAll();
```

### Create a tag

[](#create-a-tag)

```
$response = N8nClient::tags()->createTag([
    'name' => 'Production'
]);
```

### Get a tag

[](#get-a-tag)

```
$response = N8nClient::tags()->getTag('tag-id');
```

### Update a tag

[](#update-a-tag)

```
$response = N8nClient::tags()->updateTag('tag-id', [
    'name' => 'Updated Tag Name'
]);
```

### Delete a tag

[](#delete-a-tag)

```
$response = N8nClient::tags()->deleteTag('tag-id');
```

---

Working with Variables
----------------------

[](#working-with-variables)

### List variables

[](#list-variables)

```
$response = N8nClient::variables()->listVariables();
```

### Get all variables

[](#get-all-variables)

```
$response = N8nClient::variables()->listVariablesAll();
```

### Create a variable

[](#create-a-variable)

```
$response = N8nClient::variables()->createVariable([
    'key' => 'API_KEY',
    'value' => 'secret-value'
]);
```

### Update a variable

[](#update-a-variable)

```
$response = N8nClient::variables()->updateVariable('variable-id', [
    'value' => 'new-secret-value'
]);
```

### Delete a variable

[](#delete-a-variable)

```
$response = N8nClient::variables()->deleteVariable('variable-id');
```

---

Working with Projects
---------------------

[](#working-with-projects)

### List projects

[](#list-projects)

```
$response = N8nClient::projects()->listProjects();
```

### Get all projects

[](#get-all-projects)

```
$response = N8nClient::projects()->listProjectsAll();
```

### Create a project

[](#create-a-project)

```
$response = N8nClient::projects()->createProject([
    'name' => 'My New Project'
]);
```

### Update a project

[](#update-a-project)

```
$response = N8nClient::projects()->updateProject('project-id', [
    'name' => 'Updated Project Name'
]);
```

### Delete a project

[](#delete-a-project)

```
$response = N8nClient::projects()->deleteProject('project-id');
```

### Add users to a project

[](#add-users-to-a-project)

```
$response = N8nClient::projects()->addUsers('project-id', [
    [
        'userId' => 'user-id-1',
        'role' => 'member'
    ],
    [
        'userId' => 'user-id-2',
        'role' => 'admin'
    ]
]);
```

### Change user role in a project

[](#change-user-role-in-a-project)

```
$response = N8nClient::projects()->changeUserRole('project-id', 'user-id', 'admin');
```

### Remove user from a project

[](#remove-user-from-a-project)

```
$response = N8nClient::projects()->deleteUser('project-id', 'user-id');
```

---

Working with Executions
-----------------------

[](#working-with-executions)

### List executions

[](#list-executions)

```
// Get first 10 executions
$response = N8nClient::executions()->listExecutions(10);
```

### Get all executions

[](#get-all-executions)

```
$response = N8nClient::executions()->listExecutionsAll();
```

### Get a single execution

[](#get-a-single-execution)

```
// Get execution details by ID (basic info only)
$response = N8nClient::executions()->getExecution('execution-id');

// Get execution with full workflow and input/output data
// When $includeData = true, the SDK fetches all execution data from n8n,
// including the workflow structure and the data present when the workflow started.
$includeData = true;
$response = N8nClient::executions()->getExecution('execution-id', $includeData);
```

### Delete an execution

[](#delete-an-execution)

```
$response = N8nClient::executions()->deleteExecution('execution-id');
```

### Stop a running execution

[](#stop-a-running-execution)

```
$response = N8nClient::executions()->stopExecution('execution-id');
```

### Retry a failed execution

[](#retry-a-failed-execution)

```
$response = N8nClient::executions()->retryExecution('execution-id', [
    'inputData' => []  // Optional custom input data
]);
```

---

Working with Credentials
------------------------

[](#working-with-credentials)

### Get credential schema

[](#get-credential-schema)

```
$response = N8nClient::credentials()->getCredentialSchema('githubApi');
```

### Create a credential

[](#create-a-credential)

```
$response = N8nClient::credentials()->createCredential([
    'name' => 'My GitHub Token',
    'type' => 'githubApi',
    'data' => [
        'token' => 'your-github-token'
    ]
]);
```

### Delete a credential

[](#delete-a-credential)

```
$response = N8nClient::credentials()->deleteCredential('credential-id');
```

---

Working with Audit
------------------

[](#working-with-audit)

Generate audit logs:

```
$response = N8nClient::audit()->generateAudit([
    'action' => 'workflow_created',
    'additionalData' => []
]);
```

---

Pagination
----------

[](#pagination)

Most list methods support pagination. There are three ways to handle it:

### 1. Manual pagination with limits

[](#1-manual-pagination-with-limits)

```
$response = N8nClient::workflows()->listWorkflows(['limit' => 10]);
```

### 2. Get all items automatically

[](#2-get-all-items-automatically)

```
$response = N8nClient::workflows()->listWorkflowsAll();
// Fetches all pages automatically
```

### 3. Manual page appending

[](#3-manual-page-appending)

```
$response = N8nClient::tags()->listTags();

$tagList = $response->data;
$tagsClient = N8nClient::tags();

// Check if more pages exist
while ($tagsClient->hasMore($tagList)) {
    // Append next page to existing list
    $tagsClient->appendNextTagPage($tagList);
}

// Now $tagList contains all tags from all pages
foreach ($tagList->items as $tag) {
    echo $tag->name . PHP_EOL;
}
```

**Available append methods:**

- `appendNextWorkflowPage()`
- `appendNextUserPage()`
- `appendNextTagPage()`
- `appendNextVariablePage()`
- `appendNextProjectPage()`
- `appendNextExecutionPage()`

---

Contributing
------------

[](#contributing)

Contributions are welcome! If you have ideas, find bugs, or want to add features:

1. Fork this repository
2. Create your feature branch
3. Submit a pull request

Every contribution helps make this SDK better for the PHP community.

---

License
-------

[](#license)

MIT © Usman Zahid

---

Why This Exists
---------------

[](#why-this-exists)

I needed a clean way to integrate n8n into my PHP projects. Instead of writing the same API calls over and over, I built this SDK to make n8n integration simple and straightforward for PHP developers.

It's feature-complete for core use cases and ready for production. If you find it useful, star the repo and share it with others!

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance64

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

4

Last Release

208d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e7f93f7407d7c7fbe8a27d3c8aaf863066168fbb6e1e75b0b847511571a4236?d=identicon)[Usmanzahidcode](/maintainers/Usmanzahidcode)

---

Top Contributors

[![usmanx03](https://avatars.githubusercontent.com/u/112874031?v=4)](https://github.com/usmanx03 "usmanx03 (92 commits)")

---

Tags

apiautomationn8nn8n-automationn8n-clientn8n-workflowphpsdksdk-phpapisdkautomationworkflown8n

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/usmanzahid-n8n-php/health.svg)

```
[![Health](https://phpackages.com/badges/usmanzahid-n8n-php/health.svg)](https://phpackages.com/packages/usmanzahid-n8n-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
