PHPackages                             invoiceninja/sdk-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. invoiceninja/sdk-php

ActiveLibrary[API Development](/categories/api)

invoiceninja/sdk-php
====================

The Invoice Ninja v5 PHP SDK

v1.4.0(1y ago)8752.7k↓18%41MITPHPPHP ^8

Since Nov 13Pushed 4mo ago8 watchersCompare

[ Source](https://github.com/invoiceninja/sdk-php)[ Packagist](https://packagist.org/packages/invoiceninja/sdk-php)[ RSS](/packages/invoiceninja-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (19)Used By (0)

Invoice Ninja SDK v5!
=====================

[](#invoice-ninja-sdk-v5)

### Installation

[](#installation)

Add the Invoice Ninja SDK

```
composer require invoiceninja/sdk-php

```

### Setup

[](#setup)

```
use InvoiceNinja\Sdk\InvoiceNinja;

$ninja = new InvoiceNinja("your_token");
$invoices = $ninja->invoices->all();
```

- To connect to a self hosted version use `->setUrl()` on the $ninja object.

### Supports

[](#supports)

- Clients
- Invoices
- Quotes
- Products
- Payments
- TaxRates
- Statics
- Expenses
- Expense Categories
- Recurring Invoices
- Credits
- Projects
- Tasks
- Vendors
- Companies
- Subscriptions
- Purchase Orders
- Bank Integrations
- Bank Transactions

### Retrieving Models

[](#retrieving-models)

Retrieve all clients

```
    $clients = $ninja->clients->all();
```

You can perform complex filtering on the -&gt;all() method.

Query parameters can be chained together to form complex queries. The current supported values are:

**per\_page**: The number of clients per page you want returned
**page**: The page number
**include**: A comma separated list of relations to include ie. contacts,documents,gateway\_tokens
**balance**: A query to return clients with a balance using an operator and value

- ie ?balance=lt:10 Returns clients with a balance less than 10
- available operators lt, lte, gt, gte, eq

**between\_balance**: Returns clients with a balance between two values

- ie ?between\_balance=10:20 - Returns clients with a balance between 10 and 20

**email**: Returns clients with a contacts.email field equal to an email
**id\_number**: Search by id\_number
**number**: Search by number
**filter**: Search across multiple columns (name, id\_number, first\_name, last\_name, email, custom\_value1, custom\_value2, custom\_value3, custom\_value4)
**created\_at**: Search by created at (Unix timestamp)
**is\_deleted**: Search using is\_deleted boolean flag

For example,

```
$clients = $ninja->clients->all([
    'balance' => 'lt:10', // get all clients with a balance less than 10
    'per_page' => 10, // return 10 results per page
    'page' => 2, // paginate to page 2
    'include' => 'documents', // include the documents relationship
]);
```

Retrieve a client by its primary key.

```
    $client = $ninja->clients->get("CLIENT_HASHED_ID");
```

Retrieving an invoice by it's number:

```
    $client = $ninja->invoices->all(['number' => '0001']);
```

### Inserting &amp; Updating Models

[](#inserting--updating-models)

Create a new client

```
    $client = $ninja->clients->create(['name' => 'A new client']);
```

Create a new Client with a contact

```
    $clients = $ninja->clients->create([
        'name' => 'Brand spanking new client',
        'contacts' => [
            [
                'first_name' => 'first',
                'last_name' => 'last',
                'send_email' => true,
                'email' => 'gi-joe@example.com',
            ],

        ]
    ]);

```

Update an existing client

```
    $client = $ninja->clients->update("CLIENT_HASHED_ID",['name' => 'A client with a updated name']);
```

***Please Note***

When updating a client, you must always include the current contacts (array), if no contacts are included, the system will wipe the contacts from the client record.

Create an invoice

```
    $invoice = $ninja->invoices->create([
        'client_id' => $client_hashed_id,
        'date' => '2022-10-31',
        'due_date' => '2022-12-01',
        'terms' => 'These are your invoice terms.',
        'footer' => 'Invoice footer text',
        'line_items' => [
            [
                'product_key' => 'some_product_key',
                'notes' => 'description',
                'quantity' => 1,
                'cost' => 10
            ],
            [
                'product_key' => 'another_product_key',
                'notes' => 'description',
                'quantity' => 1,
                'cost' => 10
            ],
        ],
    ]);
```

When creating an invoice, you can perform actions on the invoice in a single call, for example, say you wish to create an invoice and also apply a payment to the invoice:

```
    $invoice = $ninja->invoices->create([
        'client_id' => $client_hashed_id,
        'date' => '2022-10-31',
        'due_date' => '2022-12-01',
        'terms' => 'These are your invoice terms.',
        'footer' => 'Invoice footer text',
        'line_items' => [
            [
                'product_key' => 'some_product_key',
                'notes' => 'description',
                'quantity' => 1,
                'cost' => 10
            ],
            [
                'product_key' => 'another_product_key',
                'notes' => 'description',
                'quantity' => 1,
                'cost' => 10
            ],
        ],
    ],
    ['paid' => true] //the second parameter in this method is an array of actions ie paid,mark_sent_send_email,auto_bill
);
```

Or if you wish to apply a partial payment

```
    $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['amount_paid' => 10]);
```

Or you may want to automatically send and charge the invoice **note requires a payment method on file**

```
    $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['auto_bill' => true, 'send_email' => true]);
```

### Bulk actions

[](#bulk-actions)

You can perform bulk actions against one or many entities. For example if you wish to batch archive a range of invoice you would do

```
  $bulk = $ninja->invoices->archive(["hash_1","hash_2"]);
```

You can access the raw bulk method using the following:

```
$bulk = $ninja->invoices->bulk("archive", ["hash_1","hash_2"]);
```

If you wanted to download a invoice PDF

```
    $pdf = $ninja->invoices->bulk("download", ["hash_1"]);
```

The following are a list of available bulk actions for invoices:

- mark\_sent
- download
- restore
- archive
- delete
- paid
- clone\_to\_quote
- clone\_to\_invoice
- cancel
- reverse
- email

For more examples of what can be achieved with the SDK, please inspect the tests folder in this repository. If you need clarity or more explicit examples of how to use the SDK, please create a issue.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance60

Regular maintenance activity

Popularity46

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~186 days

Total

17

Last Release

494d ago

Major Versions

v0.5 → v1.0.02021-09-16

PHP version history (4 changes)v1.0.0PHP ^7.4|^8.0

v1.1.0PHP ^7.4|^8.0|^8.1

v1.2.0PHP ^8.1|^8.2

v1.3.0PHP ^8

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5827962?v=4)[David Bomba](/maintainers/turbo124)[@turbo124](https://github.com/turbo124)

![](https://www.gravatar.com/avatar/82f43da7e9c0d36034457d44f89525b66d5bde876ddf9fef79a139e5643b6b7d?d=identicon)[hillel369](/maintainers/hillel369)

---

Top Contributors

[![turbo124](https://avatars.githubusercontent.com/u/5827962?v=4)](https://github.com/turbo124 "turbo124 (73 commits)")[![hillelcoren](https://avatars.githubusercontent.com/u/4629496?v=4)](https://github.com/hillelcoren "hillelcoren (56 commits)")[![realnsleo](https://avatars.githubusercontent.com/u/1863115?v=4)](https://github.com/realnsleo "realnsleo (5 commits)")[![gserafini](https://avatars.githubusercontent.com/u/200852?v=4)](https://github.com/gserafini "gserafini (4 commits)")[![TheNewSound](https://avatars.githubusercontent.com/u/1410503?v=4)](https://github.com/TheNewSound "TheNewSound (4 commits)")[![skylarmt](https://avatars.githubusercontent.com/u/6668965?v=4)](https://github.com/skylarmt "skylarmt (3 commits)")[![hjone72](https://avatars.githubusercontent.com/u/4342811?v=4)](https://github.com/hjone72 "hjone72 (3 commits)")[![varunity](https://avatars.githubusercontent.com/u/178009?v=4)](https://github.com/varunity "varunity (2 commits)")[![xavierhb](https://avatars.githubusercontent.com/u/2368418?v=4)](https://github.com/xavierhb "xavierhb (2 commits)")[![proudcommerce](https://avatars.githubusercontent.com/u/4111533?v=4)](https://github.com/proudcommerce "proudcommerce (1 commits)")[![d00p](https://avatars.githubusercontent.com/u/1757229?v=4)](https://github.com/d00p "d00p (1 commits)")[![gopalindians](https://avatars.githubusercontent.com/u/1937433?v=4)](https://github.com/gopalindians "gopalindians (1 commits)")[![lbausch](https://avatars.githubusercontent.com/u/5747127?v=4)](https://github.com/lbausch "lbausch (1 commits)")[![ledererIO](https://avatars.githubusercontent.com/u/20355127?v=4)](https://github.com/ledererIO "ledererIO (1 commits)")[![ma2t](https://avatars.githubusercontent.com/u/195865?v=4)](https://github.com/ma2t "ma2t (1 commits)")[![ClassicCut](https://avatars.githubusercontent.com/u/5478735?v=4)](https://github.com/ClassicCut "ClassicCut (1 commits)")[![stojankukrika](https://avatars.githubusercontent.com/u/10199584?v=4)](https://github.com/stojankukrika "stojankukrika (1 commits)")[![woodspire](https://avatars.githubusercontent.com/u/1275609?v=4)](https://github.com/woodspire "woodspire (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/invoiceninja-sdk-php/health.svg)

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

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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