Skip to main content

External Service Limits

The platform enforces call-rate limits and tracks usage costs for every external API integration. Limits are configured per service in application.yml; usage data is available via a tenant-scoped admin endpoint.

Rate limit configuration

Add a mosterd.rate-limits.services block to application.yml. Each key is a service name (see Service names below).

mosterd:
rate-limits:
services:
gemini:
calls: 100
window: HOURS
units: 500000
document-ai:
calls: 50
window: HOURS
kvk:
calls: 500
window: DAYS
companies-house:
calls: 600
window: DAYS
webservices:
calls: 1000
window: DAYS
FieldTypeRequiredDescription
callsintegeryesMaximum number of calls per window
windowHOURS | DAYSyesReset interval for the call counter
unitsintegernoCumulative units limit per window (tokens for gemini, pages for document-ai)
budgetEurdecimalnoMonthly spend budget in EUR — informational, shown in the usage response

When the calls limit is reached the platform returns HTTP 429 to the script or import that triggered the call. The counter resets automatically when the current hour or day rolls over. The units limit works independently: it accumulates across the window and blocks further calls once reached.

Service names

Service nameGateway(s)Tracked cost
geminiAi, DocumentTriage, InvoiceTokens (input + output) at per-model USD rate
document-aiMarkdownConversionPages processed ($0.01 / page)
kvkCompanyRegister (NL), CompanySearch (NL)€0.02 per Basisprofiel lookup; searches are free
companies-houseCompanyRegister (GB), CompanySearch (GB)Free — rate limit only
webservicesWebservices€0.0707 per address enrichment call

See Gateways Reference for gateway parameters and usage.

Exchange rate configuration

Costs tracked in non-EUR currencies are converted using configurable exchange rates. Add rates under mosterd.exchange-rates:

mosterd:
exchange-rates:
USD: 1.1641 # EUR per USD (amount / rate)

If no rate is configured for a currency, costLocal is null on records for that service.

Usage data

Every external call is recorded as a system.serviceCallLog DataObject. These records are queryable and aggregatable using the same endpoints as regular data types.

Fields

FieldTypeDescription
serviceLIST (system.externalService)Service identifier
timestampDATETIMEWhen the call was made
successBOOLEANWhether the call completed without error
costUnitsINTEGERUnits consumed (tokens for gemini, pages for document-ai); null if not applicable
costUnitTEXTUnit label for costUnits (e.g. tokens, pages)
costCURRENCYCost in the service's native currency
costLocalCURRENCYCost normalized to EUR; null if no exchange rate is configured
referenceTEXTIdentifier of the object that triggered the call

Endpoints

All endpoints require admin authorization. Replace {tenantId} with the tenant UUID.

GET /system/{tenantId}/serviceCallLogs

Returns a paginated list of log records. Supports the same filter and sort parameters as standard data queries. See API Search for filter syntax.

GET /system/{tenantId}/serviceCallLogs/{id}

Returns a single log record by ID.

GET /system/{tenantId}/serviceCallLogs/aggregations

Returns aggregated values for the matching records. The default view includes SUM aggregates for costUnits and costLocal. See API Aggregations for the response format.