Skip to main content

Use cases

Bulk invoice generation

POST /v1/tenant/invoices/bulk — up to 50 invoices per call

For monthly billing workflows (recurring SaaS, payroll, subscriptions), Scell.io exposes a bulk endpoint `POST /api/v1/tenant/invoices/bulk` accepting an array of 1 to 50 invoices per request. Each invoice is processed individually; the response returns an array of per-item results (success / error). On partial failure, successful invoices are created (no global transaction) and failed ones return a detailed error code. For volumes > 50, paginate on the client side. Bulk respects the global rate limit but consumes a single slot per call.

Key facts

  • Max 50 invoices per request
  • No global transaction: partial success allowed
  • Response: array of results with `index`, `status`, `invoice_id` or `error`
  • Consumes 1 rate-limit slot (vs 50 unit calls)
  • Idempotency-Key valid at batch level
  • Latency ~3-5s for 50 Factur-X EN16931

Code example

import { ScellClient } from '@scell/sdk';
const scell = new ScellClient({ apiKey: process.env.SCELL_SECRET_KEY! });

const subscriptions = await loadActiveSubscriptions(); // 200 abonnés

// Chunker en batches de 50
for (let i = 0; i < subscriptions.length; i += 50) {
  const chunk = subscriptions.slice(i, i + 50);
  const batch = await scell.invoices.createBulk({
    invoices: chunk.map((sub) => ({
      format: 'factur-x',
      buyer: sub.buyer,
      lines: [{ description: `Abonnement ${sub.plan}`, quantity: 1, unit_price: sub.amount, vat_rate: 20 }],
      external_id: sub.id, // pour le rapprochement
    })),
  });

  for (const result of batch.results) {
    if (result.status === 'error') console.error(`Index ${result.index}:`, result.error);
  }
}

See also

Your cookie preferences

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