Developer en Billing Platform

Self-service SaaS met tenant API toegang, usage metering en facturatie

Externen registreren zichzelf, maken een organisatie, kiezen een plan, beheren API keys en gebruiken alleen hun eigen data. Elk gebruik wordt gemeten, gelogd en financieel afgerekend.

1. Hoofdmodules

  1. 01Identity en Registration
  2. 02Organization en Tenant Management
  3. 03Subscription en Billing
  4. 04API Key Management
  5. 05Usage Tracking
  6. 06Developer Portal
  7. 07Audit en Compliance
  8. 08Admin Backoffice

2. Registratieproces

  1. 01Bezoeker
  2. 02Account aanmaken
  3. 03E-mail verifiëren
  4. 04Organisatie aanmaken
  5. 05Plan kiezen
  6. 06Betaalmethode of facturatie aanvragen
  7. 07Voorwaarden accepteren
  8. 08Tenant activeren
  9. 09API key aanmaken
  10. 10API gebruiken
  11. 11Usage meten
  12. 12Factureren

3. Datamodel

Organization

public class Organization
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string LegalName { get; set; }
    public string ChamberOfCommerceNumber { get; set; }
    public string VatNumber { get; set; }
    public string BillingEmail { get; set; }
    public string Country { get; set; }
    public string Status { get; set; } // Pending, Active, Suspended, Cancelled
    public DateTime Created { get; set; }
}

OrganizationUser

public class OrganizationUser
{
    public int Id { get; set; }
    public int OrganizationId { get; set; }
    public int UserId { get; set; }
    public string Role { get; set; } // Owner, Admin, Developer, Billing, Viewer
    public bool IsActive { get; set; }
    public DateTime Created { get; set; }
}

BillingPlan

public class BillingPlan
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal MonthlyFee { get; set; }

    public int IncludedApiCalls { get; set; }
    public int IncludedAssets { get; set; }
    public decimal IncludedStorageGb { get; set; }

    public decimal OveragePricePerApiCall { get; set; }
    public decimal OveragePricePerAsset { get; set; }
    public decimal OveragePricePerGb { get; set; }

    public bool IsActive { get; set; }
}

Subscription

public class Subscription
{
    public int Id { get; set; }
    public int OrganizationId { get; set; }
    public int BillingPlanId { get; set; }

    public string Status { get; set; } // Trial, Active, PastDue, Suspended, Cancelled
    public DateTime StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public DateTime NextBillingDate { get; set; }
}

ApiKey

public class ApiKey
{
    public int Id { get; set; }
    public int OrganizationId { get; set; }

    public string Name { get; set; }
    public string KeyPrefix { get; set; }
    public string SecretHash { get; set; }

    public string Environment { get; set; } // Test, Live
    public string Scopes { get; set; }
    public int RateLimitPerMinute { get; set; }
    public int MonthlyQuota { get; set; }

    public string Status { get; set; } // Active, Revoked, Expired
    public DateTime Created { get; set; }
    public DateTime? LastUsed { get; set; }
    public DateTime? Expires { get; set; }
}

ApiUsageLog

public class ApiUsageLog
{
    public long Id { get; set; }
    public int OrganizationId { get; set; }
    public int ApiKeyId { get; set; }

    public string Endpoint { get; set; }
    public string Method { get; set; }
    public DateTime Timestamp { get; set; }

    public int StatusCode { get; set; }
    public long DurationMs { get; set; }

    public long BytesIn { get; set; }
    public long BytesOut { get; set; }

    public int BillableUnits { get; set; }
    public decimal UnitPrice { get; set; }
    public decimal TotalAmount { get; set; }

    public string CorrelationId { get; set; }
    public string IpAddress { get; set; }
}

Invoice + InvoiceLine

public class Invoice
{
    public int Id { get; set; }
    public int OrganizationId { get; set; }

    public string InvoiceNumber { get; set; }
    public DateTime PeriodStart { get; set; }
    public DateTime PeriodEnd { get; set; }

    public decimal Subtotal { get; set; }
    public decimal VatAmount { get; set; }
    public decimal Total { get; set; }

    public string Status { get; set; } // Draft, Sent, Paid, Overdue, Cancelled
    public DateTime Created { get; set; }
}

public class InvoiceLine
{
    public int Id { get; set; }
    public int InvoiceId { get; set; }

    public string Description { get; set; }
    public decimal Quantity { get; set; }
    public decimal UnitPrice { get; set; }
    public decimal Total { get; set; }

    public string SourceType { get; set; } // Subscription, ApiUsage, Asset, Storage, Report
    public int? SourceId { get; set; }
}

4. Rollen en rechten

Owner

Alles beheren, abonnement wijzigen, gebruikers beheren, facturen bekijken.

Admin

Gebruikers, API keys en data beheren.

Developer

API keys maken, documentatie en logs bekijken.

Billing

Facturen bekijken, betaalgegevens beheren.

Viewer

Alleen dashboards bekijken.

5. API key scopes

assets.readassets.writemeasurements.readmeasurements.writealerts.readalerts.writereports.readreports.createbilling.readwebhooks.manage

6. API endpoints

Registratie
  • POST /api/public/register
  • POST /api/public/verify-email
  • POST /api/public/create-organization
  • POST /api/public/accept-terms
Organisatie
  • GET /api/organizations/me
  • PUT /api/organizations/me
  • GET /api/organizations/users
  • POST /api/organizations/users/invite
  • DELETE /api/organizations/users/{id}
Billing
  • GET /api/billing/plans
  • POST /api/billing/subscription
  • GET /api/billing/usage/current
  • GET /api/billing/invoices
  • GET /api/billing/invoices/{id}
API keys
  • GET /api/developer/api-keys
  • POST /api/developer/api-keys
  • PUT /api/developer/api-keys/{id}
  • DELETE /api/developer/api-keys/{id}
Usage
  • GET /api/developer/usage/summary
  • GET /api/developer/usage/logs
  • GET /api/developer/usage/costs

7. Developer portal schermen

Dashboard

Accountstatus, huidig abonnement, API calls deze maand, geschatte kosten, actieve keys, laatste errors, openstaande facturen.

API Keys

Key aanmaken met naam, Test of Live, scopes en quota. Intrekken en laatste gebruik bekijken. Secret wordt slechts één keer getoond.

Usage

Calls per dag, kosten per endpoint, top endpoints, errors, response tijden en dataverbruik.

Billing

Plan, verbruik t.o.v. bundel, overage, facturen, betaalstatus en BTW-gegevens.

Docs

Swagger/OpenAPI, voorbeelden, authenticatie, rate limits, error codes en webhooks.

8. Prijsmodel

Starter
€49 / maand

Inbegrepen: 10.000 API calls, 10 assets

Overage: €0,002 / call, €1,50 / asset

Professional
€199 / maand

Inbegrepen: 250.000 API calls, 250 assets

Overage: €0,001 / call, €1,00 / asset

Enterprise
Maatwerk

Inbegrepen: Volume, SLA, dedicated support

Overage: Contractprijzen

9. Voorbeeld factuur

Starter abonnement mei 2026              €49,00
Extra API calls: 12.500 x €0,002         €25,00
Extra assets: 15 x €1,50                 €22,50
PDF rapportages: 8 x €2,50               €20,00
Subtotaal                               €116,50
BTW 21%                                  €24,47
Totaal                                  €140,97

10. Audit trail

public class AuditLog
{
    public long Id { get; set; }
    public int OrganizationId { get; set; }
    public int? UserId { get; set; }
    public int? ApiKeyId { get; set; }

    public string Action { get; set; }
    public string EntityType { get; set; }
    public string EntityId { get; set; }

    public string OldValueJson { get; set; }
    public string NewValueJson { get; set; }

    public string IpAddress { get; set; }
    public DateTime Created { get; set; }
}

Voorbeeld events

ApiKeyCreatedApiKeyRevokedSubscriptionChangedPaymentFailedUserInvitedScopeChangedInvoiceGeneratedOrganizationSuspended

11. API authenticatie middleware

  1. 01Lees API key uit Authorization header
  2. 02Hash key en zoek actieve record
  3. 03Bepaal OrganizationId
  4. 04Controleer subscription status
  5. 05Controleer scope tegen endpoint
  6. 06Controleer rate limit en quota
  7. 07Voer request uit
  8. 08Log usage met duur en bytes
  9. 09Bereken billable units en kosten

12. Dataveiligheid en tenantfiltering

Elke tabel met klantdata krijgt verplicht een OrganizationId. Geen enkele query mag zonder tenantfilter draaien.

  • WindFarm.OrganizationId
  • WindTurbine.OrganizationId
  • Measurement.OrganizationId
  • Alert.OrganizationId
  • Report.OrganizationId
WHERE OrganizationId = @CurrentOrganizationId

13. MVP fasering

Fase 1: Basis
RegistratieE-mailverificatieOrganisatie aanmakenPlan kiezenAPI keys makenAPI key authenticatieTenantfilteringUsage logging
Fase 2: Billing
Usage aggregatieFactuurregelsFactuuroverzichtBTW-berekeningPDF-facturenHandmatige betaalstatus
Fase 3: Developer Portal
Usage dashboardAPI logsKey managementSwagger documentatieQuota zichtbaar maken
Fase 4: Automatisering
Stripe of Mollie koppelingAutomatische incassoPayment failed flowSuspension logicPlan upgrades en downgrades
Fase 5: Enterprise
ContractprijzenCustom quotaSLA'sPrivate integrationsDedicated API clientsAdvanced audit exports

14. Samenvatting

Je bouwt geen losse registratiemodule, maar een complete SaaS basis: self-service onboarding, tenant-based API toegang, scoped API keys, usage metering, billing en auditability. De kern blijft eenvoudig:

OrganizationId + ApiKeyId + UsageLog + BillingPlan

Als die vier goed staan, kun je alles veilig, meetbaar en factureerbaar maken.