Skip to main content

Quickstart

Quickstart: create an invoice in PHP

Official scell/sdk for Laravel and PHP 8.2+

The official PHP SDK `scell/sdk` (Composer) exposes `ScellApiClient` to create Factur-X invoices, credit notes, and eIDAS signatures from any PHP 8.2+ project. Compatible with Laravel, Symfony, Slim, vanilla. Authenticated via `sk_live_*` (production) or `sk_test_*` (sandbox) key. The SDK handles retries, idempotency (`Idempotency-Key` header), and snake_case ↔ camelCase mapping automatically. Available on Packagist, v3.5.0.

Key facts

  • Requirements: PHP 8.2+, Composer 2.x, ext-curl, ext-json
  • Install: `composer require scell/sdk`
  • Env var: `SCELL_API_KEY=sk_live_xxx` or `sk_test_xxx`
  • HTTP: Guzzle 7 (transitive dependency)
  • Expected output: `inv_01HXYZ...` (UUID v7) + `status: draft`
  • Error codes: 401 (invalid key), 422 (validation), 402 (insufficient balance), 429 (rate limit)

Code example

<?php
require 'vendor/autoload.php';

use Scell\Sdk\ScellApiClient;

$client = new ScellApiClient(getenv('SCELL_API_KEY'));

// 1. Facture B2B (avec SIRET acheteur)
$b2b = $client->invoices()->create([
    'format' => 'factur-x',
    'profile' => 'EN16931',
    'currency' => 'EUR',
    'seller' => [
        'siret' => '12345678901234',
        'name' => 'Ma SAS',
        'address' => ['street' => '1 rue Test', 'city' => 'Paris', 'postal_code' => '75001', 'country' => 'FR'],
        'vat_number' => 'FR12345678901',
    ],
    'buyer' => [
        'siret' => '98765432109876',
        'name' => 'Client SARL',
        'address' => ['street' => '2 avenue Demo', 'city' => 'Lyon', 'postal_code' => '69001', 'country' => 'FR'],
    ],
    'lines' => [['description' => 'Prestation conseil', 'quantity' => 1, 'unit_price' => 1000.00, 'vat_rate' => 20.0]],
]);
echo "B2B: {$b2b['id']} ({$b2b['status']})\n";

// 2. Facture B2C (particulier, BR-CO-26 appliquée)
$b2c = $client->invoices()->create([
    'format' => 'factur-x',
    'profile' => 'EN16931',
    'currency' => 'EUR',
    'seller' => $b2b['seller'],
    'buyer' => [
        'buyer_is_individual' => true,
        'name' => 'Jean Dupont',
        'email' => 'jean@example.com',
        'address' => ['street' => '3 bd Client', 'city' => 'Marseille', 'postal_code' => '13001', 'country' => 'FR'],
    ],
    'lines' => [['description' => 'Abonnement', 'quantity' => 1, 'unit_price' => 49.90, 'vat_rate' => 20.0]],
]);
echo "B2C: {$b2c['id']} ({$b2c['status']})\n";

// 3. Signature simple eIDAS EU-SES
$sig = $client->signatures()->create([
    'document_url' => 'https://example.com/contrat.pdf',
    'signers' => [['name' => 'Jean Dupont', 'email' => 'jean@example.com', 'phone' => '+33612345678']],
    'signature_options' => ['signature_mode' => 'drawn', 'timezone' => 'Europe/Paris'],
]);
echo "Signature: {$sig['id']} → {$sig['signing_url']}\n";

See also

Your cookie preferences

We use cookies to improve your experience. Essential cookies are always active. Cookie policy.