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
- 01Identity en Registration
- 02Organization en Tenant Management
- 03Subscription en Billing
- 04API Key Management
- 05Usage Tracking
- 06Developer Portal
- 07Audit en Compliance
- 08Admin Backoffice
2. Registratieproces
- 01Bezoeker
- 02Account aanmaken
- 03E-mail verifiëren
- 04Organisatie aanmaken
- 05Plan kiezen
- 06Betaalmethode of facturatie aanvragen
- 07Voorwaarden accepteren
- 08Tenant activeren
- 09API key aanmaken
- 10API gebruiken
- 11Usage meten
- 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
Alles beheren, abonnement wijzigen, gebruikers beheren, facturen bekijken.
Gebruikers, API keys en data beheren.
API keys maken, documentatie en logs bekijken.
Facturen bekijken, betaalgegevens beheren.
Alleen dashboards bekijken.
5. API key scopes
6. API endpoints
- POST /api/public/register
- POST /api/public/verify-email
- POST /api/public/create-organization
- POST /api/public/accept-terms
- GET /api/organizations/me
- PUT /api/organizations/me
- GET /api/organizations/users
- POST /api/organizations/users/invite
- DELETE /api/organizations/users/{id}
- GET /api/billing/plans
- POST /api/billing/subscription
- GET /api/billing/usage/current
- GET /api/billing/invoices
- GET /api/billing/invoices/{id}
- GET /api/developer/api-keys
- POST /api/developer/api-keys
- PUT /api/developer/api-keys/{id}
- DELETE /api/developer/api-keys/{id}
- GET /api/developer/usage/summary
- GET /api/developer/usage/logs
- GET /api/developer/usage/costs
7. Developer portal schermen
Accountstatus, huidig abonnement, API calls deze maand, geschatte kosten, actieve keys, laatste errors, openstaande facturen.
Key aanmaken met naam, Test of Live, scopes en quota. Intrekken en laatste gebruik bekijken. Secret wordt slechts één keer getoond.
Calls per dag, kosten per endpoint, top endpoints, errors, response tijden en dataverbruik.
Plan, verbruik t.o.v. bundel, overage, facturen, betaalstatus en BTW-gegevens.
Swagger/OpenAPI, voorbeelden, authenticatie, rate limits, error codes en webhooks.
8. Prijsmodel
Inbegrepen: 10.000 API calls, 10 assets
Overage: €0,002 / call, €1,50 / asset
Inbegrepen: 250.000 API calls, 250 assets
Overage: €0,001 / call, €1,00 / asset
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,9710. 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
11. API authenticatie middleware
- 01Lees API key uit Authorization header
- 02Hash key en zoek actieve record
- 03Bepaal OrganizationId
- 04Controleer subscription status
- 05Controleer scope tegen endpoint
- 06Controleer rate limit en quota
- 07Voer request uit
- 08Log usage met duur en bytes
- 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 = @CurrentOrganizationId13. MVP fasering
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 + BillingPlanAls die vier goed staan, kun je alles veilig, meetbaar en factureerbaar maken.