Quickstart
Install and add your key.
Laravel package discovery registers Apirelio automatically. Publish the configuration and copy the ingestion key displayed once in your project settings.
composer require apirelio/laravel:^0.2
php artisan vendor:publish --tag=apirelio-configAPIRELIO_ENABLED=true
APIRELIO_ENDPOINT=https://api.apirelio.com
APIRELIO_API_KEY=apr_live_xxxxxxxxx
APIRELIO_SERVICE=billing-api
APIRELIO_ENVIRONMENT=production
APIRELIO_RELEASE=2026.07.30.1
APIRELIO_TRANSPORT=queueThe queue transport keeps Apirelio network activity outside the observed customer request.
Request tracking
Attach the middleware.
Apply apirelio after authentication to the API route groups that matter. Laravel route templates are retained, so concrete identifiers and query strings never become endpoint dimensions.
Route::middleware(['auth:sanctum', 'apirelio'])
->group(function (): void {
Route::post(
'/invoices/{invoice}/send',
SendInvoiceController::class,
);
});Customer context
Identify the B2B account.
Register a resolver in an application service provider. Use a stable external ID; names and plans can evolve without breaking customer history.
use Illuminate\Http\Request;
use Apirelio\Laravel\Data\ApirelioCustomer;
use Apirelio\Laravel\Facades\Apirelio;
Apirelio::resolveCustomerUsing(
static function (Request $request): ?ApirelioCustomer {
$user = $request->user();
return $user === null ? null : new ApirelioCustomer(
id: (string) $user->company_id,
name: $user->company->name,
plan: $user->company->plan,
);
},
);Diagnostics
Add actionable context.
HTTP status is automatic. Set a stable error code when the response body does not expose one, and only add low-cardinality metadata allowed in config/apirelio.php.
Apirelio::setErrorCode('INVALID_CURRENCY');
Apirelio::addMetadata([
'integration_type' => 'accounting',
'region' => 'eu-central',
]);Unlisted keys, complex values and known secret-like fields are discarded before delivery.
Reliability
Run the worker and scheduler.
The queue transport batches events through a locked local buffer. Keep both normal Laravel processes running so full and low-traffic batches are delivered.
php artisan queue:work
php artisan schedule:workqueue
Recommended production transport with off-request delivery.
sync
Immediate delivery for local diagnostics and setup verification.
file-buffer
Locked NDJSON buffering with size and interval flushes.