PHPackages                             laratables/monta-partner-api - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. laratables/monta-partner-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

laratables/monta-partner-api
============================

Laravel SDK for the Monta Partner API — authentication, token caching, and a fluent HTTP client.

v1.0.0(1mo ago)00MITPHPPHP ^8.2

Since Apr 22Pushed 1mo agoCompare

[ Source](https://github.com/laratables/monta-partner-api)[ Packagist](https://packagist.org/packages/laratables/monta-partner-api)[ Docs](https://docs.partner-api.monta.com)[ RSS](/packages/laratables-monta-partner-api/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

laratables/monta-partner-api
============================

[](#laratablesmonta-partner-api)

A Laravel 11/12/13 SDK for the [Monta Partner API](https://docs.partner-api.monta.com). Handles OAuth token exchange, automatic caching &amp; refresh, and exposes a clean fluent client for every HTTP verb.

---

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

[](#installation)

```
composer require laratables/monta-partner-api
```

The service provider and `Monta` facade are auto-discovered via Laravel's package discovery. No manual registration needed.

Publish the config (optional):

```
php artisan vendor:publish --tag=monta-config
```

---

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

[](#configuration)

Add to your `.env`:

```
MONTA_CLIENT_ID=your-client-id
MONTA_CLIENT_SECRET=your-client-secret

# Optional — these are the defaults:
MONTA_BASE_URL=https://api.monta.com
MONTA_API_VERSION=v2024-01-18
MONTA_CACHE_STORE=default      # any Laravel cache store
MONTA_HTTP_TIMEOUT=30
MONTA_HTTP_CONNECT_TIMEOUT=10
```

---

Usage
-----

[](#usage)

### Dependency Injection (recommended)

[](#dependency-injection-recommended)

```
use Monta\PartnerApi\Contracts\MontaClientInterface;

class ChargeController extends Controller
{
    public function __construct(private MontaClientInterface $monta) {}

    public function index(): JsonResponse
    {
        $data = $this->monta->get('/charge-points', ['pageSize' => 25])->json();
        return response()->json($data);
    }

    public function start(int $id): JsonResponse
    {
        $result = $this->monta->post("/charge-points/{$id}/start")->json();
        return response()->json($result);
    }
}
```

### Facade

[](#facade)

```
use Monta\PartnerApi\Facades\Monta;

$chargePoints = Monta::get('/charge-points', ['pageSize' => 50])->json();
$charge       = Monta::post('/charges', ['chargePointId' => 123])->json();
$updated      = Monta::patch('/charge-points/456', ['name' => 'Bay 1'])->json();
Monta::delete('/webhooks/789');
```

### Accessing any Monta API endpoint

[](#accessing-any-monta-api-endpoint)

The client works with any endpoint from the [Monta API docs](https://docs.partner-api.monta.com/reference)— just pass the path and any parameters:

```
// Charges
$charges = $this->monta->get('/charges', ['pageSize' => 25, 'page' => 1])->json();
$charge  = $this->monta->post('/charges', ['chargePointId' => 123])->json();

// Teams
$teams = $this->monta->get('/teams')->json();
$team  = $this->monta->get('/teams/456')->json();

// Webhooks
$webhook = $this->monta->post('/webhooks', [
    'url'    => 'https://yourapp.com/webhooks/monta',
    'events' => ['charge.started', 'charge.stopped'],
])->json();
$this->monta->delete('/webhooks/789');

// Wallets
$wallet = $this->monta->get('/wallets/123')->json();

// Any other endpoint — same pattern
$this->monta->patch('/charge-points/456', ['name' => 'Bay 1']);
```

### Working with responses

[](#working-with-responses)

Every method returns a standard Laravel `Illuminate\Http\Client\Response` object:

```
$response = $this->monta->get('/charges');

$response->json();            // full decoded array
$response->json('data');      // single key from the response
$response->json('data.0.id'); // nested key using dot notation
$response->collect('data');   // returns a Laravel Collection
$response->status();          // HTTP status code e.g. 200
$response->successful();      // true if 2xx
```

### Domain resource classes

[](#domain-resource-classes)

Copy `ChargePointsResource` as a template for each API domain (Charges, Teams, Wallets, Webhooks…):

```
use Monta\PartnerApi\Http\Resources\ChargePointsResource;

// Register in a service provider:
$this->app->bind(ChargePointsResource::class, fn($app) =>
    new ChargePointsResource($app->make(MontaClientInterface::class))
);

// Use in a controller:
public function __construct(private ChargePointsResource $chargePoints) {}

public function index(): JsonResponse
{
    return response()->json($this->chargePoints->list(['pageSize' => 50]));
}
```

---

Error Handling
--------------

[](#error-handling)

```
use Monta\PartnerApi\Exceptions\MontaApiException;
use Monta\PartnerApi\Exceptions\MontaAuthenticationException;

try {
    $result = $this->monta->post('/charges', $payload)->json();
} catch (MontaAuthenticationException $e) {
    // Bad credentials, or the API returned 401
    // The cached token is automatically cleared; the next request will re-authenticate
    Log::critical('Monta auth failed', ['error' => $e->getMessage()]);
} catch (MontaApiException $e) {
    // Any other non-2xx response
    Log::error('Monta API error', [
        'status' => $e->getStatusCode(),
        'body'   => $e->getResponse()->json(),
    ]);
}
```

---

Token Caching
-------------

[](#token-caching)

Access tokens are cached in the Laravel cache store defined by `MONTA_CACHE_STORE`. They are proactively refreshed 30 seconds before expiry to avoid clock-skew issues. A 401 response automatically evicts the cached token so the next call re-authenticates transparently.

---

Testing
-------

[](#testing)

### Running the test suite

[](#running-the-test-suite)

```
composer test
# or directly:
./vendor/bin/phpunit
```

### Mocking in your application tests

[](#mocking-in-your-application-tests)

Because everything is bound against `MontaClientInterface`, swapping in a mock is straightforward:

```
use Monta\PartnerApi\Contracts\MontaClientInterface;

// Using Laravel's built-in mock helper (Mockery under the hood):
$this->mock(MontaClientInterface::class, function ($mock) {
    $mock->shouldReceive('get')
         ->with('/charge-points', \Mockery::any())
         ->andReturn(new \Illuminate\Http\Client\Response(
             new \GuzzleHttp\Psr7\Response(200, [], json_encode(['data' => []]))
         ));
});

// Or use Http::fake() to intercept at the HTTP layer:
Http::fake([
    'https://api.monta.com/auth/token'    => Http::response(['accessToken' => 'tok', 'expiresIn' => 3600]),
    'https://api.monta.com/charge-points' => Http::response(['data' => []]),
]);
```

---

Package Structure
-----------------

[](#package-structure)

```
src/
├── Contracts/
│   └── MontaClientInterface.php      Type-hint this in your code
├── Exceptions/
│   ├── MontaApiException.php         Non-2xx API responses
│   └── MontaAuthenticationException.php  Auth / token failures
├── Facades/
│   └── Monta.php                     Monta:: facade
├── Http/
│   ├── MontaClient.php               Core client (auth + all verbs)
│   └── Resources/
│       └── ChargePointsResource.php  Example domain resource — copy this pattern
├── Support/
│   └── MontaToken.php                Token value object with expiry
└── MontaServiceProvider.php          Auto-discovered service provider

config/
└── monta.php

tests/
├── TestCase.php                      Orchestra Testbench base
├── Unit/
│   ├── MontaTokenTest.php            Token parsing & expiry logic
│   ├── ExceptionsTest.php            Exception message / code derivation
│   ├── MontaClientAuthTest.php       Token fetch, caching, refresh
│   ├── MontaClientHttpTest.php       HTTP verbs, headers, error handling
│   └── ChargePointsResourceTest.php  Resource method → client delegation
└── Feature/
    ├── AuthenticationFlowTest.php    Full auth + API call flows
    └── ServiceProviderTest.php       DI bindings, singleton, facade, config

```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ead92e25bfaca6770b0cb494aadd2a135bdd33d44ccde970666a94f7a110d375?d=identicon)[laratables](/maintainers/laratables)

---

Top Contributors

[![MattWiseParking](https://avatars.githubusercontent.com/u/127202190?v=4)](https://github.com/MattWiseParking "MattWiseParking (1 commits)")

---

Tags

laravelMontaPartner-APIevCharging

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laratables-monta-partner-api/health.svg)

```
[![Health](https://phpackages.com/badges/laratables-monta-partner-api/health.svg)](https://phpackages.com/packages/laratables-monta-partner-api)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M120](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[omniphx/forrest

A Laravel library for Salesforce

2744.6M9](/packages/omniphx-forrest)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

2037.5k](/packages/onlime-laravel-http-client-global-logger)

PHPackages © 2026

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