Skip to main content

Partner Management API

Partner management enables multi-tenant support for billing and administrative operations through role-based access control.

Overview

Partner management in Aventora Admin allows:

  • Partner account provisioning with dedicated role-based access
  • Scoped billing visibility so partners see only their account data
  • Administrative delegation to partner admins without super-admin privileges
  • Staged rollout with dark-mode observation before enforcement

Architecture

Partner management uses a centralized authorization policy engine with staged rollout controls:

  1. Policy evaluation — Centralized authorization policy engine in Aventora Admin
  2. Role resolution — Backward compatible with existing is_admin + domain signals
  3. Staged enforcement — Dark-mode observation, followed by optional enforcement
  4. Observability — Structured audit events and metric counters

Feature flags

All partner features are gated by environment variables, all defaulting to false:

FlagPurposeScope
PARTNER_MANAGEMENT_ENABLEDMaster gate for partner code pathsServer
PARTNER_MANAGEMENT_ACCESS_GRANT_ENABLEDAllow partner account provisioningServer
PARTNER_MANAGEMENT_DARK_AUTH_MODE_ENABLEDObserve-only policy enforcementServer
PARTNER_MANAGEMENT_ENFORCE_AUTH_MODE_ENABLEDEnforce deny policies (returns 403)Server
NEXT_PUBLIC_PARTNER_MANAGEMENT_ENABLEDShow partner UI to clientsClient
NEXT_PUBLIC_PARTNER_MANAGEMENT_ACCESS_GRANT_ENABLEDEnable partner access grant workflowsClient

Protected billing routes

Partner authorization is enforced on these API routes when flags enable it:

RouteActionDescription
GET /api/billing/accountbilling.account.readFetch account data
PATCH /api/billing/accountbilling.account.updateUpdate account settings
GET /api/billing/usage-summarybilling.usage-summary.readFetch usage summary
GET /api/billing/usage-reportbilling.usage-report.readExport usage CSV
GET /api/billing/purchasesbilling.purchases.readFetch purchase history
GET /api/partner/domains/{domain}/integration-keys/hubintegration-keys.readList Hub partner integration keys
POST /api/partner/domains/{domain}/integration-keys/hubintegration-keys.createCreate Hub partner integration key
DELETE /api/partner/domains/{domain}/integration-keys/hub/{id}integration-keys.revokeRevoke Hub partner integration key
GET /api/partner/domains/{domain}/integration-keys/domain-chatbotintegration-keys.readList Domain-Chatbot partner keys
POST /api/partner/domains/{domain}/integration-keys/domain-chatbotintegration-keys.createCreate Domain-Chatbot partner key
DELETE /api/partner/domains/{domain}/integration-keys/domain-chatbot/{id}integration-keys.revokeRevoke Domain-Chatbot partner key

Partners manage keys in the Admin UI at Integration Keys (/domains/{domain}/integration-keys). See Partner Integration API Keys for key scopes and HTTP examples.

User roles

Partner management supports four role levels:

RoleDescriptionBilling Access
super_adminFull platform accessAll operations
partner_adminPartner account managementAll operations
domain_adminSingle domain managementDenied for partner actions
viewerRead-only accessDenied for partner actions

Response format

Success (allowed)

Protected routes return their normal response when authorization passes.

Denied (enforce mode only)

When enforce mode is enabled and a policy denies access:

HTTP/1.1 403 Forbidden
Content-Type: application/json

{
"error": "Forbidden",
"code": "PARTNER_AUTHORIZATION_DENIED",
"action": "billing.account.read",
"reason": "role-not-allowed-for-partner-action"
}

Audit and monitoring

Structured audit events

Partner authorization emits structured JSON events for observability:

Audit event prefix: [partner-auth][event]

{
"event": "partner_authorization_decision",
"timestamp": "2026-06-22T10:30:00Z",
"action": "billing.account.read",
"role": "domain_admin",
"allowed": false,
"wouldDenyIfEnforced": true,
"reason": "role-not-allowed-for-partner-action",
"darkAuthModeEnabled": true,
"enforceAuthModeEnabled": false,
"userId": "user123",
"userEmail": "user@example.com",
"userDomain": "example.com",
"partnerId": null,
"requestId": "req-abc123",
"correlationId": "corr-xyz789",
"method": "GET",
"path": "/api/billing/account",
"host": "admin.aventora.ai",
"runtime": "server"
}

Metric counters

Partner authorization emits counter metrics for aggregation:

Metric prefix: [partner-auth][metric]

MetricIncrementedDescription
partner_auth_would_deny_totalIn dark mode, when policy would denyTrack deny candidates before enforcement
partner_auth_denied_totalIn enforce mode, when request is deniedTrack active denials

Each metric event includes action, role, reason, and request correlation fields.

Implementation guide

For integrators

When calling protected routes in partner scenarios:

  1. Authenticate with user token via existing auth mechanism
  2. Include headers: x-request-id, x-correlation-id (optional, for tracing)
  3. Handle 403 responses with code: PARTNER_AUTHORIZATION_DENIED
  4. Fallback gracefully in client when access is denied

Example:

curl -X GET https://admin.aventora.ai/api/billing/account \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "x-request-id: req-12345" \
-H "x-correlation-id: trace-xyz"

For Aventora operations

See Partner Management Rollout (Internal) for staging, monitoring, and production activation procedures.

Backward compatibility

Partner management is fully backward compatible:

  • All feature flags default to false
  • When disabled, routes behave identically to before
  • No response schema changes; new fields are optional in auth types
  • Existing admin/domain logic is preserved as fallback

Error handling

Common error scenarios:

ScenarioHTTP StatusCodeAction
Invalid token401(standard auth)Retry with valid token
Partner access denied (enforce mode)403PARTNER_AUTHORIZATION_DENIEDInform user or escalate
Billing API unavailable500(standard error)Retry or check backend status

Changelog

DateChange
2026-07-06Partner Integration API Keys: partners can create/list/revoke Hub and Domain-Chatbot keys per assigned domain from /domains/{domain}/integration-keys. See Partner Integration API Keys.
2026-07-02Partner user invite (POST /api/partners/{id}/invite) re-invites existing accounts: resets password, assigns partner, and sends invitation email instead of returning 401. Returns 400 if the user belongs to a different partner.

Next steps: