Use cases
Sub-tenant management (CRUD via /tenant/sub-tenants)
Create, list, update and deactivate sub-tenants
The `/api/v1/tenant/sub-tenants` API exposes a full CRUD for managing sub-tenants from the parent account: `POST` to create (returns sub_tenant_id + publishable key `pk_*`), `GET /` to list (cursor-based pagination), `GET /{id}` to retrieve, `PATCH /{id}` to update (template, branding, metadata), `DELETE /{id}` to deactivate (soft delete, data retained 10 years for fiscal compliance (French Commerce Code L123-22 / LPF L102 B)). Deactivation prevents new invoices but does not delete existing data (10-year fiscal obligation). To reactivate: `POST /{id}/reactivate`. Each sub-tenant has its own numbering and fiscal log.
Key facts
- Full CRUD: POST, GET, PATCH, DELETE
- Cursor-based pagination (next_cursor)
- DELETE = soft delete (10-year retention, French Commerce Code L123-22 / LPF L102 B)
- Reactivate via `POST /{id}/reactivate`
- Publishable key `pk_*` returned at creation
- Custom metadata (JSON) for CRM reconciliation
Code example
import { ScellClient } from '@scell/sdk';
const scell = new ScellClient({ apiKey: process.env.SCELL_SECRET_KEY! });
// Lister tous les sub-tenants actifs (paginé)
let cursor: string | undefined;
do {
const page = await scell.subTenants.list({ limit: 100, cursor, status: 'active' });
for (const st of page.data) {
console.log(`${st.id}\t${st.name}\t${st.invoice_numbering_prefix}`);
}
cursor = page.next_cursor;
} while (cursor);
// Désactiver un sub-tenant (les factures existantes restent accessibles)
await scell.subTenants.delete('st_abc123');
// Réactiver plus tard
await scell.subTenants.reactivate('st_abc123');