Exemple curl
multipart/form-data — /convert + invoice_data JSON curl -X POST https://api.facturxapi.com/api/v1/convert \
-H "Authorization: Bearer $FACTURX_API_KEY" \
-F "file=@./facture-dolibarr.pdf" \
-F 'invoice_data={"invoice_number":"FA-2026-001","issue_date":"2026-05-15","currency":"EUR","seller":{"name":"Ma Société","siren":"552120222","vat_number":"FR40552120222"},"buyer":{"name":"Client Final","siren":"123456789"}}'
Snippet Dolibarr
Hook Dolibarr — appel /api/v1/convert <?php
/**
* Hook Dolibarr custom — appel FacturX API /convert
* Place ce code dans un module Dolibarr custom (htdocs/custom/yourmodule/)
* et déclenche-le depuis BILL_VALIDATE ou un cron.
*/
use Symfony\Component\HttpClient\HttpClient;
function facturx_convert_dolibarr_invoice(string $pdfPath, array $invoice): array
{
$client = HttpClient::create([
'timeout' => 20,
'headers' => [
'Authorization' => 'Bearer ' . getenv('FACTURX_API_KEY'),
],
]);
// Compléter ce que l'export Dolibarr ne fournit pas toujours
$invoiceData = [
'invoice_number' => $invoice['facnumber'],
'issue_date' => $invoice['date'],
'currency' => $invoice['multicurrency_code'] ?: 'EUR',
'seller' => [
'name' => $invoice['seller_name'],
'siren' => $invoice['seller_siren'], // BT-30, schemeID 0002
'vat_number' => $invoice['seller_tva'], // BT-31
],
'buyer' => [
'name' => $invoice['buyer_name'],
'siren' => $invoice['buyer_siren'],
],
];
$response = $client->request('POST', 'https://api.facturxapi.com/api/v1/convert', [
'body' => [
'file' => fopen($pdfPath, 'r'),
'invoice_data' => json_encode($invoiceData),
],
]);
return $response->toArray(false);
}