Skip to main content

Customer Portal — Sync Contract

Status: populated Owner: Product Engineering (Frontend) Last updated: 2026-04-18

1. Overview​

The customer-portal's sync contract is its dependency on Kong-routed backend API endpoints. All communication is synchronous REST over HTTPS.

2. Kong Routes Consumed​

All routes pass through Kong at https://api.ghasi.io (public) or http://kong-proxy.kong.svc.cluster.local (internal server-side).

Auth Service Routes​

MethodKong RouteUpstreamAuth Required
POST/v1/auth/firebaseauth-serviceNo (pre-login)
POST/v1/auth/refreshauth-serviceRefresh token cookie
GET/v1/auth/meauth-serviceBearer JWT
GET/v1/api-keysauth-serviceBearer JWT
POST/v1/api-keysauth-serviceBearer JWT
DELETE/v1/api-keys/{keyId}auth-serviceBearer JWT

Message Routes​

MethodKong RouteUpstreamAuth Required
POST/v1/messagessms-orchestratorBearer JWT
GET/v1/messagesmessage-store / sms-orchestratorBearer JWT
GET/v1/messages/{messageId}message-store / sms-orchestratorBearer JWT

Webhook Routes​

MethodKong RouteUpstreamAuth Required
GET/v1/webhookswebhook-dispatcherBearer JWT
POST/v1/webhookswebhook-dispatcherBearer JWT
PUT/v1/webhooks/{webhookId}webhook-dispatcherBearer JWT
DELETE/v1/webhooks/{webhookId}webhook-dispatcherBearer JWT

Billing Routes​

MethodKong RouteUpstreamAuth Required
GET/v1/billing/invoicesbilling-serviceBearer JWT
GET/v1/billing/invoices/{invoiceId}billing-serviceBearer JWT
GET/v1/billing/usagebilling-serviceBearer JWT

3. JWT Contract​

Kong validates the JWT signature using the JWKS published by auth-service. The portal consumes the following JWT claims:

ClaimTypeNotes
substringuserId
account_idstringAccount UUID
emailstringUser email
rolesstring[]Must include customer for portal access
expunix timestampUsed by middleware for cookie expiry
issstringhttps://api.ghasi.io

4. Kong Headers Injected by Auth Plugin​

After JWT validation, Kong injects these headers into upstream requests. The portal itself does not need to set them — they are added by Kong before reaching the backend.

HeaderValue
X-Account-IdExtracted from account_id JWT claim
X-User-IdExtracted from sub JWT claim
X-Consumer-UsernameKong consumer identifier

5. Rate Limits​

Kong applies the following rate limits on portal-facing routes:

Route GroupLimitWindow
Auth endpoints10 reqper minute per IP
API key creation5 reqper minute per account
Message send60 reqper minute per account
Read endpoints (GET)120 reqper minute per account

The portal handles 429 responses with a toast notification: "Rate limit exceeded — please try again shortly."

6. Timeout Configuration​

Next.js server component fetch calls use these timeouts:

Endpoint GroupTimeout
Auth (/v1/auth/*)5s
Message send10s
Message list / detail8s
Billing8s
Webhooks5s